summaryrefslogtreecommitdiffstats
path: root/src/server/net/filedownloader.cpp
blob: b930869064e46f17b405166964ffbbda0010c85f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * FileDownloader.cpp
 *
 *  Created on: Mar 7, 2014
 *      Author: nils
 */

#include <QFileInfo>

#include "filedownloader.h"

FileDownloader::FileDownloader(QObject *parent) :
	QObject(parent)
{
	connect(&m_WebCtrl, SIGNAL(finished(QNetworkReply*)),
	        SLOT(fileDownloaded(QNetworkReply*)));
}

FileDownloader::~FileDownloader()
{

}

void FileDownloader::connectSlot(QObject* obj, const char* slot)
{
	QObject::connect(this, SIGNAL(downloaded(QByteArray&)),
	                 obj, slot);
}

void FileDownloader::fileDownloaded(QNetworkReply* pReply)
{
	QByteArray downloadedData = pReply->readAll();
	//emit a signal
	pReply->deleteLater();
	emit downloaded(downloadedData);
}

void FileDownloader::downloadFile(const QUrl& fileUrl)
{
	m_WebCtrl.get(QNetworkRequest(fileUrl));
}