/pidgin/main: 7acd79998245: Merged in rw_grim/pidgin (pull reque...

Gary Kramlich grim at reaperworld.com
Wed Dec 23 23:33:36 EST 2015


Changeset: 7acd799982458935d8a0a8101ffe14fb3559067d
Author:	 Gary Kramlich <grim at reaperworld.com>
Date:	 2015-12-23 22:32 -0600
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/7acd79998245

Description:

Merged in rw_grim/pidgin (pull request #3)

Replace custom DNS code with GResolver

diffstat:

 configure.ac                                   |     6 +-
 libpurple/Makefile.am                          |     4 -
 libpurple/core.c                               |     3 -
 libpurple/dnsquery.c                           |  1080 ----------------------
 libpurple/dnsquery.h                           |   195 ----
 libpurple/dnssrv.c                             |  1163 ------------------------
 libpurple/dnssrv.h                             |   213 ----
 libpurple/glibcompat.h                         |    59 -
 libpurple/network.c                            |    62 +-
 libpurple/protocols/gg/resolver-purple.c       |   124 +-
 libpurple/protocols/jabber/disco.c             |    92 +-
 libpurple/protocols/jabber/google/jingleinfo.c |    67 +-
 libpurple/protocols/jabber/jabber.c            |   170 +-
 libpurple/protocols/jabber/jabber.h            |    11 +-
 libpurple/protocols/simple/simple.c            |   106 +-
 libpurple/protocols/simple/simple.h            |     6 +-
 libpurple/protocols/yahoo/yahoo_filexfer.c     |    70 +-
 libpurple/proxy.c                              |   263 +++--
 libpurple/purple.h.in                          |     2 -
 libpurple/stun.c                               |   100 +-
 20 files changed, 561 insertions(+), 3235 deletions(-)

diffs (truncated from 4536 to 300 lines):

diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -477,13 +477,13 @@ fi #enable_i18n
 AM_CONDITIONAL(INSTALL_I18N, test "x$enable_i18n" = "xyes")
 
 dnl #######################################################################
-dnl # Check for GLib 2.20 (required)
+dnl # Check for GLib 2.34 (required)
 dnl #######################################################################
-PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.28.0 gio-2.0 gobject-2.0 gthread-2.0], , [
+PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.34.0 gio-2.0 gobject-2.0 gthread-2.0], , [
 	AC_MSG_RESULT(no)
 	AC_MSG_ERROR([
 
-You must have GLib 2.20.0 or newer development headers installed to build.
+You must have GLib 2.34.0 or newer development headers installed to build.
 
 If you have these installed already you may need to install pkg-config so
 I can find them.
diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am
--- a/libpurple/Makefile.am
+++ b/libpurple/Makefile.am
@@ -106,8 +106,6 @@ purple_coresources = \
 	smiley-parser.c \
 	smiley-theme.c \
 	smiley.c \
-	dnsquery.c \
-	dnssrv.c\
 	status.c \
 	stringref.c \
 	stun.c \
@@ -187,8 +185,6 @@ purple_coreheaders = \
 	smiley-parser.h \
 	smiley-theme.h \
 	smiley.h \
-	dnsquery.h \
-	dnssrv.h \
 	status.h \
 	stringref.h \
 	stun.h \
diff --git a/libpurple/core.c b/libpurple/core.c
--- a/libpurple/core.c
+++ b/libpurple/core.c
@@ -26,7 +26,6 @@
 #include "conversation.h"
 #include "core.h"
 #include "debug.h"
-#include "dnsquery.h"
 #include "xfer.h"
 #include "glibcompat.h"
 #include "http.h"
@@ -200,7 +199,6 @@ purple_core_init(const char *ui)
 	purple_pounces_init();
 	_purple_socket_init();
 	purple_proxy_init();
-	purple_dnsquery_init();
 	purple_sound_init();
 	purple_ssl_init();
 	purple_stun_init();
@@ -276,7 +274,6 @@ purple_core_quit(void)
 	purple_xfers_uninit();
 	purple_proxy_uninit();
 	_purple_socket_uninit();
-	purple_dnsquery_uninit();
 	_purple_image_store_uninit();
 	purple_network_uninit();
 
diff --git a/libpurple/dnsquery.c b/libpurple/dnsquery.c
deleted file mode 100644
--- a/libpurple/dnsquery.c
+++ /dev/null
@@ -1,1080 +0,0 @@
-/* purple
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here.  Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
- *
- */
-#define _PURPLE_DNSQUERY_C_
-
-#include "internal.h"
-#include "debug.h"
-#include "dnsquery.h"
-#include "network.h"
-#include "notify.h"
-#include "prefs.h"
-#include "util.h"
-
-#ifndef _WIN32
-#include <resolv.h>
-#endif
-
-#define MAX_ADDR_RESPONSE_LEN 1048576
-
-#if (defined(__APPLE__) || defined (__unix__)) && !defined(__osf__)
-#define PURPLE_DNSQUERY_USE_FORK
-#endif
-/**************************************************************************
- * DNS query API
- **************************************************************************/
-
-static PurpleDnsQueryUiOps *dns_query_ui_ops = NULL;
-
-typedef struct _PurpleDnsQueryResolverProcess PurpleDnsQueryResolverProcess;
-
-struct _PurpleDnsQueryData {
-	char *hostname;
-	int port;
-	PurpleDnsQueryConnectFunction callback;
-	gpointer data;
-	guint timeout;
-	PurpleAccount *account;
-
-#if defined(PURPLE_DNSQUERY_USE_FORK)
-	PurpleDnsQueryResolverProcess *resolver;
-#elif defined _WIN32 /* end PURPLE_DNSQUERY_USE_FORK  */
-	GThread *resolver;
-	GSList *hosts;
-	gchar *error_message;
-#endif
-};
-
-#if defined(PURPLE_DNSQUERY_USE_FORK)
-
-#define MAX_DNS_CHILDREN 4
-
-/*
- * This structure keeps a reference to a child resolver process.
- */
-struct _PurpleDnsQueryResolverProcess {
-	guint inpa;
-	int fd_in, fd_out;
-	pid_t dns_pid;
-};
-
-static GSList *free_dns_children = NULL;
-static GQueue *queued_requests = NULL;
-
-static int number_of_dns_children = 0;
-
-/*
- * This is a convenience struct used to pass data to
- * the child resolver process.
- */
-typedef struct {
-	char hostname[512];
-	int port;
-} dns_params_t;
-#endif /* end PURPLE_DNSQUERY_USE_FORK */
-
-static void
-purple_dnsquery_resolved(PurpleDnsQueryData *query_data, GSList *hosts)
-{
-	purple_debug_info("dnsquery", "IP resolved for %s\n", query_data->hostname);
-	if (query_data->callback != NULL)
-		query_data->callback(hosts, query_data->data, NULL);
-	else
-	{
-		/*
-		 * Callback is a required parameter, but it can get set to
-		 * NULL if we cancel a thread-based DNS lookup.  So we need
-		 * to free hosts.
-		 */
-		while (hosts != NULL)
-		{
-			hosts = g_slist_remove(hosts, hosts->data);
-			g_free(hosts->data);
-			hosts = g_slist_remove(hosts, hosts->data);
-		}
-	}
-
-#ifdef PURPLE_DNSQUERY_USE_FORK
-	/*
-	 * Add the resolver to the list of available resolvers, and set it
-	 * to NULL so that it doesn't get destroyed along with the query_data
-	 */
-	if (query_data->resolver)
-	{
-		free_dns_children = g_slist_prepend(free_dns_children, query_data->resolver);
-		query_data->resolver = NULL;
-	}
-#endif /* PURPLE_DNSQUERY_USE_FORK */
-
-	purple_dnsquery_destroy(query_data);
-}
-
-static void
-purple_dnsquery_failed(PurpleDnsQueryData *query_data, const gchar *error_message)
-{
-	purple_debug_error("dnsquery", "%s\n", error_message);
-	if (query_data->callback != NULL)
-		query_data->callback(NULL, query_data->data, error_message);
-	purple_dnsquery_destroy(query_data);
-}
-
-static gboolean
-purple_dnsquery_ui_resolve(PurpleDnsQueryData *query_data)
-{
-	PurpleDnsQueryUiOps *ops = purple_dnsquery_get_ui_ops();
-
-	if (ops && ops->resolve_host)
-		return ops->resolve_host(query_data, purple_dnsquery_resolved, purple_dnsquery_failed);
-
-	return FALSE;
-}
-
-static gboolean
-resolve_ip(PurpleDnsQueryData *query_data)
-{
-#if defined(HAVE_GETADDRINFO) && defined(AI_NUMERICHOST)
-	struct addrinfo hints, *res;
-	char servname[20];
-
-	g_snprintf(servname, sizeof(servname), "%d", query_data->port);
-	memset(&hints, 0, sizeof(hints));
-	hints.ai_family = AF_UNSPEC;
-	hints.ai_flags |= AI_NUMERICHOST;
-
-	if (0 == getaddrinfo(query_data->hostname, servname, &hints, &res))
-	{
-		GSList *hosts = NULL;
-		hosts = g_slist_append(hosts, GINT_TO_POINTER(res->ai_addrlen));
-		hosts = g_slist_append(hosts, g_memdup(res->ai_addr, res->ai_addrlen));
-		purple_dnsquery_resolved(query_data, hosts);
-
-		freeaddrinfo(res);
-		return TRUE;
-	}
-#else /* defined(HAVE_GETADDRINFO) && defined(AI_NUMERICHOST) */
-	struct sockaddr_in sin;
-	if (inet_aton(query_data->hostname, &sin.sin_addr))
-	{
-		/*
-		 * The given "hostname" is actually an IP address, so we
-		 * don't need to do anything.
-		 */
-		GSList *hosts = NULL;
-		sin.sin_family = AF_INET;
-		sin.sin_port = htons(query_data->port);
-		hosts = g_slist_append(hosts, GINT_TO_POINTER(sizeof(sin)));
-		hosts = g_slist_append(hosts, g_memdup(&sin, sizeof(sin)));
-		purple_dnsquery_resolved(query_data, hosts);
-
-		return TRUE;
-	}
-#endif
-
-	return FALSE;
-}
-
-#ifdef USE_IDN
-static gboolean
-dns_str_is_ascii(const char *name)
-{
-	guchar *c;
-	for (c = (guchar *)name; c && *c; ++c) {
-		if (*c > 0x7f)
-			return FALSE;
-	}
-
-	return TRUE;
-}
-#endif
-
-#if defined(PURPLE_DNSQUERY_USE_FORK)
-
-/*
- * Unix!
- */
-
-/*
- * Begin the DNS resolver child process functions.
- */
-#ifdef HAVE_SIGNAL_H
-G_GNUC_NORETURN static void
-trap_gdb_bug(int sig)
-{
-	const char *message =
-		"Purple's DNS child got a SIGTRAP signal.\n"
-		"This can be caused by trying to run purple inside gdb.\n"
-		"There is a known gdb bug which prevents this.  Supposedly purple\n"
-		"should have detected you were using gdb and used an ugly hack,\n"
-		"check cope_with_gdb_brokenness() in dnsquery.c.\n\n"
-		"For more info about this bug, see http://sources.redhat.com/ml/gdb/2001-07/msg00349.html\n";



More information about the Commits mailing list