1
/* This program is free software; you can redistribute it and/or modify
2
* it under the terms of the GNU General Public License version 2
3
* as published by the Free Software Foundation.
5
* This program is distributed in the hope that it will be useful,
6
* but WITHOUT ANY WARRANTY; without even the implied warranty of
7
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8
* GNU General Public License for more details.
10
* You should have received a copy of the GNU General Public License
11
* along with this program; if not, write to the Free Software
12
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14
* Author: Moshe Wagner. <moshe.wagner@gmail.com>
17
#ifndef FILEDOWNLOADER_H
18
#define FILEDOWNLOADER_H
22
#include <QtNetwork/QHttp>
24
This class provides a simple method to download requested files;
25
The download is saved into $path+".part" untill download is succesfull,
26
and only then it is moved to the given path.
28
( If a file exists in the given position, it is asuumed to be a successfull previous download,
29
and the download is instantly done. )
31
It emits these signalls:
32
-> downloadProgress(int) - gives a integer between 1 to 100 representing the current dowload progress.
33
(or zero as long as it didn't start yet)
34
-> done() - emitted when the download is finished succesfully
35
-> Error() - emitted when the download failed due to an error, but not if it was aborted
37
And accepts these slots:
38
-> abort() - stops the download, removes the ".part" file, but does not emmit a "error" signal
41
class FileDownloader : public QObject
48
//Downloads the file at the given url to the given target.
49
// Returns nothing, but emits signalls representing what happened
50
void Download(QString url, QString target, bool overwrite);
52
//Returns the filename of the last download (NOTE: also if it was unsuccessful)
53
QString getFileName();
55
//Returns true if a download is running (at any state), and false if not
59
//The class's Http object
61
//The file handling the download proccess
63
//File name for the finished download
64
// (Until it's done it's saved to the same name with ".part" after it)
68
//Aborts the download, and emits no error
72
//Connects to the Http object's done() signall
73
void downloadDone(bool error);
74
//Connects to the Http object's download progress() signall
75
void downloadProgress(int,int);
78
//Emitted when download WAS successfuly done
80
//Emitted when download WASN'T successfuly done
82
//Emitted as the download continues, giving it's progress in percents.
83
void downloadProgress(int);
86
#endif // FILEDOWNLOADER_H