/pidgin/main: 7f1d2f3ba6ae: Clear ununused functions from proxy....
Mike Ruprecht
cmaiku at gmail.com
Thu Jan 14 20:42:57 EST 2016
Changeset: 7f1d2f3ba6ae337195d7b86e30bdb9a16e19ef6b
Author: Mike Ruprecht <cmaiku at gmail.com>
Date: 2016-01-10 03:23 -0600
Branch: purple-proxy-to-gio
URL: https://hg.pidgin.im/pidgin/main/rev/7f1d2f3ba6ae
Description:
Clear ununused functions from proxy.[ch] including purple_proxy_connect_udp()
Since porting libpurple's proxy API to internally use Gio, a lot of
functions remain unused. purple_proxy_connect_udp() was added for the
QQ prpl (ticket #6589), but no longer appears to be used. This patch
removes all of these functions in favor of the Gio versions.
diffstat:
libpurple/proxy.c | 1676 +----------------------------------------------------
libpurple/proxy.h | 30 -
2 files changed, 4 insertions(+), 1702 deletions(-)
diffs (truncated from 1750 to 300 lines):
diff --git a/libpurple/proxy.c b/libpurple/proxy.c
--- a/libpurple/proxy.c
+++ b/libpurple/proxy.c
@@ -99,8 +99,6 @@ static PurpleProxyInfo *global_proxy_inf
static GSList *handles = NULL;
-static void try_connect(PurpleProxyConnectData *connect_data);
-
/*
* TODO: Eventually (GObjectification) this bad boy will be removed, because it is
* a gross fix for a crashy problem.
@@ -639,35 +637,13 @@ purple_proxy_connect_data_disconnect(Pur
{
purple_debug_error("proxy", "Connection attempt failed: %s\n",
error_message);
- if (connect_data->hosts != NULL)
- try_connect(connect_data);
- else
- {
- /* Everything failed! Tell the originator of the request. */
- connect_data->connect_cb(connect_data->data, -1, error_message);
- purple_proxy_connect_data_destroy(connect_data);
- }
+
+ /* Everything failed! Tell the originator of the request. */
+ connect_data->connect_cb(connect_data->data, -1, error_message);
+ purple_proxy_connect_data_destroy(connect_data);
}
}
-/*
- * This calls purple_proxy_connect_data_disconnect(), but it lets you
- * specify the error_message using a printf()-like syntax.
- */
-static void
-purple_proxy_connect_data_disconnect_formatted(PurpleProxyConnectData *connect_data, const char *format, ...)
-{
- va_list args;
- gchar *tmp;
-
- va_start(args, format);
- tmp = g_strdup_vprintf(format, args);
- va_end(args);
-
- purple_proxy_connect_data_disconnect(connect_data, tmp);
- g_free(tmp);
-}
-
static void
purple_proxy_connect_data_connected(PurpleProxyConnectData *connect_data)
{
@@ -687,1572 +663,6 @@ purple_proxy_connect_data_connected(Purp
purple_proxy_connect_data_destroy(connect_data);
}
-static void
-socket_ready_cb(gpointer data, gint source, PurpleInputCondition cond)
-{
- PurpleProxyConnectData *connect_data = data;
- int error = 0;
- int ret;
-
- /* If the socket-connected message had already been triggered when connect_data
- * was destroyed via purple_proxy_connect_cancel(), we may get here with a freed connect_data.
- */
- if (!PURPLE_PROXY_CONNECT_DATA_IS_VALID(connect_data))
- return;
-
- purple_debug_info("proxy", "Connecting to %s:%d.\n",
- connect_data->host, connect_data->port);
-
- /*
- * purple_input_get_error after a non-blocking connect returns -1 if something is
- * really messed up (bad descriptor, usually). Otherwise, it returns 0 and
- * error holds what connect would have returned if it blocked until now.
- * Thus, error == 0 is success, error == EINPROGRESS means "try again",
- * and anything else is a real error.
- *
- * (error == EINPROGRESS can happen after a select because the kernel can
- * be overly optimistic sometimes. select is just a hint that you might be
- * able to do something.)
- */
- ret = purple_input_get_error(connect_data->fd, &error);
-
- if (ret == 0 && error == EINPROGRESS) {
- /* No worries - we'll be called again later */
- /* TODO: Does this ever happen? */
- purple_debug_info("proxy", "(ret == 0 && error == EINPROGRESS)\n");
- return;
- }
-
- if (ret != 0 || error != 0) {
- if (ret != 0)
- error = errno;
- purple_debug_error("proxy", "Error connecting to %s:%d (%s).\n",
- connect_data->host, connect_data->port, g_strerror(error));
-
- purple_proxy_connect_data_disconnect(connect_data, g_strerror(error));
- return;
- }
-
- purple_proxy_connect_data_connected(connect_data);
-}
-
-static gboolean
-clean_connect(gpointer data)
-{
- purple_proxy_connect_data_connected(data);
-
- return FALSE;
-}
-
-static void
-proxy_connect_udp_none(PurpleProxyConnectData *connect_data, common_sockaddr_t *addr, socklen_t addrlen)
-{
- purple_debug_info("proxy", "UDP Connecting to %s:%d with no proxy\n",
- connect_data->host, connect_data->port);
-
- connect_data->fd = socket(addr->sa.sa_family, SOCK_DGRAM, 0);
- if (connect_data->fd < 0)
- {
- purple_proxy_connect_data_disconnect_formatted(connect_data,
- _("Unable to create socket: %s"), g_strerror(errno));
- return;
- }
- _purple_network_set_common_socket_flags(connect_data->fd);
-
- if (connect(connect_data->fd, &addr->sa, addrlen) != 0)
- {
- if ((errno == EINPROGRESS) || (errno == EINTR))
- {
- purple_debug_info("proxy", "UDP connection in progress\n");
- connect_data->inpa = purple_input_add(connect_data->fd,
- PURPLE_INPUT_WRITE, socket_ready_cb, connect_data);
- }
- else
- {
- purple_proxy_connect_data_disconnect(connect_data, g_strerror(errno));
- }
- }
- else
- {
- /*
- * The connection happened IMMEDIATELY... strange, but whatever.
- */
- int error = ETIMEDOUT;
- int ret;
-
- purple_debug_info("proxy", "UDP Connected immediately.\n");
-
- ret = purple_input_get_error(connect_data->fd, &error);
- if ((ret != 0) || (error != 0))
- {
- if (ret != 0)
- error = errno;
- purple_proxy_connect_data_disconnect(connect_data, g_strerror(error));
- return;
- }
-
- /*
- * We want to call the "connected" callback eventually, but we
- * don't want to call it before we return, just in case.
- */
- purple_timeout_add(10, clean_connect, connect_data);
- }
-}
-
-static void
-proxy_connect_none(PurpleProxyConnectData *connect_data, common_sockaddr_t *addr, socklen_t addrlen)
-{
- purple_debug_info("proxy", "Connecting to %s:%d with no proxy\n",
- connect_data->host, connect_data->port);
-
- connect_data->fd = socket(addr->sa.sa_family, SOCK_STREAM, 0);
- if (connect_data->fd < 0)
- {
- purple_proxy_connect_data_disconnect_formatted(connect_data,
- _("Unable to create socket: %s"), g_strerror(errno));
- return;
- }
- _purple_network_set_common_socket_flags(connect_data->fd);
-
- if (connect(connect_data->fd, &addr->sa, addrlen) != 0)
- {
- if ((errno == EINPROGRESS) || (errno == EINTR))
- {
- purple_debug_info("proxy", "Connection in progress\n");
- connect_data->inpa = purple_input_add(connect_data->fd,
- PURPLE_INPUT_WRITE, socket_ready_cb, connect_data);
- }
- else
- {
- purple_proxy_connect_data_disconnect(connect_data, g_strerror(errno));
- }
- }
- else
- {
- /*
- * The connection happened IMMEDIATELY... strange, but whatever.
- */
- int error = ETIMEDOUT;
- int ret;
-
- purple_debug_info("proxy", "Connected immediately.\n");
-
- ret = purple_input_get_error(connect_data->fd, &error);
- if ((ret != 0) || (error != 0))
- {
- if (ret != 0)
- error = errno;
- purple_proxy_connect_data_disconnect(connect_data, g_strerror(error));
- return;
- }
-
- /*
- * We want to call the "connected" callback eventually, but we
- * don't want to call it before we return, just in case.
- */
- purple_timeout_add(10, clean_connect, connect_data);
- }
-}
-
-/*
- * This is a utility function used by the HTTP, SOCKS4 and SOCKS5
- * connect functions. It writes data from a buffer to a socket.
- * When all the data is written it sets up a watcher to read a
- * response and call a specified function.
- */
-static void
-proxy_do_write(gpointer data, gint source, PurpleInputCondition cond)
-{
- PurpleProxyConnectData *connect_data;
- const guchar *request;
- gsize request_len;
- int ret;
-
- connect_data = data;
- request = connect_data->write_buffer + connect_data->written_len;
- request_len = connect_data->write_buf_len - connect_data->written_len;
-
- ret = write(connect_data->fd, request, request_len);
- if (ret <= 0)
- {
- if (errno == EAGAIN)
- /* No worries */
- return;
-
- /* Error! */
- purple_proxy_connect_data_disconnect(connect_data, g_strerror(errno));
- return;
- }
- if ((gsize)ret < request_len) {
- connect_data->written_len += ret;
- return;
- }
-
- /* We're done writing data! Wait for a response. */
- g_free(connect_data->write_buffer);
- connect_data->write_buffer = NULL;
- purple_input_remove(connect_data->inpa);
- connect_data->inpa = purple_input_add(connect_data->fd,
- PURPLE_INPUT_READ, connect_data->read_cb, connect_data);
-}
-
-/*
- * We're using an HTTP proxy for a non-port 80 tunnel. Read the
- * response to the CONNECT request.
- */
-static void
-http_canread(gpointer data, gint source, PurpleInputCondition cond)
-{
- int len, headers_len, status = 0;
- gboolean error;
- PurpleProxyConnectData *connect_data = data;
- char *p;
- gsize max_read;
-
- 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 = (char *)connect_data->read_buffer + connect_data->read_len;
- max_read = connect_data->read_buf_len - connect_data->read_len - 1;
-
- len = read(connect_data->fd, p, max_read);
-
- if (len == 0) {
- purple_proxy_connect_data_disconnect(connect_data,
- _("Server closed the connection"));
- return;
- }
-
- if (len < 0) {
- if (errno == EAGAIN)
- /* No worries */
- return;
-
More information about the Commits
mailing list