From 7ebbc12bde85079f3f6f97c76fa2a16dc7bbda8c Mon Sep 17 00:00:00 2001 From: Fawzi Mohamed <fawzi.mohamed@nokia.com> Date: Tue, 18 Oct 2011 14:30:51 +0200 Subject: [PATCH] zeroconf: fix windows building Correct exports, fixed commented out ifdef, moved socket including to a separate header. Change-Id: Iadb6f58e2c3dbadee411fc0df7c7519c1d90309d Reviewed-by: Leandro T. C. Melo <leandro.melo@nokia.com> --- src/libs/zeroconf/avahiLib.cpp | 4 +- src/libs/zeroconf/embeddedLib.cpp | 13 ++--- src/libs/zeroconf/nativeLib.cpp | 2 + src/libs/zeroconf/servicebrowser.cpp | 87 ++++++++++++---------------- src/libs/zeroconf/syssocket.h | 56 ++++++++++++++++++ src/libs/zeroconf/zeroconf.pro | 4 +- 6 files changed, 106 insertions(+), 60 deletions(-) create mode 100644 src/libs/zeroconf/syssocket.h diff --git a/src/libs/zeroconf/avahiLib.cpp b/src/libs/zeroconf/avahiLib.cpp index 9558d023065..bc4e0086630 100644 --- a/src/libs/zeroconf/avahiLib.cpp +++ b/src/libs/zeroconf/avahiLib.cpp @@ -38,9 +38,9 @@ #include <QString> #include <QStringList> -//#ifdef Q_OS_LINUX +#ifdef Q_OS_LINUX #define AVAHI_LIB -//#endif +#endif #ifdef AVAHI_LIB diff --git a/src/libs/zeroconf/embeddedLib.cpp b/src/libs/zeroconf/embeddedLib.cpp index 8c9ac039afb..aca6bf7eca9 100644 --- a/src/libs/zeroconf/embeddedLib.cpp +++ b/src/libs/zeroconf/embeddedLib.cpp @@ -29,14 +29,9 @@ ** Nokia at info@qt.nokia.com. ** **************************************************************************/ -#include <qglobal.h> -#ifdef Q_OS_LINUX -#define EMBEDDED_LIB -#endif -#ifdef Q_OS_WIN -# include <Winsock2.h> -#endif +#include "syssocket.h" // this should be the first header included + #include "servicebrowser_p.h" #include <QtCore/QString> @@ -45,6 +40,10 @@ #include <QtCore/QCoreApplication> #include <QtCore/QDebug> +#ifdef Q_OS_LINUX +#define EMBEDDED_LIB +#endif + #ifdef EMBEDDED_LIB #include "embed/dnssd_ipc.c" #include "embed/dnssd_clientlib.c" diff --git a/src/libs/zeroconf/nativeLib.cpp b/src/libs/zeroconf/nativeLib.cpp index d5bb6746766..c9fd4d5ad98 100644 --- a/src/libs/zeroconf/nativeLib.cpp +++ b/src/libs/zeroconf/nativeLib.cpp @@ -30,6 +30,8 @@ ** **************************************************************************/ +#include "syssocket.h" // this should be the first header included + #include "servicebrowser.h" #include "servicebrowser_p.h" diff --git a/src/libs/zeroconf/servicebrowser.cpp b/src/libs/zeroconf/servicebrowser.cpp index bab9e511e5b..3fa8d23e14b 100644 --- a/src/libs/zeroconf/servicebrowser.cpp +++ b/src/libs/zeroconf/servicebrowser.cpp @@ -30,19 +30,6 @@ ** **************************************************************************/ -#ifdef Q_OS_WIN32 -# include <Winsock2.h> -# ifndef SHUT_RDWR -# ifdef SD_BOTH -# define SHUT_RDWR SD_BOTH -# else -# define SHUT_RDWR 2 -# endif -# endif -#else -# include <sys/socket.h> -#endif - #include "mdnsderived.h" #include "servicebrowser_p.h" @@ -442,16 +429,16 @@ void initLib(LibUsage usage, const QString &libName, const QString &daemonPath) namespace Internal { // ----------------- dns-sd C callbacks ----------------- -extern "C" void cServiceResolveReply(DNSServiceRef sdRef, - DNSServiceFlags flags, - uint32_t interfaceIndex, - DNSServiceErrorType errorCode, - const char *fullname, - const char *hosttarget, - uint16_t port, /* In network byte order */ - uint16_t txtLen, - const unsigned char *txtRecord, - void *context) +extern "C" void DNSSD_API cServiceResolveReply(DNSServiceRef sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceErrorType errorCode, + const char *fullname, + const char *hosttarget, + uint16_t port, /* In network byte order */ + uint16_t txtLen, + const unsigned char *txtRecord, + void *context) { if (DEBUG_ZEROCONF) qDebug() << "cServiceResolveReply(" << ((size_t)sdRef) << ", " << ((quint32)flags) << ", " << interfaceIndex @@ -469,17 +456,17 @@ extern "C" void cServiceResolveReply(DNSServiceRef sdRef, } } -extern "C" void cTxtRecordReply(DNSServiceRef sdRef, - DNSServiceFlags flags, - uint32_t interfaceIndex, - DNSServiceErrorType errorCode, - const char *fullname, - uint16_t rrtype, - uint16_t rrclass, - uint16_t rdlen, - const void *rdata, - uint32_t ttl, - void *context) +extern "C" void DNSSD_API cTxtRecordReply(DNSServiceRef sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceErrorType errorCode, + const char *fullname, + uint16_t rrtype, + uint16_t rrclass, + uint16_t rdlen, + const void *rdata, + uint32_t ttl, + void *context) { if (DEBUG_ZEROCONF) qDebug() << "cTxtRecordReply(" << ((size_t)sdRef) << ", " << ((int)flags) << ", " << interfaceIndex @@ -495,14 +482,14 @@ extern "C" void cTxtRecordReply(DNSServiceRef sdRef, } } -extern "C" void cAddrReply(DNSServiceRef sdRef, - DNSServiceFlags flags, - uint32_t interfaceIndex, - DNSServiceErrorType errorCode, - const char *hostname, - const struct sockaddr *address, - uint32_t ttl, - void *context) +extern "C" void DNSSD_API cAddrReply(DNSServiceRef sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceErrorType errorCode, + const char *hostname, + const struct sockaddr *address, + uint32_t ttl, + void *context) { if (DEBUG_ZEROCONF) qDebug() << "cAddrReply(" << ((size_t)sdRef) << ", " << ((int)flags) << ", " << interfaceIndex @@ -515,14 +502,14 @@ extern "C" void cAddrReply(DNSServiceRef sdRef, } /// callback for service browsing -extern "C" void cBrowseReply(DNSServiceRef sdRef, - DNSServiceFlags flags, - uint32_t interfaceIndex, - DNSServiceErrorType errorCode, - const char *serviceName, - const char *regtype, - const char *replyDomain, - void *context) +extern "C" void DNSSD_API cBrowseReply(DNSServiceRef sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceErrorType errorCode, + const char *serviceName, + const char *regtype, + const char *replyDomain, + void *context) { if (DEBUG_ZEROCONF) qDebug() << "cBrowseReply(" << ((size_t)sdRef) << ", " << flags << ", " << interfaceIndex diff --git a/src/libs/zeroconf/syssocket.h b/src/libs/zeroconf/syssocket.h new file mode 100644 index 00000000000..fc9fb6991a6 --- /dev/null +++ b/src/libs/zeroconf/syssocket.h @@ -0,0 +1,56 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef SYSSOCKET_H +#define SYSSOCKET_H + +// WARNING: +// +// we use Winsock2, which means that this header should be included *before* +// any other windows header + +#include <qglobal.h> + +#ifdef Q_OS_WIN32 +# include <Winsock2.h> +# ifndef SHUT_RDWR +# ifdef SD_BOTH +# define SHUT_RDWR SD_BOTH +# else +# define SHUT_RDWR 2 +# endif +# endif +#else +# include <sys/socket.h> +#endif + +#endif // SYSSOCKET_H diff --git a/src/libs/zeroconf/zeroconf.pro b/src/libs/zeroconf/zeroconf.pro index 7081d4646a8..6dca3c066b5 100644 --- a/src/libs/zeroconf/zeroconf.pro +++ b/src/libs/zeroconf/zeroconf.pro @@ -16,7 +16,8 @@ HEADERS += servicebrowser.h \ zeroconf_global.h \ dns_sd_types.h \ servicebrowser_p.h \ - mdnsderived.h + mdnsderived.h \ + syssocket.h include(../../qtcreatorlibrary.pri) @@ -25,3 +26,4 @@ win32{ } + -- GitLab