Quantum GIS API Documentation  1.8
src/core/qgsnetworkaccessmanager.h
Go to the documentation of this file.
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 
00018 #ifndef QGSNETWORKACCESSMANAGER_H
00019 #define QGSNETWORKACCESSMANAGER_H
00020 
00021 #include <QList>
00022 #include <QStringList>
00023 #include <QNetworkAccessManager>
00024 #include <QNetworkProxy>
00025 
00026 /*
00027  * \class QgsNetworkAccessManager
00028  * \brief network access manager for QGIS
00029  * \ingroup core
00030  * \since 1.5
00031  *
00032  * This class implements the QGIS network access manager.  It's a singleton
00033  * that can be use across QGIS.
00034  *
00035  * Plugins can insert proxy factories and thereby redirect requests to
00036  * individual proxies.
00037  *
00038  * If no proxy factories are there or none returns a proxy for an URL a
00039  * fallback proxy can be set.  There's also a exclude list that defines URLs
00040  * that the fallback proxy should not be used for, then no proxy will be used.
00041  *
00042  */
00043 class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
00044 {
00045     Q_OBJECT
00046 
00047   public:
00049     // and creates that instance on the first call.
00050     static QgsNetworkAccessManager *instance();
00051 
00053     ~QgsNetworkAccessManager();
00054 
00055 #if QT_VERSION >= 0x40500
00056 
00057     void insertProxyFactory( QNetworkProxyFactory *factory );
00058 
00060     void removeProxyFactory( QNetworkProxyFactory *factory );
00061 
00063     const QList<QNetworkProxyFactory *> proxyFactories() const;
00064 #endif
00065 
00067     const QNetworkProxy &fallbackProxy() const;
00068 
00070     const QStringList &excludeList() const;
00071 
00073     void setFallbackProxyAndExcludes( const QNetworkProxy &proxy, const QStringList &excludes );
00074 
00075   signals:
00076     void requestAboutToBeCreated( QNetworkAccessManager::Operation, const QNetworkRequest &, QIODevice * );
00077     void requestCreated( QNetworkReply * );
00078 
00079   protected:
00080     virtual QNetworkReply *createRequest( QNetworkAccessManager::Operation op, const QNetworkRequest & req, QIODevice * outgoingData = 0 );
00081 
00082   private:
00083     QgsNetworkAccessManager( QObject *parent = 0 );
00084 #if QT_VERSION >= 0x40500
00085     QList<QNetworkProxyFactory*> mProxyFactories;
00086 #endif
00087     QNetworkProxy mFallbackProxy;
00088     QStringList mExcludedURLs;
00089 
00090     static QgsNetworkAccessManager *smNAM;
00091 };
00092 
00093 #endif // QGSNETWORKACCESSMANAGER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines