Mercurial > pidgin
changeset 14262:baff095b146c
[gaim-migrate @ 16944]
Rename GaimProxyConnectInfo to GaimProxyConnectData, and change the
variables from connect_info to connect_data. Sorry, but I wanted
to get this right before it becomes permanent.
committer: Tailor Script <tailor@pidgin.im>
line wrap: on
line diff
--- a/libgaim/protocols/irc/irc.c Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/irc/irc.c Mon Aug 21 05:25:44 2006 +0000 @@ -324,11 +324,11 @@ if (!irc->gsc) { - irc->connect_info = gaim_proxy_connect(account, irc->server, + irc->connect_data = gaim_proxy_connect(account, irc->server, gaim_account_get_int(account, "port", IRC_DEFAULT_PORT), irc_login_cb, gc); - if (!irc->connect_info || !gaim_account_get_connection(account)) { + if (!irc->connect_data || !gaim_account_get_connection(account)) { gaim_connection_error(gc, _("Couldn't create socket")); return; } @@ -390,7 +390,7 @@ GaimConnection *gc = data; struct irc_conn *irc = gc->proto_data; - irc->connect_info = NULL; + irc->connect_data = NULL; if (source < 0) { gaim_connection_error(gc, _("Couldn't connect to host")); @@ -433,8 +433,8 @@ if (irc->gsc || (irc->fd >= 0)) irc_cmd_quit(irc, "quit", NULL, NULL); - if (irc->connect_info) - gaim_proxy_connect_cancel(irc->connect_info); + 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 Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/irc/irc.h Mon Aug 21 05:25:44 2006 +0000 @@ -54,7 +54,7 @@ guint timer; GHashTable *buddies; - GaimProxyConnectInfo *connect_info; + GaimProxyConnectData *connect_data; char *inbuf; int inbuflen;
--- a/libgaim/protocols/jabber/jabber.c Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/jabber/jabber.c Mon Aug 21 05:25:44 2006 +0000 @@ -420,7 +420,7 @@ GaimConnection *gc = data; JabberStream *js = gc->proto_data; - js->connect_info = NULL; + js->connect_data = NULL; if (source < 0) { gaim_connection_error(gc, _("Couldn't connect to host")); @@ -465,10 +465,10 @@ static void jabber_login_connect(JabberStream *js, const char *server, int port) { - js->connect_info = gaim_proxy_connect(js->gc->account, server, + js->connect_data = gaim_proxy_connect(js->gc->account, server, port, jabber_login_callback, js->gc); - if (js->connect_info == NULL) + if (js->connect_data == NULL) gaim_connection_error(js->gc, _("Unable to create socket")); } @@ -900,11 +900,11 @@ } if(!js->gsc) { - js->connect_info = gaim_proxy_connect(account, server, + js->connect_data = gaim_proxy_connect(account, server, gaim_account_get_int(account, "port", 5222), jabber_login_callback, gc); - if (js->connect_info == NULL) + if (js->connect_data == NULL) gaim_connection_error(gc, _("Unable to create socket")); } } @@ -920,8 +920,8 @@ if (!gc->disconnect_timeout) jabber_send_raw(js, "</stream:stream>", -1); - if (js->connect_info) - gaim_proxy_connect_cancel(js->connect_info); + if (js->connect_data) + gaim_proxy_connect_cancel(js->connect_data); if(js->gsc) { #ifdef HAVE_OPENSSL
--- a/libgaim/protocols/jabber/jabber.h Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/jabber/jabber.h Mon Aug 21 05:25:44 2006 +0000 @@ -67,7 +67,7 @@ { int fd; - GaimProxyConnectInfo *connect_info; + GaimProxyConnectData *connect_data; #ifdef HAVE_LIBXML xmlParserCtxt *context;
--- a/libgaim/protocols/jabber/si.c Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/jabber/si.c Mon Aug 21 05:25:44 2006 +0000 @@ -46,7 +46,7 @@ typedef struct _JabberSIXfer { JabberStream *js; - GaimProxyConnectInfo *connect_info; + GaimProxyConnectData *connect_data; gboolean accepted; @@ -100,7 +100,7 @@ struct bytestreams_streamhost *streamhost = jsx->streamhosts->data; gaim_proxy_info_destroy(jsx->gpi); - jsx->connect_info = NULL; + jsx->connect_data = NULL; if(source < 0) { jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost); @@ -171,11 +171,11 @@ for(i=0; i<20; i++, p+=2) snprintf(p, 3, "%02x", hashval[i]); - jsx->connect_info = gaim_proxy_connect_socks5(jsx->gpi, dstaddr, 0, + jsx->connect_data = gaim_proxy_connect_socks5(jsx->gpi, dstaddr, 0, jabber_si_bytestreams_connect_cb, xfer); g_free(dstaddr); - if (jsx->connect_info == NULL) + if (jsx->connect_data == NULL) { jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost); g_free(streamhost->jid); @@ -696,8 +696,8 @@ js->file_transfers = g_list_remove(js->file_transfers, xfer); - if (jsx->connect_info != NULL) - gaim_proxy_connect_cancel(jsx->connect_info); + if (jsx->connect_data != NULL) + gaim_proxy_connect_cancel(jsx->connect_data); g_free(jsx->stream_id); g_free(jsx->iq_id);
--- a/libgaim/protocols/msn/directconn.c Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/msn/directconn.c Mon Aug 21 05:25:44 2006 +0000 @@ -361,7 +361,7 @@ gaim_debug_misc("msn", "directconn: connect_cb: %d\n", source); directconn = data; - directconn->connect_info = NULL; + directconn->connect_data = NULL; if (TRUE) { @@ -423,10 +423,10 @@ } #endif - directconn->connect_info = gaim_proxy_connect(session->account, host, port, + directconn->connect_data = gaim_proxy_connect(session->account, host, port, connect_cb, directconn); - if (directconn->connect_info != NULL) + if (directconn->connect_data != NULL) { return TRUE; } @@ -476,8 +476,8 @@ void msn_directconn_destroy(MsnDirectConn *directconn) { - if (directconn->connect_info != NULL) - gaim_proxy_connect_cancel(directconn->connect_info); + if (directconn->connect_data != NULL) + gaim_proxy_connect_cancel(directconn->connect_data); if (directconn->inpa != 0) gaim_input_remove(directconn->inpa);
--- a/libgaim/protocols/msn/directconn.h Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/msn/directconn.h Mon Aug 21 05:25:44 2006 +0000 @@ -35,7 +35,7 @@ MsnSlpLink *slplink; MsnSlpCall *initial_call; - GaimProxyConnectInfo *connect_info; + GaimProxyConnectData *connect_data; gboolean acked;
--- a/libgaim/protocols/msn/httpconn.c Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/msn/httpconn.c Mon Aug 21 05:25:44 2006 +0000 @@ -698,7 +698,7 @@ MsnHttpConn *httpconn; httpconn = data; - httpconn->connect_info = NULL; + httpconn->connect_data = NULL; httpconn->fd = source; if (source >= 0) @@ -727,10 +727,10 @@ if (httpconn->connected) msn_httpconn_disconnect(httpconn); - httpconn->connect_info = gaim_proxy_connect(httpconn->session->account, + httpconn->connect_data = gaim_proxy_connect(httpconn->session->account, "gateway.messenger.hotmail.com", 80, connect_cb, httpconn); - if (httpconn->connect_info != NULL) + if (httpconn->connect_data != NULL) { httpconn->waiting_response = TRUE; httpconn->connected = TRUE; @@ -747,10 +747,10 @@ if (!httpconn->connected) return; - if (httpconn->connect_info != NULL) + if (httpconn->connect_data != NULL) { - gaim_proxy_connect_cancel(httpconn->connect_info); - httpconn->connect_info = NULL; + gaim_proxy_connect_cancel(httpconn->connect_data); + httpconn->connect_data = NULL; } if (httpconn->timer)
--- a/libgaim/protocols/msn/httpconn.h Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/msn/httpconn.h Mon Aug 21 05:25:44 2006 +0000 @@ -37,7 +37,7 @@ MsnSession *session; /**< The MSN Session. */ MsnServConn *servconn; /**< The connection object. */ - GaimProxyConnectInfo *connect_info; + GaimProxyConnectData *connect_data; char *full_session_id; /**< The full session id. */ char *session_id; /**< The trimmed session id. */
--- a/libgaim/protocols/msn/servconn.c Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/msn/servconn.c Mon Aug 21 05:25:44 2006 +0000 @@ -171,7 +171,7 @@ MsnServConn *servconn; servconn = data; - servconn->connect_info = NULL; + servconn->connect_data = NULL; servconn->processing = FALSE; if (servconn->wasted) @@ -233,10 +233,10 @@ return TRUE; } - servconn->connect_info = gaim_proxy_connect(session->account, host, port, + servconn->connect_data = gaim_proxy_connect(session->account, host, port, connect_cb, servconn); - if (servconn->connect_info != NULL) + if (servconn->connect_data != NULL) { servconn->processing = TRUE; return TRUE; @@ -268,10 +268,10 @@ return; } - if (servconn->connect_info != NULL) + if (servconn->connect_data != NULL) { - gaim_proxy_connect_cancel(servconn->connect_info); - servconn->connect_info = NULL; + gaim_proxy_connect_cancel(servconn->connect_data); + servconn->connect_data = NULL; } if (servconn->inpa > 0)
--- a/libgaim/protocols/msn/servconn.h Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/msn/servconn.h Mon Aug 21 05:25:44 2006 +0000 @@ -63,7 +63,7 @@ MsnSession *session; /**< The MSN session of this connection. */ MsnCmdProc *cmdproc; /**< The command processor of this connection. */ - GaimProxyConnectInfo *connect_info; + GaimProxyConnectData *connect_data; gboolean connected; /**< A flag that states if it's connected. */ gboolean processing; /**< A flag that states if something is working
--- a/libgaim/protocols/oscar/flap_connection.c Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/oscar/flap_connection.c Mon Aug 21 05:25:44 2006 +0000 @@ -140,17 +140,17 @@ void flap_connection_close(OscarData *od, FlapConnection *conn) { - if (conn->connect_info != NULL) + if (conn->connect_data != NULL) { - gaim_proxy_connect_cancel(conn->connect_info); - conn->connect_info = NULL; + gaim_proxy_connect_cancel(conn->connect_data); + conn->connect_data = NULL; } if (conn->connect_data != NULL) { if (conn->type == SNAC_FAMILY_CHAT) { - oscar_chat_destroy(conn->connect_data); + oscar_chat_destroy(conn->new_conn_data); conn->connect_data = NULL; } }
--- a/libgaim/protocols/oscar/oscar.c Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/oscar/oscar.c Mon Aug 21 05:25:44 2006 +0000 @@ -919,7 +919,7 @@ gc = od->gc; account = gaim_connection_get_account(gc); - conn->connect_info = NULL; + conn->connect_data = NULL; conn->fd = source; if (source < 0) @@ -972,8 +972,8 @@ } else if (conn->type == SNAC_FAMILY_CHAT) { - od->oscar_chats = g_slist_append(od->oscar_chats, conn->connect_data); - conn->connect_data = NULL; + od->oscar_chats = g_slist_append(od->oscar_chats, conn->new_conn_data); + conn->new_conn_data = NULL; } } @@ -1197,11 +1197,11 @@ gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); newconn = flap_connection_new(od, SNAC_FAMILY_AUTH); - newconn->connect_info = gaim_proxy_connect(account, + newconn->connect_data = gaim_proxy_connect(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); - if (newconn->connect_info == NULL) + if (newconn->connect_data == NULL) { gaim_connection_error(gc, _("Couldn't connect to host")); return; @@ -1314,10 +1314,10 @@ newconn = flap_connection_new(od, SNAC_FAMILY_LOCATE); newconn->cookielen = info->cookielen; newconn->cookie = g_memdup(info->cookie, info->cookielen); - newconn->connect_info = gaim_proxy_connect(account, host, port, + newconn->connect_data = gaim_proxy_connect(account, host, port, connection_established_cb, newconn); g_free(host); - if (newconn->connect_info == NULL) + if (newconn->connect_data == NULL) { gaim_connection_error(gc, _("Could Not Connect")); od->killme = TRUE; @@ -1609,13 +1609,13 @@ cc->exchange = redir->chat.exchange; cc->instance = redir->chat.instance; cc->show = extract_name(redir->chat.room); - newconn->connect_data = cc; + newconn->new_conn_data = cc; gaim_debug_info("oscar", "Connecting to chat room %s exchange %hu\n", cc->name, cc->exchange); } - newconn->connect_info = gaim_proxy_connect(account, host, port, + newconn->connect_data = gaim_proxy_connect(account, host, port, connection_established_cb, newconn); - if (newconn->connect_info == NULL) + if (newconn->connect_data == NULL) { flap_connection_schedule_destroy(newconn, OSCAR_DISCONNECT_COULD_NOT_CONNECT); gaim_debug_error("oscar", "Unable to connect to FLAP server "
--- a/libgaim/protocols/oscar/oscar.h Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/oscar/oscar.h Mon Aug 21 05:25:44 2006 +0000 @@ -368,10 +368,10 @@ OscarDisconnectReason disconnect_reason; /* A few variables that are only used when connecting */ - GaimProxyConnectInfo *connect_info; + GaimProxyConnectData *connect_data; guint16 cookielen; guint8 *cookie; - gpointer connect_data; + gpointer new_conn_data; int fd; FlapFrame buffer_incoming;
--- a/libgaim/protocols/oscar/peer.c Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/oscar/peer.c Mon Aug 21 05:25:44 2006 +0000 @@ -139,10 +139,10 @@ else if (conn->type == OSCAR_CAPABILITY_SENDFILE) peer_oft_close(conn); - if (conn->connect_info != NULL) + if (conn->connect_data != NULL) { - gaim_proxy_connect_cancel(conn->connect_info); - conn->connect_info = NULL; + gaim_proxy_connect_cancel(conn->connect_data); + conn->connect_data = NULL; } if (conn->connect_timeout_timer != 0) @@ -488,7 +488,7 @@ conn = data; - conn->connect_info = NULL; + conn->connect_data = NULL; gaim_timeout_remove(conn->connect_timeout_timer); conn->connect_timeout_timer = 0; @@ -702,10 +702,10 @@ g_free(tmp); } - conn->connect_info = gaim_proxy_connect(account, + conn->connect_data = gaim_proxy_connect(account, conn->verifiedip, conn->port, peer_connection_established_cb, conn); - if (conn->connect_info != NULL) + if (conn->connect_data != NULL) { /* Connecting... */ conn->connect_timeout_timer = gaim_timeout_add(15000, @@ -737,10 +737,10 @@ g_free(tmp); } - conn->connect_info = gaim_proxy_connect(account, + conn->connect_data = gaim_proxy_connect(account, conn->clientip, conn->port, peer_connection_established_cb, conn); - if (conn->connect_info != NULL) + if (conn->connect_data != NULL) { /* Connecting... */ conn->connect_timeout_timer = gaim_timeout_add(15000, @@ -808,11 +808,11 @@ g_free(tmp); } - conn->connect_info = gaim_proxy_connect(account, + conn->connect_data = gaim_proxy_connect(account, (conn->proxyip != NULL) ? conn->proxyip : PEER_PROXY_SERVER, PEER_PROXY_PORT, peer_proxy_connection_established_cb, conn); - if (conn->connect_info != NULL) + if (conn->connect_data != NULL) { /* Connecting... */ return;
--- a/libgaim/protocols/oscar/peer.h Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/oscar/peer.h Mon Aug 21 05:25:44 2006 +0000 @@ -161,7 +161,7 @@ /** * This is only used when the peer connection is being established. */ - GaimProxyConnectInfo *connect_info; + GaimProxyConnectData *connect_data; /** * This is only used when the peer connection is being established.
--- a/libgaim/protocols/oscar/peer_proxy.c Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/oscar/peer_proxy.c Mon Aug 21 05:25:44 2006 +0000 @@ -332,7 +332,7 @@ conn = data; - conn->connect_info = NULL; + conn->connect_data = NULL; if (source < 0) {
--- a/libgaim/protocols/sametime/sametime.c Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/sametime/sametime.c Mon Aug 21 05:25:44 2006 +0000 @@ -226,7 +226,7 @@ /** socket fd */ int socket; gint outpa; /* like inpa, but the other way */ - GaimProxyConnectInfo *connect_info; + GaimProxyConnectData *connect_data; /** circular buffer for outgoing data */ GaimCircBuffer *sock_buf; @@ -1675,7 +1675,7 @@ struct mwGaimPluginData *pd = data; GaimConnection *gc = pd->gc; - pd->connect_info = NULL; + pd->connect_data = NULL; if(source < 0) { /* connection failed */ @@ -3681,8 +3681,8 @@ gaim_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); - pd->connect_info = gaim_proxy_connect(account, host, port, connect_cb, pd); - if(pd->connect_info == NULL) { + pd->connect_data = gaim_proxy_connect(account, host, port, connect_cb, pd); + if(pd->connect_data == NULL) { gaim_connection_error(gc, _("Unable to connect to host")); } } @@ -3715,9 +3715,9 @@ gc->inpa = 0; } - if(pd->connect_info != NULL) { - gaim_proxy_connect_cancel(pd->connect_info); - pd->connect_info = NULL; + if(pd->connect_data != NULL) { + gaim_proxy_connect_cancel(pd->connect_data); + pd->connect_data = NULL; } /* clean up the rest */
--- a/libgaim/protocols/silc/silc.c Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/silc/silc.c Mon Aug 21 05:25:44 2006 +0000 @@ -154,7 +154,7 @@ g_return_if_fail(gc != NULL); sg = gc->proto_data; - sg->connect_info = NULL; + sg->connect_data = NULL; if (source < 0) { gaim_connection_error(gc, _("Connection failed")); @@ -357,12 +357,12 @@ gc->proto_data = sg; /* Connect to the SILC server */ - sg->connect_info = gaim_proxy_connect(account, + sg->connect_data = gaim_proxy_connect(account, gaim_account_get_string(account, "server", "silc.silcnet.org"), gaim_account_get_int(account, "port", 706), silcgaim_login_connected, gc); - if (sg->connect_info == NULL) + if (sg->connect_data == NULL) { gaim_connection_error(gc, _("Unable to create connection")); return; @@ -382,8 +382,8 @@ SilcGaim sg = (SilcGaim)context; silc_client_stop(sg->client); silc_client_free(sg->client); - if (sg->connect_info != NULL) - gaim_proxy_connect_cancel(sg->connect_info); + 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 Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/silc/silcgaim.h Mon Aug 21 05:25:44 2006 +0000 @@ -67,7 +67,7 @@ SilcClient client; SilcClientConnection conn; - GaimProxyConnectInfo *connect_info; + GaimProxyConnectData *connect_data; guint scheduler; GaimConnection *gc; GaimAccount *account;
--- a/libgaim/protocols/simple/simple.c Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/protocols/simple/simple.c Mon Aug 21 05:25:44 2006 +0000 @@ -457,12 +457,12 @@ static void sendlater(GaimConnection *gc, const char *buf) { struct simple_account_data *sip = gc->proto_data; - GaimProxyConnectInfo *connect_info; + GaimProxyConnectData *connect_data; if(!sip->connecting) { gaim_debug_info("simple", "connecting to %s port %d\n", sip->realhostname ? sip->realhostname : "{NULL}", sip->realport); - connect_info = gaim_proxy_connect(sip->account, sip->realhostname, sip->realport, send_later_cb, gc); - if(connect_info == NULL) { + connect_data = gaim_proxy_connect(sip->account, sip->realhostname, sip->realport, send_later_cb, gc); + if(connect_data == NULL) { gaim_connection_error(gc, _("Couldn't create socket")); } sip->connecting = TRUE; @@ -1556,7 +1556,7 @@ static void simple_tcp_connect_listen_cb(int listenfd, gpointer data) { struct simple_account_data *sip = (struct simple_account_data*) data; - GaimProxyConnectInfo *connect_info; + GaimProxyConnectData *connect_data; sip->listenfd = listenfd; if(sip->listenfd == -1) { @@ -1571,9 +1571,9 @@ gaim_debug_info("simple", "connecting to %s port %d\n", sip->realhostname, sip->realport); /* open tcp connection to the server */ - connect_info = gaim_proxy_connect(sip->account, sip->realhostname, + connect_data = gaim_proxy_connect(sip->account, sip->realhostname, sip->realport, login_cb, sip->gc); - if(connect_info == NULL) { + if(connect_data == NULL) { gaim_connection_error(sip->gc, _("Couldn't create socket")); } }
--- a/libgaim/proxy.c Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/proxy.c Mon Aug 21 05:25:44 2006 +0000 @@ -39,7 +39,7 @@ #include "proxy.h" #include "util.h" -struct _GaimProxyConnectInfo { +struct _GaimProxyConnectData { GaimProxyConnectFunction connect_cb; gpointer data; char *host; @@ -87,9 +87,9 @@ * of the return value from that function this linked list * will no longer be needed. */ -static GSList *connect_infos = NULL; +static GSList *connect_datas = NULL; -static void try_connect(GaimProxyConnectInfo *connect_info); +static void try_connect(GaimProxyConnectData *connect_data); /************************************************************************** * Proxy structure API @@ -281,63 +281,63 @@ * be called immediately after this. */ static void -gaim_proxy_connect_info_disconnect(GaimProxyConnectInfo *connect_info) +gaim_proxy_connect_data_disconnect(GaimProxyConnectData *connect_data) { - if (connect_info->inpa > 0) + if (connect_data->inpa > 0) { - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; + gaim_input_remove(connect_data->inpa); + connect_data->inpa = 0; } - if (connect_info->fd >= 0) + if (connect_data->fd >= 0) { - close(connect_info->fd); - connect_info->fd = -1; + close(connect_data->fd); + connect_data->fd = -1; } - g_free(connect_info->write_buffer); - connect_info->write_buffer = NULL; + g_free(connect_data->write_buffer); + connect_data->write_buffer = NULL; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + g_free(connect_data->read_buffer); + connect_data->read_buffer = NULL; } static void -gaim_proxy_connect_info_destroy(GaimProxyConnectInfo *connect_info) +gaim_proxy_connect_data_destroy(GaimProxyConnectData *connect_data) { - gaim_proxy_connect_info_disconnect(connect_info); + gaim_proxy_connect_data_disconnect(connect_data); - connect_infos = g_slist_remove(connect_infos, connect_info); + connect_datas = g_slist_remove(connect_datas, connect_data); - if (connect_info->query_data != NULL) - gaim_dnsquery_destroy(connect_info->query_data); + if (connect_data->query_data != NULL) + gaim_dnsquery_destroy(connect_data->query_data); - while (connect_info->hosts != NULL) + while (connect_data->hosts != NULL) { /* Discard the length... */ - connect_info->hosts = g_slist_remove(connect_info->hosts, connect_info->hosts->data); + connect_data->hosts = g_slist_remove(connect_data->hosts, connect_data->hosts->data); /* Free the address... */ - g_free(connect_info->hosts->data); - connect_info->hosts = g_slist_remove(connect_info->hosts, connect_info->hosts->data); + g_free(connect_data->hosts->data); + connect_data->hosts = g_slist_remove(connect_data->hosts, connect_data->hosts->data); } - g_free(connect_info->host); - g_free(connect_info); + g_free(connect_data->host); + g_free(connect_data); } static void -gaim_proxy_connect_info_connected(GaimProxyConnectInfo *connect_info) +gaim_proxy_connect_data_connected(GaimProxyConnectData *connect_data) { - connect_info->connect_cb(connect_info->data, connect_info->fd, NULL); + connect_data->connect_cb(connect_data->data, connect_data->fd, NULL); /* * We've passed the file descriptor to the protocol, so it's no longer * our responsibility, and we should be careful not to free it when - * we destroy the connect_info. + * we destroy the connect_data. */ - connect_info->fd = -1; + connect_data->fd = -1; - gaim_proxy_connect_info_destroy(connect_info); + gaim_proxy_connect_data_destroy(connect_data); } /** @@ -350,16 +350,16 @@ * good error_message. */ static void -gaim_proxy_connect_info_error(GaimProxyConnectInfo *connect_info, const gchar *error_message) +gaim_proxy_connect_data_error(GaimProxyConnectData *connect_data, const gchar *error_message) { - connect_info->connect_cb(connect_info->data, -1, error_message); - gaim_proxy_connect_info_destroy(connect_info); + connect_data->connect_cb(connect_data->data, -1, error_message); + gaim_proxy_connect_data_destroy(connect_data); } static void no_one_calls(gpointer data, gint source, GaimInputCondition cond) { - GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectData *connect_data = data; socklen_t len; int error=0, ret; @@ -378,7 +378,7 @@ * be overly optimistic sometimes. select is just a hint that you might be * able to do something.) */ - ret = getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len); + ret = getsockopt(connect_data->fd, SOL_SOCKET, SO_ERROR, &error, &len); if (ret == 0 && error == EINPROGRESS) return; /* we'll be called again later */ if (ret < 0 || error != 0) { @@ -388,57 +388,57 @@ gaim_debug_error("proxy", "getsockopt SO_ERROR check: %s\n", strerror(error)); - gaim_proxy_connect_info_disconnect(connect_info); - try_connect(connect_info); + gaim_proxy_connect_data_disconnect(connect_data); + try_connect(connect_data); return; } - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; + gaim_input_remove(connect_data->inpa); + connect_data->inpa = 0; - gaim_proxy_connect_info_connected(connect_info); + gaim_proxy_connect_data_connected(connect_data); } static gboolean clean_connect(gpointer data) { - GaimProxyConnectInfo *connect_info; + GaimProxyConnectData *connect_data; - connect_info = data; - gaim_proxy_connect_info_connected(connect_info); + connect_data = data; + gaim_proxy_connect_data_connected(connect_data); return FALSE; } static int -proxy_connect_none(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_none(GaimProxyConnectData *connect_data, struct sockaddr *addr, socklen_t addrlen) { gaim_debug_info("proxy", "Connecting to %s:%d with no proxy\n", - connect_info->host, connect_info->port); + connect_data->host, connect_data->port); - connect_info->fd = socket(addr->sa_family, SOCK_STREAM, 0); - if (connect_info->fd < 0) + connect_data->fd = socket(addr->sa_family, SOCK_STREAM, 0); + if (connect_data->fd < 0) { gaim_debug_error("proxy", "Unable to create socket: %s\n", strerror(errno)); return -1; } - fcntl(connect_info->fd, F_SETFL, O_NONBLOCK); + fcntl(connect_data->fd, F_SETFL, O_NONBLOCK); #ifndef _WIN32 - fcntl(connect_info->fd, F_SETFD, FD_CLOEXEC); + fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(connect_info->fd, (struct sockaddr *)addr, addrlen) != 0) + if (connect(connect_data->fd, (struct sockaddr *)addr, addrlen) != 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { gaim_debug_info("proxy", "Connection in progress\n"); - connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, no_one_calls, connect_info); + connect_data->inpa = gaim_input_add(connect_data->fd, GAIM_INPUT_WRITE, no_one_calls, connect_data); } else { gaim_debug_error("proxy", "Connect failed: %s\n", strerror(errno)); - close(connect_info->fd); - connect_info->fd = -1; + close(connect_data->fd); + connect_data->fd = -1; return -1; } } @@ -451,11 +451,11 @@ int error = ETIMEDOUT; gaim_debug_info("proxy", "Connected immediately.\n"); len = sizeof(error); - if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + if (getsockopt(connect_data->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) { gaim_debug_error("proxy", "getsockopt failed.\n"); - close(connect_info->fd); - connect_info->fd = -1; + close(connect_data->fd); + connect_data->fd = -1; return -1; } @@ -463,38 +463,38 @@ * We want to call the "connected" callback eventually, but we * don't want to call it before we return, just in case. */ - gaim_timeout_add(10, clean_connect, connect_info); + gaim_timeout_add(10, clean_connect, connect_data); } - return connect_info->fd; + return connect_data->fd; } static void proxy_do_write(gpointer data, gint source, GaimInputCondition cond) { - GaimProxyConnectInfo *connect_info = data; - const guchar *request = connect_info->write_buffer + connect_info->written_len; - gsize request_len = connect_info->write_buf_len - connect_info->written_len; + GaimProxyConnectData *connect_data = data; + const guchar *request = connect_data->write_buffer + connect_data->written_len; + gsize request_len = connect_data->write_buf_len - connect_data->written_len; - int ret = write(connect_info->fd, request, request_len); + int ret = write(connect_data->fd, request, request_len); if(ret < 0 && errno == EAGAIN) return; else if(ret < 0) { - gaim_proxy_connect_info_disconnect(connect_info); - try_connect(connect_info); + gaim_proxy_connect_data_disconnect(connect_data); + try_connect(connect_data); return; } else if (ret < request_len) { - connect_info->written_len += ret; + connect_data->written_len += ret; return; } - gaim_input_remove(connect_info->inpa); - g_free(connect_info->write_buffer); - connect_info->write_buffer = NULL; + gaim_input_remove(connect_data->inpa); + g_free(connect_data->write_buffer); + connect_data->write_buffer = NULL; /* register the response handler for the response */ - connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_READ, connect_info->read_cb, connect_info); + connect_data->inpa = gaim_input_add(connect_data->fd, GAIM_INPUT_READ, connect_data->read_cb, connect_data); } #define HTTP_GOODSTRING "HTTP/1.0 200" @@ -506,44 +506,44 @@ { int len, headers_len, status = 0; gboolean error; - GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectData *connect_data = data; guchar *p; gsize max_read; gchar *msg; - if(connect_info->read_buffer == NULL) { - connect_info->read_buf_len = 8192; - connect_info->read_buffer = g_malloc(connect_info->read_buf_len); - connect_info->read_len = 0; + if(connect_data->read_buffer == NULL) { + connect_data->read_buf_len = 8192; + connect_data->read_buffer = g_malloc(connect_data->read_buf_len); + connect_data->read_len = 0; } - p = connect_info->read_buffer + connect_info->read_len; - max_read = connect_info->read_buf_len - connect_info->read_len - 1; + p = connect_data->read_buffer + connect_data->read_len; + max_read = connect_data->read_buf_len - connect_data->read_len - 1; - len = read(connect_info->fd, p, max_read); + len = read(connect_data->fd, p, max_read); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { - gaim_proxy_connect_info_error(connect_info, _("Lost connection with server for an unknown reason.")); + gaim_proxy_connect_data_error(connect_data, _("Lost connection with server for an unknown reason.")); return; } else { - connect_info->read_len += len; + connect_data->read_len += len; } p[len] = '\0'; - if((p = (guchar *)g_strstr_len((const gchar *)connect_info->read_buffer, connect_info->read_len, "\r\n\r\n"))) { + if((p = (guchar *)g_strstr_len((const gchar *)connect_data->read_buffer, connect_data->read_len, "\r\n\r\n"))) { *p = '\0'; - headers_len = (p - connect_info->read_buffer) + 4; + headers_len = (p - connect_data->read_buffer) + 4; } else if(len == max_read) headers_len = len; else return; - error = strncmp((const char *)connect_info->read_buffer, "HTTP/", 5) != 0; + error = strncmp((const char *)connect_data->read_buffer, "HTTP/", 5) != 0; if (!error) { int major; - p = connect_info->read_buffer + 5; + p = connect_data->read_buffer + 5; major = strtol((const char *)p, (char **)&p, 10); error = (major == 0) || (*p != '.'); if(!error) { @@ -560,7 +560,7 @@ } /* Read the contents */ - p = (guchar *)g_strrstr((const gchar *)connect_info->read_buffer, "Content-Length: "); + p = (guchar *)g_strrstr((const gchar *)connect_data->read_buffer, "Content-Length: "); if (p != NULL) { gchar *tmp; @@ -575,12 +575,12 @@ *tmp = '\r'; /* Compensate for what has already been read */ - len -= connect_info->read_len - headers_len; + len -= connect_data->read_len - headers_len; /* I'm assuming that we're doing this to prevent the server from complaining / breaking since we don't read the whole page */ while(len--) { /* TODO: deal with EAGAIN (and other errors) better */ - if (read(connect_info->fd, &tmpc, 1) < 0 && errno != EAGAIN) + if (read(connect_data->fd, &tmpc, 1) < 0 && errno != EAGAIN) break; } } @@ -588,8 +588,8 @@ if (error) { msg = g_strdup_printf("Unable to parse response from HTTP proxy: %s\n", - connect_info->read_buffer); - gaim_proxy_connect_info_error(connect_info, msg); + connect_data->read_buffer); + gaim_proxy_connect_data_error(connect_data, msg); g_free(msg); return; } @@ -597,15 +597,15 @@ { gaim_debug_error("proxy", "Proxy server replied with:\n%s\n", - connect_info->read_buffer); + connect_data->read_buffer); if(status == 407 /* Proxy Auth */) { gchar *ntlm; - if((ntlm = g_strrstr((const gchar *)connect_info->read_buffer, "Proxy-Authenticate: NTLM "))) { /* Check for Type-2 */ + if((ntlm = g_strrstr((const gchar *)connect_data->read_buffer, "Proxy-Authenticate: NTLM "))) { /* Check for Type-2 */ gchar *tmp = ntlm; guint8 *nonce; - gchar *domain = (gchar*)gaim_proxy_info_get_username(connect_info->gpi); + gchar *domain = (gchar*)gaim_proxy_info_get_username(connect_data->gpi); gchar *username; gchar *request; gchar *response; @@ -613,7 +613,7 @@ if (username == NULL) { msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); - gaim_proxy_connect_info_error(connect_info, msg); + gaim_proxy_connect_data_error(connect_data, msg); g_free(msg); return; } @@ -624,8 +624,8 @@ *tmp = '\0'; nonce = gaim_ntlm_parse_type2(ntlm, NULL); response = gaim_ntlm_gen_type3(username, - (gchar*) gaim_proxy_info_get_password(connect_info->gpi), - (gchar*) gaim_proxy_info_get_host(connect_info->gpi), + (gchar*) gaim_proxy_info_get_password(connect_data->gpi), + (gchar*) gaim_proxy_info_get_host(connect_data->gpi), domain, nonce, NULL); username--; *username = '\\'; @@ -634,35 +634,35 @@ "Host: %s:%d\r\n" "Proxy-Authorization: NTLM %s\r\n" "Proxy-Connection: Keep-Alive\r\n\r\n", - connect_info->host, connect_info->port, connect_info->host, - connect_info->port, response); + connect_data->host, connect_data->port, connect_data->host, + connect_data->port, response); g_free(response); - gaim_input_remove(connect_info->inpa); - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_input_remove(connect_data->inpa); + g_free(connect_data->read_buffer); + connect_data->read_buffer = NULL; - connect_info->write_buffer = (guchar *)request; - connect_info->write_buf_len = strlen(request); - connect_info->written_len = 0; + connect_data->write_buffer = (guchar *)request; + connect_data->write_buf_len = strlen(request); + connect_data->written_len = 0; - connect_info->read_cb = http_canread; + connect_data->read_cb = http_canread; - connect_info->inpa = gaim_input_add(connect_info->fd, - GAIM_INPUT_WRITE, proxy_do_write, connect_info); + connect_data->inpa = gaim_input_add(connect_data->fd, + GAIM_INPUT_WRITE, proxy_do_write, connect_data); - proxy_do_write(connect_info, connect_info->fd, cond); + proxy_do_write(connect_data, connect_data->fd, cond); return; - } else if((ntlm = g_strrstr((const char *)connect_info->read_buffer, "Proxy-Authenticate: NTLM"))) { /* Empty message */ + } else if((ntlm = g_strrstr((const char *)connect_data->read_buffer, "Proxy-Authenticate: NTLM"))) { /* Empty message */ gchar request[2048]; - gchar *domain = (gchar*) gaim_proxy_info_get_username(connect_info->gpi); + gchar *domain = (gchar*) gaim_proxy_info_get_username(connect_data->gpi); gchar *username; int request_len; username = strchr(domain, '\\'); if (username == NULL) { msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); - gaim_proxy_connect_info_error(connect_info, msg); + gaim_proxy_connect_data_error(connect_data, msg); g_free(msg); return; } @@ -671,8 +671,8 @@ request_len = g_snprintf(request, sizeof(request), "CONNECT %s:%d HTTP/1.1\r\n" "Host: %s:%d\r\n", - connect_info->host, connect_info->port, - connect_info->host, connect_info->port); + connect_data->host, connect_data->port, + connect_data->host, connect_data->port); g_return_if_fail(request_len < sizeof(request)); request_len += g_snprintf(request + request_len, @@ -680,48 +680,48 @@ "Proxy-Authorization: NTLM %s\r\n" "Proxy-Connection: Keep-Alive\r\n\r\n", gaim_ntlm_gen_type1( - (gchar*) gaim_proxy_info_get_host(connect_info->gpi), + (gchar*) gaim_proxy_info_get_host(connect_data->gpi), domain)); *username = '\\'; - gaim_input_remove(connect_info->inpa); - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_input_remove(connect_data->inpa); + g_free(connect_data->read_buffer); + connect_data->read_buffer = NULL; - connect_info->write_buffer = g_memdup(request, request_len); - connect_info->write_buf_len = request_len; - connect_info->written_len = 0; + connect_data->write_buffer = g_memdup(request, request_len); + connect_data->write_buf_len = request_len; + connect_data->written_len = 0; - connect_info->read_cb = http_canread; + connect_data->read_cb = http_canread; - connect_info->inpa = gaim_input_add(connect_info->fd, - GAIM_INPUT_WRITE, proxy_do_write, connect_info); + connect_data->inpa = gaim_input_add(connect_data->fd, + GAIM_INPUT_WRITE, proxy_do_write, connect_data); - proxy_do_write(connect_info, connect_info->fd, cond); + proxy_do_write(connect_data, connect_data->fd, cond); return; } else { msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); - gaim_proxy_connect_info_error(connect_info, msg); + gaim_proxy_connect_data_error(connect_data, msg); g_free(msg); return; } } if(status == 403 /* Forbidden */ ) { - msg = g_strdup_printf(_("Access denied: HTTP proxy server forbids port %d tunnelling."), connect_info->port); - gaim_proxy_connect_info_error(connect_info, msg); + msg = g_strdup_printf(_("Access denied: HTTP proxy server forbids port %d tunnelling."), connect_data->port); + gaim_proxy_connect_data_error(connect_data, msg); g_free(msg); } else { msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); - gaim_proxy_connect_info_error(connect_info, msg); + gaim_proxy_connect_data_error(connect_data, msg); g_free(msg); } } else { - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_input_remove(connect_data->inpa); + connect_data->inpa = 0; + g_free(connect_data->read_buffer); + connect_data->read_buffer = NULL; gaim_debug_info("proxy", "HTTP proxy connection established\n"); - gaim_proxy_connect_info_connected(connect_info); + gaim_proxy_connect_data_connected(connect_data); return; } } @@ -733,38 +733,38 @@ { char request[8192]; int request_len = 0; - GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectData *connect_data = data; socklen_t len; int error = ETIMEDOUT; gaim_debug_info("http proxy", "Connected.\n"); - if (connect_info->inpa > 0) + if (connect_data->inpa > 0) { - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; + gaim_input_remove(connect_data->inpa); + connect_data->inpa = 0; } len = sizeof(error); - if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { - gaim_proxy_connect_info_disconnect(connect_info); - try_connect(connect_info); + if (getsockopt(connect_data->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + gaim_proxy_connect_data_disconnect(connect_data); + try_connect(connect_data); return; } gaim_debug_info("proxy", "using CONNECT tunnelling for %s:%d\n", - connect_info->host, connect_info->port); + connect_data->host, connect_data->port); request_len = g_snprintf(request, sizeof(request), "CONNECT %s:%d HTTP/1.1\r\nHost: %s:%d\r\n", - connect_info->host, connect_info->port, connect_info->host, connect_info->port); + connect_data->host, connect_data->port, connect_data->host, connect_data->port); - if (gaim_proxy_info_get_username(connect_info->gpi) != NULL) { + if (gaim_proxy_info_get_username(connect_data->gpi) != NULL) { char *t1, *t2; t1 = g_strdup_printf("%s:%s", - gaim_proxy_info_get_username(connect_info->gpi), - gaim_proxy_info_get_password(connect_info->gpi) ? - gaim_proxy_info_get_password(connect_info->gpi) : ""); + gaim_proxy_info_get_username(connect_data->gpi), + gaim_proxy_info_get_password(connect_data->gpi) ? + gaim_proxy_info_get_password(connect_data->gpi) : ""); t2 = gaim_base64_encode((const guchar *)t1, strlen(t1)); g_free(t1); g_return_if_fail(request_len < sizeof(request)); @@ -775,59 +775,59 @@ "Proxy-Authorization: NTLM %s\r\n" "Proxy-Connection: Keep-Alive\r\n", t2, gaim_ntlm_gen_type1( - (gchar*)gaim_proxy_info_get_host(connect_info->gpi),"")); + (gchar*)gaim_proxy_info_get_host(connect_data->gpi),"")); g_free(t2); } g_return_if_fail(request_len < sizeof(request)); strcpy(request + request_len, "\r\n"); request_len += 2; - connect_info->write_buffer = g_memdup(request, request_len); - connect_info->write_buf_len = request_len; - connect_info->written_len = 0; + connect_data->write_buffer = g_memdup(request, request_len); + connect_data->write_buf_len = request_len; + connect_data->written_len = 0; - connect_info->read_cb = http_canread; + connect_data->read_cb = http_canread; - connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, - connect_info); + connect_data->inpa = gaim_input_add(connect_data->fd, GAIM_INPUT_WRITE, proxy_do_write, + connect_data); - proxy_do_write(connect_info, connect_info->fd, cond); + proxy_do_write(connect_data, connect_data->fd, cond); } static int -proxy_connect_http(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_http(GaimProxyConnectData *connect_data, struct sockaddr *addr, socklen_t addrlen) { gaim_debug_info("http proxy", "Connecting to %s:%d via %s:%d using HTTP\n", - (connect_info->host ? connect_info->host : "(null)"), connect_info->port, - (gaim_proxy_info_get_host(connect_info->gpi) ? gaim_proxy_info_get_host(connect_info->gpi) : "(null)"), - gaim_proxy_info_get_port(connect_info->gpi)); + (connect_data->host ? connect_data->host : "(null)"), connect_data->port, + (gaim_proxy_info_get_host(connect_data->gpi) ? gaim_proxy_info_get_host(connect_data->gpi) : "(null)"), + gaim_proxy_info_get_port(connect_data->gpi)); - connect_info->fd = socket(addr->sa_family, SOCK_STREAM, 0); - if (connect_info->fd < 0) + connect_data->fd = socket(addr->sa_family, SOCK_STREAM, 0); + if (connect_data->fd < 0) return -1; - fcntl(connect_info->fd, F_SETFL, O_NONBLOCK); + fcntl(connect_data->fd, F_SETFL, O_NONBLOCK); #ifndef _WIN32 - fcntl(connect_info->fd, F_SETFD, FD_CLOEXEC); + fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(connect_info->fd, addr, addrlen) != 0) + if (connect(connect_data->fd, addr, addrlen) != 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { gaim_debug_info("http proxy", "Connection in progress\n"); - if (connect_info->port != 80) { + if (connect_data->port != 80) { /* we need to do CONNECT first */ - connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, - http_canwrite, connect_info); + connect_data->inpa = gaim_input_add(connect_data->fd, GAIM_INPUT_WRITE, + http_canwrite, connect_data); } else { gaim_debug_info("proxy", "HTTP proxy connection established\n"); - gaim_proxy_connect_info_connected(connect_info); + gaim_proxy_connect_data_connected(connect_data); } } else { - close(connect_info->fd); - connect_info->fd = -1; + close(connect_data->fd); + connect_data->fd = -1; return -1; } } @@ -838,51 +838,51 @@ gaim_debug_info("http proxy", "Connected immediately.\n"); len = sizeof(error); - if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + if (getsockopt(connect_data->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) { - close(connect_info->fd); - connect_info->fd = -1; + close(connect_data->fd); + connect_data->fd = -1; return -1; } - http_canwrite(connect_info, connect_info->fd, GAIM_INPUT_WRITE); + http_canwrite(connect_data, connect_data->fd, GAIM_INPUT_WRITE); } - return connect_info->fd; + return connect_data->fd; } static void s4_canread(gpointer data, gint source, GaimInputCondition cond) { - GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectData *connect_data = data; guchar *buf; int len, max_read; /* This is really not going to block under normal circumstances, but to * be correct, we deal with the unlikely scenario */ - if (connect_info->read_buffer == NULL) { - connect_info->read_buf_len = 12; - connect_info->read_buffer = g_malloc(connect_info->read_buf_len); - connect_info->read_len = 0; + if (connect_data->read_buffer == NULL) { + connect_data->read_buf_len = 12; + connect_data->read_buffer = g_malloc(connect_data->read_buf_len); + connect_data->read_len = 0; } - buf = connect_info->read_buffer + connect_info->read_len; - max_read = connect_info->read_buf_len - connect_info->read_len; + buf = connect_data->read_buffer + connect_data->read_len; + max_read = connect_data->read_buf_len - connect_data->read_len; - len = read(connect_info->fd, buf, max_read); + len = read(connect_data->fd, buf, max_read); - if ((len < 0 && errno == EAGAIN) || (len > 0 && len + connect_info->read_len < 4)) + if ((len < 0 && errno == EAGAIN) || (len > 0 && len + connect_data->read_len < 4)) return; - else if (len + connect_info->read_len >= 4) { - if (connect_info->read_buffer[1] == 90) { - gaim_proxy_connect_info_connected(connect_info); + else if (len + connect_data->read_len >= 4) { + if (connect_data->read_buffer[1] == 90) { + gaim_proxy_connect_data_connected(connect_data); return; } } - gaim_proxy_connect_info_disconnect(connect_info); - try_connect(connect_info); + gaim_proxy_connect_data_disconnect(connect_data); + try_connect(connect_data); } static void @@ -890,23 +890,23 @@ { unsigned char packet[9]; struct hostent *hp; - GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectData *connect_data = data; socklen_t len; int error = ETIMEDOUT; gaim_debug_info("socks4 proxy", "Connected.\n"); - if (connect_info->inpa > 0) + if (connect_data->inpa > 0) { - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; + gaim_input_remove(connect_data->inpa); + connect_data->inpa = 0; } len = sizeof(error); - if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { - gaim_proxy_connect_info_disconnect(connect_info); - try_connect(connect_info); + if (getsockopt(connect_data->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + gaim_proxy_connect_data_disconnect(connect_data); + try_connect(connect_data); return; } @@ -919,60 +919,60 @@ * meantime, stick with plain old SOCKS4. */ /* TODO: This needs to be non-blocking! */ - hp = gethostbyname(connect_info->host); + hp = gethostbyname(connect_data->host); if (hp == NULL) { - gaim_proxy_connect_info_disconnect(connect_info); - try_connect(connect_info); + gaim_proxy_connect_data_disconnect(connect_data); + try_connect(connect_data); return; } packet[0] = 4; packet[1] = 1; - packet[2] = connect_info->port >> 8; - packet[3] = connect_info->port & 0xff; + packet[2] = connect_data->port >> 8; + packet[3] = connect_data->port & 0xff; packet[4] = (unsigned char)(hp->h_addr_list[0])[0]; packet[5] = (unsigned char)(hp->h_addr_list[0])[1]; packet[6] = (unsigned char)(hp->h_addr_list[0])[2]; packet[7] = (unsigned char)(hp->h_addr_list[0])[3]; packet[8] = 0; - connect_info->write_buffer = g_memdup(packet, sizeof(packet)); - connect_info->write_buf_len = sizeof(packet); - connect_info->written_len = 0; - connect_info->read_cb = s4_canread; + connect_data->write_buffer = g_memdup(packet, sizeof(packet)); + connect_data->write_buf_len = sizeof(packet); + connect_data->written_len = 0; + connect_data->read_cb = s4_canread; - connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); + connect_data->inpa = gaim_input_add(connect_data->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_data); - proxy_do_write(connect_info, connect_info->fd, cond); + proxy_do_write(connect_data, connect_data->fd, cond); } static int -proxy_connect_socks4(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_socks4(GaimProxyConnectData *connect_data, struct sockaddr *addr, socklen_t addrlen) { gaim_debug_info("socks4 proxy", "Connecting to %s:%d via %s:%d using SOCKS4\n", - connect_info->host, connect_info->port, - gaim_proxy_info_get_host(connect_info->gpi), - gaim_proxy_info_get_port(connect_info->gpi)); + connect_data->host, connect_data->port, + gaim_proxy_info_get_host(connect_data->gpi), + gaim_proxy_info_get_port(connect_data->gpi)); - connect_info->fd = socket(addr->sa_family, SOCK_STREAM, 0); - if (connect_info->fd < 0) + connect_data->fd = socket(addr->sa_family, SOCK_STREAM, 0); + if (connect_data->fd < 0) return -1; - fcntl(connect_info->fd, F_SETFL, O_NONBLOCK); + fcntl(connect_data->fd, F_SETFL, O_NONBLOCK); #ifndef _WIN32 - fcntl(connect_info->fd, F_SETFD, FD_CLOEXEC); + fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(connect_info->fd, addr, addrlen) != 0) + if (connect(connect_data->fd, addr, addrlen) != 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { gaim_debug_info("socks4 proxy", "Connection in progress.\n"); - connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, s4_canwrite, connect_info); + connect_data->inpa = gaim_input_add(connect_data->fd, GAIM_INPUT_WRITE, s4_canwrite, connect_data); } else { - close(connect_info->fd); - connect_info->fd = -1; + close(connect_data->fd); + connect_data->fd = -1; return -1; } } else { @@ -983,49 +983,49 @@ len = sizeof(error); - if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + if (getsockopt(connect_data->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) { - close(connect_info->fd); - connect_info->fd = -1; + close(connect_data->fd); + connect_data->fd = -1; return -1; } - s4_canwrite(connect_info, connect_info->fd, GAIM_INPUT_WRITE); + s4_canwrite(connect_data, connect_data->fd, GAIM_INPUT_WRITE); } - return connect_info->fd; + return connect_data->fd; } static void s5_canread_again(gpointer data, gint source, GaimInputCondition cond) { guchar *dest, *buf; - GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectData *connect_data = data; int len; - if (connect_info->read_buffer == NULL) { - connect_info->read_buf_len = 512; - connect_info->read_buffer = g_malloc(connect_info->read_buf_len); - connect_info->read_len = 0; + if (connect_data->read_buffer == NULL) { + connect_data->read_buf_len = 512; + connect_data->read_buffer = g_malloc(connect_data->read_buf_len); + connect_data->read_len = 0; } - dest = connect_info->read_buffer + connect_info->read_len; - buf = connect_info->read_buffer; + dest = connect_data->read_buffer + connect_data->read_len; + buf = connect_data->read_buffer; gaim_debug_info("socks5 proxy", "Able to read again.\n"); - len = read(connect_info->fd, dest, (connect_info->read_buf_len - connect_info->read_len)); + len = read(connect_data->fd, dest, (connect_data->read_buf_len - connect_data->read_len)); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { gaim_debug_warning("socks5 proxy", "or not...\n"); - gaim_proxy_connect_info_disconnect(connect_info); - try_connect(connect_info); + gaim_proxy_connect_data_disconnect(connect_data); + try_connect(connect_data); return; } - connect_info->read_len += len; + connect_data->read_len += len; - if(connect_info->read_len < 4) + if(connect_data->read_len < 4) return; if ((buf[0] != 0x05) || (buf[1] != 0x00)) { @@ -1033,109 +1033,109 @@ gaim_debug_error("socks5 proxy", socks5errors[buf[1]]); else gaim_debug_error("socks5 proxy", "Bad data.\n"); - gaim_proxy_connect_info_disconnect(connect_info); - try_connect(connect_info); + gaim_proxy_connect_data_disconnect(connect_data); + try_connect(connect_data); return; } /* Skip past BND.ADDR */ switch(buf[3]) { case 0x01: /* the address is a version-4 IP address, with a length of 4 octets */ - if(connect_info->read_len < 4 + 4) + if(connect_data->read_len < 4 + 4) return; buf += 4 + 4; break; case 0x03: /* the address field contains a fully-qualified domain name. The first octet of the address field contains the number of octets of name that follow, there is no terminating NUL octet. */ - if(connect_info->read_len < 4 + 1) + if(connect_data->read_len < 4 + 1) return; buf += 4 + 1; - if(connect_info->read_len < 4 + 1 + buf[0]) + if(connect_data->read_len < 4 + 1 + buf[0]) return; buf += buf[0]; break; case 0x04: /* the address is a version-6 IP address, with a length of 16 octets */ - if(connect_info->read_len < 4 + 16) + if(connect_data->read_len < 4 + 16) return; buf += 4 + 16; break; } - if(connect_info->read_len < (buf - connect_info->read_buffer) + 2) + if(connect_data->read_len < (buf - connect_data->read_buffer) + 2) return; /* Skip past BND.PORT */ buf += 2; - gaim_proxy_connect_info_connected(connect_info); + gaim_proxy_connect_data_connected(connect_data); } static void s5_sendconnect(gpointer data, int source) { - GaimProxyConnectInfo *connect_info = data; - int hlen = strlen(connect_info->host); - connect_info->write_buf_len = 5 + hlen + 2; - connect_info->write_buffer = g_malloc(connect_info->write_buf_len); - connect_info->written_len = 0; + GaimProxyConnectData *connect_data = data; + int hlen = strlen(connect_data->host); + connect_data->write_buf_len = 5 + hlen + 2; + connect_data->write_buffer = g_malloc(connect_data->write_buf_len); + connect_data->written_len = 0; - connect_info->write_buffer[0] = 0x05; - connect_info->write_buffer[1] = 0x01; /* CONNECT */ - connect_info->write_buffer[2] = 0x00; /* reserved */ - connect_info->write_buffer[3] = 0x03; /* address type -- host name */ - connect_info->write_buffer[4] = hlen; - memcpy(connect_info->write_buffer + 5, connect_info->host, hlen); - connect_info->write_buffer[5 + hlen] = connect_info->port >> 8; - connect_info->write_buffer[5 + hlen + 1] = connect_info->port & 0xff; + connect_data->write_buffer[0] = 0x05; + connect_data->write_buffer[1] = 0x01; /* CONNECT */ + connect_data->write_buffer[2] = 0x00; /* reserved */ + connect_data->write_buffer[3] = 0x03; /* address type -- host name */ + connect_data->write_buffer[4] = hlen; + memcpy(connect_data->write_buffer + 5, connect_data->host, hlen); + connect_data->write_buffer[5 + hlen] = connect_data->port >> 8; + connect_data->write_buffer[5 + hlen + 1] = connect_data->port & 0xff; - connect_info->read_cb = s5_canread_again; + connect_data->read_cb = s5_canread_again; - connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, connect_info->fd, GAIM_INPUT_WRITE); + connect_data->inpa = gaim_input_add(connect_data->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_data); + proxy_do_write(connect_data, connect_data->fd, GAIM_INPUT_WRITE); } static void s5_readauth(gpointer data, gint source, GaimInputCondition cond) { - GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectData *connect_data = data; int len; - if (connect_info->read_buffer == NULL) { - connect_info->read_buf_len = 2; - connect_info->read_buffer = g_malloc(connect_info->read_buf_len); - connect_info->read_len = 0; + if (connect_data->read_buffer == NULL) { + connect_data->read_buf_len = 2; + connect_data->read_buffer = g_malloc(connect_data->read_buf_len); + connect_data->read_len = 0; } gaim_debug_info("socks5 proxy", "Got auth response.\n"); - len = read(connect_info->fd, connect_info->read_buffer + connect_info->read_len, - connect_info->read_buf_len - connect_info->read_len); + len = read(connect_data->fd, connect_data->read_buffer + connect_data->read_len, + connect_data->read_buf_len - connect_data->read_len); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { - gaim_proxy_connect_info_disconnect(connect_info); - try_connect(connect_info); + gaim_proxy_connect_data_disconnect(connect_data); + try_connect(connect_data); return; } - connect_info->read_len += len; + connect_data->read_len += len; - if (connect_info->read_len < 2) + if (connect_data->read_len < 2) return; - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; + gaim_input_remove(connect_data->inpa); + connect_data->inpa = 0; - if ((connect_info->read_buffer[0] != 0x01) || (connect_info->read_buffer[1] != 0x00)) { - gaim_proxy_connect_info_disconnect(connect_info); - try_connect(connect_info); + if ((connect_data->read_buffer[0] != 0x01) || (connect_data->read_buffer[1] != 0x00)) { + gaim_proxy_connect_data_disconnect(connect_data); + try_connect(connect_data); return; } - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + g_free(connect_data->read_buffer); + connect_data->read_buffer = NULL; - s5_sendconnect(connect_info, connect_info->fd); + s5_sendconnect(connect_data, connect_data->fd); } static void @@ -1186,37 +1186,37 @@ s5_readchap(gpointer data, gint source, GaimInputCondition cond) { guchar *cmdbuf, *buf; - GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectData *connect_data = data; int len, navas, currentav; gaim_debug(GAIM_DEBUG_INFO, "socks5 proxy", "Got CHAP response.\n"); - if (connect_info->read_buffer == NULL) { - connect_info->read_buf_len = 20; - connect_info->read_buffer = g_malloc(connect_info->read_buf_len); - connect_info->read_len = 0; + if (connect_data->read_buffer == NULL) { + connect_data->read_buf_len = 20; + connect_data->read_buffer = g_malloc(connect_data->read_buf_len); + connect_data->read_len = 0; } - len = read(connect_info->fd, connect_info->read_buffer + connect_info->read_len, - connect_info->read_buf_len - connect_info->read_len); + len = read(connect_data->fd, connect_data->read_buffer + connect_data->read_len, + connect_data->read_buf_len - connect_data->read_len); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { - gaim_proxy_connect_info_disconnect(connect_info); - try_connect(connect_info); + gaim_proxy_connect_data_disconnect(connect_data); + try_connect(connect_data); return; } - connect_info->read_len += len; + connect_data->read_len += len; - if (connect_info->read_len < 2) + if (connect_data->read_len < 2) return; - cmdbuf = connect_info->read_buffer; + cmdbuf = connect_data->read_buffer; if (*cmdbuf != 0x01) { - gaim_proxy_connect_info_disconnect(connect_info); - try_connect(connect_info); + gaim_proxy_connect_data_disconnect(connect_data); + try_connect(connect_data); return; } cmdbuf++; @@ -1225,57 +1225,57 @@ cmdbuf++; for (currentav = 0; currentav < navas; currentav++) { - if (connect_info->read_len - (cmdbuf - connect_info->read_buffer) < 2) + if (connect_data->read_len - (cmdbuf - connect_data->read_buffer) < 2) return; - if (connect_info->read_len - (cmdbuf - connect_info->read_buffer) < cmdbuf[1]) + if (connect_data->read_len - (cmdbuf - connect_data->read_buffer) < cmdbuf[1]) return; buf = cmdbuf + 2; switch (cmdbuf[0]) { case 0x00: /* Did auth work? */ if (buf[0] == 0x00) { - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_input_remove(connect_data->inpa); + connect_data->inpa = 0; + g_free(connect_data->read_buffer); + connect_data->read_buffer = NULL; /* Success */ - s5_sendconnect(connect_info, connect_info->fd); + s5_sendconnect(connect_data, connect_data->fd); return; } else { /* Failure */ gaim_debug_warning("proxy", "socks5 CHAP authentication " "failed. Disconnecting..."); - gaim_proxy_connect_info_disconnect(connect_info); - try_connect(connect_info); + gaim_proxy_connect_data_disconnect(connect_data); + try_connect(connect_data); return; } break; case 0x03: /* Server wants our credentials */ - connect_info->write_buf_len = 16 + 4; - connect_info->write_buffer = g_malloc(connect_info->write_buf_len); - connect_info->written_len = 0; + connect_data->write_buf_len = 16 + 4; + connect_data->write_buffer = g_malloc(connect_data->write_buf_len); + connect_data->written_len = 0; hmacmd5_chap(buf, cmdbuf[1], - gaim_proxy_info_get_password(connect_info->gpi), - connect_info->write_buffer + 4); - connect_info->write_buffer[0] = 0x01; - connect_info->write_buffer[1] = 0x01; - connect_info->write_buffer[2] = 0x04; - connect_info->write_buffer[3] = 0x10; + gaim_proxy_info_get_password(connect_data->gpi), + connect_data->write_buffer + 4); + connect_data->write_buffer[0] = 0x01; + connect_data->write_buffer[1] = 0x01; + connect_data->write_buffer[2] = 0x04; + connect_data->write_buffer[3] = 0x10; - gaim_input_remove(connect_info->inpa); - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_input_remove(connect_data->inpa); + g_free(connect_data->read_buffer); + connect_data->read_buffer = NULL; - connect_info->read_cb = s5_readchap; + connect_data->read_cb = s5_readchap; - connect_info->inpa = gaim_input_add(connect_info->fd, - GAIM_INPUT_WRITE, proxy_do_write, connect_info); + connect_data->inpa = gaim_input_add(connect_data->fd, + GAIM_INPUT_WRITE, proxy_do_write, connect_data); - proxy_do_write(connect_info, connect_info->fd, GAIM_INPUT_WRITE); + proxy_do_write(connect_data, connect_data->fd, GAIM_INPUT_WRITE); break; case 0x11: /* Server wants to select an algorithm */ @@ -1287,8 +1287,8 @@ "as supporting. This is a violation " "of the socks5 CHAP specification. " "Disconnecting..."); - gaim_proxy_connect_info_disconnect(connect_info); - try_connect(connect_info); + gaim_proxy_connect_data_disconnect(connect_data); + try_connect(connect_data); return; } break; @@ -1303,107 +1303,107 @@ static void s5_canread(gpointer data, gint source, GaimInputCondition cond) { - GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectData *connect_data = data; int len; - if (connect_info->read_buffer == NULL) { - connect_info->read_buf_len = 2; - connect_info->read_buffer = g_malloc(connect_info->read_buf_len); - connect_info->read_len = 0; + if (connect_data->read_buffer == NULL) { + connect_data->read_buf_len = 2; + connect_data->read_buffer = g_malloc(connect_data->read_buf_len); + connect_data->read_len = 0; } gaim_debug_info("socks5 proxy", "Able to read.\n"); - len = read(connect_info->fd, connect_info->read_buffer + connect_info->read_len, - connect_info->read_buf_len - connect_info->read_len); + len = read(connect_data->fd, connect_data->read_buffer + connect_data->read_len, + connect_data->read_buf_len - connect_data->read_len); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { - gaim_proxy_connect_info_disconnect(connect_info); - try_connect(connect_info); + gaim_proxy_connect_data_disconnect(connect_data); + try_connect(connect_data); return; } - connect_info->read_len += len; + connect_data->read_len += len; - if (connect_info->read_len < 2) + if (connect_data->read_len < 2) return; - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; + gaim_input_remove(connect_data->inpa); + connect_data->inpa = 0; - if ((connect_info->read_buffer[0] != 0x05) || (connect_info->read_buffer[1] == 0xff)) { - gaim_proxy_connect_info_disconnect(connect_info); - try_connect(connect_info); + if ((connect_data->read_buffer[0] != 0x05) || (connect_data->read_buffer[1] == 0xff)) { + gaim_proxy_connect_data_disconnect(connect_data); + try_connect(connect_data); return; } - if (connect_info->read_buffer[1] == 0x02) { + if (connect_data->read_buffer[1] == 0x02) { gsize i, j; const char *u, *p; - u = gaim_proxy_info_get_username(connect_info->gpi); - p = gaim_proxy_info_get_password(connect_info->gpi); + u = gaim_proxy_info_get_username(connect_data->gpi); + p = gaim_proxy_info_get_password(connect_data->gpi); i = (u == NULL) ? 0 : strlen(u); j = (p == NULL) ? 0 : strlen(p); - connect_info->write_buf_len = 1 + 1 + i + 1 + j; - connect_info->write_buffer = g_malloc(connect_info->write_buf_len); - connect_info->written_len = 0; + connect_data->write_buf_len = 1 + 1 + i + 1 + j; + connect_data->write_buffer = g_malloc(connect_data->write_buf_len); + connect_data->written_len = 0; - connect_info->write_buffer[0] = 0x01; /* version 1 */ - connect_info->write_buffer[1] = i; + connect_data->write_buffer[0] = 0x01; /* version 1 */ + connect_data->write_buffer[1] = i; if (u != NULL) - memcpy(connect_info->write_buffer + 2, u, i); - connect_info->write_buffer[2 + i] = j; + memcpy(connect_data->write_buffer + 2, u, i); + connect_data->write_buffer[2 + i] = j; if (p != NULL) - memcpy(connect_info->write_buffer + 2 + i + 1, p, j); + memcpy(connect_data->write_buffer + 2 + i + 1, p, j); - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + g_free(connect_data->read_buffer); + connect_data->read_buffer = NULL; - connect_info->read_cb = s5_readauth; + connect_data->read_cb = s5_readauth; - connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, - proxy_do_write, connect_info); + connect_data->inpa = gaim_input_add(connect_data->fd, GAIM_INPUT_WRITE, + proxy_do_write, connect_data); - proxy_do_write(connect_info, connect_info->fd, GAIM_INPUT_WRITE); + proxy_do_write(connect_data, connect_data->fd, GAIM_INPUT_WRITE); return; - } else if (connect_info->read_buffer[1] == 0x03) { + } else if (connect_data->read_buffer[1] == 0x03) { gsize userlen; - userlen = strlen(gaim_proxy_info_get_username(connect_info->gpi)); + userlen = strlen(gaim_proxy_info_get_username(connect_data->gpi)); - connect_info->write_buf_len = 7 + userlen; - connect_info->write_buffer = g_malloc(connect_info->write_buf_len); - connect_info->written_len = 0; + connect_data->write_buf_len = 7 + userlen; + connect_data->write_buffer = g_malloc(connect_data->write_buf_len); + connect_data->written_len = 0; - connect_info->write_buffer[0] = 0x01; - connect_info->write_buffer[1] = 0x02; - connect_info->write_buffer[2] = 0x11; - connect_info->write_buffer[3] = 0x01; - connect_info->write_buffer[4] = 0x85; - connect_info->write_buffer[5] = 0x02; - connect_info->write_buffer[6] = userlen; - memcpy(connect_info->write_buffer + 7, - gaim_proxy_info_get_username(connect_info->gpi), userlen); + connect_data->write_buffer[0] = 0x01; + connect_data->write_buffer[1] = 0x02; + connect_data->write_buffer[2] = 0x11; + connect_data->write_buffer[3] = 0x01; + connect_data->write_buffer[4] = 0x85; + connect_data->write_buffer[5] = 0x02; + connect_data->write_buffer[6] = userlen; + memcpy(connect_data->write_buffer + 7, + gaim_proxy_info_get_username(connect_data->gpi), userlen); - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + g_free(connect_data->read_buffer); + connect_data->read_buffer = NULL; - connect_info->read_cb = s5_readchap; + connect_data->read_cb = s5_readchap; - connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, - proxy_do_write, connect_info); + connect_data->inpa = gaim_input_add(connect_data->fd, GAIM_INPUT_WRITE, + proxy_do_write, connect_data); - proxy_do_write(connect_info, connect_info->fd, GAIM_INPUT_WRITE); + proxy_do_write(connect_data, connect_data->fd, GAIM_INPUT_WRITE); return; } else { - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + g_free(connect_data->read_buffer); + connect_data->read_buffer = NULL; - s5_sendconnect(connect_info, connect_info->fd); + s5_sendconnect(connect_data, connect_data->fd); } } @@ -1412,29 +1412,29 @@ { unsigned char buf[5]; int i; - GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectData *connect_data = data; socklen_t len; int error = ETIMEDOUT; gaim_debug_info("socks5 proxy", "Connected.\n"); - if (connect_info->inpa > 0) + if (connect_data->inpa > 0) { - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; + gaim_input_remove(connect_data->inpa); + connect_data->inpa = 0; } len = sizeof(error); - if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { - gaim_proxy_connect_info_disconnect(connect_info); - try_connect(connect_info); + if (getsockopt(connect_data->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + gaim_proxy_connect_data_disconnect(connect_data); + try_connect(connect_data); return; } i = 0; buf[0] = 0x05; /* SOCKS version 5 */ - if (gaim_proxy_info_get_username(connect_info->gpi) != NULL) { + if (gaim_proxy_info_get_username(connect_data->gpi) != NULL) { buf[1] = 0x03; /* three methods */ buf[2] = 0x00; /* no authentication */ buf[3] = 0x03; /* CHAP authentication */ @@ -1447,43 +1447,43 @@ i = 3; } - connect_info->write_buf_len = i; - connect_info->write_buffer = g_malloc(connect_info->write_buf_len); - memcpy(connect_info->write_buffer, buf, i); + connect_data->write_buf_len = i; + connect_data->write_buffer = g_malloc(connect_data->write_buf_len); + memcpy(connect_data->write_buffer, buf, i); - connect_info->read_cb = s5_canread; + connect_data->read_cb = s5_canread; - connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, connect_info->fd, GAIM_INPUT_WRITE); + connect_data->inpa = gaim_input_add(connect_data->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_data); + proxy_do_write(connect_data, connect_data->fd, GAIM_INPUT_WRITE); } static int -proxy_connect_socks5(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_socks5(GaimProxyConnectData *connect_data, struct sockaddr *addr, socklen_t addrlen) { gaim_debug_info("socks5 proxy", "Connecting to %s:%d via %s:%d using SOCKS5\n", - connect_info->host, connect_info->port, - gaim_proxy_info_get_host(connect_info->gpi), - gaim_proxy_info_get_port(connect_info->gpi)); + connect_data->host, connect_data->port, + gaim_proxy_info_get_host(connect_data->gpi), + gaim_proxy_info_get_port(connect_data->gpi)); - connect_info->fd = socket(addr->sa_family, SOCK_STREAM, 0); - if (connect_info->fd < 0) + connect_data->fd = socket(addr->sa_family, SOCK_STREAM, 0); + if (connect_data->fd < 0) return -1; - fcntl(connect_info->fd, F_SETFL, O_NONBLOCK); + fcntl(connect_data->fd, F_SETFL, O_NONBLOCK); #ifndef _WIN32 - fcntl(connect_info->fd, F_SETFD, FD_CLOEXEC); + fcntl(connect_data->fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(connect_info->fd, addr, addrlen) != 0) + if (connect(connect_data->fd, addr, addrlen) != 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { gaim_debug_info("socks5 proxy", "Connection in progress\n"); - connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, s5_canwrite, connect_info); + connect_data->inpa = gaim_input_add(connect_data->fd, GAIM_INPUT_WRITE, s5_canwrite, connect_data); } else { - close(connect_info->fd); - connect_info->fd = -1; + close(connect_data->fd); + connect_data->fd = -1; return -1; } } @@ -1495,17 +1495,17 @@ len = sizeof(error); - if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + if (getsockopt(connect_data->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) { - close(connect_info->fd); - connect_info->fd = -1; + close(connect_data->fd); + connect_data->fd = -1; return -1; } - s5_canwrite(connect_info, connect_info->fd, GAIM_INPUT_WRITE); + s5_canwrite(connect_data, connect_data->fd, GAIM_INPUT_WRITE); } - return connect_info->fd; + return connect_data->fd; } /** @@ -1513,44 +1513,44 @@ * to connect to each one. This is called after the hostname is * resolved, and if a connection attempt fails. */ -static void try_connect(GaimProxyConnectInfo *connect_info) +static void try_connect(GaimProxyConnectData *connect_data) { size_t addrlen; struct sockaddr *addr; int ret = -1; - if (connect_info->hosts == NULL) + if (connect_data->hosts == NULL) { - gaim_proxy_connect_info_error(connect_info, _("Could not resolve host name")); + gaim_proxy_connect_data_error(connect_data, _("Could not resolve host name")); return; } - while (connect_info->hosts) + while (connect_data->hosts) { - addrlen = GPOINTER_TO_INT(connect_info->hosts->data); - connect_info->hosts = g_slist_remove(connect_info->hosts, connect_info->hosts->data); - addr = connect_info->hosts->data; - connect_info->hosts = g_slist_remove(connect_info->hosts, connect_info->hosts->data); + addrlen = GPOINTER_TO_INT(connect_data->hosts->data); + connect_data->hosts = g_slist_remove(connect_data->hosts, connect_data->hosts->data); + addr = connect_data->hosts->data; + connect_data->hosts = g_slist_remove(connect_data->hosts, connect_data->hosts->data); - switch (gaim_proxy_info_get_type(connect_info->gpi)) { + switch (gaim_proxy_info_get_type(connect_data->gpi)) { case GAIM_PROXY_NONE: - ret = proxy_connect_none(connect_info, addr, addrlen); + ret = proxy_connect_none(connect_data, addr, addrlen); break; case GAIM_PROXY_HTTP: - ret = proxy_connect_http(connect_info, addr, addrlen); + ret = proxy_connect_http(connect_data, addr, addrlen); break; case GAIM_PROXY_SOCKS4: - ret = proxy_connect_socks4(connect_info, addr, addrlen); + ret = proxy_connect_socks4(connect_data, addr, addrlen); break; case GAIM_PROXY_SOCKS5: - ret = proxy_connect_socks5(connect_info, addr, addrlen); + ret = proxy_connect_socks5(connect_data, addr, addrlen); break; case GAIM_PROXY_USE_ENVVAR: - ret = proxy_connect_http(connect_info, addr, addrlen); + ret = proxy_connect_http(connect_data, addr, addrlen); break; default: @@ -1564,7 +1564,7 @@ } if (ret < 0) { - gaim_proxy_connect_info_error(connect_info, _("Unable to establish a connection")); + gaim_proxy_connect_data_error(connect_data, _("Unable to establish a connection")); } } @@ -1572,23 +1572,23 @@ connection_host_resolved(GSList *hosts, gpointer data, const char *error_message) { - GaimProxyConnectInfo *connect_info; + GaimProxyConnectData *connect_data; - connect_info = data; - connect_info->query_data = NULL; + connect_data = data; + connect_data->query_data = NULL; if (error_message != NULL) { gchar *tmp; tmp = g_strdup_printf("Error while resolving hostname: %s\n", error_message); - gaim_proxy_connect_info_error(connect_info, tmp); + gaim_proxy_connect_data_error(connect_data, tmp); g_free(tmp); return; } - connect_info->hosts = hosts; + connect_data->hosts = hosts; - try_connect(connect_info); + try_connect(connect_data); } GaimProxyInfo * @@ -1657,36 +1657,36 @@ return gpi; } -GaimProxyConnectInfo * +GaimProxyConnectData * gaim_proxy_connect(GaimAccount *account, const char *host, int port, GaimProxyConnectFunction connect_cb, gpointer data) { const char *connecthost = host; int connectport = port; - GaimProxyConnectInfo *connect_info; + GaimProxyConnectData *connect_data; g_return_val_if_fail(host != NULL, NULL); g_return_val_if_fail(port > 0, NULL); g_return_val_if_fail(connect_cb != NULL, NULL); - connect_info = g_new0(GaimProxyConnectInfo, 1); - connect_info->fd = -1; - connect_info->connect_cb = connect_cb; - connect_info->data = data; - connect_info->host = g_strdup(host); - connect_info->port = port; - connect_info->gpi = gaim_proxy_get_setup(account); + connect_data = g_new0(GaimProxyConnectData, 1); + connect_data->fd = -1; + connect_data->connect_cb = connect_cb; + connect_data->data = data; + connect_data->host = g_strdup(host); + connect_data->port = port; + connect_data->gpi = gaim_proxy_get_setup(account); - if ((gaim_proxy_info_get_type(connect_info->gpi) != GAIM_PROXY_NONE) && - (gaim_proxy_info_get_host(connect_info->gpi) == NULL || - gaim_proxy_info_get_port(connect_info->gpi) <= 0)) { + if ((gaim_proxy_info_get_type(connect_data->gpi) != GAIM_PROXY_NONE) && + (gaim_proxy_info_get_host(connect_data->gpi) == NULL || + gaim_proxy_info_get_port(connect_data->gpi) <= 0)) { gaim_notify_error(NULL, NULL, _("Invalid proxy settings"), _("Either the host name or port number specified for your given proxy type is invalid.")); - gaim_proxy_connect_info_destroy(connect_info); + gaim_proxy_connect_data_destroy(connect_data); return NULL; } - switch (gaim_proxy_info_get_type(connect_info->gpi)) + switch (gaim_proxy_info_get_type(connect_data->gpi)) { case GAIM_PROXY_NONE: break; @@ -1695,68 +1695,68 @@ case GAIM_PROXY_SOCKS4: case GAIM_PROXY_SOCKS5: case GAIM_PROXY_USE_ENVVAR: - connecthost = gaim_proxy_info_get_host(connect_info->gpi); - connectport = gaim_proxy_info_get_port(connect_info->gpi); + connecthost = gaim_proxy_info_get_host(connect_data->gpi); + connectport = gaim_proxy_info_get_port(connect_data->gpi); break; default: - gaim_proxy_connect_info_destroy(connect_info); + gaim_proxy_connect_data_destroy(connect_data); return NULL; } - connect_info->query_data = gaim_dnsquery_a(connecthost, - connectport, connection_host_resolved, connect_info); - if (connect_info->query_data == NULL) + connect_data->query_data = gaim_dnsquery_a(connecthost, + connectport, connection_host_resolved, connect_data); + if (connect_data->query_data == NULL) { - gaim_proxy_connect_info_destroy(connect_info); + gaim_proxy_connect_data_destroy(connect_data); return NULL; } - connect_infos = g_slist_prepend(connect_infos, connect_info); + connect_datas = g_slist_prepend(connect_datas, connect_data); - return connect_info; + return connect_data; } /* * Combine some of this code with gaim_proxy_connect() */ -GaimProxyConnectInfo * +GaimProxyConnectData * gaim_proxy_connect_socks5(GaimProxyInfo *gpi, const char *host, int port, GaimProxyConnectFunction connect_cb, gpointer data) { - GaimProxyConnectInfo *connect_info; + GaimProxyConnectData *connect_data; g_return_val_if_fail(host != NULL, NULL); g_return_val_if_fail(port > 0, NULL); g_return_val_if_fail(connect_cb != NULL, NULL); - connect_info = g_new0(GaimProxyConnectInfo, 1); - connect_info->fd = -1; - connect_info->connect_cb = connect_cb; - connect_info->data = data; - connect_info->host = g_strdup(host); - connect_info->port = port; - connect_info->gpi = gpi; + connect_data = g_new0(GaimProxyConnectData, 1); + connect_data->fd = -1; + connect_data->connect_cb = connect_cb; + connect_data->data = data; + connect_data->host = g_strdup(host); + connect_data->port = port; + connect_data->gpi = gpi; - connect_info->query_data = + connect_data->query_data = gaim_dnsquery_a(gaim_proxy_info_get_host(gpi), gaim_proxy_info_get_port(gpi), - connection_host_resolved, connect_info); - if (connect_info->query_data == NULL) + connection_host_resolved, connect_data); + if (connect_data->query_data == NULL) { - gaim_proxy_connect_info_destroy(connect_info); + gaim_proxy_connect_data_destroy(connect_data); return NULL; } - connect_infos = g_slist_prepend(connect_infos, connect_info); + connect_datas = g_slist_prepend(connect_datas, connect_data); - return connect_info; + return connect_data; } void -gaim_proxy_connect_cancel(GaimProxyConnectInfo *connect_info) +gaim_proxy_connect_cancel(GaimProxyConnectData *connect_data) { - gaim_proxy_connect_info_destroy(connect_info); + gaim_proxy_connect_data_destroy(connect_data); } static void @@ -1834,6 +1834,6 @@ void gaim_proxy_uninit(void) { - while (connect_infos != NULL) - gaim_proxy_connect_info_destroy(connect_infos->data); + while (connect_datas != NULL) + gaim_proxy_connect_data_destroy(connect_datas->data); }
--- a/libgaim/proxy.h Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/proxy.h Mon Aug 21 05:25:44 2006 +0000 @@ -56,7 +56,7 @@ } GaimProxyInfo; -typedef struct _GaimProxyConnectInfo GaimProxyConnectInfo; +typedef struct _GaimProxyConnectData GaimProxyConnectData; typedef void (*GaimProxyConnectFunction)(gpointer data, gint source, const gchar *error_message); @@ -237,7 +237,7 @@ * structure that can be used to cancel the pending * connection, if needed. */ -GaimProxyConnectInfo *gaim_proxy_connect(GaimAccount *account, +GaimProxyConnectData *gaim_proxy_connect(GaimAccount *account, const char *host, int port, GaimProxyConnectFunction connect_cb, gpointer data); @@ -257,7 +257,7 @@ * structure that can be used to cancel the pending * connection, if needed. */ -GaimProxyConnectInfo *gaim_proxy_connect_socks5(GaimProxyInfo *gpi, +GaimProxyConnectData *gaim_proxy_connect_socks5(GaimProxyInfo *gpi, const char *host, int port, GaimProxyConnectFunction connect_cb, gpointer data); @@ -270,7 +270,7 @@ * attempt early rather than just letting the OS's TCP/IP stack * time-out the connection. */ -void gaim_proxy_connect_cancel(GaimProxyConnectInfo *connect_info); +void gaim_proxy_connect_cancel(GaimProxyConnectData *connect_data); /*@}*/
--- a/libgaim/sslconn.c Mon Aug 21 05:07:42 2006 +0000 +++ b/libgaim/sslconn.c Mon Aug 21 05:25:44 2006 +0000 @@ -73,7 +73,7 @@ GaimSslOps *ops; gsc = data; - gsc->connect_info = NULL; + gsc->connect_data = NULL; if (source < 0) { @@ -117,9 +117,9 @@ gsc->connect_cb = func; gsc->error_cb = error_func; - gsc->connect_info = gaim_proxy_connect(account, host, port, gaim_ssl_connect_cb, gsc); + gsc->connect_data = gaim_proxy_connect(account, host, port, gaim_ssl_connect_cb, gsc); - if (gsc->connect_info == NULL) + if (gsc->connect_data == NULL) { g_free(gsc->host); g_free(gsc); @@ -192,8 +192,8 @@ ops = gaim_ssl_get_ops(); (ops->close)(gsc); - if (gsc->connect_info != NULL) - gaim_proxy_connect_cancel(gsc->connect_info); + if (gsc->connect_data != NULL) + gaim_proxy_connect_cancel(gsc->connect_data); if (gsc->inpa > 0) gaim_input_remove(gsc->inpa);