QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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:
52 
71  static QgsNetworkAccessManager *instance( Qt::ConnectionType connectionType = Qt::BlockingQueuedConnection );
72 
73  QgsNetworkAccessManager( QObject *parent = nullptr );
74 
76  void insertProxyFactory( QNetworkProxyFactory *factory SIP_TRANSFER );
77 
79  void removeProxyFactory( QNetworkProxyFactory *factory SIP_TRANSFERBACK );
80 
82  const QList<QNetworkProxyFactory *> proxyFactories() const;
83 
85  const QNetworkProxy &fallbackProxy() const;
86 
88  QStringList excludeList() const;
89 
91  void setFallbackProxyAndExcludes( const QNetworkProxy &proxy, const QStringList &excludes );
92 
94  static QString cacheLoadControlName( QNetworkRequest::CacheLoadControl control );
95 
97  static QNetworkRequest::CacheLoadControl cacheLoadControlFromName( const QString &name );
98 
106  void setupDefaultProxyAndCache( Qt::ConnectionType connectionType = Qt::BlockingQueuedConnection );
107 
109  bool useSystemProxy() const { return mUseSystemProxy; }
110 
111  signals:
112  void requestAboutToBeCreated( QNetworkAccessManager::Operation, const QNetworkRequest &, QIODevice * );
113  void requestCreated( QNetworkReply * );
114  void requestTimedOut( QNetworkReply * );
115 
116  private slots:
117  void abortRequest();
118 
119  protected:
120  QNetworkReply *createRequest( QNetworkAccessManager::Operation op, const QNetworkRequest &req, QIODevice *outgoingData = nullptr ) override;
121 
122  private:
123  QList<QNetworkProxyFactory *> mProxyFactories;
124  QNetworkProxy mFallbackProxy;
125  QStringList mExcludedURLs;
126  bool mUseSystemProxy = false;
127  bool mInitialized = false;
128  static QgsNetworkAccessManager *sMainNAM;
129 };
130 
131 #endif // QGSNETWORKACCESSMANAGER_H
132 
#define SIP_TRANSFERBACK
Definition: qgis_sip.h:41
bool useSystemProxy() const
Returns whether the system proxy should be used.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
network access manager for QGISThis class implements the QGIS network access manager.