From 3241e63f07c5fa493788897ddfb87a201205f621 Mon Sep 17 00:00:00 2001 From: Niels Ole Salscheider Date: Sun, 3 Sep 2017 21:55:36 +0200 Subject: Initial CMake build system --- src/CMakeLists.txt | 191 +++++++++++++++++++++++++++++++++++++++ src/base/base.pri | 102 --------------------- src/client/client.pri | 46 ---------- src/server/QXmppServerPlugin.cpp | 25 +++++ src/server/server.pri | 20 ---- src/src.pro | 42 --------- 6 files changed, 216 insertions(+), 210 deletions(-) create mode 100644 src/CMakeLists.txt delete mode 100644 src/base/base.pri delete mode 100644 src/client/client.pri create mode 100644 src/server/QXmppServerPlugin.cpp delete mode 100644 src/server/server.pri delete mode 100644 src/src.pro (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000..b4f659cb --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,191 @@ +add_definitions(-DQXMPP_BUILD) + +include_directories(base) +include_directories(client) +include_directories(server) + +set(INSTALL_HEADER_FILES + # Base + base/QXmppArchiveIq.h + base/QXmppBindIq.h + base/QXmppBookmarkSet.h + base/QXmppByteStreamIq.h + base/QXmppDataForm.h + base/QXmppDiscoveryIq.h + base/QXmppElement.h + base/QXmppEntityTimeIq.h + base/QXmppGlobal.h + base/QXmppIbbIq.h + base/QXmppIq.h + base/QXmppJingleIq.h + base/QXmppLogger.h + base/QXmppMamIq.h + base/QXmppMessage.h + base/QXmppMucIq.h + base/QXmppNonSASLAuth.h + base/QXmppPingIq.h + base/QXmppPresence.h + base/QXmppPubSubIq.h + base/QXmppRegisterIq.h + base/QXmppResultSet.h + base/QXmppRosterIq.h + base/QXmppRpcIq.h + base/QXmppRtcpPacket.h + base/QXmppRtpChannel.h + base/QXmppRtpPacket.h + base/QXmppSessionIq.h + base/QXmppSocks.h + base/QXmppStanza.h + base/QXmppStream.h + base/QXmppStreamFeatures.h + base/QXmppStun.h + base/QXmppUtils.h + base/QXmppVCardIq.h + base/QXmppVersionIq.h + + # Client + client/QXmppArchiveManager.h + client/QXmppBookmarkManager.h + client/QXmppCallManager.h + client/QXmppCarbonManager.h + client/QXmppClient.h + client/QXmppClientExtension.h + client/QXmppConfiguration.h + client/QXmppDiscoveryManager.h + client/QXmppEntityTimeManager.h + client/QXmppInvokable.h + client/QXmppMamManager.h + client/QXmppMessageReceiptManager.h + client/QXmppMucManager.h + client/QXmppOutgoingClient.h + client/QXmppRemoteMethod.h + client/QXmppRosterManager.h + client/QXmppRpcManager.h + client/QXmppTransferManager.h + client/QXmppTransferManager_p.h + client/QXmppVCardManager.h + client/QXmppVersionManager.h + + # Server + server/QXmppDialback.h + server/QXmppIncomingClient.h + server/QXmppIncomingServer.h + server/QXmppOutgoingServer.h + server/QXmppPasswordChecker.h + server/QXmppServer.h + server/QXmppServerExtension.h + server/QXmppServerPlugin.h +) + +set(SOURCE_FILES + # Base + base/QXmppArchiveIq.cpp + base/QXmppBindIq.cpp + base/QXmppBookmarkSet.cpp + base/QXmppByteStreamIq.cpp + base/QXmppCodec.cpp + base/QXmppConstants.cpp + base/QXmppDataForm.cpp + base/QXmppDiscoveryIq.cpp + base/QXmppElement.cpp + base/QXmppEntityTimeIq.cpp + base/QXmppGlobal.cpp + base/QXmppIbbIq.cpp + base/QXmppIq.cpp + base/QXmppJingleIq.cpp + base/QXmppLogger.cpp + base/QXmppMamIq.cpp + base/QXmppMessage.cpp + base/QXmppMucIq.cpp + base/QXmppNonSASLAuth.cpp + base/QXmppPingIq.cpp + base/QXmppPresence.cpp + base/QXmppPubSubIq.cpp + base/QXmppRegisterIq.cpp + base/QXmppResultSet.cpp + base/QXmppRosterIq.cpp + base/QXmppRpcIq.cpp + base/QXmppRtcpPacket.cpp + base/QXmppRtpChannel.cpp + base/QXmppRtpPacket.cpp + base/QXmppSasl.cpp + base/QXmppSessionIq.cpp + base/QXmppSocks.cpp + base/QXmppStanza.cpp + base/QXmppStream.cpp + base/QXmppStreamFeatures.cpp + base/QXmppStreamInitiationIq.cpp + base/QXmppStreamManagement.cpp + base/QXmppStun.cpp + base/QXmppUtils.cpp + base/QXmppVCardIq.cpp + base/QXmppVersionIq.cpp + + # Client + client/QXmppDiscoveryManager.cpp + client/QXmppArchiveManager.cpp + client/QXmppBookmarkManager.cpp + client/QXmppCallManager.cpp + client/QXmppCarbonManager.cpp + client/QXmppClient.cpp + client/QXmppClientExtension.cpp + client/QXmppConfiguration.cpp + client/QXmppEntityTimeManager.cpp + client/QXmppInvokable.cpp + client/QXmppMamManager.cpp + client/QXmppMessageReceiptManager.cpp + client/QXmppMucManager.cpp + client/QXmppOutgoingClient.cpp + client/QXmppRemoteMethod.cpp + client/QXmppRosterManager.cpp + client/QXmppRpcManager.cpp + client/QXmppTransferManager.cpp + client/QXmppVCardManager.cpp + client/QXmppVersionManager.cpp + + # Server + server/QXmppDialback.cpp + server/QXmppIncomingClient.cpp + server/QXmppIncomingServer.cpp + server/QXmppOutgoingServer.cpp + server/QXmppPasswordChecker.cpp + server/QXmppServer.cpp + server/QXmppServerExtension.cpp + server/QXmppServerPlugin.cpp +) + +add_library(qxmpp SHARED ${SOURCE_FILES}) + +set_target_properties(qxmpp PROPERTIES + VERSION ${VERSION_STRING} + SOVERSION ${SO_VERSION} + EXPORT_NAME QXmpp + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_INSTALL_FULL_INCLUDEDIR}/qxmpp" +) + +target_link_libraries(qxmpp + PUBLIC + Qt5::Core + Qt5::Network + Qt5::Xml +) + +install( + TARGETS qxmpp + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + EXPORT QXmppTarget +) + +install( + EXPORT QXmppTarget + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/qxmpp" + FILE QXmpp.cmake + NAMESPACE QXmpp:: + COMPONENT Devel +) + +install( + FILES ${INSTALL_HEADER_FILES} + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/qxmpp" +) + diff --git a/src/base/base.pri b/src/base/base.pri deleted file mode 100644 index 45a74afb..00000000 --- a/src/base/base.pri +++ /dev/null @@ -1,102 +0,0 @@ -# Header files -INSTALL_HEADERS += \ - base/QXmppArchiveIq.h \ - base/QXmppBindIq.h \ - base/QXmppBookmarkSet.h \ - base/QXmppByteStreamIq.h \ - base/QXmppDataForm.h \ - base/QXmppDiscoveryIq.h \ - base/QXmppElement.h \ - base/QXmppEntityTimeIq.h \ - base/QXmppGlobal.h \ - base/QXmppIbbIq.h \ - base/QXmppIq.h \ - base/QXmppJingleIq.h \ - base/QXmppLogger.h \ - base/QXmppMamIq.h \ - base/QXmppMessage.h \ - base/QXmppMucIq.h \ - base/QXmppNonSASLAuth.h \ - base/QXmppPingIq.h \ - base/QXmppPresence.h \ - base/QXmppPubSubIq.h \ - base/QXmppRegisterIq.h \ - base/QXmppResultSet.h \ - base/QXmppRosterIq.h \ - base/QXmppRpcIq.h \ - base/QXmppRtcpPacket.h \ - base/QXmppRtpChannel.h \ - base/QXmppRtpPacket.h \ - base/QXmppSessionIq.h \ - base/QXmppSocks.h \ - base/QXmppStanza.h \ - base/QXmppStream.h \ - base/QXmppStreamFeatures.h \ - base/QXmppStun.h \ - base/QXmppUtils.h \ - base/QXmppVCardIq.h \ - base/QXmppVersionIq.h - -HEADERS += \ - base/QXmppCodec_p.h \ - base/QXmppConstants_p.h \ - base/QXmppSasl_p.h \ - base/QXmppStanza_p.h \ - base/QXmppStreamInitiationIq_p.h \ - base/QXmppStun_p.h - -# Source files -SOURCES += \ - base/QXmppArchiveIq.cpp \ - base/QXmppBindIq.cpp \ - base/QXmppBookmarkSet.cpp \ - base/QXmppByteStreamIq.cpp \ - base/QXmppCodec.cpp \ - base/QXmppConstants.cpp \ - base/QXmppDataForm.cpp \ - base/QXmppDiscoveryIq.cpp \ - base/QXmppElement.cpp \ - base/QXmppEntityTimeIq.cpp \ - base/QXmppGlobal.cpp \ - base/QXmppIbbIq.cpp \ - base/QXmppIq.cpp \ - base/QXmppJingleIq.cpp \ - base/QXmppLogger.cpp \ - base/QXmppMamIq.cpp \ - base/QXmppMessage.cpp \ - base/QXmppMucIq.cpp \ - base/QXmppNonSASLAuth.cpp \ - base/QXmppPingIq.cpp \ - base/QXmppPresence.cpp \ - base/QXmppPubSubIq.cpp \ - base/QXmppRegisterIq.cpp \ - base/QXmppResultSet.cpp \ - base/QXmppRosterIq.cpp \ - base/QXmppRpcIq.cpp \ - base/QXmppRtcpPacket.cpp \ - base/QXmppRtpChannel.cpp \ - base/QXmppRtpPacket.cpp \ - base/QXmppSasl.cpp \ - base/QXmppSessionIq.cpp \ - base/QXmppSocks.cpp \ - base/QXmppStanza.cpp \ - base/QXmppStream.cpp \ - base/QXmppStreamFeatures.cpp \ - base/QXmppStreamInitiationIq.cpp \ - base/QXmppStreamManagement.cpp \ - base/QXmppStun.cpp \ - base/QXmppUtils.cpp \ - base/QXmppVCardIq.cpp \ - base/QXmppVersionIq.cpp - -# DNS -qt_version = $$QT_MAJOR_VERSION -contains(qt_version, 4) { - INSTALL_HEADERS += base/qdnslookup.h base/qdnslookup_p.h - SOURCES += base/qdnslookup.cpp - android:SOURCES += base/qdnslookup_stub.cpp - else:symbian:SOURCES += base/qdnslookup_symbian.cpp - else:unix:SOURCES += base/qdnslookup_unix.cpp - else:win32:SOURCES += base/qdnslookup_win.cpp - else:SOURCES += base/qdnslookup_stub.cpp -} diff --git a/src/client/client.pri b/src/client/client.pri deleted file mode 100644 index bfb3094f..00000000 --- a/src/client/client.pri +++ /dev/null @@ -1,46 +0,0 @@ -# Header files -INSTALL_HEADERS += \ - client/QXmppArchiveManager.h \ - client/QXmppBookmarkManager.h \ - client/QXmppCallManager.h \ - client/QXmppCarbonManager.h \ - client/QXmppClient.h \ - client/QXmppClientExtension.h \ - client/QXmppConfiguration.h \ - client/QXmppDiscoveryManager.h \ - client/QXmppEntityTimeManager.h \ - client/QXmppInvokable.h \ - client/QXmppMamManager.h \ - client/QXmppMessageReceiptManager.h \ - client/QXmppMucManager.h \ - client/QXmppOutgoingClient.h \ - client/QXmppRemoteMethod.h \ - client/QXmppRosterManager.h \ - client/QXmppRpcManager.h \ - client/QXmppTransferManager.h \ - client/QXmppTransferManager_p.h \ - client/QXmppVCardManager.h \ - client/QXmppVersionManager.h - -# Source files -SOURCES += \ - client/QXmppDiscoveryManager.cpp \ - client/QXmppArchiveManager.cpp \ - client/QXmppBookmarkManager.cpp \ - client/QXmppCallManager.cpp \ - client/QXmppCarbonManager.cpp \ - client/QXmppClient.cpp \ - client/QXmppClientExtension.cpp \ - client/QXmppConfiguration.cpp \ - client/QXmppEntityTimeManager.cpp \ - client/QXmppInvokable.cpp \ - client/QXmppMamManager.cpp \ - client/QXmppMessageReceiptManager.cpp \ - client/QXmppMucManager.cpp \ - client/QXmppOutgoingClient.cpp \ - client/QXmppRemoteMethod.cpp \ - client/QXmppRosterManager.cpp \ - client/QXmppRpcManager.cpp \ - client/QXmppTransferManager.cpp \ - client/QXmppVCardManager.cpp \ - client/QXmppVersionManager.cpp diff --git a/src/server/QXmppServerPlugin.cpp b/src/server/QXmppServerPlugin.cpp new file mode 100644 index 00000000..d723ee4d --- /dev/null +++ b/src/server/QXmppServerPlugin.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2017 The QXmpp developers + * + * Author: + * Niels Ole Salscheider + * + * Source: + * https://github.com/qxmpp-project/qxmpp + * + * This file is a part of QXmpp library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + */ + +#include "QXmppServerPlugin.h" + diff --git a/src/server/server.pri b/src/server/server.pri deleted file mode 100644 index 718119a8..00000000 --- a/src/server/server.pri +++ /dev/null @@ -1,20 +0,0 @@ -# Headers -INSTALL_HEADERS += \ - server/QXmppDialback.h \ - server/QXmppIncomingClient.h \ - server/QXmppIncomingServer.h \ - server/QXmppOutgoingServer.h \ - server/QXmppPasswordChecker.h \ - server/QXmppServer.h \ - server/QXmppServerExtension.h \ - server/QXmppServerPlugin.h - -# Source files -SOURCES += \ - server/QXmppDialback.cpp \ - server/QXmppIncomingClient.cpp \ - server/QXmppIncomingServer.cpp \ - server/QXmppOutgoingServer.cpp \ - server/QXmppPasswordChecker.cpp \ - server/QXmppServer.cpp \ - server/QXmppServerExtension.cpp diff --git a/src/src.pro b/src/src.pro deleted file mode 100644 index 6d4aa331..00000000 --- a/src/src.pro +++ /dev/null @@ -1,42 +0,0 @@ -include(../qxmpp.pri) - -QT -= gui - -TEMPLATE = lib - -CONFIG += $$QXMPP_LIBRARY_TYPE -DEFINES += QXMPP_BUILD -DEFINES += $$QXMPP_INTERNAL_DEFINES -INCLUDEPATH += $$QXMPP_INCLUDEPATH $$QXMPP_INTERNAL_INCLUDES -LIBS += $$QXMPP_INTERNAL_LIBS - -# Target definition -TARGET = $$QXMPP_LIBRARY_NAME -VERSION = $$QXMPP_VERSION -win32 { - DESTDIR = $$OUT_PWD -} - -include(base/base.pri) -include(client/client.pri) -include(server/server.pri) - -HEADERS += $$INSTALL_HEADERS - -# Installation -headers.files = $$INSTALL_HEADERS -headers.path = $$PREFIX/include/qxmpp -target.path = $$PREFIX/$$LIBDIR -INSTALLS += headers target - -# pkg-config support -CONFIG += create_pc create_prl no_install_prl -QMAKE_PKGCONFIG_DESTDIR = pkgconfig -QMAKE_PKGCONFIG_LIBDIR = $$target.path -QMAKE_PKGCONFIG_INCDIR = $$headers.path -equals(QXMPP_LIBRARY_TYPE,staticlib) { - QMAKE_PKGCONFIG_CFLAGS = -DQXMPP_STATIC -} else { - QMAKE_PKGCONFIG_CFLAGS = -DQXMPP_SHARED -} -unix:QMAKE_CLEAN += -r pkgconfig lib$${TARGET}.prl -- cgit v1.2.3 From 2a5ccd3bd191b75b9fa148a8fa7f3d3ddc225add Mon Sep 17 00:00:00 2001 From: Niels Ole Salscheider Date: Sun, 3 Sep 2017 22:00:29 +0200 Subject: Drop support for Qt 4 --- src/base/QXmppSasl.cpp | 18 +- src/base/qdnslookup.cpp | 989 ------------------------------------- src/base/qdnslookup.h | 240 --------- src/base/qdnslookup_p.h | 216 -------- src/base/qdnslookup_stub.cpp | 54 -- src/base/qdnslookup_symbian.cpp | 98 ---- src/base/qdnslookup_unix.cpp | 323 ------------ src/base/qdnslookup_win.cpp | 150 ------ src/client/QXmppInvokable.cpp | 12 - src/client/QXmppOutgoingClient.cpp | 6 - src/server/QXmppOutgoingServer.cpp | 6 - src/server/QXmppServer.cpp | 4 - src/server/QXmppServer.h | 4 - 13 files changed, 1 insertion(+), 2119 deletions(-) delete mode 100644 src/base/qdnslookup.cpp delete mode 100644 src/base/qdnslookup.h delete mode 100644 src/base/qdnslookup_p.h delete mode 100644 src/base/qdnslookup_stub.cpp delete mode 100644 src/base/qdnslookup_symbian.cpp delete mode 100644 src/base/qdnslookup_unix.cpp delete mode 100644 src/base/qdnslookup_win.cpp (limited to 'src') diff --git a/src/base/QXmppSasl.cpp b/src/base/QXmppSasl.cpp index cb44007f..cf3347e2 100644 --- a/src/base/QXmppSasl.cpp +++ b/src/base/QXmppSasl.cpp @@ -27,11 +27,7 @@ #include #include #include -#if QT_VERSION >= 0x050000 #include -#else -#include -#endif #include "QXmppSasl_p.h" #include "QXmppUtils.h" @@ -437,23 +433,14 @@ bool QXmppSaslClientFacebook::respond(const QByteArray &challenge, QByteArray &r return true; } else if (m_step == 1) { // parse request -#if QT_VERSION >= 0x050000 QUrlQuery requestUrl(challenge); -#else - QUrl requestUrl; - requestUrl.setEncodedQuery(challenge); -#endif if (!requestUrl.hasQueryItem("method") || !requestUrl.hasQueryItem("nonce")) { warning("QXmppSaslClientFacebook : Invalid challenge, nonce or method missing"); return false; } // build response -#if QT_VERSION >= 0x050000 QUrlQuery responseUrl; -#else - QUrl responseUrl; -#endif responseUrl.addQueryItem("access_token", password()); responseUrl.addQueryItem("api_key", username()); responseUrl.addQueryItem("call_id", 0); @@ -461,11 +448,8 @@ bool QXmppSaslClientFacebook::respond(const QByteArray &challenge, QByteArray &r responseUrl.addQueryItem("nonce", requestUrl.queryItemValue("nonce")); responseUrl.addQueryItem("v", "1.0"); -#if QT_VERSION >= 0x050000 response = responseUrl.query().toUtf8(); -#else - response = responseUrl.encodedQuery(); -#endif + m_step++; return true; } else { diff --git a/src/base/qdnslookup.cpp b/src/base/qdnslookup.cpp deleted file mode 100644 index 7b1e7c8f..00000000 --- a/src/base/qdnslookup.cpp +++ /dev/null @@ -1,989 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Jeremy Lainé -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdnslookup.h" -#include "qdnslookup_p.h" - -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QDnsLookupThreadPool, theDnsLookupThreadPool); -Q_GLOBAL_STATIC(QThreadStorage, theDnsLookupSeedStorage); - -static bool qt_qdnsmailexchangerecord_less_than(const QDnsMailExchangeRecord &r1, const QDnsMailExchangeRecord &r2) -{ - // Lower numbers are more preferred than higher ones. - return r1.preference() < r2.preference(); -} - -/*! - Sorts a list of QDnsMailExchangeRecord objects according to RFC 5321. -*/ - -static void qt_qdnsmailexchangerecord_sort(QList &records) -{ - // If we have no more than one result, we are done. - if (records.size() <= 1) - return; - - // Order the records by preference. - qSort(records.begin(), records.end(), qt_qdnsmailexchangerecord_less_than); - - int i = 0; - while (i < records.size()) { - - // Determine the slice of records with the current preference. - QList slice; - const quint16 slicePreference = records[i].preference(); - for (int j = i; j < records.size(); ++j) { - if (records[j].preference() != slicePreference) - break; - slice << records[j]; - } - - // Randomize the slice of records. - while (!slice.isEmpty()) { - const unsigned int pos = qrand() % slice.size(); - records[i++] = slice.takeAt(pos); - } - } -} - -static bool qt_qdnsservicerecord_less_than(const QDnsServiceRecord &r1, const QDnsServiceRecord &r2) -{ - // Order by priority, or if the priorities are equal, - // put zero weight records first. - return r1.priority() < r2.priority() - || (r1.priority() == r2.priority() - && r1.weight() == 0 && r2.weight() > 0); -} - -/*! - Sorts a list of QDnsServiceRecord objects according to RFC 2782. -*/ - -static void qt_qdnsservicerecord_sort(QList &records) -{ - // If we have no more than one result, we are done. - if (records.size() <= 1) - return; - - // Order the records by priority, and for records with an equal - // priority, put records with a zero weight first. - qSort(records.begin(), records.end(), qt_qdnsservicerecord_less_than); - - int i = 0; - while (i < records.size()) { - - // Determine the slice of records with the current priority. - QList slice; - const quint16 slicePriority = records[i].priority(); - unsigned int sliceWeight = 0; - for (int j = i; j < records.size(); ++j) { - if (records[j].priority() != slicePriority) - break; - sliceWeight += records[j].weight(); - slice << records[j]; - } -#ifdef QDNSLOOKUP_DEBUG - qDebug("qt_qdnsservicerecord_sort() : priority %i (size: %i, total weight: %i)", - slicePriority, slice.size(), sliceWeight); -#endif - - // Order the slice of records. - while (!slice.isEmpty()) { - const unsigned int weightThreshold = qrand() % (sliceWeight + 1); - unsigned int summedWeight = 0; - for (int j = 0; j < slice.size(); ++j) { - summedWeight += slice[j].weight(); - if (summedWeight >= weightThreshold) { -#ifdef QDNSLOOKUP_DEBUG - qDebug("qt_qdnsservicerecord_sort() : adding %s %i (weight: %i)", - qPrintable(slice[j].target()), slice[j].port(), - slice[j].weight()); -#endif - // Adjust the slice weight and take the current record. - sliceWeight -= slice[j].weight(); - records[i++] = slice.takeAt(j); - break; - } - } - } - } -} - -/*! - \class QDnsLookup - \brief The QDnsLookup class represents a DNS lookup. - - \inmodule QtNetwork - \ingroup network - - QDnsLookup uses the mechanisms provided by the operating system to perform - DNS lookups. To perform a lookup you need to specify a \l name and \l type - then invoke the \l{QDnsLookup::lookup()}{lookup()} slot. The - \l{QDnsLookup::finished()}{finished()} signal will be emitted upon - completion. - - For example, you can determine which servers an XMPP chat client should - connect to for a given domain with: - - \snippet doc/src/snippets/code/src_network_kernel_qdnslookup.cpp 0 - - Once the request finishes you can handle the results with: - - \snippet doc/src/snippets/code/src_network_kernel_qdnslookup.cpp 1 - - \note If you simply want to find the IP address(es) associated with a host - name, or the host name associated with an IP address you should use - QHostInfo instead. -*/ - -/*! - \enum QDnsLookup::Error - - Indicates all possible error conditions found during the - processing of the DNS lookup. - - \value NoError no error condition. - - \value ResolverError there was an error initializing the system's - DNS resolver. - - \value OperationCancelledError the lookup was aborted using the abort() - method. - - \value InvalidRequestError the requested DNS lookup was invalid. - - \value InvalidReplyError the reply returned by the server was invalid. - - \value ServerFailureError the server encountered an internal failure - while processing the request (SERVFAIL). - - \value ServerRefusedError the server refused to process the request for - security or policy reasons (REFUSED). - - \value NotFoundError the requested domain name does not exist - (NXDOMAIN). -*/ - -/*! - \enum QDnsLookup::Type - - Indicates the type of DNS lookup that was performed. - - \value A IPv4 address records. - - \value AAAA IPv6 address records. - - \value ANY any records. - - \value CNAME canonical name records. - - \value MX mail exchange records. - - \value NS name server records. - - \value PTR pointer records. - - \value SRV service records. - - \value TXT text records. -*/ - -/*! - \fn void QDnsLookup::finished() - - This signal is emitted when the reply has finished processing. -*/ - -/*! - \fn void QDnsLookup::nameChanged(const QString &name) - - This signal is emitted when the lookup \l name changes. - \a name is the new lookup name. -*/ - -/*! - \fn void QDnsLookup::typeChanged(Type type) - - This signal is emitted when the lookup \l type changes. - \a type is the new lookup type. -*/ - -/*! - Constructs a QDnsLookup object and sets \a parent as the parent object. - - The \l type property will default to QDnsLookup::A. -*/ - -QDnsLookup::QDnsLookup(QObject *parent) - : QObject(parent) - , d_ptr(new QDnsLookupPrivate(this)) -{ - qRegisterMetaType(); -} -/*! - Constructs a QDnsLookup object for the given \a type and \a name and sets - \a parent as the parent object. -*/ - -QDnsLookup::QDnsLookup(Type type, const QString &name, QObject *parent) - : QObject(parent) - , d_ptr(new QDnsLookupPrivate(this)) -{ - Q_D(QDnsLookup); - qRegisterMetaType(); - d->name = name; - d->type = type; -} - -/*! - Destroys the QDnsLookup object. - - It is safe to delete a QDnsLookup object even if it is not finished, you - will simply never receive its results. -*/ - -QDnsLookup::~QDnsLookup() -{ -} - -/*! - \property QDnsLookup::error - \brief the type of error that occurred if the DNS lookup failed, or NoError. -*/ - -QDnsLookup::Error QDnsLookup::error() const -{ - return d_func()->reply.error; -} - -/*! - \property QDnsLookup::errorString - \brief a human-readable description of the error if the DNS lookup failed. -*/ - -QString QDnsLookup::errorString() const -{ - return d_func()->reply.errorString; -} - -/*! - \property QDnsLookup::finished - \brief whether the reply has finished or was aborted. -*/ - -bool QDnsLookup::isFinished() const -{ - return d_func()->isFinished; -} - -/*! - \property QDnsLookup::name - \brief the name to lookup. - - \note The name will be encoded using IDNA, which means it's unsuitable for - querying SRV records compatible with the DNS-SD specification. -*/ - -QString QDnsLookup::name() const -{ - return d_func()->name; -} - -void QDnsLookup::setName(const QString &name) -{ - Q_D(QDnsLookup); - if (name != d->name) { - d->name = name; - emit nameChanged(name); - } -} - -/*! - \property QDnsLookup::type - \brief the type of DNS lookup. -*/ - -QDnsLookup::Type QDnsLookup::type() const -{ - return d_func()->type; -} - -void QDnsLookup::setType(Type type) -{ - Q_D(QDnsLookup); - if (type != d->type) { - d->type = type; - emit typeChanged(type); - } -} - -/*! - Returns the list of canonical name records associated with this lookup. -*/ - -QList QDnsLookup::canonicalNameRecords() const -{ - return d_func()->reply.canonicalNameRecords; -} - -/*! - Returns the list of host address records associated with this lookup. -*/ - -QList QDnsLookup::hostAddressRecords() const -{ - return d_func()->reply.hostAddressRecords; -} - -/*! - Returns the list of mail exchange records associated with this lookup. - - The records are sorted according to - \l{http://www.rfc-editor.org/rfc/rfc5321.txt}{RFC 5321}, so if you use them - to connect to servers, you should try them in the order they are listed. -*/ - -QList QDnsLookup::mailExchangeRecords() const -{ - return d_func()->reply.mailExchangeRecords; -} - -/*! - Returns the list of name server records associated with this lookup. -*/ - -QList QDnsLookup::nameServerRecords() const -{ - return d_func()->reply.nameServerRecords; -} - -/*! - Returns the list of pointer records associated with this lookup. -*/ - -QList QDnsLookup::pointerRecords() const -{ - return d_func()->reply.pointerRecords; -} - -/*! - Returns the list of service records associated with this lookup. - - The records are sorted according to - \l{http://www.rfc-editor.org/rfc/rfc2782.txt}{RFC 2782}, so if you use them - to connect to servers, you should try them in the order they are listed. -*/ - -QList QDnsLookup::serviceRecords() const -{ - return d_func()->reply.serviceRecords; -} - -/*! - Returns the list of text records associated with this lookup. -*/ - -QList QDnsLookup::textRecords() const -{ - return d_func()->reply.textRecords; -} - -/*! - Aborts the DNS lookup operation. - - If the lookup is already finished, does nothing. -*/ - -void QDnsLookup::abort() -{ - Q_D(QDnsLookup); - if (d->runnable) { - d->runnable = 0; - d->reply = QDnsLookupReply(); - d->reply.error = QDnsLookup::OperationCancelledError; - d->reply.errorString = tr("Operation cancelled"); - d->isFinished = true; - emit finished(); - } -} - -/*! - Performs the DNS lookup. - - The \l{QDnsLookup::finished()}{finished()} signal is emitted upon completion. -*/ - -void QDnsLookup::lookup() -{ - Q_D(QDnsLookup); - d->isFinished = false; - d->reply = QDnsLookupReply(); - d->runnable = new QDnsLookupRunnable(d->type, QUrl::toAce(d->name)); - connect(d->runnable, SIGNAL(finished(QDnsLookupReply)), - this, SLOT(_q_lookupFinished(QDnsLookupReply)), - Qt::BlockingQueuedConnection); - theDnsLookupThreadPool()->start(d->runnable); -} - -/*! - \class QDnsDomainNameRecord - \brief The QDnsDomainNameRecord class stores information about a domain - name record. - - \inmodule QtNetwork - \ingroup network - - When performing a name server lookup, zero or more records will be returned. - Each record is represented by a QDnsDomainNameRecord instance. - - \sa QDnsLookup -*/ - -/*! - Constructs an empty domain name record object. -*/ - -QDnsDomainNameRecord::QDnsDomainNameRecord() - : d(new QDnsDomainNameRecordPrivate) -{ -} - -/*! - Constructs a copy of \a other. -*/ - -QDnsDomainNameRecord::QDnsDomainNameRecord(const QDnsDomainNameRecord &other) - : d(other.d) -{ -} - -/*! - Destroys a domain name record. -*/ - -QDnsDomainNameRecord::~QDnsDomainNameRecord() -{ -} - -/*! - Returns the name for this record. -*/ - -QString QDnsDomainNameRecord::name() const -{ - return d->name; -} - -/*! - Returns the duration in seconds for which this record is valid. -*/ - -quint32 QDnsDomainNameRecord::timeToLive() const -{ - return d->timeToLive; -} - -/*! - Returns the value for this domain name record. -*/ - -QString QDnsDomainNameRecord::value() const -{ - return d->value; -} - -/*! - Assigns the data of the \a other object to this record object, - and returns a reference to it. -*/ - -QDnsDomainNameRecord &QDnsDomainNameRecord::operator=(const QDnsDomainNameRecord &other) -{ - d = other.d; - return *this; -} - -/*! - \class QDnsHostAddressRecord - \brief The QDnsHostAddressRecord class stores information about a host - address record. - - \inmodule QtNetwork - \ingroup network - - When performing an address lookup, zero or more records will be - returned. Each record is represented by a QDnsHostAddressRecord instance. - - \sa QDnsLookup -*/ - -/*! - Constructs an empty host address record object. -*/ - -QDnsHostAddressRecord::QDnsHostAddressRecord() - : d(new QDnsHostAddressRecordPrivate) -{ -} - -/*! - Constructs a copy of \a other. -*/ - -QDnsHostAddressRecord::QDnsHostAddressRecord(const QDnsHostAddressRecord &other) - : d(other.d) -{ -} - -/*! - Destroys a host address record. -*/ - -QDnsHostAddressRecord::~QDnsHostAddressRecord() -{ -} - -/*! - Returns the name for this record. -*/ - -QString QDnsHostAddressRecord::name() const -{ - return d->name; -} - -/*! - Returns the duration in seconds for which this record is valid. -*/ - -quint32 QDnsHostAddressRecord::timeToLive() const -{ - return d->timeToLive; -} - -/*! - Returns the value for this host address record. -*/ - -QHostAddress QDnsHostAddressRecord::value() const -{ - return d->value; -} - -/*! - Assigns the data of the \a other object to this record object, - and returns a reference to it. -*/ - -QDnsHostAddressRecord &QDnsHostAddressRecord::operator=(const QDnsHostAddressRecord &other) -{ - d = other.d; - return *this; -} - -/*! - \class QDnsMailExchangeRecord - \brief The QDnsMailExchangeRecord class stores information about a DNS MX record. - - \inmodule QtNetwork - \ingroup network - - When performing a lookup on a service, zero or more records will be - returned. Each record is represented by a QDnsMailExchangeRecord instance. - - The meaning of the fields is defined in - \l{http://www.rfc-editor.org/rfc/rfc1035.txt}{RFC 1035}. - - \sa QDnsLookup -*/ - -/*! - Constructs an empty mail exchange record object. -*/ - -QDnsMailExchangeRecord::QDnsMailExchangeRecord() - : d(new QDnsMailExchangeRecordPrivate) -{ -} - -/*! - Constructs a copy of \a other. -*/ - -QDnsMailExchangeRecord::QDnsMailExchangeRecord(const QDnsMailExchangeRecord &other) - : d(other.d) -{ -} - -/*! - Destroys a mail exchange record. -*/ - -QDnsMailExchangeRecord::~QDnsMailExchangeRecord() -{ -} - -/*! - Returns the domain name of the mail exchange for this record. -*/ - -QString QDnsMailExchangeRecord::exchange() const -{ - return d->exchange; -} - -/*! - Returns the name for this record. -*/ - -QString QDnsMailExchangeRecord::name() const -{ - return d->name; -} - -/*! - Returns the preference for this record. -*/ - -quint16 QDnsMailExchangeRecord::preference() const -{ - return d->preference; -} - -/*! - Returns the duration in seconds for which this record is valid. -*/ - -quint32 QDnsMailExchangeRecord::timeToLive() const -{ - return d->timeToLive; -} - -/*! - Assigns the data of the \a other object to this record object, - and returns a reference to it. -*/ - -QDnsMailExchangeRecord &QDnsMailExchangeRecord::operator=(const QDnsMailExchangeRecord &other) -{ - d = other.d; - return *this; -} - -/*! - \class QDnsServiceRecord - \brief The QDnsServiceRecord class stores information about a DNS SRV record. - - \inmodule QtNetwork - \ingroup network - - When performing a lookup on a service, zero or more records will be - returned. Each record is represented by a QDnsServiceRecord instance. - - The meaning of the fields is defined in - \l{http://www.rfc-editor.org/rfc/rfc2782.txt}{RFC 2782}. - - \sa QDnsLookup -*/ - -/*! - Constructs an empty service record object. -*/ - -QDnsServiceRecord::QDnsServiceRecord() - : d(new QDnsServiceRecordPrivate) -{ -} - -/*! - Constructs a copy of \a other. -*/ - -QDnsServiceRecord::QDnsServiceRecord(const QDnsServiceRecord &other) - : d(other.d) -{ -} - -/*! - Destroys a service record. -*/ - -QDnsServiceRecord::~QDnsServiceRecord() -{ -} - -/*! - Returns the name for this record. -*/ - -QString QDnsServiceRecord::name() const -{ - return d->name; -} - -/*! - Returns the port on the target host for this service record. -*/ - -quint16 QDnsServiceRecord::port() const -{ - return d->port; -} - -/*! - Returns the priority for this service record. - - A client must attempt to contact the target host with the lowest-numbered - priority. -*/ - -quint16 QDnsServiceRecord::priority() const -{ - return d->priority; -} - -/*! - Returns the domain name of the target host for this service record. -*/ - -QString QDnsServiceRecord::target() const -{ - return d->target; -} - -/*! - Returns the duration in seconds for which this record is valid. -*/ - -quint32 QDnsServiceRecord::timeToLive() const -{ - return d->timeToLive; -} - -/*! - Returns the weight for this service record. - - The weight field specifies a relative weight for entries with the same - priority. Entries with higher weights should be selected with a higher - probability. -*/ - -quint16 QDnsServiceRecord::weight() const -{ - return d->weight; -} - -/*! - Assigns the data of the \a other object to this record object, - and returns a reference to it. -*/ - -QDnsServiceRecord &QDnsServiceRecord::operator=(const QDnsServiceRecord &other) -{ - d = other.d; - return *this; -} - -/*! - \class QDnsTextRecord - \brief The QDnsTextRecord class stores information about a DNS TXT record. - - \inmodule QtNetwork - \ingroup network - - When performing a text lookup, zero or more records will be - returned. Each record is represented by a QDnsTextRecord instance. - - The meaning of the fields is defined in - \l{http://www.rfc-editor.org/rfc/rfc1035.txt}{RFC 1035}. - - \sa QDnsLookup -*/ - -/*! - Constructs an empty text record object. -*/ - -QDnsTextRecord::QDnsTextRecord() - : d(new QDnsTextRecordPrivate) -{ -} - -/*! - Constructs a copy of \a other. -*/ - -QDnsTextRecord::QDnsTextRecord(const QDnsTextRecord &other) - : d(other.d) -{ -} - -/*! - Destroys a text record. -*/ - -QDnsTextRecord::~QDnsTextRecord() -{ -} - -/*! - Returns the name for this text record. -*/ - -QString QDnsTextRecord::name() const -{ - return d->name; -} - -/*! - Returns the duration in seconds for which this record is valid. -*/ - -quint32 QDnsTextRecord::timeToLive() const -{ - return d->timeToLive; -} - -/*! - Returns the values for this text record. -*/ - -QList QDnsTextRecord::values() const -{ - return d->values; -} - -/*! - Assigns the data of the \a other object to this record object, - and returns a reference to it. -*/ - -QDnsTextRecord &QDnsTextRecord::operator=(const QDnsTextRecord &other) -{ - d = other.d; - return *this; -} - -void QDnsLookupPrivate::_q_lookupFinished(const QDnsLookupReply &_reply) -{ - Q_Q(QDnsLookup); - if (runnable == q->sender()) { -#ifdef QDNSLOOKUP_DEBUG - qDebug("DNS reply for %s: %i (%s)", qPrintable(name), _reply.error, qPrintable(_reply.errorString)); -#endif - reply = _reply; - runnable = 0; - isFinished = true; - emit q->finished(); - } -} - -void QDnsLookupRunnable::run() -{ - QDnsLookupReply reply; - - // Validate input. - if (requestName.isEmpty()) { - reply.error = QDnsLookup::InvalidRequestError; - reply.errorString = tr("Invalid domain name"); - emit finished(reply); - return; - } - - // Perform request. - query(requestType, requestName, &reply); - - // Sort results. - if (!theDnsLookupSeedStorage()->hasLocalData()) { - qsrand(QTime(0,0,0).msecsTo(QTime::currentTime()) ^ reinterpret_cast(this)); - theDnsLookupSeedStorage()->setLocalData(new bool(true)); - } - qt_qdnsmailexchangerecord_sort(reply.mailExchangeRecords); - qt_qdnsservicerecord_sort(reply.serviceRecords); - - emit finished(reply); -} - -QDnsLookupThreadPool::QDnsLookupThreadPool() - : signalsConnected(false) -{ - // Run up to 5 lookups in parallel. - setMaxThreadCount(5); -} - -void QDnsLookupThreadPool::start(QRunnable *runnable) -{ - // Ensure threads complete at application destruction. - if (!signalsConnected) { - QMutexLocker signalsLocker(&signalsMutex); - if (!signalsConnected) { - QCoreApplication *app = QCoreApplication::instance(); - if (!app) { - qWarning("QDnsLookup requires a QCoreApplication"); - delete runnable; - return; - } - - moveToThread(app->thread()); - connect(app, SIGNAL(destroyed()), - SLOT(_q_applicationDestroyed()), Qt::DirectConnection); - signalsConnected = true; - } - } - - QThreadPool::start(runnable); -} - -void QDnsLookupThreadPool::_q_applicationDestroyed() -{ - waitForDone(); - signalsConnected = false; -} - -QT_END_NAMESPACE diff --git a/src/base/qdnslookup.h b/src/base/qdnslookup.h deleted file mode 100644 index bd5f6602..00000000 --- a/src/base/qdnslookup.h +++ /dev/null @@ -1,240 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Jeremy Lainé -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDNSLOOKUP_H -#define QDNSLOOKUP_H - -#include -#include -#include -#include -#include - -#include "QXmppGlobal.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Network) - -class QHostAddress; -class QDnsLookupPrivate; -class QDnsDomainNameRecordPrivate; -class QDnsHostAddressRecordPrivate; -class QDnsMailExchangeRecordPrivate; -class QDnsServiceRecordPrivate; -class QDnsTextRecordPrivate; - -class QXMPP_EXPORT QDnsDomainNameRecord -{ -public: - QDnsDomainNameRecord(); - QDnsDomainNameRecord(const QDnsDomainNameRecord &other); - ~QDnsDomainNameRecord(); - - QString name() const; - quint32 timeToLive() const; - QString value() const; - - QDnsDomainNameRecord &operator=(const QDnsDomainNameRecord &other); - -private: - QSharedDataPointer d; - friend class QDnsLookupRunnable; -}; - -class QXMPP_EXPORT QDnsHostAddressRecord -{ -public: - QDnsHostAddressRecord(); - QDnsHostAddressRecord(const QDnsHostAddressRecord &other); - ~QDnsHostAddressRecord(); - - QString name() const; - quint32 timeToLive() const; - QHostAddress value() const; - - QDnsHostAddressRecord &operator=(const QDnsHostAddressRecord &other); - -private: - QSharedDataPointer d; - friend class QDnsLookupRunnable; -}; - -class QXMPP_EXPORT QDnsMailExchangeRecord -{ -public: - QDnsMailExchangeRecord(); - QDnsMailExchangeRecord(const QDnsMailExchangeRecord &other); - ~QDnsMailExchangeRecord(); - - QString exchange() const; - QString name() const; - quint16 preference() const; - quint32 timeToLive() const; - - QDnsMailExchangeRecord &operator=(const QDnsMailExchangeRecord &other); - -private: - QSharedDataPointer d; - friend class QDnsLookupRunnable; -}; - -class QXMPP_EXPORT QDnsServiceRecord -{ -public: - QDnsServiceRecord(); - QDnsServiceRecord(const QDnsServiceRecord &other); - ~QDnsServiceRecord(); - - QString name() const; - quint16 port() const; - quint16 priority() const; - QString target() const; - quint32 timeToLive() const; - quint16 weight() const; - - QDnsServiceRecord &operator=(const QDnsServiceRecord &other); - -private: - QSharedDataPointer d; - friend class QDnsLookupRunnable; -}; - -class QXMPP_EXPORT QDnsTextRecord -{ -public: - QDnsTextRecord(); - QDnsTextRecord(const QDnsTextRecord &other); - ~QDnsTextRecord(); - - QString name() const; - quint32 timeToLive() const; - QList values() const; - - QDnsTextRecord &operator=(const QDnsTextRecord &other); - -private: - QSharedDataPointer d; - friend class QDnsLookupRunnable; -}; - -class QXMPP_EXPORT QDnsLookup : public QObject -{ - Q_OBJECT - Q_ENUMS(Error Type) - Q_PROPERTY(Error error READ error NOTIFY finished) - Q_PROPERTY(QString errorString READ errorString NOTIFY finished) - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(Type type READ type WRITE setType NOTIFY typeChanged) - -public: - enum Error - { - NoError = 0, - ResolverError, - OperationCancelledError, - InvalidRequestError, - InvalidReplyError, - ServerFailureError, - ServerRefusedError, - NotFoundError - }; - - enum Type - { - A = 1, - AAAA = 28, - ANY = 255, - CNAME = 5, - MX = 15, - NS = 2, - PTR = 12, - SRV = 33, - TXT = 16 - }; - - QDnsLookup(QObject *parent = 0); - QDnsLookup(Type type, const QString &name, QObject *parent = 0); - ~QDnsLookup(); - - Error error() const; - QString errorString() const; - bool isFinished() const; - - QString name() const; - void setName(const QString &name); - - Type type() const; - void setType(QDnsLookup::Type); - - QList canonicalNameRecords() const; - QList hostAddressRecords() const; - QList mailExchangeRecords() const; - QList nameServerRecords() const; - QList pointerRecords() const; - QList serviceRecords() const; - QList textRecords() const; - - -public Q_SLOTS: - void abort(); - void lookup(); - -Q_SIGNALS: - void finished(); - void nameChanged(const QString &name); - void typeChanged(Type type); - -private: - QDnsLookupPrivate *d_ptr; - Q_DECLARE_PRIVATE(QDnsLookup) - Q_PRIVATE_SLOT(d_func(), void _q_lookupFinished(const QDnsLookupReply &reply)) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#include "qdnslookup_p.h" - -#endif // QDNSLOOKUP_H diff --git a/src/base/qdnslookup_p.h b/src/base/qdnslookup_p.h deleted file mode 100644 index 4797f345..00000000 --- a/src/base/qdnslookup_p.h +++ /dev/null @@ -1,216 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Jeremy Lainé -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDNSLOOKUP_P_H -#define QDNSLOOKUP_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of the QDnsLookup class. This header file may change from -// version to version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include -#include -#include -#include - -#include "qdnslookup.h" - -QT_BEGIN_NAMESPACE - -//#define QDNSLOOKUP_DEBUG - -class QDnsLookupRunnable; - -class QDnsLookupReply -{ -public: - QDnsLookupReply() - : error(QDnsLookup::NoError) - { } - - QDnsLookup::Error error; - QString errorString; - - QList canonicalNameRecords; - QList hostAddressRecords; - QList mailExchangeRecords; - QList nameServerRecords; - QList pointerRecords; - QList serviceRecords; - QList textRecords; -}; - -class QDnsLookupPrivate -{ -public: - QDnsLookupPrivate(QDnsLookup *qq) - : isFinished(false) - , type(QDnsLookup::A) - , runnable(0) - , q_ptr(qq) - { } - - void _q_lookupFinished(const QDnsLookupReply &reply); - - bool isFinished; - QString name; - QDnsLookup::Type type; - QDnsLookupReply reply; - QDnsLookupRunnable *runnable; - QDnsLookup *q_ptr; - - Q_DECLARE_PUBLIC(QDnsLookup) -}; - -class QDnsLookupRunnable : public QObject, public QRunnable -{ - Q_OBJECT - -public: - QDnsLookupRunnable(QDnsLookup::Type type, const QByteArray &name) - : requestType(type) - , requestName(name) - { } - void run(); - -signals: - void finished(const QDnsLookupReply &reply); - -private: - static void query(const int requestType, const QByteArray &requestName, QDnsLookupReply *reply); - QDnsLookup::Type requestType; - QByteArray requestName; -}; - -class QDnsLookupThreadPool : public QThreadPool -{ - Q_OBJECT - -public: - QDnsLookupThreadPool(); - void start(QRunnable *runnable); - -private slots: - void _q_applicationDestroyed(); - -private: - QMutex signalsMutex; - bool signalsConnected; -}; - -class QDnsRecordPrivate : public QSharedData -{ -public: - QDnsRecordPrivate() - : timeToLive(0) - { } - - QString name; - quint32 timeToLive; -}; - -class QDnsDomainNameRecordPrivate : public QDnsRecordPrivate -{ -public: - QDnsDomainNameRecordPrivate() - { } - - QString value; -}; - -class QDnsHostAddressRecordPrivate : public QDnsRecordPrivate -{ -public: - QDnsHostAddressRecordPrivate() - { } - - QHostAddress value; -}; - -class QDnsMailExchangeRecordPrivate : public QDnsRecordPrivate -{ -public: - QDnsMailExchangeRecordPrivate() - : preference(0) - { } - - QString exchange; - quint16 preference; -}; - -class QDnsServiceRecordPrivate : public QDnsRecordPrivate -{ -public: - QDnsServiceRecordPrivate() - : port(0), - priority(0), - weight(0) - { } - - QString target; - quint16 port; - quint16 priority; - quint16 weight; -}; - -class QDnsTextRecordPrivate : public QDnsRecordPrivate -{ -public: - QDnsTextRecordPrivate() - { } - - QList values; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QDnsLookupReply) - -#endif // QDNSLOOKUP_P_H diff --git a/src/base/qdnslookup_stub.cpp b/src/base/qdnslookup_stub.cpp deleted file mode 100644 index df9ed349..00000000 --- a/src/base/qdnslookup_stub.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Jeremy Lainé -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdnslookup_p.h" - -QT_BEGIN_NAMESPACE - -void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, QDnsLookupReply *reply) -{ - Q_UNUSED(requestType); - Q_UNUSED(requestName); - reply->error = QDnsLookup::ResolverError; - reply->errorString = QLatin1String("QDnsLookup is not implemented for this platform"); -} - -QT_END_NAMESPACE diff --git a/src/base/qdnslookup_symbian.cpp b/src/base/qdnslookup_symbian.cpp deleted file mode 100644 index bed5278e..00000000 --- a/src/base/qdnslookup_symbian.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Jeremy Lainé -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdnslookup_p.h" - -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, QDnsLookupReply *reply) -{ - RHostResolver dnsResolver; - RSocketServ dnsSocket; - - // Initialise resolver. - TInt err = dnsSocket.Connect(); - err = dnsResolver.Open(dnsSocket, KAfInet, KProtocolInetUdp); - if (err != KErrNone) { - reply->error = QDnsLookup::ResolverError; - reply->errorString = QLatin1String("RHostResolver::Open failed"); - return; - } - - // Perform DNS query. - TDnsQueryBuf dnsQuery; - TDnsRespSRVBuf dnsResponse; - dnsQuery().SetClass(KDnsRRClassIN); - TPtrC8 queryPtr(reinterpret_cast(requestName.constData()), requestName.size()); - dnsQuery().SetData(queryPtr); - dnsQuery().SetType(requestType); - err = dnsResolver.Query(dnsQuery, dnsResponse); - if (err != KErrNone) { - reply->error = QDnsLookup::NotFoundError; - reply->errorString = QLatin1String("RHostResolver::Query failed"); - return; - } - - // Extract results. - while (err == KErrNone) { - const QByteArray aceName((const char*)dnsResponse().Target().Ptr(), - dnsResponse().Target().Length()); - - QDnsServiceRecord record; - record.d->name = QUrl::fromAce(requestName); - record.d->target = QUrl::fromAce(aceName); - record.d->port = dnsResponse().Port(); - record.d->priority = dnsResponse().Priority(); - record.d->timeToLive = dnsResponse().RRTtl(); - record.d->weight = dnsResponse().Weight(); - reply->serviceRecords.append(record); - - err = dnsResolver.QueryGetNext(dnsResponse); - } -} - -QT_END_NAMESPACE diff --git a/src/base/qdnslookup_unix.cpp b/src/base/qdnslookup_unix.cpp deleted file mode 100644 index f4d1c64c..00000000 --- a/src/base/qdnslookup_unix.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Jeremy Lainé -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdnslookup_p.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -static QMutex local_res_mutex; -typedef int (*dn_expand_proto)(const unsigned char *, const unsigned char *, const unsigned char *, char *, int); -static dn_expand_proto local_dn_expand = 0; -typedef void (*res_nclose_proto)(res_state); -static res_nclose_proto local_res_nclose = 0; -typedef int (*res_ninit_proto)(res_state); -static res_ninit_proto local_res_ninit = 0; -typedef int (*res_nquery_proto)(res_state, const char *, int, int, unsigned char *, int); -static res_nquery_proto local_res_nquery = 0; - -// Custom deleter to close resolver state. - -struct QDnsLookupStateDeleter -{ - static inline void cleanup(struct __res_state *pointer) - { - local_res_nclose(pointer); - } -}; - -static void resolveLibrary() -{ - QLibrary lib(QLatin1String("resolv")); - if (!lib.load()) - return; - - local_dn_expand = dn_expand_proto(lib.resolve("__dn_expand")); - if (!local_dn_expand) - local_dn_expand = dn_expand_proto(lib.resolve("dn_expand")); - - local_res_nclose = res_nclose_proto(lib.resolve("__res_nclose")); - if (!local_res_nclose) - local_res_nclose = res_nclose_proto(lib.resolve("res_9_nclose")); - if (!local_res_nclose) - local_res_nclose = res_nclose_proto(lib.resolve("res_nclose")); - - local_res_ninit = res_ninit_proto(lib.resolve("__res_ninit")); - if (!local_res_ninit) - local_res_ninit = res_ninit_proto(lib.resolve("res_9_ninit")); - if (!local_res_ninit) - local_res_ninit = res_ninit_proto(lib.resolve("res_ninit")); - - local_res_nquery = res_nquery_proto(lib.resolve("__res_nquery")); - if (!local_res_nquery) - local_res_nquery = res_nquery_proto(lib.resolve("res_9_nquery")); - if (!local_res_nquery) - local_res_nquery = res_nquery_proto(lib.resolve("res_nquery")); -} - -void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, QDnsLookupReply *reply) -{ - // Load dn_expand, res_ninit and res_nquery on demand. - static volatile bool triedResolve = false; - if (!triedResolve) { - QMutexLocker locker(&local_res_mutex); - if (!triedResolve) { - resolveLibrary(); - triedResolve = true; - } - } - - // If dn_expand, res_ninit or res_nquery is missing, fail. - if (!local_dn_expand || !local_res_nclose || !local_res_ninit || !local_res_nquery) { - reply->error = QDnsLookup::ResolverError; - reply->errorString = tr("Resolver functions not found"); - return; - } - - // Initialize state. - struct __res_state state; - memset(&state, 0, sizeof(state)); - if (local_res_ninit(&state) < 0) { - reply->error = QDnsLookup::ResolverError; - reply->errorString = tr("Resolver initialization failed"); - return; - } -#ifdef QDNSLOOKUP_DEBUG - state.options |= RES_DEBUG; -#endif - QScopedPointer state_ptr(&state); - - // Perform DNS query. - unsigned char response[PACKETSZ]; - memset(response, 0, sizeof(response)); - const int responseLength = local_res_nquery(&state, requestName, C_IN, requestType, response, sizeof(response)); - - // Check the response header. - HEADER *header = (HEADER*)response; - const int answerCount = ntohs(header->ancount); - switch (header->rcode) { - case NOERROR: - break; - case FORMERR: - reply->error = QDnsLookup::InvalidRequestError; - reply->errorString = tr("Server could not process query"); - return; - case SERVFAIL: - reply->error = QDnsLookup::ServerFailureError; - reply->errorString = tr("Server failure"); - return; - case NXDOMAIN: - reply->error = QDnsLookup::NotFoundError; - reply->errorString = tr("Non existent domain"); - return; - case REFUSED: - reply->error = QDnsLookup::ServerRefusedError; - reply->errorString = tr("Server refused to answer"); - return; - default: - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid reply received"); - return; - } - - // Check the reply is valid. - if (responseLength < int(sizeof(HEADER))) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid reply received"); - return; - } - - // Skip the query host, type (2 bytes) and class (2 bytes). - char host[PACKETSZ], answer[PACKETSZ]; - unsigned char *p = response + sizeof(HEADER); - int status = local_dn_expand(response, response + responseLength, p, host, sizeof(host)); - if (status < 0) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Could not expand domain name"); - return; - } - p += status + 4; - - // Extract results. - int answerIndex = 0; - while ((p < response + responseLength) && (answerIndex < answerCount)) { - status = local_dn_expand(response, response + responseLength, p, host, sizeof(host)); - if (status < 0) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Could not expand domain name"); - return; - } - const QString name = QUrl::fromAce(host); - - p += status; - const quint16 type = (p[0] << 8) | p[1]; - p += 2; // RR type - p += 2; // RR class - const quint32 ttl = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; - p += 4; - const quint16 size = (p[0] << 8) | p[1]; - p += 2; - - if (type == QDnsLookup::A) { - if (size != 4) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid IPv4 address record"); - return; - } - const quint32 addr = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; - QDnsHostAddressRecord record; - record.d->name = name; - record.d->timeToLive = ttl; - record.d->value = QHostAddress(addr); - reply->hostAddressRecords.append(record); - } else if (type == QDnsLookup::AAAA) { - if (size != 16) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid IPv6 address record"); - return; - } - QDnsHostAddressRecord record; - record.d->name = name; - record.d->timeToLive = ttl; - record.d->value = QHostAddress(p); - reply->hostAddressRecords.append(record); - } else if (type == QDnsLookup::CNAME) { - status = local_dn_expand(response, response + responseLength, p, answer, sizeof(answer)); - if (status < 0) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid canonical name record"); - return; - } - QDnsDomainNameRecord record; - record.d->name = name; - record.d->timeToLive = ttl; - record.d->value = QUrl::fromAce(answer); - reply->canonicalNameRecords.append(record); - } else if (type == QDnsLookup::NS) { - status = local_dn_expand(response, response + responseLength, p, answer, sizeof(answer)); - if (status < 0) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid name server record"); - return; - } - QDnsDomainNameRecord record; - record.d->name = name; - record.d->timeToLive = ttl; - record.d->value = QUrl::fromAce(answer); - reply->nameServerRecords.append(record); - } else if (type == QDnsLookup::PTR) { - status = local_dn_expand(response, response + responseLength, p, answer, sizeof(answer)); - if (status < 0) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid pointer record"); - return; - } - QDnsDomainNameRecord record; - record.d->name = name; - record.d->timeToLive = ttl; - record.d->value = QUrl::fromAce(answer); - reply->pointerRecords.append(record); - } else if (type == QDnsLookup::MX) { - const quint16 preference = (p[0] << 8) | p[1]; - status = local_dn_expand(response, response + responseLength, p + 2, answer, sizeof(answer)); - if (status < 0) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid mail exchange record"); - return; - } - QDnsMailExchangeRecord record; - record.d->exchange = QUrl::fromAce(answer); - record.d->name = name; - record.d->preference = preference; - record.d->timeToLive = ttl; - reply->mailExchangeRecords.append(record); - } else if (type == QDnsLookup::SRV) { - const quint16 priority = (p[0] << 8) | p[1]; - const quint16 weight = (p[2] << 8) | p[3]; - const quint16 port = (p[4] << 8) | p[5]; - status = local_dn_expand(response, response + responseLength, p + 6, answer, sizeof(answer)); - if (status < 0) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid service record"); - return; - } - QDnsServiceRecord record; - record.d->name = name; - record.d->target = QUrl::fromAce(answer); - record.d->port = port; - record.d->priority = priority; - record.d->timeToLive = ttl; - record.d->weight = weight; - reply->serviceRecords.append(record); - } else if (type == QDnsLookup::TXT) { - unsigned char *txt = p; - QDnsTextRecord record; - record.d->name = name; - record.d->timeToLive = ttl; - while (txt < p + size) { - const unsigned char length = *txt; - txt++; - if (txt + length > p + size) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid text record"); - return; - } - record.d->values << QByteArray((char*)txt, length); - txt += length; - } - reply->textRecords.append(record); - } - p += size; - answerIndex++; - } -} - -QT_END_NAMESPACE diff --git a/src/base/qdnslookup_win.cpp b/src/base/qdnslookup_win.cpp deleted file mode 100644 index d89ec623..00000000 --- a/src/base/qdnslookup_win.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Jeremy Lainé -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qdnslookup_p.h" - -#include -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, QDnsLookupReply *reply) -{ - // Perform DNS query. - PDNS_RECORD dns_records = 0; - const DNS_STATUS status = DnsQuery_UTF8(requestName, requestType, DNS_QUERY_STANDARD, NULL, &dns_records, NULL); - switch (status) { - case ERROR_SUCCESS: - break; - case DNS_ERROR_RCODE_FORMAT_ERROR: - reply->error = QDnsLookup::InvalidRequestError; - reply->errorString = tr("Server could not process query"); - return; - case DNS_ERROR_RCODE_SERVER_FAILURE: - reply->error = QDnsLookup::ServerFailureError; - reply->errorString = tr("Server failure"); - return; - case DNS_ERROR_RCODE_NAME_ERROR: - reply->error = QDnsLookup::NotFoundError; - reply->errorString = tr("Non existent domain"); - return; - case DNS_ERROR_RCODE_REFUSED: - reply->error = QDnsLookup::ServerRefusedError; - reply->errorString = tr("Server refused to answer"); - return; - default: - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid reply received"); - return; - } - - // Extract results. - for (PDNS_RECORD ptr = dns_records; ptr != NULL; ptr = ptr->pNext) { - const QString name = QUrl::fromAce((char*)ptr->pName); - if (ptr->wType == QDnsLookup::A) { - QDnsHostAddressRecord record; - record.d->name = name; - record.d->timeToLive = ptr->dwTtl; - record.d->value = QHostAddress(ntohl(ptr->Data.A.IpAddress)); - reply->hostAddressRecords.append(record); - } else if (ptr->wType == QDnsLookup::AAAA) { - Q_IPV6ADDR addr; - memcpy(&addr, &ptr->Data.AAAA.Ip6Address, sizeof(Q_IPV6ADDR)); - - QDnsHostAddressRecord record; - record.d->name = name; - record.d->timeToLive = ptr->dwTtl; - record.d->value = QHostAddress(addr); - reply->hostAddressRecords.append(record); - } else if (ptr->wType == QDnsLookup::CNAME) { - QDnsDomainNameRecord record; - record.d->name = name; - record.d->timeToLive = ptr->dwTtl; - record.d->value = QUrl::fromAce((char*)ptr->Data.Cname.pNameHost); - reply->canonicalNameRecords.append(record); - } else if (ptr->wType == QDnsLookup::MX) { - QDnsMailExchangeRecord record; - record.d->name = name; - record.d->exchange = QUrl::fromAce((char*)ptr->Data.Mx.pNameExchange); - record.d->preference = ptr->Data.Mx.wPreference; - record.d->timeToLive = ptr->dwTtl; - reply->mailExchangeRecords.append(record); - } else if (ptr->wType == QDnsLookup::NS) { - QDnsDomainNameRecord record; - record.d->name = name; - record.d->timeToLive = ptr->dwTtl; - record.d->value = QUrl::fromAce((char*)ptr->Data.Ns.pNameHost); - reply->nameServerRecords.append(record); - } else if (ptr->wType == QDnsLookup::PTR) { - QDnsDomainNameRecord record; - record.d->name = name; - record.d->timeToLive = ptr->dwTtl; - record.d->value = QUrl::fromAce((char*)ptr->Data.Ptr.pNameHost); - reply->pointerRecords.append(record); - } else if (ptr->wType == QDnsLookup::SRV) { - QDnsServiceRecord record; - record.d->name = name; - record.d->target = QUrl::fromAce((char*)ptr->Data.Srv.pNameTarget); - record.d->port = ptr->Data.Srv.wPort; - record.d->priority = ptr->Data.Srv.wPriority; - record.d->timeToLive = ptr->dwTtl; - record.d->weight = ptr->Data.Srv.wWeight; - reply->serviceRecords.append(record); - } else if (ptr->wType == QDnsLookup::TXT) { - QDnsTextRecord record; - record.d->name = name; - record.d->timeToLive = ptr->dwTtl; - for (unsigned int i = 0; i < ptr->Data.Txt.dwStringCount; ++i) { - record.d->values << QByteArray((char*)ptr->Data.Txt.pStringArray[i]); - } - reply->textRecords.append(record); - } - } - - DnsRecordListFree(dns_records, DnsFreeRecordList); -} - -QT_END_NAMESPACE diff --git a/src/client/QXmppInvokable.cpp b/src/client/QXmppInvokable.cpp index 39b92f85..e44b6296 100644 --- a/src/client/QXmppInvokable.cpp +++ b/src/client/QXmppInvokable.cpp @@ -58,11 +58,7 @@ QVariant QXmppInvokable::dispatch( const QByteArray & method, const QList< QVari const char *typeName = metaObject()->method(idx).typeName(); int resultType = QMetaType::type(typeName); -#if QT_VERSION >= 0x050000 void *result = QMetaType::create(resultType, 0); -#else - void *result = QMetaType::construct(resultType, 0); -#endif QGenericReturnArgument ret( typeName, result ); QList genericArgs; @@ -115,11 +111,7 @@ void QXmppInvokable::buildMethodHash( ) int methodCount = metaObject()->methodCount (); for( int idx = 0; idx < methodCount; ++idx) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) QByteArray signature = metaObject()->method(idx).methodSignature(); -#else - QByteArray signature = metaObject()->method(idx).signature(); -#endif m_methodHash[signature.left(signature.indexOf('('))] = idx; // qDebug() << metaObject()->method(idx).parameterTypes(); } @@ -133,11 +125,7 @@ QStringList QXmppInvokable::interfaces( ) const { if( metaObject()->method(idx).methodType() == QMetaMethod::Slot ) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) QByteArray signature = metaObject()->method(idx).methodSignature(); -#else - QByteArray signature = metaObject()->method(idx).signature(); -#endif results << signature.left(signature.indexOf('(')); } } diff --git a/src/client/QXmppOutgoingClient.cpp b/src/client/QXmppOutgoingClient.cpp index 552f6f07..b5c7052a 100644 --- a/src/client/QXmppOutgoingClient.cpp +++ b/src/client/QXmppOutgoingClient.cpp @@ -26,11 +26,7 @@ #include #include #include -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #include -#else -#include "qdnslookup.h" -#endif #include "QXmppConfiguration.h" #include "QXmppConstants_p.h" @@ -144,10 +140,8 @@ void QXmppOutgoingClientPrivate::connectToHost(const QString &host, quint16 port // respect proxy q->socket()->setProxy(config.networkProxy()); -#if (QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)) // set the name the SSL certificate should match q->socket()->setPeerVerifyName(config.domain()); -#endif // connect to host const QXmppConfiguration::StreamSecurityMode localSecurity = q->configuration().streamSecurityMode(); diff --git a/src/server/QXmppOutgoingServer.cpp b/src/server/QXmppOutgoingServer.cpp index 3855da4d..2da1628a 100644 --- a/src/server/QXmppOutgoingServer.cpp +++ b/src/server/QXmppOutgoingServer.cpp @@ -25,11 +25,7 @@ #include #include #include -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #include -#else -#include "qdnslookup.h" -#endif #include "QXmppConstants_p.h" #include "QXmppDialback.h" @@ -137,10 +133,8 @@ void QXmppOutgoingServer::_q_dnsLookupFinished() port = 5269; } -#if (QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)) // set the name the SSL certificate should match socket()->setPeerVerifyName(d->remoteDomain); -#endif // connect to server info(QString("Connecting to %1:%2").arg(host, QString::number(port))); diff --git a/src/server/QXmppServer.cpp b/src/server/QXmppServer.cpp index 13be2169..53b6ba83 100644 --- a/src/server/QXmppServer.cpp +++ b/src/server/QXmppServer.cpp @@ -891,11 +891,7 @@ QXmppSslServer::~QXmppSslServer() delete d; } -#if QT_VERSION < 0x050000 void QXmppSslServer::incomingConnection(int socketDescriptor) -#else -void QXmppSslServer::incomingConnection(qintptr socketDescriptor) -#endif { QSslSocket *socket = new QSslSocket; if (!socket->setSocketDescriptor(socketDescriptor)) { diff --git a/src/server/QXmppServer.h b/src/server/QXmppServer.h index f6866f92..2734105d 100644 --- a/src/server/QXmppServer.h +++ b/src/server/QXmppServer.h @@ -143,11 +143,7 @@ signals: void newConnection(QSslSocket *socket); private: - #if QT_VERSION < 0x050000 void incomingConnection(int socketDescriptor); - #else - void incomingConnection(qintptr socketDescriptor); - #endif QXmppSslServerPrivate * const d; }; -- cgit v1.2.3 From ad7910dabd6cdbbb62fe4c8718f69e6c291a78cc Mon Sep 17 00:00:00 2001 From: Niels Ole Salscheider Date: Mon, 4 Sep 2017 12:58:48 +0200 Subject: Generate QXmppGlobal from the build system --- src/CMakeLists.txt | 7 ++++-- src/base/QXmppGlobal.cpp | 34 --------------------------- src/base/QXmppGlobal.h | 59 ----------------------------------------------- src/base/QXmppGlobal.h.in | 56 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 95 deletions(-) delete mode 100644 src/base/QXmppGlobal.cpp delete mode 100644 src/base/QXmppGlobal.h create mode 100644 src/base/QXmppGlobal.h.in (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b4f659cb..dedfccae 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,7 +4,12 @@ include_directories(base) include_directories(client) include_directories(server) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/base/QXmppGlobal.h.in ${CMAKE_CURRENT_BINARY_DIR}/base/QXmppGlobal.h @ONLY) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/base) + set(INSTALL_HEADER_FILES + ${CMAKE_CURRENT_BINARY_DIR}/base/QXmppGlobal.h + # Base base/QXmppArchiveIq.h base/QXmppBindIq.h @@ -14,7 +19,6 @@ set(INSTALL_HEADER_FILES base/QXmppDiscoveryIq.h base/QXmppElement.h base/QXmppEntityTimeIq.h - base/QXmppGlobal.h base/QXmppIbbIq.h base/QXmppIq.h base/QXmppJingleIq.h @@ -89,7 +93,6 @@ set(SOURCE_FILES base/QXmppDiscoveryIq.cpp base/QXmppElement.cpp base/QXmppEntityTimeIq.cpp - base/QXmppGlobal.cpp base/QXmppIbbIq.cpp base/QXmppIq.cpp base/QXmppJingleIq.cpp diff --git a/src/base/QXmppGlobal.cpp b/src/base/QXmppGlobal.cpp deleted file mode 100644 index a0d9ce89..00000000 --- a/src/base/QXmppGlobal.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - */ - - -#include "QXmppGlobal.h" - -QString QXmppVersion() -{ - return QString("%1.%2.%3").arg( - QString::number((QXMPP_VERSION >> 16) & 0xff), - QString::number((QXMPP_VERSION >> 8) & 0xff), - QString::number(QXMPP_VERSION & 0xff)); -} - diff --git a/src/base/QXmppGlobal.h b/src/base/QXmppGlobal.h deleted file mode 100644 index 8024ce73..00000000 --- a/src/base/QXmppGlobal.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - */ - - -#ifndef QXMPPGLOBAL_H -#define QXMPPGLOBAL_H - -#include - -#if defined(QXMPP_STATIC) -# define QXMPP_EXPORT -#else -# if defined(QXMPP_BUILD) -# define QXMPP_EXPORT Q_DECL_EXPORT -# else -# define QXMPP_EXPORT Q_DECL_IMPORT -# endif -#endif - -#if defined(QXMPP_AUTOTEST_INTERNAL) -# define QXMPP_AUTOTEST_EXPORT QXMPP_EXPORT -#else -# define QXMPP_AUTOTEST_EXPORT -#endif - -/// This macro expands a numeric value of the form 0xMMNNPP (MM = -/// major, NN = minor, PP = patch) that specifies QXmpp's version -/// number. For example, if you compile your application against -/// QXmpp 1.2.3, the QXMPP_VERSION macro will expand to 0x010203. -/// -/// You can use QXMPP_VERSION to use the latest QXmpp features where -/// available. -/// - -#define QXMPP_VERSION 0x000903 - -QXMPP_EXPORT QString QXmppVersion(); - -#endif //QXMPPGLOBAL_H diff --git a/src/base/QXmppGlobal.h.in b/src/base/QXmppGlobal.h.in new file mode 100644 index 00000000..80ba8375 --- /dev/null +++ b/src/base/QXmppGlobal.h.in @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2008-2017 The QXmpp developers + * + * Author: + * Manjeet Dahiya + * Niels Ole Salscheider + * + * Source: + * https://github.com/qxmpp-project/qxmpp + * + * This file is a part of QXmpp library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + */ + + +#ifndef QXMPPGLOBAL_H +#define QXMPPGLOBAL_H + +#include + +#if defined(QXMPP_BUILD) +# define QXMPP_EXPORT Q_DECL_EXPORT +#else +# define QXMPP_EXPORT Q_DECL_IMPORT +#endif + +#define QXMPP_AUTOTEST_EXPORT + +/// This macro expands a numeric value of the form 0xMMNNPP (MM = +/// major, NN = minor, PP = patch) that specifies QXmpp's version +/// number. For example, if you compile your application against +/// QXmpp 1.2.3, the QXMPP_VERSION macro will expand to 0x010203. +/// +/// You can use QXMPP_VERSION to use the latest QXmpp features where +/// available. +/// + +#define QXMPP_VERSION (0x@VERSION_MAJOR@ << 16) | (0x@VERSION_MINOR@ << 8) | 0x@VERSION_PATCH@ + +inline QLatin1String QXmppVersion() +{ + return QLatin1String("@VERSION_STRING@"); +} + +#endif //QXMPPGLOBAL_H + -- cgit v1.2.3 From 77d52eb507474ae5a2c1b2f540e3c67945eaea37 Mon Sep 17 00:00:00 2001 From: Niels Ole Salscheider Date: Sun, 3 Sep 2017 22:27:25 +0200 Subject: Re-add codecs support to the build system --- CMakeLists.txt | 2 ++ cmake/modules/FindOpus.cmake | 25 +++++++++++++++++++++++++ cmake/modules/FindSpeex.cmake | 25 +++++++++++++++++++++++++ cmake/modules/FindTheora.cmake | 33 +++++++++++++++++++++++++++++++++ cmake/modules/FindVPX.cmake | 25 +++++++++++++++++++++++++ src/CMakeLists.txt | 32 ++++++++++++++++++++++++++++++++ 6 files changed, 142 insertions(+) create mode 100644 cmake/modules/FindOpus.cmake create mode 100644 cmake/modules/FindSpeex.cmake create mode 100644 cmake/modules/FindTheora.cmake create mode 100644 cmake/modules/FindVPX.cmake (limited to 'src') diff --git a/CMakeLists.txt b/CMakeLists.txt index 22a9321f..21782128 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,8 @@ set(SO_VERSION 0) set(VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) mark_as_advanced(VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_STRING) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules") + find_package(Qt5 REQUIRED COMPONENTS Core Network Xml) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) diff --git a/cmake/modules/FindOpus.cmake b/cmake/modules/FindOpus.cmake new file mode 100644 index 00000000..fc13497b --- /dev/null +++ b/cmake/modules/FindOpus.cmake @@ -0,0 +1,25 @@ +# Try to find Opus +# Once done this will define +# Opus_FOUND - System has Opus +# Opus_INCLUDE_DIRS - The Opus include directories +# Opus_LIBRARIES - The libraries needed to use Opus + +find_package(PkgConfig) +pkg_check_modules(PC_Opus QUIET libopus) + +find_path(Opus_INCLUDE_DIR opus/opus.h + HINTS ${PC_Opus_INCLUDEDIR} ${PC_Opus_INCLUDE_DIRS} +) + +find_library(Opus_LIBRARY NAMES opus + HINTS ${PC_Opus_LIBDIR} ${PC_Opus_LIBRARY_DIRS} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Opus DEFAULT_MSG Opus_LIBRARY Opus_INCLUDE_DIR) + +mark_as_advanced(Opus_INCLUDE_DIR Opus_LIBRARY) + +set(Opus_LIBRARIES ${Opus_LIBRARY}) +set(Opus_INCLUDE_DIRS ${Opus_INCLUDE_DIR}) + diff --git a/cmake/modules/FindSpeex.cmake b/cmake/modules/FindSpeex.cmake new file mode 100644 index 00000000..3929b2ec --- /dev/null +++ b/cmake/modules/FindSpeex.cmake @@ -0,0 +1,25 @@ +# Try to find Speex +# Once done this will define +# Speex_FOUND - System has Speex +# Speex_INCLUDE_DIRS - The Speex include directories +# Speex_LIBRARIES - The libraries needed to use Speex + +find_package(PkgConfig) +pkg_check_modules(PC_Speex QUIET libspeex) + +find_path(Speex_INCLUDE_DIR speex/speex.h + HINTS ${PC_Speex_INCLUDEDIR} ${PC_Speex_INCLUDE_DIRS} +) + +find_library(Speex_LIBRARY NAMES speex + HINTS ${PC_Speex_LIBDIR} ${PC_Speex_LIBRARY_DIRS} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Speex DEFAULT_MSG Speex_LIBRARY Speex_INCLUDE_DIR) + +mark_as_advanced(Speex_INCLUDE_DIR Speex_LIBRARY) + +set(Speex_LIBRARIES ${Speex_LIBRARY}) +set(Speex_INCLUDE_DIRS ${Speex_INCLUDE_DIR}) + diff --git a/cmake/modules/FindTheora.cmake b/cmake/modules/FindTheora.cmake new file mode 100644 index 00000000..24462794 --- /dev/null +++ b/cmake/modules/FindTheora.cmake @@ -0,0 +1,33 @@ +# Try to find Theora +# Once done this will define +# Theora_FOUND - System has Theora +# Theora_INCLUDE_DIRS - The Theora include directories +# Theora_LIBRARIES - The libraries needed to use Theora + +find_package(PkgConfig) +pkg_check_modules(PC_Theora QUIET libtheora) + +find_path(Theora_INCLUDE_DIR theora/theora.h + HINTS ${PC_Theora_INCLUDEDIR} ${PC_Theora_INCLUDE_DIRS} +) + +find_library(Theora_LIBRARY NAMES theora + HINTS ${PC_Theora_LIBDIR} ${PC_Theora_LIBRARY_DIRS} +) + +find_library(Theora_enc_LIBRARY NAMES theoraenc + HINTS ${PC_Theora_LIBDIR} ${PC_Theora_LIBRARY_DIRS} +) + +find_library(Theora_dec_LIBRARY NAMES theoradec + HINTS ${PC_Theora_LIBDIR} ${PC_Theora_LIBRARY_DIRS} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Theora DEFAULT_MSG Theora_LIBRARY Theora_enc_LIBRARY Theora_dec_LIBRARY Theora_INCLUDE_DIR) + +mark_as_advanced(Theora_INCLUDE_DIR Theora_LIBRARY Theora_enc_LIBRARY Theora_dec_LIBRARY) + +set(Theora_LIBRARIES ${Theora_LIBRARY} ${Theora_enc_LIBRARY} ${Theora_dec_LIBRARY}) +set(Theora_INCLUDE_DIRS ${Theora_INCLUDE_DIR}) + diff --git a/cmake/modules/FindVPX.cmake b/cmake/modules/FindVPX.cmake new file mode 100644 index 00000000..8c60a555 --- /dev/null +++ b/cmake/modules/FindVPX.cmake @@ -0,0 +1,25 @@ +# Try to find VPX +# Once done this will define +# VPX_FOUND - System has VPX +# VPX_INCLUDE_DIRS - The VPX include directories +# VPX_LIBRARIES - The libraries needed to use VPX + +find_package(PkgConfig) +pkg_check_modules(PC_VPX QUIET libvpx) + +find_path(VPX_INCLUDE_DIR vpx/vp8.h + HINTS ${PC_VPX_INCLUDEDIR} ${PC_VPX_INCLUDE_DIRS} +) + +find_library(VPX_LIBRARY NAMES vpx + HINTS ${PC_VPX_LIBDIR} ${PC_VPX_LIBRARY_DIRS} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(VPX DEFAULT_MSG VPX_LIBRARY VPX_INCLUDE_DIR) + +mark_as_advanced(VPX_INCLUDE_DIR VPX_LIBRARY) + +set(VPX_LIBRARIES ${VPX_LIBRARY}) +set(VPX_INCLUDE_DIRS ${VPX_INCLUDE_DIR}) + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dedfccae..62b4693f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -157,6 +157,36 @@ set(SOURCE_FILES server/QXmppServerPlugin.cpp ) +option(WITH_SPEEX "Support the Speex codec" OFF) +option(WITH_OPUS "Support the Opus codec" OFF) +option(WITH_THEORA "Support the Theora codec" OFF) +option(WITH_VPX "Support the VPX codec" OFF) + +if(WITH_SPEEX) + find_package(Speex REQUIRED) + include_directories(${Speex_INCLUDE_DIRS}) + set(MULTIMEDIA_LIBS ${MULTIMEDIA_LIBS} ${Speex_LIBRARIES}) + add_definitions(-DQXMPP_USE_SPEEX) +endif() +if(WITH_OPUS) + find_package(Opus REQUIRED) + include_directories(${Opus_INCLUDE_DIRS}) + set(MULTIMEDIA_LIBS ${MULTIMEDIA_LIBS} ${Opus_LIBRARIES}) + add_definitions(-DQXMPP_USE_OPUS) +endif() +if(WITH_THEORA) + find_package(Theora REQUIRED) + include_directories(${Theora_INCLUDE_DIRS}) + set(MULTIMEDIA_LIBS ${MULTIMEDIA_LIBS} ${Theora_LIBRARIES}) + add_definitions(-DQXMPP_USE_THEORA) +endif() +if(WITH_VPX) + find_package(VPX REQUIRED) + include_directories(${VPX_INCLUDE_DIRS}) + set(MULTIMEDIA_LIBS ${MULTIMEDIA_LIBS} ${VPX_LIBRARIES}) + add_definitions(-DQXMPP_USE_VPX) +endif() + add_library(qxmpp SHARED ${SOURCE_FILES}) set_target_properties(qxmpp PROPERTIES @@ -171,6 +201,8 @@ target_link_libraries(qxmpp Qt5::Core Qt5::Network Qt5::Xml + PRIVATE + ${MULTIMEDIA_LIBS} ) install( -- cgit v1.2.3 From b71c01824c1637ad75248f5ce46fb4be6032ffc1 Mon Sep 17 00:00:00 2001 From: Niels Ole Salscheider Date: Mon, 4 Sep 2017 18:36:23 +0200 Subject: Fix QXmppSslServer::incomingConnection signature --- src/server/QXmppServer.cpp | 2 +- src/server/QXmppServer.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/server/QXmppServer.cpp b/src/server/QXmppServer.cpp index 53b6ba83..73a7415e 100644 --- a/src/server/QXmppServer.cpp +++ b/src/server/QXmppServer.cpp @@ -891,7 +891,7 @@ QXmppSslServer::~QXmppSslServer() delete d; } -void QXmppSslServer::incomingConnection(int socketDescriptor) +void QXmppSslServer::incomingConnection(qintptr socketDescriptor) { QSslSocket *socket = new QSslSocket; if (!socket->setSocketDescriptor(socketDescriptor)) { diff --git a/src/server/QXmppServer.h b/src/server/QXmppServer.h index 2734105d..992f0c4a 100644 --- a/src/server/QXmppServer.h +++ b/src/server/QXmppServer.h @@ -143,7 +143,7 @@ signals: void newConnection(QSslSocket *socket); private: - void incomingConnection(int socketDescriptor); + void incomingConnection(qintptr socketDescriptor) override; QXmppSslServerPrivate * const d; }; -- cgit v1.2.3 From 39fe288bcbbe12ba3ec8d494def76cfddb65fc0d Mon Sep 17 00:00:00 2001 From: Niels Ole Salscheider Date: Sun, 17 Jun 2018 16:25:43 +0200 Subject: Fix paths in CMakeLists.txt --- CMakeLists.txt | 2 +- doc/CMakeLists.txt | 2 +- examples/CMakeLists.txt | 7 ++++--- src/CMakeLists.txt | 6 +++--- tests/CMakeLists.txt | 7 ++++--- 5 files changed, 13 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/CMakeLists.txt b/CMakeLists.txt index bbc43278..db0dbfe0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ set(SO_VERSION 0) set(VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) mark_as_advanced(VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_STRING) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/modules") find_package(Qt5 REQUIRED COMPONENTS Core Network Xml) set(CMAKE_AUTOMOC ON) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index fbffdcac..2fb54f3c 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -4,7 +4,7 @@ set(DOXYGEN_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/index.doc ${CMAKE_CURRENT_SOURCE_DIR}/using.doc ${CMAKE_CURRENT_SOURCE_DIR}/xep.doc - ${CMAKE_SOURCE_DIR}/src + ${PROJECT_SOURCE_DIR}/src ) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 0d026cff..564745c6 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -3,9 +3,10 @@ macro(add_simple_example EXAMPLE_NAME) target_link_libraries(${EXAMPLE_NAME} qxmpp) endmacro() -include_directories(../src/base) -include_directories(../src/client) -include_directories(../src/server) +include_directories(${PROJECT_SOURCE_DIR}/src/base) +include_directories(${PROJECT_SOURCE_DIR}/src/client) +include_directories(${PROJECT_SOURCE_DIR}/src/server) +include_directories(${PROJECT_BINARY_DIR}/src/base) add_simple_example(0_connected) add_simple_example(1_echoClient) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 62b4693f..9acdfbaf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,8 +1,8 @@ add_definitions(-DQXMPP_BUILD) -include_directories(base) -include_directories(client) -include_directories(server) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/base) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/client) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/server) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/base/QXmppGlobal.h.in ${CMAKE_CURRENT_BINARY_DIR}/base/QXmppGlobal.h @ONLY) include_directories(${CMAKE_CURRENT_BINARY_DIR}/base) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bd2fc16a..64bd58d7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,9 +8,10 @@ macro(add_simple_test TEST_NAME) target_link_libraries(tst_${TEST_NAME} Qt5::Test qxmpp) endmacro() -include_directories(../src/base) -include_directories(../src/client) -include_directories(../src/server) +include_directories(${PROJECT_SOURCE_DIR}/src/base) +include_directories(${PROJECT_SOURCE_DIR}/src/client) +include_directories(${PROJECT_SOURCE_DIR}/src/server) +include_directories(${PROJECT_BINARY_DIR}/src/base) add_simple_test(qxmpparchiveiq) add_simple_test(qxmppbindiq) -- cgit v1.2.3 From 31f0a42073b68823e85835ec3e25114d79705a04 Mon Sep 17 00:00:00 2001 From: Niels Ole Salscheider Date: Sun, 17 Jun 2018 18:22:30 +0200 Subject: CMake: Make the library properly importable --- src/CMakeLists.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9acdfbaf..628c0ae5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -193,7 +193,15 @@ set_target_properties(qxmpp PROPERTIES VERSION ${VERSION_STRING} SOVERSION ${SO_VERSION} EXPORT_NAME QXmpp - INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_INSTALL_FULL_INCLUDEDIR}/qxmpp" +) + +target_include_directories(qxmpp + PUBLIC + $ + $ + $ + $ + $ ) target_link_libraries(qxmpp @@ -219,6 +227,11 @@ install( COMPONENT Devel ) +export( + TARGETS qxmpp + FILE QXmpp.cmake +) + install( FILES ${INSTALL_HEADER_FILES} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/qxmpp" -- cgit v1.2.3