/pidgin/main: e5cc097d6c82: cross-win32: fix bonjour

Tomasz Wasilczyk twasilczyk at pidgin.im
Wed Apr 23 09:39:18 EDT 2014


Changeset: e5cc097d6c828db6f2c37231a9b33a3733b143af
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-23 15:39 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/e5cc097d6c82

Description:

cross-win32: fix bonjour

diffstat:

 configure.ac                               |    7 +-
 libpurple/protocols/bonjour/Makefile.am    |   17 ++++-
 libpurple/protocols/bonjour/dns_sd_proxy.c |    2 +-
 libpurple/protocols/bonjour/dns_sd_proxy.h |  100 +++++++++++++++++++++++++++-
 libpurple/protocols/bonjour/jabber.c       |    2 -
 5 files changed, 117 insertions(+), 11 deletions(-)

diffs (218 lines):

diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -1175,7 +1175,10 @@ AC_ARG_ENABLE(avahi,
 		[compile without avahi (required for Bonjour support)])],
 	enable_avahi="$enableval", enable_avahi="yes")
 
-if test "x$enable_avahi" = "xyes"; then
+if test "x$enable_avahi" = "xyes" -a "x$is_win32" = "xyes" ; then
+	avahiincludes="yes"
+	avahilibs="yes"
+elif test "x$enable_avahi" = "xyes"; then
 	AC_ARG_WITH(avahi-client-includes, [AS_HELP_STRING([--with-avahi-client-includes=DIR], [compile the Bonjour plugin against the Avahi Client includes in DIR])], [ac_avahi_client_includes="$withval"], [ac_avahi_client_includes="no"])
 	AC_ARG_WITH(avahi-client-libs, [AS_HELP_STRING([--with-avahi-client-libs=DIR], [compile the Bonjour plugin against the Avahi Client libs in DIR])], [ac_avahi_client_libs="$withval"], [ac_avahi_client_libs="no"])
 	AVAHI_CFLAGS=""
@@ -1931,10 +1934,12 @@ if test "x$enable_dbus" = "xyes" || test
 		enable_dbus=no
 	fi
 
+	if test "x$PYTHON" != "xno" ; then
 	if $PYTHON -c "import sys; sys.exit(sys.version[[:3]] >= '2.4')" ; then
 		AC_MSG_WARN([python version >= 2.4 required])
 		enable_dbus=no
 	fi
+	fi
 fi
 
 dnl ###########################################################################
diff --git a/libpurple/protocols/bonjour/Makefile.am b/libpurple/protocols/bonjour/Makefile.am
--- a/libpurple/protocols/bonjour/Makefile.am
+++ b/libpurple/protocols/bonjour/Makefile.am
@@ -1,4 +1,5 @@
 EXTRA_DIST = \
+	mdns_avahi.c \
 	mdns_win32.c \
 	dns_sd_proxy.c \
 	dns_sd_proxy.h \
@@ -13,7 +14,6 @@ BONJOURSOURCES = \
 	buddy.h \
 	jabber.c \
 	jabber.h \
-	mdns_avahi.c \
 	mdns_common.c \
 	mdns_common.h \
 	mdns_interface.h \
@@ -23,6 +23,15 @@ BONJOURSOURCES = \
 	bonjour_ft.c \
 	bonjour_ft.h 
 
+if IS_WIN32
+BONJOURSOURCES += \
+	dns_sd_proxy.c \
+	mdns_win32.c
+else
+BONJOURSOURCES += \
+	mdns_avahi.c
+endif
+
 AM_CFLAGS = $(st)
 
 libbonjour_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
@@ -44,10 +53,14 @@ endif
 
 libbonjour_la_LIBADD  = @PURPLE_LIBS@ $(LIBXML_LIBS) $(AVAHI_LIBS)
 
+if IS_WIN32
+libbonjour_la_LIBADD += -lnetapi32
+endif
+
 AM_CPPFLAGS = \
 	-I$(top_srcdir)/libpurple \
 	-I$(top_builddir)/libpurple \
 	$(GLIB_CFLAGS) \
 	$(DEBUG_CFLAGS) \
 	$(LIBXML_CFLAGS) \
-	$(AVAHI_CFLAGS)
\ No newline at end of file
+	$(AVAHI_CFLAGS)
diff --git a/libpurple/protocols/bonjour/dns_sd_proxy.c b/libpurple/protocols/bonjour/dns_sd_proxy.c
--- a/libpurple/protocols/bonjour/dns_sd_proxy.c
+++ b/libpurple/protocols/bonjour/dns_sd_proxy.c
@@ -19,7 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA.
  */
 
-#include "win32dep.h"
+#include "internal.h"
 #include "dns_sd_proxy.h"
 
 #ifndef LINK_DNS_SD_DIRECTLY
diff --git a/libpurple/protocols/bonjour/dns_sd_proxy.h b/libpurple/protocols/bonjour/dns_sd_proxy.h
--- a/libpurple/protocols/bonjour/dns_sd_proxy.h
+++ b/libpurple/protocols/bonjour/dns_sd_proxy.h
@@ -21,17 +21,107 @@
 #ifndef _DNS_SD_PROXY
 #define _DNS_SD_PROXY
 
+#include <config.h>
 
 #ifndef _MSC_VER
 #include <stdint.h>
 #endif
 
+#ifdef IS_WIN32_CROSS_COMPILED
+
+/* I'm not sure, if we really need to include this for the following definitions
+ * modeled after Apple's dns_sd.h file.
+ *
+ * Copyright (c) 2003-2004, Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation
+ *     and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of its
+ *     contributors may be used to endorse or promote products derived from this
+ *     software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#  if defined(_WIN32) && !defined(EFI32) && !defined(EFI64)
+#    define DNSSD_API __stdcall
+#  else
+#    define DNSSD_API
+#  endif
+
+#  define kDNSServiceInterfaceIndexAny 0
+#  define kDNSServiceMaxDomainName 1009
+
+typedef gint32 DNSServiceErrorType;
+typedef guint32 DNSServiceFlags;
+typedef struct _DNSServiceRef_t *DNSServiceRef;
+typedef struct _DNSRecordRef_t *DNSRecordRef;
+typedef guint32 DNSServiceProtocol;
+
+typedef union _TXTRecordRef_t {
+	gchar PrivateData[16];
+	gchar *ForceNaturalAlignment;
+} TXTRecordRef;
+
+typedef void (DNSSD_API *DNSServiceBrowseReply)();
+typedef void (DNSSD_API *DNSServiceGetAddrInfoReply)();
+typedef void (DNSSD_API *DNSServiceQueryRecordReply)(
+	DNSServiceRef sdRef, DNSServiceFlags flags, guint32 interfaceIndex,
+	DNSServiceErrorType errorCode, const gchar *fullname,
+	guint16 rrtype, guint16 rrclass, guint16 rdlen, const void *rdata,
+	guint32 ttl, void *context);
+typedef void (DNSSD_API *DNSServiceRegisterReply)();
+typedef void (DNSSD_API *DNSServiceResolveReply)(
+	DNSServiceRef sdRef, DNSServiceFlags flags, guint32 interfaceIndex,
+	DNSServiceErrorType errorCode, const gchar *fullname,
+	const gchar *hosttarget, guint16 port, guint16 txtLen,
+	const guchar *txtRecord, void *context);
+
+enum {
+	kDNSServiceErr_NoError = 0,
+	kDNSServiceErr_Unknown = -65537,
+};
+
+enum {
+	kDNSServiceFlagsAdd = 0x2,
+	kDNSServiceFlagsLongLivedQuery = 0x100,
+};
+
+enum {
+	kDNSServiceType_NULL = 10,
+	kDNSServiceType_TXT = 16,
+};
+
+enum {
+	kDNSServiceClass_IN = 1,
+};
+
+enum {
+	kDNSServiceProtocol_IPv4 = 0x01,
+};
+
+#else
 /* fixup to make pidgin compile against win32 bonjour */
-#if defined(_WIN32) && !defined(_MSC_VER)
-#define _MSL_STDINT_H
-#endif
-
-#include <dns_sd.h>
+#  if defined(_WIN32) && !defined(_MSC_VER)
+#    define _MSL_STDINT_H
+#  endif
+#  include <dns_sd.h>
+#endif /* IS_WIN32_CROSS_COMPILED */
 
 gboolean dns_sd_available(void);
 
diff --git a/libpurple/protocols/bonjour/jabber.c b/libpurple/protocols/bonjour/jabber.c
--- a/libpurple/protocols/bonjour/jabber.c
+++ b/libpurple/protocols/bonjour/jabber.c
@@ -28,8 +28,6 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
-#else
-#include "libc_interface.h"
 #endif
 #include <sys/types.h>
 



More information about the Commits mailing list