From ba3c5aa40274c11f9cefd4e9842be3488cad07b4 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 15 Jun 2018 14:05:25 +0200 Subject: Fix indentation, cleanup, refactoring, deletions * Remove unused methods for adding hostname and user to xml * Avoid copying/(de)serializing XML a thousand times * Fix Session::isValid() or rather make it a bit more usable (although it's unused currently) * baseDir is global, not per VSession, which doesn't make any sense without the legacy approach of recusively loading one xml file per entry --- src/filedownloader.cpp | 64 +++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'src/filedownloader.cpp') diff --git a/src/filedownloader.cpp b/src/filedownloader.cpp index 0af2544..7e2574b 100644 --- a/src/filedownloader.cpp +++ b/src/filedownloader.cpp @@ -15,7 +15,7 @@ static QNetworkAccessManager m_WebCtrl; FileDownloader::FileDownloader(const QUrl& fileUrl, QObject *parent) : - QObject(parent), started(false), url(fileUrl) { + QObject(parent), started(false), url(fileUrl) { } FileDownloader::~FileDownloader() { @@ -23,15 +23,15 @@ FileDownloader::~FileDownloader() { } bool FileDownloader::downloadFile() { - if (this->started) - return true; - QNetworkReply *reply = m_WebCtrl.get(QNetworkRequest(this->url)); - if (reply == NULL) - return false; - this->started = true; - connect(reply, SIGNAL(finished()), SLOT(fileDownloaded())); - connect(reply, SIGNAL(downloadProgress(qint64, qint64)), SLOT(downloadProgress(qint64, qint64))); - return true; + if (this->started) + return true; + QNetworkReply *reply = m_WebCtrl.get(QNetworkRequest(this->url)); + if (reply == NULL) + return false; + this->started = true; + connect(reply, SIGNAL(finished()), SLOT(fileDownloaded())); + connect(reply, SIGNAL(downloadProgress(qint64, qint64)), SLOT(downloadProgress(qint64, qint64))); + return true; } /* @@ -39,35 +39,35 @@ bool FileDownloader::downloadFile() { */ void FileDownloader::downloadFailed(QNetworkReply::NetworkError) { - QNetworkReply *reply = (QNetworkReply*)this->sender(); - killReply(reply); - emit downloaded(this->url, QByteArray()); + QNetworkReply *reply = (QNetworkReply*)this->sender(); + killReply(reply); + emit downloaded(this->url, QByteArray()); } void FileDownloader::fileDownloaded() { - QNetworkReply *reply = (QNetworkReply*)this->sender(); - if (reply == NULL) - return; - QByteArray downloadedData(reply->readAll()); - killReply(reply); - //emit a signal - emit downloaded(this->url, downloadedData); + QNetworkReply *reply = (QNetworkReply*)this->sender(); + if (reply == NULL) + return; + QByteArray downloadedData(reply->readAll()); + killReply(reply); + //emit a signal + emit downloaded(this->url, downloadedData); } void FileDownloader::downloadProgress(qint64 received, qint64 totalSize) { - QNetworkReply *reply = (QNetworkReply*)this->sender(); - if (reply == NULL) - return; - if (received > MAXSIZE || totalSize > MAXSIZE) { - killReply(reply); - emit downloaded(this->url, QByteArray()); - } + QNetworkReply *reply = (QNetworkReply*)this->sender(); + if (reply == NULL) + return; + if (received > MAXSIZE || totalSize > MAXSIZE) { + killReply(reply); + emit downloaded(this->url, QByteArray()); + } } void FileDownloader::killReply(QNetworkReply *reply) { - if (reply == NULL) - return; - reply->blockSignals(true); - reply->abort(); - reply->deleteLater(); + if (reply == NULL) + return; + reply->blockSignals(true); + reply->abort(); + reply->deleteLater(); } -- cgit v1.2.3-55-g7522