MPEGPlayer: Skip to next file when there is a problem with a video file in all-play...
[kugel-rb.git] / rbutil / rbutilqt / base / httpget.h
blob49bea0f8129615c11a7b2154761dc3924c5f912a
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 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(const QDir&);
43 void setCache(bool);
44 int httpResponse(void);
45 QByteArray readAll(void);
46 bool isCached()
47 { return m_cached; }
48 QDateTime timestamp(void)
49 { return m_serverTimestamp; }
50 void setDumbCache(bool b) //< disable checking of http header timestamp for caching
51 { m_dumbCache = b; }
52 static void setGlobalCache(const QDir& d) //< set global cache path
53 { m_globalCache = d; }
54 static void setGlobalProxy(const QUrl& p) //< set global proxy value
55 { m_globalProxy = p; }
56 static void setGlobalDumbCache(bool b) //< set "dumb" (ignore server status) caching mode
57 { m_globalDumbCache = b; }
58 static void setGlobalUserAgent(const QString& u) //< set global user agent string
59 { m_globalUserAgent = u; }
61 public slots:
62 void abort(void);
64 signals:
65 void done(bool);
66 void dataReadProgress(int, int);
67 void requestFinished(int, bool);
68 void headerFinished(void);
70 private slots:
71 void httpDone(bool error);
72 void httpFinished(int, bool);
73 void httpResponseHeader(const QHttpResponseHeader&);
74 void httpState(int);
75 void httpStarted(int);
76 void getFileFinish(void);
78 private:
79 bool initializeCache(const QDir&);
80 QHttp http; //< download object
81 QFile *outputFile;
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;
86 bool outputToBuffer;
87 bool m_usecache;
88 QDir m_cachedir;
89 QString m_cachefile; // cached filename
90 bool m_cached;
91 QUrl m_proxy;
92 bool m_useproxy;
93 QDateTime m_serverTimestamp; //< timestamp of file on server
94 QString m_query; //< constructed query to pass http getter
95 QString m_path; //< constructed path to pass http getter
96 QString m_hash; //< caching hash
97 bool m_dumbCache; //< true if caching should ignore the server header
98 QHttpRequestHeader m_header;
100 static QDir m_globalCache; //< global cache path value
101 static QUrl m_globalProxy; //< global proxy value
102 static bool m_globalDumbCache; //< cache "dumb" mode global setting
103 static QString m_globalUserAgent; //< global user agent string
106 #endif