add global proxy / cache settings to httpget class. This removes the need of passing...
[Rockbox.git] / rbutil / rbutilqt / httpget.h
blob79522f6e8fe92578924a10171323ca686715580a
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2007 by Dominik Riebeling
10 * $Id$
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
21 #ifndef HTTPGET_H
22 #define HTTPGET_H
24 #include <QtCore>
25 #include <QtNetwork>
27 class QUrl;
29 class HttpGet : public QObject
31 Q_OBJECT
33 public:
34 HttpGet(QObject *parent = 0);
36 bool getFile(const QUrl &url);
37 void setProxy(const QUrl &url);
38 void setProxy(bool);
39 QHttp::Error error(void);
40 QString errorString(void);
41 void setFile(QFile*);
42 void setCache(QDir);
43 void setCache(bool);
44 int httpResponse(void);
45 QByteArray readAll(void);
46 bool isCached() { return cached; }
47 static void setGlobalCache(const QDir d) //< set global cache path
48 { m_globalCache = d; }
49 static void setGlobalProxy(const QUrl p) //< set global proxy value
50 { m_globalProxy = p; }
52 public slots:
53 void abort(void);
55 signals:
56 void done(bool);
57 void dataReadProgress(int, int);
58 void requestFinished(int, bool);
60 private slots:
61 void httpDone(bool error);
62 void httpProgress(int, int);
63 void httpFinished(int, bool);
64 void httpResponseHeader(const QHttpResponseHeader&);
65 void httpState(int);
66 void httpStarted(int);
68 private:
69 QHttp http; //< download object
70 QFile *outputFile;
71 int response; //< http response
72 int getRequest;
73 QByteArray dataBuffer;
74 bool outputToBuffer;
75 QString query;
76 bool m_usecache;
77 QDir m_cachedir;
78 QString cachefile;
79 bool cached;
80 QUrl m_proxy;
81 static QDir m_globalCache; //< global cache path value
82 static QUrl m_globalProxy; //< global proxy value
85 #endif