diff options
author | Peter Hartmann <peter.hartmann@nokia.com> | 2012-01-20 13:55:15 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-25 19:35:05 +0100 |
commit | 07662f93ac700d18bf2c7f5e3df1fa310327130d (patch) | |
tree | 8a1a81ab5d9e905b3e09f83673777fb8b4b1e978 /src/network/socket | |
parent | 0da4451b783b02d6df464fba9f0c34828df1ac06 (diff) |
QAbstractSocket / QSslSocket: add API to pause and resume
pause and resume is currently only supported upon emitting the
QSslSocket::sslErrors() signal. The API was added in QAbstractSocket to
also support QAbstractSocket::proxyAuthenticationRequired() in the
future.
This is the first patch to support that feature on the socket level,
another patch will follow to support sslErrors() and
authenticationRequired() in QNetworkAccessManager / QNetworkReply.
Task-number: QTBUG-19032
Change-Id: Ide2918268590ab9a01454ab26cb7fdca3dc840ab
Reviewed-by: Shane Kearns <ext-shane.2.kearns@nokia.com>
Diffstat (limited to 'src/network/socket')
-rw-r--r-- | src/network/socket/qabstractsocket.cpp | 63 | ||||
-rw-r--r-- | src/network/socket/qabstractsocket.h | 8 | ||||
-rw-r--r-- | src/network/socket/qabstractsocket_p.h | 2 |
3 files changed, 73 insertions, 0 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 0c5deb58fc..b20b229239 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -425,6 +425,19 @@ + ReuseAddressHint), and on Windows, its equivalent to ShareAddress. */ +/*! \enum QAbstractSocket::PauseMode + \since 5.0 + + This enum describes the behavior of when the socket should hold + back with continuing data transfer. + + \value PauseNever Do not pause data transfer on the socket. This is the + default and matches the behaviour of Qt 4. + \value PauseOnNotify Pause data transfer on the socket upon receiving a + notification. The only notification currently supported is + QSslSocket::sslErrors(). +*/ + #include "qabstractsocket.h" #include "qabstractsocket_p.h" @@ -529,6 +542,7 @@ QAbstractSocketPrivate::QAbstractSocketPrivate() abortCalled(false), closeCalled(false), pendingClose(false), + pauseMode(QAbstractSocket::PauseNever), port(0), localPort(0), peerPort(0), @@ -1354,6 +1368,55 @@ QAbstractSocket::~QAbstractSocket() /*! \since 5.0 + Continues data transfer on the socket. This method should only be used + after the socket has been set to pause upon notifications and a + notification has been received. + The only notification currently supported is QSslSocket::sslErrors(). + Calling this method if the socket is not paused results in undefined + behavior. + + \sa pauseMode(), setPauseMode() +*/ +void QAbstractSocket::resume() +{ + Q_D(QAbstractSocket); + d->resumeSocketNotifiers(this); +} + +/*! + \since 5.0 + + Returns the pause mode of this socket. + + \sa setPauseMode(), resume() +*/ +QAbstractSocket::PauseMode QAbstractSocket::pauseMode() const +{ + return d_func()->pauseMode; +} + + +/*! + \since 5.0 + + Controls whether to pause upon receiving a notification. The only notification + currently supported is QSslSocket::sslErrors(). If set to PauseOnNotify, + data transfer on the socket will be paused and needs to be enabled explicitly + again by calling resume(). + By default this option is set to PauseNever. + This option must be called before connecting to the server, otherwise it will + result in undefined behavior. + + \sa pauseMode(), resume() +*/ +void QAbstractSocket::setPauseMode(PauseMode pauseMode) +{ + d_func()->pauseMode = pauseMode; +} + +/*! + \since 5.0 + Binds to \a address on port \a port, using the BindMode \a mode. Binds this socket to the address \a address and the port \a port. diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h index 6b85bd9c8c..f1d26c2efa 100644 --- a/src/network/socket/qabstractsocket.h +++ b/src/network/socket/qabstractsocket.h @@ -123,10 +123,18 @@ public: ReuseAddressHint = 0x4 }; Q_DECLARE_FLAGS(BindMode, BindFlag) + enum PauseMode { + PauseNever, + PauseOnNotify + }; QAbstractSocket(SocketType socketType, QObject *parent); virtual ~QAbstractSocket(); + virtual void resume(); // to continue after proxy authentication required, SSL errors etc. + PauseMode pauseMode() const; + void setPauseMode(PauseMode pauseMode); + bool bind(const QHostAddress &address, quint16 port = 0, BindMode mode = DefaultForPlatform); bool bind(quint16 port = 0, BindMode mode = DefaultForPlatform); diff --git a/src/network/socket/qabstractsocket_p.h b/src/network/socket/qabstractsocket_p.h index 4423c0250e..b0cf8906da 100644 --- a/src/network/socket/qabstractsocket_p.h +++ b/src/network/socket/qabstractsocket_p.h @@ -106,6 +106,8 @@ public: bool closeCalled; bool pendingClose; + QAbstractSocket::PauseMode pauseMode; + QString hostName; quint16 port; QHostAddress host; |