From 0a8ab1c45108155434e22131ecc94989f564d58a Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Wed, 4 May 2011 13:24:24 +0200 Subject: download manager constructor comments & typos fix --- src/downloadmanager.cpp | 19 +++++++++++++++---- src/downloadmanager.h | 2 +- src/fbgui.cpp | 3 ++- 3 files changed, 18 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 8f7d8bb..5bada3a 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -1,19 +1,30 @@ #include "downloadmanager.h" +// static counter to save the number of successfully downloaded files. int DownloadManager::_downloaded = 0; // ------------------------------------------------------------------------------------------------------- +// Initialisation +// ------------------------------------------------------------------------------------------------------- +// Constructor initialises a QNetworkAccessManager needed to create/received download requests/replies +// This object is then moved to the thread for the download manager, to ensure that downloads +// are done in a separate thread (to avoid GUI blocking.) +// The flag "_dip" starts as false, since no download is in progress. +// This flag is needed to control queueing functionality. +// Lastly the given download directory's existance is checked. (see below) + DownloadManager::DownloadManager() { qxtLog->debug() << "Initializing download manager..."; - check_downloadDirectory(); + checkDownloadDirectory(); _qnam = new QNetworkAccessManager(); _qnam->moveToThread(&dmThread); _dip = false; } +// Destructor DownloadManager::~DownloadManager() { delete _qnam; } // ------------------------------------------------------------------------------------------------------- -void DownloadManager::check_downloadDirectory() { +void DownloadManager::checkDownloadDirectory() { // check if downloadPath exists, if not create it. _downloadDir = QDir(downloadPath); if (!_downloadDir.exists()) { @@ -188,9 +199,9 @@ void DownloadManager::downloadFinished() { _outfile.close(); _downloaded++; qxtLog->debug() << "[dm] Download of " << _currentDownload->url().toString() - << " finished. (_downloaded = " << _downloaded << ")"; + << " finished. (downloaded = " << _downloaded << ")"; emit - notify(QString("Successfully _downloaded %1").arg(_currentDownload->url().toString())); + notify(QString("Successfully downloaded %1").arg(_currentDownload->url().toString())); _currentDownload->deleteLater(); } _dip = false; diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 58bcd53..62df4bc 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -39,7 +39,7 @@ public: private: // checks for valid download directory, ran once in constructor - void check_downloadDirectory(); + void checkDownloadDirectory(); // private control function for queueing mechanism. void processDownloadRequest(const QUrl& url); diff --git a/src/fbgui.cpp b/src/fbgui.cpp index 1f1a1b5..9e3dba5 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -231,6 +231,7 @@ void fbgui::loadURLDone(bool success) { if (!success) { qxtLog->debug() << "[gui] Loading failed. URL: " << _webView->url().toString(); + qxtLog->debug() << "[gui] You can quit with CTRL + X ..."; // TODO handle failure properly... } else { qxtLog->debug() << "[gui] Loaded URL: " << _webView->url().toString(); @@ -261,7 +262,7 @@ QByteArray fbgui::generatePOSTData() { if (!mbserial.isEmpty()) data.append(mbserial); else { - qxtLog->debug() << "[gui] Mainboard serial was empty. Not appending..."; + qxtLog->debug() << "[gui] Mainboard serial was empty. Not appending to base hash data."; } qxtLog->debug() << "[post] Hashing: " << data; // generate MD5 hash of data -- cgit v1.2.3-55-g7522