QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
45 {
46  Q_OBJECT
47 
48  public:
50  // and creates that instance on the first call.
51  static QgsNetworkAccessManager* instance();
52 
53  QgsNetworkAccessManager( QObject *parent = nullptr );
54 
57 
59  void insertProxyFactory( QNetworkProxyFactory *factory );
60 
62  void removeProxyFactory( QNetworkProxyFactory *factory );
63 
65  const QList<QNetworkProxyFactory *> proxyFactories() const;
66 
68  const QNetworkProxy &fallbackProxy() const;
69 
71  const QStringList &excludeList() const;
72 
74  void setFallbackProxyAndExcludes( const QNetworkProxy &proxy, const QStringList &excludes );
75 
77  static QString cacheLoadControlName( QNetworkRequest::CacheLoadControl theControl );
78 
80  static QNetworkRequest::CacheLoadControl cacheLoadControlFromName( const QString &theName );
81 
83  void setupDefaultProxyAndCache();
84 
86  bool useSystemProxy() const { return mUseSystemProxy; }
87 
88  public slots:
94  Q_DECL_DEPRECATED void sendGet( const QNetworkRequest & request );
99  Q_DECL_DEPRECATED void deleteReply( QNetworkReply * reply );
100 
101  signals:
102  void requestAboutToBeCreated( QNetworkAccessManager::Operation, const QNetworkRequest &, QIODevice * );
103  void requestCreated( QNetworkReply * );
104  void requestTimedOut( QNetworkReply * );
110  void requestSent( QNetworkReply * reply, QObject *sender );
111 
112  private slots:
113  void abortRequest();
114 
115  protected:
116  virtual QNetworkReply *createRequest( QNetworkAccessManager::Operation op, const QNetworkRequest &req, QIODevice *outgoingData = nullptr ) override;
117 
118  private:
119  QList<QNetworkProxyFactory*> mProxyFactories;
120  QNetworkProxy mFallbackProxy;
121  QStringList mExcludedURLs;
122  bool mUseSystemProxy;
123  bool mInitialized;
124  static QgsNetworkAccessManager *smMainNAM;
125 };
126 
127 #endif // QGSNETWORKACCESSMANAGER_H
128 
virtual QNetworkReply * createRequest(Operation op, const QNetworkRequest &req, QIODevice *outgoingData)
bool useSystemProxy() const
return whether the system proxy should be used
network access manager for QGIS