Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
qgsnetworkaccessmanager.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsnetworkaccessmanager.h - description
3  -------------------
4  begin : 2010-05-08
5  copyright : (C) 2010 by Juergen E. Fischer
6  email : jef at norbit dot de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 /* $Id$ */
18 
19 #ifndef QGSNETWORKACCESSMANAGER_H
20 #define QGSNETWORKACCESSMANAGER_H
21 
22 #include <QList>
23 #include <QStringList>
24 #include <QNetworkAccessManager>
25 #include <QNetworkProxy>
26 
27 /*
28  * \class QgsNetworkAccessManager
29  * \brief network access manager for QGIS
30  * \ingroup core
31  * \since 1.5
32  *
33  * This class implements the QGIS network access manager. It's a singleton
34  * that can be use across QGIS.
35  *
36  * Plugins can insert proxy factories and thereby redirect requests to
37  * individual proxies.
38  *
39  * If no proxy factories are there or none returns a proxy for an URL a
40  * fallback proxy can be set. There's also a exclude list that defines URLs
41  * that the fallback proxy should not be used for, then no proxy will be used.
42  *
43  */
44 class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
45 {
46  Q_OBJECT
47 
48  public:
50  // and creates that instance on the first call.
51  static QgsNetworkAccessManager *instance();
52 
55 
56 #if QT_VERSION >= 0x40500
57  void insertProxyFactory( QNetworkProxyFactory *factory );
59 
61  void removeProxyFactory( QNetworkProxyFactory *factory );
62 
64  const QList<QNetworkProxyFactory *> proxyFactories() const;
65 #endif
66 
68  const QNetworkProxy &fallbackProxy() const;
69 
71  const QStringList &excludeList() const;
72 
74  void setFallbackProxyAndExcludes( const QNetworkProxy &proxy, const QStringList &excludes );
75 
76  signals:
77  void requestAboutToBeCreated( QNetworkAccessManager::Operation, const QNetworkRequest &, QIODevice * );
78  void requestCreated( QNetworkReply * );
79 
80  protected:
81  virtual QNetworkReply *createRequest( QNetworkAccessManager::Operation op, const QNetworkRequest & req, QIODevice * outgoingData = 0 );
82 
83  private:
84  QgsNetworkAccessManager( QObject *parent = 0 );
85 #if QT_VERSION >= 0x40500
86  QList<QNetworkProxyFactory*> mProxyFactories;
87 #endif
88  QNetworkProxy mFallbackProxy;
89  QStringList mExcludedURLs;
90 
92 };
93 
94 #endif // QGSNETWORKACCESSMANAGER_H