1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Riebeling
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 ****************************************************************************/
29 class HttpGet
: public QObject
34 HttpGet(QObject
*parent
= 0);
36 bool getFile(const QUrl
&url
);
37 void setProxy(const QUrl
&url
);
39 QHttp::Error
error(void);
40 QString
errorString(void);
44 int httpResponse(void);
45 QByteArray
readAll(void);
46 bool isCached() { return m_cached
; }
47 void setDumbCache(bool b
) //< disable checking of http header timestamp for caching
49 static void setGlobalCache(const QDir d
) //< set global cache path
50 { m_globalCache
= d
; }
51 static void setGlobalProxy(const QUrl p
) //< set global proxy value
52 { m_globalProxy
= p
; }
53 static void setGlobalDumbCache(bool b
) //< set "dumb" (ignore server status) caching mode
54 { m_globalDumbCache
= b
; }
61 void dataReadProgress(int, int);
62 void requestFinished(int, bool);
63 void headerFinished(void);
66 void httpDone(bool error
);
67 void httpProgress(int, int);
68 void httpFinished(int, bool);
69 void httpResponseHeader(const QHttpResponseHeader
&);
71 void httpStarted(int);
72 void getFileFinish(void);
75 bool initializeCache(const QDir
&);
76 QHttp http
; //< download object
78 int m_response
; //< http response
79 int getRequest
; //! get file http request id
80 int headRequest
; //! get http header request id
81 QByteArray dataBuffer
;
85 QString m_cachefile
; // cached filename
88 static QDir m_globalCache
; //< global cache path value
89 static QUrl m_globalProxy
; //< global proxy value
90 static bool m_globalDumbCache
; //< cache "dumb" mode global setting
91 QDateTime m_serverTimestamp
; //< timestamp of file on server
92 QString m_query
; //< constructed query to pass http getter
93 QString m_path
; //< constructed path to pass http getter
94 QString m_hash
; //< caching hash
95 bool m_dumbCache
; //< true if caching should ignore the server header