summaryrefslogtreecommitdiffstats
path: root/src/DownloadManager.cpp
diff options
context:
space:
mode:
authorJonathan Bauer2011-03-07 21:20:00 +0100
committerJonathan Bauer2011-03-07 21:20:00 +0100
commitdad849a0c95aeed383f6ea4b184d7fa46018db0f (patch)
treedaba889e5e14fa2c913161e7600b6a8082bd3ea8 /src/DownloadManager.cpp
parentReworked code structure (diff)
downloadfbgui-dad849a0c95aeed383f6ea4b184d7fa46018db0f.tar.gz
fbgui-dad849a0c95aeed383f6ea4b184d7fa46018db0f.tar.xz
fbgui-dad849a0c95aeed383f6ea4b184d7fa46018db0f.zip
first cleanup...
Diffstat (limited to 'src/DownloadManager.cpp')
-rw-r--r--src/DownloadManager.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/DownloadManager.cpp b/src/DownloadManager.cpp
index 600fed6..61b63d7 100644
--- a/src/DownloadManager.cpp
+++ b/src/DownloadManager.cpp
@@ -1,12 +1,13 @@
#include "DownloadManager.h"
void DownloadManager::downloadFile(QString& filename){
+ if (debug) qDebug() << "DM received signal for: " << filename;
QUrl fileUrl;
fileUrl = baseURL.resolved(QUrl(filename));
this->processDownloadRequest(fileUrl);
}
void DownloadManager::downloadFile(QUrl& fileUrl){
- qDebug() << "Received downloadFile signal for:" << fileUrl;
+ if (debug) qDebug() << "Received downloadFile signal for:" << fileUrl;
this->processDownloadRequest(fileUrl);
}
// ----------------------------------------------------------------------------------------
@@ -16,25 +17,25 @@ void DownloadManager::processDownloadRequest(QUrl& url)
// If download in progress, enqueue file and return.
if (dip)
{
- qDebug() << "Download in progress! Enqueueing:" << url.toString()
+ if (debug) qDebug() << "Download in progress! Enqueueing:" << url.toString()
<< "(" << dlQ.size() << "in queue)";
dlQ.enqueue(url);
return;
}
// No running downloads: enqueue and start next download.
dlQ.enqueue(url);
- qDebug() << "Enqueueing:" << url.toString() << endl;
+ if (debug) qDebug() << "Enqueueing:" << url.toString() << endl;
startNextDownload();
}
// ----------------------------------------------------------------------------------------
void DownloadManager::startNextDownload()
{
- qDebug() << "Starting next download: " << dlQ.head().toString()
+ if (debug) qDebug() << "Starting next download: " << dlQ.head().toString()
<< "(" << dlQ.size() << "in queue.)";
if (dlQ.isEmpty())
{
- qDebug() << "Download queue empty! Exiting...";
+ if (debug) qDebug() << "Download queue empty! Exiting...";
return;
}
// Dequeue next URL to download.
@@ -46,7 +47,7 @@ void DownloadManager::startNextDownload()
// If error upon opening, skip this file.
if (!outfile.open(QIODevice::WriteOnly))
{
- qDebug() << "Couldn't open file! Exiting...";
+ if (debug) qDebug() << "Couldn't open file! Exiting...";
startNextDownload();
return;
}
@@ -56,7 +57,7 @@ void DownloadManager::startNextDownload()
// TODO: Error handling not working properly...
if (currentDownload->error() != QNetworkReply::NoError)
{
- qDebug() << "Network reply error, skipping download...";
+ if (debug) qDebug() << "Network reply error, skipping download...";
return;
}
dip = true;
@@ -80,7 +81,7 @@ void DownloadManager::downloadReady()
void DownloadManager::downloadProgress(qint64 bytesIn, qint64 bytesTotal)
{
- qDebug() << "Download progress of " << currentDownload->url().toString()
+ if (debug) qDebug() << "Download progress of " << currentDownload->url().toString()
<< ": " << bytesIn << "/" << bytesTotal;
qint64 tmp = ((bytesIn * 100) / bytesTotal);
emit updateProgress((int)tmp);
@@ -92,8 +93,8 @@ void DownloadManager::downloadFinished()
{
// Second check if the download actually is finished.
if (currentDownload->isFinished())
- qDebug() << "Download of " << currentDownload->url().toString()
- << "finished." << endl;
+ if (debug) qDebug() << "Download of " << currentDownload->url().toString()
+ << "finished." << endl;
// Close output file.
outfile.close();
currentDownload->deleteLater();
@@ -113,8 +114,3 @@ DownloadManager::DownloadManager()
dip = false;
downloaded = 0;
}
-// Destructor.
-DownloadManager::~DownloadManager()
-{
- delete[] qnam;
-}