summaryrefslogtreecommitdiffstats
path: root/src/network/access
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-02-10 23:23:55 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-02-10 23:23:55 (GMT)
commitd7cf6d018f39607ff7315b7851665e72fc488e62 (patch)
treeb10cc34519de289514e8503850b5575a9854027d /src/network/access
parent5f885bc5a294cd831f79b5570cb41f3cae2b8b19 (diff)
downloadQt-d7cf6d018f39607ff7315b7851665e72fc488e62.zip
Qt-d7cf6d018f39607ff7315b7851665e72fc488e62.tar.gz
Qt-d7cf6d018f39607ff7315b7851665e72fc488e62.tar.bz2
Connect signals between QNAM and QNetworkReplyImpl.
Instead of iterating over children, when network session state changes.
Diffstat (limited to 'src/network/access')
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp36
-rw-r--r--src/network/access/qnetworkaccessmanager.h2
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp20
-rw-r--r--src/network/access/qnetworkreplyimpl_p.h2
4 files changed, 29 insertions, 31 deletions
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 07a8b1d..e57702b 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -811,6 +811,8 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
// first step: create the reply
QUrl url = request.url();
QNetworkReplyImpl *reply = new QNetworkReplyImpl(this);
+ if (req.url().scheme() != QLatin1String("file") && !req.url().scheme().isEmpty())
+ connect(this, SIGNAL(networkSessionOnline()), reply, SLOT(_q_networkSessionOnline()));
QNetworkReplyImplPrivate *priv = reply->d_func();
priv->manager = this;
@@ -1131,12 +1133,7 @@ void QNetworkAccessManagerPrivate::_q_sessionOpened()
{
Q_Q(QNetworkAccessManager);
- // start waiting children
- foreach (QObject *child, q->children()) {
- QNetworkReplyImpl *reply = qobject_cast<QNetworkReplyImpl *>(child);
- if (reply && reply->d_func()->state == QNetworkReplyImplPrivate::WaitingForSession)
- QMetaObject::invokeMethod(reply, "_q_startOperation", Qt::QueuedConnection);
- }
+ emit q->networkSessionOnline();
}
void QNetworkAccessManagerPrivate::_q_sessionClosed()
@@ -1183,37 +1180,14 @@ void QNetworkAccessManagerPrivate::_q_sessionNewConfigurationActivated()
qDebug() << "Accepting new configuration.";
session->accept();
- foreach (QObject *child, q->children()) {
- QNetworkReplyImpl *reply = qobject_cast<QNetworkReplyImpl *>(child);
- if (!reply)
- continue;
-
- switch (reply->d_func()->state) {
- case QNetworkReplyImplPrivate::Buffering:
- case QNetworkReplyImplPrivate::Working:
- case QNetworkReplyImplPrivate::Reconnecting:
- // Migrate existing downloads to new configuration.
- reply->d_func()->migrateBackend();
- break;
- case QNetworkReplyImplPrivate::WaitingForSession:
- // Start waiting requests.
- QMetaObject::invokeMethod(reply, "_q_startOperation", Qt::QueuedConnection);
- break;
- default:
- qDebug() << "How do we handle replies in state" << reply->d_func()->state;
- }
- }
+ emit q->networkSessionOnline();
}
void QNetworkAccessManagerPrivate::_q_sessionPreferredConfigurationChanged(const QNetworkConfiguration &, bool)
{
Q_Q(QNetworkAccessManager);
- foreach (QObject *child, q->children()) {
- QNetworkReplyImpl *replyImpl = qobject_cast<QNetworkReplyImpl *>(child);
- if (replyImpl)
- replyImpl->migrateBackend();
- }
+ emit q->networkSessionOnline();
session->migrate();
}
diff --git a/src/network/access/qnetworkaccessmanager.h b/src/network/access/qnetworkaccessmanager.h
index 371f729..f934b22 100644
--- a/src/network/access/qnetworkaccessmanager.h
+++ b/src/network/access/qnetworkaccessmanager.h
@@ -124,6 +124,8 @@ Q_SIGNALS:
void sslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
#endif
+ void networkSessionOnline();
+
void networkAccessChanged(bool enabled);
void debugMessage(const QString &message);
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index 3cf21f0..a7948c2 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -226,6 +226,26 @@ void QNetworkReplyImplPrivate::_q_bufferOutgoingData()
}
}
+void QNetworkReplyImplPrivate::_q_networkSessionOnline()
+{
+ Q_Q(QNetworkReplyImpl);
+
+ switch (state) {
+ case QNetworkReplyImplPrivate::Buffering:
+ case QNetworkReplyImplPrivate::Working:
+ case QNetworkReplyImplPrivate::Reconnecting:
+ // Migrate existing downloads to new network connection.
+ migrateBackend();
+ break;
+ case QNetworkReplyImplPrivate::WaitingForSession:
+ // Start waiting requests.
+ QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
+ break;
+ default:
+ qDebug() << "How do we handle replies in state" << state;
+ }
+}
+
void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const QNetworkRequest &req,
QIODevice *data)
{
diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h
index 639361e..9941fa7 100644
--- a/src/network/access/qnetworkreplyimpl_p.h
+++ b/src/network/access/qnetworkreplyimpl_p.h
@@ -100,6 +100,7 @@ public:
Q_PRIVATE_SLOT(d_func(), void _q_copyReadChannelFinished())
Q_PRIVATE_SLOT(d_func(), void _q_bufferOutgoingData())
Q_PRIVATE_SLOT(d_func(), void _q_bufferOutgoingDataFinished())
+ Q_PRIVATE_SLOT(d_func(), void _q_networkSessionOnline())
};
class QNetworkReplyImplPrivate: public QNetworkReplyPrivate
@@ -132,6 +133,7 @@ public:
void _q_copyReadChannelFinished();
void _q_bufferOutgoingData();
void _q_bufferOutgoingDataFinished();
+ void _q_networkSessionOnline();
void setup(QNetworkAccessManager::Operation op, const QNetworkRequest &request,
QIODevice *outgoingData);