Make the pause modes a QFlags.

The intention is to add additional pause modes over time, this will
be easier if we can just test if a particular reason for pausing is
turned on. If we don't do this we'll end up having to check for each
enum value every time we check what is enabled.

Change-Id: I6b08f0e819b5593e3f6463c3dd175eff8625e155
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
Reviewed-by: Shane Kearns <ext-shane.2.kearns@nokia.com>
This commit is contained in:
Richard Moore 2012-01-28 13:41:20 +00:00 committed by Qt by Nokia
parent e54dc7c2b5
commit b3a978d661
4 changed files with 10 additions and 8 deletions

View File

@ -1390,7 +1390,7 @@ void QAbstractSocket::resume()
\sa setPauseMode(), resume() \sa setPauseMode(), resume()
*/ */
QAbstractSocket::PauseMode QAbstractSocket::pauseMode() const QAbstractSocket::PauseModes QAbstractSocket::pauseMode() const
{ {
return d_func()->pauseMode; return d_func()->pauseMode;
} }
@ -1409,7 +1409,7 @@ QAbstractSocket::PauseMode QAbstractSocket::pauseMode() const
\sa pauseMode(), resume() \sa pauseMode(), resume()
*/ */
void QAbstractSocket::setPauseMode(PauseMode pauseMode) void QAbstractSocket::setPauseMode(PauseModes pauseMode)
{ {
d_func()->pauseMode = pauseMode; d_func()->pauseMode = pauseMode;
} }

View File

@ -124,16 +124,17 @@ public:
}; };
Q_DECLARE_FLAGS(BindMode, BindFlag) Q_DECLARE_FLAGS(BindMode, BindFlag)
enum PauseMode { enum PauseMode {
PauseNever, PauseNever = 0x0,
PauseOnNotify PauseOnNotify = 0x1
}; };
Q_DECLARE_FLAGS(PauseModes, PauseMode)
QAbstractSocket(SocketType socketType, QObject *parent); QAbstractSocket(SocketType socketType, QObject *parent);
virtual ~QAbstractSocket(); virtual ~QAbstractSocket();
virtual void resume(); // to continue after proxy authentication required, SSL errors etc. virtual void resume(); // to continue after proxy authentication required, SSL errors etc.
PauseMode pauseMode() const; PauseModes pauseMode() const;
void setPauseMode(PauseMode pauseMode); void setPauseMode(PauseModes pauseMode);
bool bind(const QHostAddress &address, quint16 port = 0, BindMode mode = DefaultForPlatform); bool bind(const QHostAddress &address, quint16 port = 0, BindMode mode = DefaultForPlatform);
bool bind(quint16 port = 0, BindMode mode = DefaultForPlatform); bool bind(quint16 port = 0, BindMode mode = DefaultForPlatform);
@ -226,6 +227,7 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractSocket::BindMode) Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractSocket::BindMode)
Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractSocket::PauseModes)
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
Q_NETWORK_EXPORT QDebug operator<<(QDebug, QAbstractSocket::SocketError); Q_NETWORK_EXPORT QDebug operator<<(QDebug, QAbstractSocket::SocketError);

View File

@ -106,7 +106,7 @@ public:
bool closeCalled; bool closeCalled;
bool pendingClose; bool pendingClose;
QAbstractSocket::PauseMode pauseMode; QAbstractSocket::PauseModes pauseMode;
QString hostName; QString hostName;
quint16 port; quint16 port;

View File

@ -1195,7 +1195,7 @@ bool QSslSocketBackendPrivate::startHandshake()
bool doEmitSslError = !verifyErrorsHaveBeenIgnored(); bool doEmitSslError = !verifyErrorsHaveBeenIgnored();
// check whether we need to emit an SSL handshake error // check whether we need to emit an SSL handshake error
if (doVerifyPeer && doEmitSslError) { if (doVerifyPeer && doEmitSslError) {
if (q->pauseMode() == QAbstractSocket::PauseOnNotify) { if (q->pauseMode() & QAbstractSocket::PauseOnNotify) {
pauseSocketNotifiers(q); pauseSocketNotifiers(q);
paused = true; paused = true;
} else { } else {