1 | /* smplayer, GUI front-end for mplayer.
|
---|
2 | Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
3 |
|
---|
4 | This program is free software; you can redistribute it and/or modify
|
---|
5 | it under the terms of the GNU General Public License as published by
|
---|
6 | the Free Software Foundation; either version 2 of the License, or
|
---|
7 | (at your option) any later version.
|
---|
8 |
|
---|
9 | This program is distributed in the hope that it will be useful,
|
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | GNU General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU General Public License
|
---|
15 | along with this program; if not, write to the Free Software
|
---|
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef CODEDOWNLOADER_H
|
---|
20 | #define CODEDOWNLOADER_H
|
---|
21 |
|
---|
22 | #include <QProgressDialog>
|
---|
23 | #include <QUrl>
|
---|
24 | #include <QNetworkProxy>
|
---|
25 | #include <QNetworkAccessManager>
|
---|
26 | #include <QNetworkReply>
|
---|
27 |
|
---|
28 | class CodeDownloader : public QProgressDialog
|
---|
29 | {
|
---|
30 | Q_OBJECT
|
---|
31 |
|
---|
32 | public:
|
---|
33 | CodeDownloader(QWidget *parent = 0);
|
---|
34 | ~CodeDownloader();
|
---|
35 |
|
---|
36 | void saveAs(const QString & output) { output_filename = output; };
|
---|
37 | void setProxy(QNetworkProxy proxy);
|
---|
38 |
|
---|
39 | public slots:
|
---|
40 | void download(QUrl url);
|
---|
41 | void cancelDownload();
|
---|
42 |
|
---|
43 | signals:
|
---|
44 | void downloadFinished();
|
---|
45 | void errorOcurred(int error_number, QString error_str);
|
---|
46 | void fileSaved(const QString &, const QString &);
|
---|
47 | void saveFailed(const QString &);
|
---|
48 |
|
---|
49 | private slots:
|
---|
50 | void gotResponse(QNetworkReply* reply);
|
---|
51 | void updateDataReadProgress(qint64 bytes_read, qint64 total_bytes);
|
---|
52 | void save(QByteArray bytes);
|
---|
53 |
|
---|
54 | void reportFileSaved(const QString &, const QString &);
|
---|
55 | void reportSaveFailed(const QString &);
|
---|
56 | void reportError(int error_number, QString error_str);
|
---|
57 |
|
---|
58 | private:
|
---|
59 | QNetworkAccessManager* manager;
|
---|
60 | QNetworkReply* reply;
|
---|
61 |
|
---|
62 | QString output_filename;
|
---|
63 | };
|
---|
64 |
|
---|
65 | #endif
|
---|