PageRenderTime 197ms CodeModel.GetById 80ms app.highlight 11ms RepoModel.GetById 100ms app.codeStats 0ms

/thirdparty/liblastfm2/src/ws/NetworkAccessManager.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 66 lines | 27 code | 12 blank | 27 comment | 0 complexity | d0b721e95d26146272bca5400894bf6f MD5 | raw file
 1/*
 2   Copyright 2009 Last.fm Ltd. 
 3      - Primarily authored by Max Howell, Jono Cole and Doug Mansell
 4
 5   This file is part of liblastfm.
 6
 7   liblastfm is free software: you can redistribute it and/or modify
 8   it under the terms of the GNU General Public License as published by
 9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11
12   liblastfm is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with liblastfm.  If not, see <http://www.gnu.org/licenses/>.
19*/
20#ifndef LASTFM_WS_ACCESS_MANAGER_H
21#define LASTFM_WS_ACCESS_MANAGER_H
22
23#include <lastfm/global.h>
24#include <QtNetwork/QNetworkAccessManager>
25#include <QNetworkRequest>
26#include <QNetworkProxy>
27
28
29namespace lastfm {
30
31/** Sets useragent and proxy. Auto detecting the proxy where possible. */
32class LASTFM_DLLEXPORT NetworkAccessManager : public QNetworkAccessManager
33{
34    Q_OBJECT
35
36#ifdef Q_WS_WIN
37    class Pac *m_pac;
38    class InternetConnectionMonitor* m_monitor;
39#endif
40
41public:
42    NetworkAccessManager( QObject *parent = 0 );
43    ~NetworkAccessManager();
44
45    /** PAC allows different proxy configurations depending on the request
46      * URL and even UserAgent! Thus we allow you to pass that in, we
47      * automatically configure the proxy for every request through 
48      * WsAccessManager */
49    QNetworkProxy proxy( const QNetworkRequest& = QNetworkRequest() );
50
51protected:
52    virtual QNetworkReply* createRequest( Operation, const QNetworkRequest&, QIODevice* outgoingdata = 0 );
53
54private slots:
55    void onConnectivityChanged( bool );
56
57private:
58    /** this function calls QNetworkAccessManager::setProxy, and thus 
59      * configures the proxy correctly for the next request created by
60      * createRequest. This is necessary due */
61    void applyProxy( const QNetworkRequest& );
62};
63
64} //namespace lastfm
65
66#endif