1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Riebeling
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 ****************************************************************************/
31 class HttpGet
: public QObject
36 HttpGet(QObject
*parent
= 0);
38 bool getFile(const QUrl
&url
);
39 void setProxy(const QUrl
&url
);
41 QHttp::Error
error(void);
42 QString
errorString(void);
46 int httpResponse(void);
47 QByteArray
readAll(void);
50 QDateTime
timestamp(void)
51 { return m_serverTimestamp
; }
52 void setDumbCache(bool b
) //< disable checking of http header timestamp for caching
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
; }
66 void dataReadProgress(int, int);
67 void requestFinished(int, bool);
68 void headerFinished(void);
71 void httpDone(bool error
);
72 void httpFinished(int, bool);
73 void httpResponseHeader(const QHttpResponseHeader
&);
75 void httpStarted(int);
76 void getFileFinish(void);
79 bool initializeCache(const QDir
&);
80 QHttp http
; //< download object
82 int m_response
; //< http response
83 int getRequest
; //! get file http request id
84 int headRequest
; //! get http header request id
85 QByteArray dataBuffer
;
89 QString m_cachefile
; // cached filename
92 static QDir m_globalCache
; //< global cache path value
93 static QUrl m_globalProxy
; //< global proxy value
94 static bool m_globalDumbCache
; //< cache "dumb" mode global setting
95 QDateTime m_serverTimestamp
; //< timestamp of file on server
96 QString m_query
; //< constructed query to pass http getter
97 QString m_path
; //< constructed path to pass http getter
98 QString m_hash
; //< caching hash
99 bool m_dumbCache
; //< true if caching should ignore the server header