Add more simulator stubs. This should get rid of the last reds
[kugel-rb.git] / rbutil / rbutilqt / base / httpget.h
blobba4cbc821e9aa4c928eb5d112b00916405b54aec
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2007 by Dominik Riebeling
10 * $Id$
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
23 #ifndef HTTPGET_H
24 #define HTTPGET_H
26 #include <QtCore>
27 #include <QtNetwork>
29 class QUrl;
31 class HttpGet : public QObject
33 Q_OBJECT
35 public:
36 HttpGet(QObject *parent = 0);
38 bool getFile(const QUrl &url);
39 void setProxy(const QUrl &url);
40 void setProxy(bool);
41 QHttp::Error error(void);
42 QString errorString(void);
43 void setFile(QFile*);
44 void setCache(QDir);
45 void setCache(bool);
46 int httpResponse(void);
47 QByteArray readAll(void);
48 bool isCached()
49 { return m_cached; }
50 QDateTime timestamp(void)
51 { return m_serverTimestamp; }
52 void setDumbCache(bool b) //< disable checking of http header timestamp for caching
53 { m_dumbCache = b; }
54 static void setGlobalCache(const QDir d) //< set global cache path
55 { m_globalCache = d; }
56 static void setGlobalProxy(const QUrl p) //< set global proxy value
57 { m_globalProxy = p; }
58 static void setGlobalDumbCache(bool b) //< set "dumb" (ignore server status) caching mode
59 { m_globalDumbCache = b; }
60 static void setGlobalUserAgent(QString u) //< set global user agent string
61 { m_globalUserAgent = u; }
63 public slots:
64 void abort(void);
66 signals:
67 void done(bool);
68 void dataReadProgress(int, int);
69 void requestFinished(int, bool);
70 void headerFinished(void);
72 private slots:
73 void httpDone(bool error);
74 void httpFinished(int, bool);
75 void httpResponseHeader(const QHttpResponseHeader&);
76 void httpState(int);
77 void httpStarted(int);
78 void getFileFinish(void);
80 private:
81 bool initializeCache(const QDir&);
82 QHttp http; //< download object
83 QFile *outputFile;
84 int m_response; //< http response
85 int getRequest; //! get file http request id
86 int headRequest; //! get http header request id
87 QByteArray dataBuffer;
88 bool outputToBuffer;
89 bool m_usecache;
90 QDir m_cachedir;
91 QString m_cachefile; // cached filename
92 bool m_cached;
93 QUrl m_proxy;
94 QDateTime m_serverTimestamp; //< timestamp of file on server
95 QString m_query; //< constructed query to pass http getter
96 QString m_path; //< constructed path to pass http getter
97 QString m_hash; //< caching hash
98 bool m_dumbCache; //< true if caching should ignore the server header
99 QHttpRequestHeader m_header;
101 static QDir m_globalCache; //< global cache path value
102 static QUrl m_globalProxy; //< global proxy value
103 static bool m_globalDumbCache; //< cache "dumb" mode global setting
104 static QString m_globalUserAgent; //< global user agent string
107 #endif