diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-01-28 01:27:49 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-02-03 06:57:42 (GMT) |
commit | df551752b7f430ab44bb1dd2ad0aa8c2a5187ef8 (patch) | |
tree | e314f8cad85765d52669a6778610c3377dd9ef9f /src/network/access/qnetworkreplyimpl.cpp | |
parent | 2149a313e671b22382828b58d2520807a5a061e1 (diff) | |
download | Qt-df551752b7f430ab44bb1dd2ad0aa8c2a5187ef8.zip Qt-df551752b7f430ab44bb1dd2ad0aa8c2a5187ef8.tar.gz Qt-df551752b7f430ab44bb1dd2ad0aa8c2a5187ef8.tar.bz2 |
Bearer Management Integration.
Perform application level roaming when all pending QNetworkReplys have
completed.
Emit temporary network failure error when connection to network is lost
but is possibly recovering due to roaming.
Don't save downloads in cache if they are not complete.
Diffstat (limited to 'src/network/access/qnetworkreplyimpl.cpp')
-rw-r--r-- | src/network/access/qnetworkreplyimpl.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index f097a2b..7eca323 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -47,6 +47,7 @@ #include "QtCore/qdatetime.h" #include "QtNetwork/qsslconfiguration.h" #include "qnetworkaccesshttpbackend_p.h" +#include "qnetworkaccessmanager_p.h" #include <QtCore/QCoreApplication> @@ -516,7 +517,33 @@ void QNetworkReplyImplPrivate::finished() emit q->uploadProgress(0, 0); resumeNotificationHandling(); - completeCacheSave(); + if (manager->d_func()->session->state() == QNetworkSession::Roaming) { + // only content with a known size will fail with a temporary network failure error + if (!totalSize.isNull()) { + qDebug() << "Connection broke during download."; + qDebug() << "Don't worry, we've already started roaming :)"; + + if (bytesDownloaded == totalSize) { + qDebug() << "Luckily download has already finished."; + } else { + qDebug() << "Download hasn't finished"; + + if (q->bytesAvailable() == bytesDownloaded) { + qDebug() << "User hasn't read data from reply, we could continue after reconnect."; + error(QNetworkReply::TemporaryNetworkFailureError, q->tr("Temporary network failure.")); + } else if (q->bytesAvailable() < bytesDownloaded) { + qDebug() << "User has already read data from reply."; + error(QNetworkReply::TemporaryNetworkFailureError, q->tr("Temporary network failure.")); + } + } + } + } + + // if we don't know the total size of or we received everything save the cache + if (totalSize.isNull() || totalSize == -1 || bytesDownloaded == totalSize) + completeCacheSave(); + else + qDebug() << "Not saving cache."; // note: might not be a good idea, since users could decide to delete us // which would delete the backend too... |