Quantum GIS API Documentation
1.7.4
|
00001 /*************************************************************************** 00002 qgsnetworkaccessmanager.h - description 00003 ------------------- 00004 begin : 2010-05-08 00005 copyright : (C) 2010 by Juergen E. Fischer 00006 email : jef at norbit dot de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 /* $Id$ */ 00018 00019 #ifndef QGSNETWORKACCESSMANAGER_H 00020 #define QGSNETWORKACCESSMANAGER_H 00021 00022 #include <QList> 00023 #include <QStringList> 00024 #include <QNetworkAccessManager> 00025 #include <QNetworkProxy> 00026 00027 /* 00028 * \class QgsNetworkAccessManager 00029 * \brief network access manager for QGIS 00030 * \ingroup core 00031 * \since 1.5 00032 * 00033 * This class implements the QGIS network access manager. It's a singleton 00034 * that can be use across QGIS. 00035 * 00036 * Plugins can insert proxy factories and thereby redirect requests to 00037 * individual proxies. 00038 * 00039 * If no proxy factories are there or none returns a proxy for an URL a 00040 * fallback proxy can be set. There's also a exclude list that defines URLs 00041 * that the fallback proxy should not be used for, then no proxy will be used. 00042 * 00043 */ 00044 class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager 00045 { 00046 Q_OBJECT 00047 00048 public: 00050 // and creates that instance on the first call. 00051 static QgsNetworkAccessManager *instance(); 00052 00054 ~QgsNetworkAccessManager(); 00055 00056 #if QT_VERSION >= 0x40500 00057 00058 void insertProxyFactory( QNetworkProxyFactory *factory ); 00059 00061 void removeProxyFactory( QNetworkProxyFactory *factory ); 00062 00064 const QList<QNetworkProxyFactory *> proxyFactories() const; 00065 #endif 00066 00068 const QNetworkProxy &fallbackProxy() const; 00069 00071 const QStringList &excludeList() const; 00072 00074 void setFallbackProxyAndExcludes( const QNetworkProxy &proxy, const QStringList &excludes ); 00075 00076 signals: 00077 void requestAboutToBeCreated( QNetworkAccessManager::Operation, const QNetworkRequest &, QIODevice * ); 00078 void requestCreated( QNetworkReply * ); 00079 00080 protected: 00081 virtual QNetworkReply *createRequest( QNetworkAccessManager::Operation op, const QNetworkRequest & req, QIODevice * outgoingData = 0 ); 00082 00083 private: 00084 QgsNetworkAccessManager( QObject *parent = 0 ); 00085 #if QT_VERSION >= 0x40500 00086 QList<QNetworkProxyFactory*> mProxyFactories; 00087 #endif 00088 QNetworkProxy mFallbackProxy; 00089 QStringList mExcludedURLs; 00090 00091 static QgsNetworkAccessManager *smNAM; 00092 }; 00093 00094 #endif // QGSNETWORKACCESSMANAGER_H