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 LOADPAGE_H
|
---|
20 | #define LOADPAGE_H
|
---|
21 |
|
---|
22 | #include <QObject>
|
---|
23 | #include <QString>
|
---|
24 |
|
---|
25 | class QNetworkAccessManager;
|
---|
26 | class QNetworkReply;
|
---|
27 |
|
---|
28 | class LoadPage : public QObject
|
---|
29 | {
|
---|
30 | Q_OBJECT
|
---|
31 |
|
---|
32 | public:
|
---|
33 | LoadPage(QNetworkAccessManager * man, QObject* parent = 0);
|
---|
34 | ~LoadPage();
|
---|
35 |
|
---|
36 | void fetchPage(const QString & url);
|
---|
37 |
|
---|
38 | static void setDefaultUserAgent(const QString & ua) { default_user_agent = ua; };
|
---|
39 | static QString defaultUserAgent() { return default_user_agent; };
|
---|
40 |
|
---|
41 | void setUserAgent(const QString & ua) { user_agent = ua; };
|
---|
42 | QString userAgent() {
|
---|
43 | if (user_agent.isNull()) return default_user_agent; else return user_agent;
|
---|
44 | }
|
---|
45 |
|
---|
46 | signals:
|
---|
47 | void errorOcurred(int error_number, QString error_str);
|
---|
48 | void pageLoaded(QByteArray page);
|
---|
49 |
|
---|
50 | protected slots:
|
---|
51 | void gotResponse();
|
---|
52 |
|
---|
53 | private:
|
---|
54 | QNetworkAccessManager * manager;
|
---|
55 | QNetworkReply * reply;
|
---|
56 | QString user_agent;
|
---|
57 |
|
---|
58 | static QString default_user_agent;
|
---|
59 | };
|
---|
60 |
|
---|
61 | #endif
|
---|