summaryrefslogtreecommitdiffstats
path: root/src/filedownloader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/filedownloader.cpp')
-rw-r--r--src/filedownloader.cpp64
1 files changed, 32 insertions, 32 deletions
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();
}