QGIS API Documentation  3.0.2-Girona (307d082)
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 
18 #ifndef QGSNETWORKACCESSMANAGER_H
19 #define QGSNETWORKACCESSMANAGER_H
20 
21 #include <QList>
22 #include "qgis.h"
23 #include <QStringList>
24 #include <QNetworkAccessManager>
25 #include <QNetworkProxy>
26 #include <QNetworkRequest>
27 
28 #include "qgis_core.h"
29 
47 class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
48 {
49  Q_OBJECT
50 
51  public:
53  // and creates that instance on the first call.
54  static QgsNetworkAccessManager *instance();
55 
56  QgsNetworkAccessManager( QObject *parent = nullptr );
57 
59  void insertProxyFactory( QNetworkProxyFactory *factory SIP_TRANSFER );
60 
62  void removeProxyFactory( QNetworkProxyFactory *factory SIP_TRANSFERBACK );
63 
65  const QList<QNetworkProxyFactory *> proxyFactories() const;
66 
68  const QNetworkProxy &fallbackProxy() const;
69 
71  QStringList excludeList() const;
72 
74  void setFallbackProxyAndExcludes( const QNetworkProxy &proxy, const QStringList &excludes );
75 
77  static QString cacheLoadControlName( QNetworkRequest::CacheLoadControl control );
78 
80  static QNetworkRequest::CacheLoadControl cacheLoadControlFromName( const QString &name );
81 
83  void setupDefaultProxyAndCache();
84 
86  bool useSystemProxy() const { return mUseSystemProxy; }
87 
88  signals:
89  void requestAboutToBeCreated( QNetworkAccessManager::Operation, const QNetworkRequest &, QIODevice * );
90  void requestCreated( QNetworkReply * );
91  void requestTimedOut( QNetworkReply * );
92 
93  private slots:
94  void abortRequest();
95 
96  protected:
97  QNetworkReply *createRequest( QNetworkAccessManager::Operation op, const QNetworkRequest &req, QIODevice *outgoingData = nullptr ) override;
98 
99  private:
100  QList<QNetworkProxyFactory *> mProxyFactories;
101  QNetworkProxy mFallbackProxy;
102  QStringList mExcludedURLs;
103  bool mUseSystemProxy = false;
104  bool mInitialized = false;
105  static QgsNetworkAccessManager *sMainNAM;
106 };
107 
108 #endif // QGSNETWORKACCESSMANAGER_H
109 
#define SIP_TRANSFERBACK
Definition: qgis_sip.h:41
#define SIP_TRANSFER
Definition: qgis_sip.h:36
bool useSystemProxy() const
return whether the system proxy should be used
network access manager for QGIS