Make QAbstractSocket's API virtual where needed.
The following methods have been made virtual: setReadBufferSize() socketDescriptor() setSocketDescriptor() socketOption() setSocketOption() waitForConnected() waitForDisconnected() Now that these methods are virtual we no longer need the nasty polymorphism workarounds for QSslSocket. Change-Id: I319989b6cdb025ba33d7d53ae90f3a6a3b6b1b7b Reviewed-by: Richard J. Moore <rich@kde.org> Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Peter Hartmann <peter.hartmann@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
1955353149
commit
b5f2dd65ac
|
|
@ -1734,10 +1734,6 @@ bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState
|
|||
OpenMode openMode)
|
||||
{
|
||||
Q_D(QAbstractSocket);
|
||||
#ifndef QT_NO_OPENSSL
|
||||
if (QSslSocket *socket = qobject_cast<QSslSocket *>(this))
|
||||
return socket->setSocketDescriptor(socketDescriptor, socketState, openMode);
|
||||
#endif
|
||||
|
||||
d->resetSocketLayer();
|
||||
d->socketEngine = QAbstractSocketEngine::createSocketEngine(socketDescriptor, this);
|
||||
|
|
@ -1786,13 +1782,6 @@ bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState
|
|||
*/
|
||||
void QAbstractSocket::setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value)
|
||||
{
|
||||
#ifndef QT_NO_OPENSSL
|
||||
if (QSslSocket *sslSocket = qobject_cast<QSslSocket*>(this)) {
|
||||
sslSocket->setSocketOption(option, value);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!d_func()->socketEngine)
|
||||
return;
|
||||
|
||||
|
|
@ -1827,12 +1816,6 @@ void QAbstractSocket::setSocketOption(QAbstractSocket::SocketOption option, cons
|
|||
*/
|
||||
QVariant QAbstractSocket::socketOption(QAbstractSocket::SocketOption option)
|
||||
{
|
||||
#ifndef QT_NO_OPENSSL
|
||||
if (QSslSocket *sslSocket = qobject_cast<QSslSocket*>(this)) {
|
||||
return sslSocket->socketOption(option);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!d_func()->socketEngine)
|
||||
return QVariant();
|
||||
|
||||
|
|
@ -1913,13 +1896,6 @@ bool QAbstractSocket::waitForConnected(int msecs)
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
// Manual polymorphism; this function is not virtual, but has an overload
|
||||
// in QSslSocket.
|
||||
if (QSslSocket *socket = qobject_cast<QSslSocket *>(this))
|
||||
return socket->waitForConnected(msecs);
|
||||
#endif
|
||||
|
||||
bool wasPendingClose = d->pendingClose;
|
||||
d->pendingClose = false;
|
||||
QElapsedTimer stopWatch;
|
||||
|
|
@ -2139,12 +2115,6 @@ bool QAbstractSocket::waitForBytesWritten(int msecs)
|
|||
bool QAbstractSocket::waitForDisconnected(int msecs)
|
||||
{
|
||||
Q_D(QAbstractSocket);
|
||||
#ifndef QT_NO_OPENSSL
|
||||
// Manual polymorphism; this function is not virtual, but has an overload
|
||||
// in QSslSocket.
|
||||
if (QSslSocket *socket = qobject_cast<QSslSocket *>(this))
|
||||
return socket->waitForDisconnected(msecs);
|
||||
#endif
|
||||
|
||||
// require calling connectToHost() before waitForDisconnected()
|
||||
if (state() == UnconnectedState) {
|
||||
|
|
@ -2756,15 +2726,6 @@ void QAbstractSocket::setReadBufferSize(qint64 size)
|
|||
{
|
||||
Q_D(QAbstractSocket);
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
// Manual polymorphism; setReadBufferSize() isn't virtual, but QSslSocket overloads
|
||||
// it.
|
||||
if (QSslSocket *socket = qobject_cast<QSslSocket *>(this)) {
|
||||
socket->setReadBufferSize(size);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (d->readBufferMaxSize == size)
|
||||
return;
|
||||
d->readBufferMaxSize = size;
|
||||
|
|
|
|||
|
|
@ -148,20 +148,17 @@ public:
|
|||
QHostAddress peerAddress() const;
|
||||
QString peerName() const;
|
||||
|
||||
// ### Qt 5: Make setReadBufferSize() virtual
|
||||
qint64 readBufferSize() const;
|
||||
void setReadBufferSize(qint64 size);
|
||||
virtual void setReadBufferSize(qint64 size);
|
||||
|
||||
void abort();
|
||||
|
||||
// ### Qt 5: Make socketDescriptor() and setSocketDescriptor() virtual.
|
||||
qintptr socketDescriptor() const;
|
||||
bool setSocketDescriptor(qintptr socketDescriptor, SocketState state = ConnectedState,
|
||||
virtual qintptr socketDescriptor() const;
|
||||
virtual bool setSocketDescriptor(qintptr socketDescriptor, SocketState state = ConnectedState,
|
||||
OpenMode openMode = ReadWrite);
|
||||
|
||||
// ### Qt 5: Make virtual?
|
||||
void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value);
|
||||
QVariant socketOption(QAbstractSocket::SocketOption option);
|
||||
virtual void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value);
|
||||
virtual QVariant socketOption(QAbstractSocket::SocketOption option);
|
||||
|
||||
SocketType socketType() const;
|
||||
SocketState state() const;
|
||||
|
|
@ -174,11 +171,10 @@ public:
|
|||
bool flush();
|
||||
|
||||
// for synchronous access
|
||||
// ### Qt 5: Make waitForConnected() and waitForDisconnected() virtual.
|
||||
bool waitForConnected(int msecs = 30000);
|
||||
virtual bool waitForConnected(int msecs = 30000);
|
||||
bool waitForReadyRead(int msecs = 30000);
|
||||
bool waitForBytesWritten(int msecs = 30000);
|
||||
bool waitForDisconnected(int msecs = 30000);
|
||||
virtual bool waitForDisconnected(int msecs = 30000);
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void setProxy(const QNetworkProxy &networkProxy);
|
||||
|
|
|
|||
Loading…
Reference in New Issue