From be2e993a9ac03a6fc43b2fa15f3df068984acd70 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Thu, 22 Oct 2015 20:04:21 +0300 Subject: [PATCH] Fix build with 'udpsocket' feature disabled Wrap related code in QNativeSocketEngine and the tuiotouch plugin in conditionals. Change-Id: Ic6861b1c6a9e041fa8a50f96149f7280473a9fba Reviewed-by: Oswald Buddenhagen Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira --- src/network/socket/qnativesocketengine.cpp | 36 ++++++++++++---------- src/network/socket/qnativesocketengine_p.h | 12 +++++--- src/plugins/generic/generic.pro | 6 +++- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp index 52e6922b5f..386e0e2cc7 100644 --- a/src/network/socket/qnativesocketengine.cpp +++ b/src/network/socket/qnativesocketengine.cpp @@ -651,6 +651,24 @@ int QNativeSocketEngine::accept() return d->nativeAccept(); } +/*! + Returns the number of bytes that are currently available for + reading. On error, -1 is returned. + + For UDP sockets, this function returns the accumulated size of all + pending datagrams, and it is therefore more useful for UDP sockets + to call hasPendingDatagrams() and pendingDatagramSize(). +*/ +qint64 QNativeSocketEngine::bytesAvailable() const +{ + Q_D(const QNativeSocketEngine); + Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::bytesAvailable(), -1); + Q_CHECK_NOT_STATE(QNativeSocketEngine::bytesAvailable(), QAbstractSocket::UnconnectedState, -1); + + return d->nativeBytesAvailable(); +} + +#ifndef QT_NO_UDPSOCKET #ifndef QT_NO_NETWORKINTERFACE /*! @@ -712,23 +730,6 @@ bool QNativeSocketEngine::setMulticastInterface(const QNetworkInterface &iface) #endif // QT_NO_NETWORKINTERFACE -/*! - Returns the number of bytes that are currently available for - reading. On error, -1 is returned. - - For UDP sockets, this function returns the accumulated size of all - pending datagrams, and it is therefore more useful for UDP sockets - to call hasPendingDatagrams() and pendingDatagramSize(). -*/ -qint64 QNativeSocketEngine::bytesAvailable() const -{ - Q_D(const QNativeSocketEngine); - Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::bytesAvailable(), -1); - Q_CHECK_NOT_STATE(QNativeSocketEngine::bytesAvailable(), QAbstractSocket::UnconnectedState, -1); - - return d->nativeBytesAvailable(); -} - /*! Returns \c true if there is at least one datagram pending. This function is only called by UDP sockets, where a datagram can have @@ -810,6 +811,7 @@ qint64 QNativeSocketEngine::writeDatagram(const char *data, qint64 size, Q_CHECK_TYPE(QNativeSocketEngine::writeDatagram(), QAbstractSocket::UdpSocket, -1); return d->nativeSendDatagram(data, size, d->adjustAddressProtocol(host), port); } +#endif // QT_NO_UDPSOCKET /*! Writes a block of \a size bytes from \a data to the socket. diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h index 24909bf310..c49ef2c3ad 100644 --- a/src/network/socket/qnativesocketengine_p.h +++ b/src/network/socket/qnativesocketengine_p.h @@ -119,6 +119,12 @@ public: int accept() Q_DECL_OVERRIDE; void close() Q_DECL_OVERRIDE; + qint64 bytesAvailable() const Q_DECL_OVERRIDE; + + qint64 read(char *data, qint64 maxlen) Q_DECL_OVERRIDE; + qint64 write(const char *data, qint64 len) Q_DECL_OVERRIDE; + +#ifndef QT_NO_UDPSOCKET #ifndef QT_NO_NETWORKINTERFACE bool joinMulticastGroup(const QHostAddress &groupAddress, const QNetworkInterface &iface) Q_DECL_OVERRIDE; @@ -128,17 +134,13 @@ public: bool setMulticastInterface(const QNetworkInterface &iface) Q_DECL_OVERRIDE; #endif - qint64 bytesAvailable() const Q_DECL_OVERRIDE; - - qint64 read(char *data, qint64 maxlen) Q_DECL_OVERRIDE; - qint64 write(const char *data, qint64 len) Q_DECL_OVERRIDE; - qint64 readDatagram(char *data, qint64 maxlen, QHostAddress *addr = 0, quint16 *port = 0) Q_DECL_OVERRIDE; qint64 writeDatagram(const char *data, qint64 len, const QHostAddress &addr, quint16 port) Q_DECL_OVERRIDE; bool hasPendingDatagrams() const Q_DECL_OVERRIDE; qint64 pendingDatagramSize() const Q_DECL_OVERRIDE; +#endif // QT_NO_UDPSOCKET qint64 bytesToWrite() const Q_DECL_OVERRIDE; diff --git a/src/plugins/generic/generic.pro b/src/plugins/generic/generic.pro index 82a4ad4ce8..0c1943b7dd 100644 --- a/src/plugins/generic/generic.pro +++ b/src/plugins/generic/generic.pro @@ -1,5 +1,7 @@ TEMPLATE = subdirs +load(qfeatures) + contains(QT_CONFIG, evdev) { SUBDIRS += evdevmouse evdevtouch evdevkeyboard evdevtablet } @@ -8,7 +10,9 @@ contains(QT_CONFIG, tslib) { SUBDIRS += tslib } -SUBDIRS += tuiotouch +!contains(QT_DISABLED_FEATURES, udpsocket) { + SUBDIRS += tuiotouch +} contains(QT_CONFIG, libinput) { SUBDIRS += libinput