From ec5b7ea367389234697a98d7243243ec689be724 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 18 Feb 2010 19:48:41 +0100 Subject: Port QtNetwork uses of QTime as a stopwatch to QTimestamp. --- src/network/socket/qabstractsocket.cpp | 10 +++++----- src/network/socket/qhttpsocketengine.cpp | 6 +++--- src/network/socket/qlocalsocket_unix.cpp | 4 ++-- src/network/socket/qnativesocketengine_unix.cpp | 4 ++-- src/network/socket/qsocks5socketengine.cpp | 18 +++++++++--------- src/network/ssl/qsslsocket.cpp | 10 +++++----- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 95721ee..fc50ee5 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -365,12 +365,12 @@ #include "private/qhostinfo_p.h" #include -#include #include #include #include #include #include +#include #ifndef QT_NO_OPENSSL #include @@ -1738,7 +1738,7 @@ bool QAbstractSocket::waitForConnected(int msecs) bool wasPendingClose = d->pendingClose; d->pendingClose = false; - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); if (d->state == HostLookupState) { @@ -1819,7 +1819,7 @@ bool QAbstractSocket::waitForReadyRead(int msecs) return false; } - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); // handle a socket in connecting state @@ -1878,7 +1878,7 @@ bool QAbstractSocket::waitForBytesWritten(int msecs) if (d->writeBuffer.isEmpty()) return false; - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); // handle a socket in connecting state @@ -1960,7 +1960,7 @@ bool QAbstractSocket::waitForDisconnected(int msecs) return false; } - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); // handle a socket in connecting state diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index 3293ff5..9d412ac 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -42,9 +42,9 @@ #include "qhttpsocketengine_p.h" #include "qtcpsocket.h" #include "qhostaddress.h" -#include "qdatetime.h" #include "qurl.h" #include "qhttp.h" +#include "qtimestamp.h" #if !defined(QT_NO_NETWORKPROXY) && !defined(QT_NO_HTTP) #include @@ -319,7 +319,7 @@ bool QHttpSocketEngine::waitForRead(int msecs, bool *timedOut) if (!d->socket || d->socket->state() == QAbstractSocket::UnconnectedState) return false; - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); // Wait for more data if nothing is available. @@ -366,7 +366,7 @@ bool QHttpSocketEngine::waitForWrite(int msecs, bool *timedOut) return true; } - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); // If we're not connected yet, wait until we are, and until bytes have diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index 1ca11d8..20301ba 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -52,9 +52,9 @@ #include #include -#include #include #include +#include #ifdef Q_OS_VXWORKS # include @@ -534,7 +534,7 @@ bool QLocalSocket::waitForConnected(int msec) int result = -1; // on Linux timeout will be updated by select, but _not_ on other systems. - QTime timer; + QTimestamp timer; timer.start(); while (state() == ConnectingState && (-1 == msec || timer.elapsed() < msec)) { diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index 9a2c349..7c1fc17 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -44,8 +44,8 @@ #include "private/qnet_unix_p.h" #include "qiodevice.h" #include "qhostaddress.h" +#include "qtimestamp.h" #include "qvarlengtharray.h" -#include "qdatetime.h" #include #include #include @@ -1003,7 +1003,7 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool c #ifndef Q_OS_SYMBIAN ret = qt_safe_select(socketDescriptor + 1, &fdread, &fdwrite, 0, timeout < 0 ? 0 : &tv); #else - QTime timer; + QTimestamp timer; timer.start(); do { diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 924530e..0c6a01a 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -49,7 +49,7 @@ #include "qdebug.h" #include "qhash.h" #include "qqueue.h" -#include "qdatetime.h" +#include "qtimestamp.h" #include "qmutex.h" #include "qthread.h" #include "qcoreapplication.h" @@ -308,7 +308,7 @@ struct QSocks5BindData : public QSocks5Data quint16 localPort; QHostAddress peerAddress; quint16 peerPort; - QDateTime timeStamp; + QTimestamp timeStamp; }; struct QSocks5RevivedDatagram @@ -369,7 +369,7 @@ void QSocks5BindStore::add(int socketDescriptor, QSocks5BindData *bindData) if (store.contains(socketDescriptor)) { // qDebug() << "delete it"; } - bindData->timeStamp = QDateTime::currentDateTime(); + bindData->timeStamp.start(); store.insert(socketDescriptor, bindData); // start sweep timer if not started if (sweepTimerId == -1) @@ -412,7 +412,7 @@ void QSocks5BindStore::timerEvent(QTimerEvent * event) QMutableHashIterator it(store); while (it.hasNext()) { it.next(); - if (it.value()->timeStamp.secsTo(QDateTime::currentDateTime()) > 350) { + if (it.value()->timeStamp.hasExpired(350000)) { QSOCKS5_DEBUG << "QSocks5BindStore removing JJJJ"; it.remove(); } @@ -1355,7 +1355,7 @@ bool QSocks5SocketEngine::bind(const QHostAddress &address, quint16 port) } int msecs = SOCKS5_BLOCKING_BIND_TIMEOUT; - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); d->data->controlSocket->connectToHost(d->proxyInfo.hostName(), d->proxyInfo.port()); if (!d->waitForConnected(msecs, 0) || @@ -1455,7 +1455,7 @@ void QSocks5SocketEngine::close() if (d->data && d->data->controlSocket) { if (d->data->controlSocket->state() == QAbstractSocket::ConnectedState) { int msecs = 100; - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); while (!d->data->controlSocket->bytesToWrite()) { if (!d->data->controlSocket->waitForBytesWritten(qt_timeout_value(msecs, stopWatch.elapsed()))) @@ -1674,7 +1674,7 @@ bool QSocks5SocketEnginePrivate::waitForConnected(int msecs, bool *timedOut) mode == BindMode ? BindSuccess : UdpAssociateSuccess; - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); while (socks5State != wantedState) { @@ -1699,7 +1699,7 @@ bool QSocks5SocketEngine::waitForRead(int msecs, bool *timedOut) d->readNotificationActivated = false; - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); // are we connected yet? @@ -1749,7 +1749,7 @@ bool QSocks5SocketEngine::waitForWrite(int msecs, bool *timedOut) Q_D(QSocks5SocketEngine); QSOCKS5_DEBUG << "waitForWrite" << msecs; - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); // are we connected yet? diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 9623570..895e32c 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -286,8 +286,8 @@ #include #include -#include #include +#include #include #include @@ -1393,7 +1393,7 @@ bool QSslSocket::waitForEncrypted(int msecs) if (d->mode == UnencryptedMode && !d->autoStartHandshake) return false; - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); if (d->plainSocket->state() != QAbstractSocket::ConnectedState) { @@ -1433,7 +1433,7 @@ bool QSslSocket::waitForReadyRead(int msecs) bool *previousReadyReadEmittedPointer = d->readyReadEmittedPointer; d->readyReadEmittedPointer = &readyReadEmitted; - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); if (!d->connectionEncrypted) { @@ -1470,7 +1470,7 @@ bool QSslSocket::waitForBytesWritten(int msecs) if (d->mode == UnencryptedMode) return d->plainSocket->waitForBytesWritten(msecs); - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); if (!d->connectionEncrypted) { @@ -1508,7 +1508,7 @@ bool QSslSocket::waitForDisconnected(int msecs) if (d->mode == UnencryptedMode) return d->plainSocket->waitForDisconnected(msecs); - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); if (!d->connectionEncrypted) { -- cgit v0.12