diff options
Diffstat (limited to 'src/DownloadManager.cpp')
-rw-r--r-- | src/DownloadManager.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/DownloadManager.cpp b/src/DownloadManager.cpp new file mode 100644 index 0000000..73d979e --- /dev/null +++ b/src/DownloadManager.cpp @@ -0,0 +1,42 @@ +#include "DownloadManager.h" + +void DownloadManager::downloadFile(QString& filename) +{ + this->filename = filename; + this->reply = this->qnam->get(this->request); + qiod = reply; + QObject::connect(this->reply, SIGNAL(finished()), this, SLOT(saveData())); +} + +void DownloadManager::saveData() +{ + QFile outfile(this->filename); + if (!outfile.open(QIODevice::WriteOnly)) + { + qDebug() << "Couldnt open file! exiting..."; + exit(1); + } + outfile.write(this->reply->readAll()); + outfile.close(); + +} + +void DownloadManager::setUrl(QUrl& qurl) +{ + this->baseUrl = qurl; +} + +void DownloadManager::print() +{ + qDebug() << "The download manager is still working"; +} + +DownloadManager::DownloadManager() +{ + this->qnam = new QNetworkAccessManager(); + this->request.setUrl(baseUrl); +} + +DownloadManager::~DownloadManager() +{ +} |