QGIS API Documentation  2.99.0-Master (314842d)
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 <QStringList>
23 #include <QNetworkAccessManager>
24 #include <QNetworkProxy>
25 #include <QNetworkRequest>
26 
27 #include "qgis_core.h"
28 
46 class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
47 {
48  Q_OBJECT
49 
50  public:
52  // and creates that instance on the first call.
53  static QgsNetworkAccessManager *instance();
54 
55  QgsNetworkAccessManager( QObject *parent = nullptr );
56 
58  void insertProxyFactory( QNetworkProxyFactory *factory );
59 
61  void removeProxyFactory( QNetworkProxyFactory *factory );
62 
64  const QList<QNetworkProxyFactory *> proxyFactories() const;
65 
67  const QNetworkProxy &fallbackProxy() const;
68 
70  QStringList excludeList() const;
71 
73  void setFallbackProxyAndExcludes( const QNetworkProxy &proxy, const QStringList &excludes );
74 
76  static QString cacheLoadControlName( QNetworkRequest::CacheLoadControl control );
77 
79  static QNetworkRequest::CacheLoadControl cacheLoadControlFromName( const QString &name );
80 
82  void setupDefaultProxyAndCache();
83 
85  bool useSystemProxy() const { return mUseSystemProxy; }
86 
87  signals:
88  void requestAboutToBeCreated( QNetworkAccessManager::Operation, const QNetworkRequest &, QIODevice * );
89  void requestCreated( QNetworkReply * );
90  void requestTimedOut( QNetworkReply * );
91 
92  private slots:
93  void abortRequest();
94 
95  protected:
96  virtual QNetworkReply *createRequest( QNetworkAccessManager::Operation op, const QNetworkRequest &req, QIODevice *outgoingData = nullptr ) override;
97 
98  private:
99  QList<QNetworkProxyFactory *> mProxyFactories;
100  QNetworkProxy mFallbackProxy;
101  QStringList mExcludedURLs;
102  bool mUseSystemProxy;
103  bool mInitialized;
104  static QgsNetworkAccessManager *sMainNAM;
105 };
106 
107 #endif // QGSNETWORKACCESSMANAGER_H
108 
bool useSystemProxy() const
return whether the system proxy should be used
network access manager for QGIS