rbutil: HttpGet: Return NetworkError in done signal.
Return the status value instead of simply a bool. Change-Id: I2bffaac0087418656e80c74dc352011a4ea32ab1
This commit is contained in:
parent
08b42791ff
commit
a0459de4d5
13 changed files with 35 additions and 46 deletions
|
@ -57,16 +57,7 @@ void BootloaderInstallBase::downloadBlStart(QUrl source)
|
|||
}
|
||||
|
||||
|
||||
void BootloaderInstallBase::downloadReqFinished(int id, bool error)
|
||||
{
|
||||
LOG_INFO() << "Download Request" << id
|
||||
<< "finished, error:" << m_http.errorString();
|
||||
|
||||
downloadBlFinish(error);
|
||||
}
|
||||
|
||||
|
||||
void BootloaderInstallBase::downloadBlFinish(bool error)
|
||||
void BootloaderInstallBase::downloadBlFinish(QNetworkReply::NetworkError error)
|
||||
{
|
||||
LOG_INFO() << "Downloading bootloader finished, error:"
|
||||
<< error;
|
||||
|
@ -80,7 +71,7 @@ void BootloaderInstallBase::downloadBlFinish(bool error)
|
|||
emit done(true);
|
||||
return;
|
||||
}
|
||||
if(error) {
|
||||
if(error != QNetworkReply::NoError) {
|
||||
emit logItem(tr("Download error: %1")
|
||||
.arg(m_http.errorString()), LOGERROR);
|
||||
emit done(true);
|
||||
|
|
|
@ -68,8 +68,7 @@ class BootloaderInstallBase : public QObject
|
|||
static QString postinstallHints(QString model);
|
||||
|
||||
protected slots:
|
||||
void downloadReqFinished(int id, bool error);
|
||||
void downloadBlFinish(bool error);
|
||||
void downloadBlFinish(QNetworkReply::NetworkError error);
|
||||
void installBlfile(void);
|
||||
void progressAborted(void);
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ void HttpGet::requestFinished(QNetworkReply* reply)
|
|||
{
|
||||
m_lastStatusCode
|
||||
= reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
LOG_INFO() << "Request finished, status code:" << m_lastStatusCode;
|
||||
LOG_INFO() << "Request finished, status code:" << m_lastStatusCode << reply->error();
|
||||
m_lastServerTimestamp
|
||||
= reply->header(QNetworkRequest::LastModifiedHeader).toDateTime().toLocalTime();
|
||||
LOG_INFO() << "Data from cache:"
|
||||
|
@ -178,11 +178,11 @@ void HttpGet::requestFinished(QNetworkReply* reply)
|
|||
m_outputFile->write(m_data);
|
||||
m_outputFile->close();
|
||||
}
|
||||
emit done(false);
|
||||
emit done(QNetworkReply::NoError);
|
||||
}
|
||||
else {
|
||||
m_data.clear();
|
||||
emit done(true);
|
||||
emit done(reply->error());
|
||||
}
|
||||
reply->deleteLater();
|
||||
m_reply = nullptr;
|
||||
|
|
|
@ -78,7 +78,7 @@ class HttpGet : public QObject
|
|||
void abort(void);
|
||||
|
||||
signals:
|
||||
void done(bool);
|
||||
void done(QNetworkReply::NetworkError error);
|
||||
void dataReadProgress(int, int);
|
||||
void headerFinished(void);
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ bool VoiceFileCreator::createVoiceFile()
|
|||
}
|
||||
|
||||
|
||||
void VoiceFileCreator::downloadDone(bool error)
|
||||
void VoiceFileCreator::downloadDone(QNetworkReply::NetworkError error)
|
||||
{
|
||||
LOG_INFO() << "download done, error:" << error;
|
||||
|
||||
|
@ -190,7 +190,7 @@ void VoiceFileCreator::downloadDone(bool error)
|
|||
|
||||
if(getter->isCached())
|
||||
emit logItem(tr("Cached file used."), LOGINFO);
|
||||
if(error)
|
||||
if(error != QNetworkReply::NoError)
|
||||
{
|
||||
emit logItem(tr("Download error: %1").arg(getter->errorString()),LOGERROR);
|
||||
emit done(true);
|
||||
|
|
|
@ -52,7 +52,7 @@ signals:
|
|||
void logProgress(int, int); //! set progress bar.
|
||||
|
||||
private slots:
|
||||
void downloadDone(bool error);
|
||||
void downloadDone(QNetworkReply::NetworkError error);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ void ZipInstaller::installStart()
|
|||
}
|
||||
|
||||
|
||||
void ZipInstaller::downloadDone(bool error)
|
||||
void ZipInstaller::downloadDone(QNetworkReply::NetworkError error)
|
||||
{
|
||||
LOG_INFO() << "download done, error:" << error;
|
||||
QStringList zipContents; // needed later
|
||||
|
@ -118,7 +118,7 @@ void ZipInstaller::downloadDone(bool error)
|
|||
}
|
||||
if(m_getter->isCached())
|
||||
emit logItem(tr("Cached file used."), LOGINFO);
|
||||
if(error) {
|
||||
if(error != QNetworkReply::NoError) {
|
||||
emit logItem(tr("Download error: %1").arg(m_getter->errorString()), LOGERROR);
|
||||
emit done(true);
|
||||
return;
|
||||
|
|
|
@ -59,7 +59,7 @@ public slots:
|
|||
void abort(void);
|
||||
|
||||
private slots:
|
||||
void downloadDone(bool);
|
||||
void downloadDone(QNetworkReply::NetworkError error);
|
||||
void installStart(void);
|
||||
void installContinue(void);
|
||||
|
||||
|
|
|
@ -214,9 +214,9 @@ void RbUtilQt::downloadInfo()
|
|||
}
|
||||
|
||||
|
||||
void RbUtilQt::downloadDone(bool error)
|
||||
void RbUtilQt::downloadDone(QNetworkReply::NetworkError error)
|
||||
{
|
||||
if(error) {
|
||||
if(error != QNetworkReply::NoError) {
|
||||
LOG_INFO() << "network error:" << daily->errorString();
|
||||
ui.statusbar->showMessage(tr("Can't get version information!"));
|
||||
QMessageBox::critical(this, tr("Network error"),
|
||||
|
@ -614,9 +614,9 @@ void RbUtilQt::checkUpdate(void)
|
|||
update->getFile(QUrl(url));
|
||||
}
|
||||
|
||||
void RbUtilQt::downloadUpdateDone(bool error)
|
||||
void RbUtilQt::downloadUpdateDone(QNetworkReply::NetworkError error)
|
||||
{
|
||||
if(error) {
|
||||
if(error != QNetworkReply::NoError) {
|
||||
LOG_INFO() << "network error:" << update->errorString();
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -87,7 +87,7 @@ class RbUtilQt : public QMainWindow
|
|||
|
||||
void createTalkFiles(void);
|
||||
void createVoiceFile(void);
|
||||
void downloadDone(bool);
|
||||
void downloadDone(QNetworkReply::NetworkError error);
|
||||
void downloadInfo(void);
|
||||
void backup(void);
|
||||
|
||||
|
@ -97,7 +97,7 @@ class RbUtilQt : public QMainWindow
|
|||
void updateTabs(int);
|
||||
|
||||
void checkUpdate(void);
|
||||
void downloadUpdateDone(bool errror);
|
||||
void downloadUpdateDone(QNetworkReply::NetworkError error);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -195,11 +195,11 @@ void TestHttpGet::cleanup(void)
|
|||
{
|
||||
rmTree(m_cachedir.absolutePath());
|
||||
if(m_getter) {
|
||||
m_getter->abort(); delete m_getter; m_getter = NULL;
|
||||
m_getter->abort(); delete m_getter; m_getter = nullptr;
|
||||
}
|
||||
if(m_daemon) { delete m_daemon; m_daemon = NULL; }
|
||||
if(m_doneSpy) { delete m_doneSpy; m_doneSpy = NULL; }
|
||||
if(m_progressSpy) { delete m_progressSpy; m_progressSpy = NULL; }
|
||||
if(m_daemon) { delete m_daemon; m_daemon = nullptr; }
|
||||
if(m_doneSpy) { delete m_doneSpy; m_doneSpy = nullptr; }
|
||||
if(m_progressSpy) { delete m_progressSpy; m_progressSpy = nullptr; }
|
||||
}
|
||||
|
||||
void TestHttpGet::testFileUrlRequest(void)
|
||||
|
@ -299,7 +299,7 @@ void TestHttpGet::testCachedRequest(void)
|
|||
|
||||
QList<QString> requests = m_daemon->lastRequestData();
|
||||
QCOMPARE(m_doneSpy->count(), 1);
|
||||
QCOMPARE(m_doneSpy->at(0).at(0).toBool(), false);
|
||||
QCOMPARE(m_doneSpy->at(0).at(0).toInt(), QNetworkReply::NoError);
|
||||
QCOMPARE(m_waitTimeoutOccured, false);
|
||||
QCOMPARE(requests.size(), 2);
|
||||
QCOMPARE(requests.at(0).startsWith("GET"), true);
|
||||
|
@ -311,7 +311,7 @@ void TestHttpGet::testCachedRequest(void)
|
|||
while(m_doneSpy->count() < 2 && m_waitTimeoutOccured == false)
|
||||
QCoreApplication::processEvents();
|
||||
QCOMPARE(m_doneSpy->count(), 2); // 2 requests, 2 times done()
|
||||
QCOMPARE(m_doneSpy->at(1).at(0).toBool(), false);
|
||||
QCOMPARE(m_doneSpy->at(1).at(0).toInt(), QNetworkReply::NoError);
|
||||
QCOMPARE(m_waitTimeoutOccured, false);
|
||||
QCOMPARE(m_daemon->lastRequestData().size(), 3);
|
||||
// redirect will not cache as the redirection target file.
|
||||
|
@ -402,7 +402,7 @@ void TestHttpGet::testResponseCode(void)
|
|||
QCoreApplication::processEvents();
|
||||
|
||||
QCOMPARE(m_doneSpy->count(), 1);
|
||||
QCOMPARE(m_doneSpy->at(0).at(0).toBool(), true);
|
||||
QCOMPARE(m_doneSpy->at(0).at(0).toInt(), QNetworkReply::ContentNotFoundError);
|
||||
QCOMPARE(m_waitTimeoutOccured, false);
|
||||
QCOMPARE(m_daemon->lastRequestData().size(), 1);
|
||||
QCOMPARE(m_daemon->lastRequestData().at(0).startsWith("GET"), true);
|
||||
|
@ -472,7 +472,7 @@ void TestHttpGet::testNoServer(void)
|
|||
QCoreApplication::processEvents();
|
||||
|
||||
QCOMPARE(m_doneSpy->count(), 1);
|
||||
QCOMPARE(m_doneSpy->at(0).at(0).toBool(), true);
|
||||
QCOMPARE(m_doneSpy->at(0).at(0).toInt(), QNetworkReply::ConnectionRefusedError);
|
||||
QCOMPARE(m_waitTimeoutOccured, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ void ThemesInstallWindow::downloadInfo()
|
|||
}
|
||||
|
||||
|
||||
void ThemesInstallWindow::downloadDone(bool error)
|
||||
void ThemesInstallWindow::downloadDone(QNetworkReply::NetworkError error)
|
||||
{
|
||||
LOG_INFO() << "Download done, error:" << error;
|
||||
|
||||
|
@ -116,7 +116,7 @@ void ThemesInstallWindow::downloadDone(bool error)
|
|||
<< iniDetails.value("error/description").toString()
|
||||
<< iniDetails.value("error/query").toString();
|
||||
|
||||
if(error) {
|
||||
if(error != QNetworkReply::NoError) {
|
||||
logger->addItem(tr("Network error: %1.\n"
|
||||
"Please check your network and proxy settings.")
|
||||
.arg(getter->errorString()), LOGERROR);
|
||||
|
@ -236,19 +236,18 @@ void ThemesInstallWindow::updateDetails(QListWidgetItem* cur, QListWidgetItem* p
|
|||
}
|
||||
|
||||
|
||||
void ThemesInstallWindow::updateImage(bool error)
|
||||
void ThemesInstallWindow::updateImage(QNetworkReply::NetworkError error)
|
||||
{
|
||||
LOG_INFO() << "Updating image:"<< !error;
|
||||
|
||||
if(error) {
|
||||
if(error != QNetworkReply::NoError) {
|
||||
ui.themePreview->clear();
|
||||
ui.themePreview->setText(tr("Retrieving theme preview failed.\n"
|
||||
"HTTP response code: %1").arg(igetter.httpResponse()));
|
||||
return;
|
||||
}
|
||||
|
||||
QPixmap p;
|
||||
if(!error) {
|
||||
else {
|
||||
QPixmap p;
|
||||
imgData = igetter.readAll();
|
||||
if(imgData.isNull()) return;
|
||||
p.loadFromData(imgData);
|
||||
|
|
|
@ -65,8 +65,8 @@ class ThemesInstallWindow : public QDialog
|
|||
bool windowSelectOnly;
|
||||
|
||||
private slots:
|
||||
void downloadDone(bool);
|
||||
void updateImage(bool);
|
||||
void downloadDone(QNetworkReply::NetworkError error);
|
||||
void updateImage(QNetworkReply::NetworkError error);
|
||||
void abort(void);
|
||||
void updateDetails(QListWidgetItem* cur, QListWidgetItem* prev);
|
||||
void updateSize(void);
|
||||
|
|
Loading…
Reference in a new issue