QGIS API Documentation  3.2.0-Bonn (bc43194)
Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
QgsNetworkAccessManager Class Reference

network access manager for QGISThis class implements the QGIS network access manager. More...

#include <qgsnetworkaccessmanager.h>

Inheritance diagram for QgsNetworkAccessManager:
Inheritance graph
[legend]

Signals

void requestAboutToBeCreated (QNetworkAccessManager::Operation, const QNetworkRequest &, QIODevice *)
 
void requestCreated (QNetworkReply *)
 
void requestTimedOut (QNetworkReply *)
 

Public Member Functions

 QgsNetworkAccessManager (QObject *parent=nullptr)
 
QStringList excludeList () const
 retrieve exclude list (urls shouldn't use the fallback proxy) More...
 
const QNetworkProxy & fallbackProxy () const
 retrieve fall back proxy (for urls that no factory returned proxies for) More...
 
void insertProxyFactory (QNetworkProxyFactory *factory)
 insert a factory into the proxy factories list More...
 
const QList< QNetworkProxyFactory * > proxyFactories () const
 retrieve proxy factory list More...
 
void removeProxyFactory (QNetworkProxyFactory *factory)
 remove a factory from the proxy factories list More...
 
void setFallbackProxyAndExcludes (const QNetworkProxy &proxy, const QStringList &excludes)
 Sets fallback proxy and URL that shouldn't use it. More...
 
void setupDefaultProxyAndCache (Qt::ConnectionType connectionType=Qt::BlockingQueuedConnection)
 Setup the QgsNetworkAccessManager (NAM) according to the user's settings. More...
 
bool useSystemProxy () const
 Returns whether the system proxy should be used. More...
 

Static Public Member Functions

static QNetworkRequest::CacheLoadControl cacheLoadControlFromName (const QString &name)
 Gets QNetworkRequest::CacheLoadControl from name. More...
 
static QString cacheLoadControlName (QNetworkRequest::CacheLoadControl control)
 Gets name for QNetworkRequest::CacheLoadControl. More...
 
static QgsNetworkAccessManagerinstance (Qt::ConnectionType connectionType=Qt::BlockingQueuedConnection)
 Returns a pointer to the active QgsNetworkAccessManager for the current thread. More...
 

Protected Member Functions

QNetworkReply * createRequest (QNetworkAccessManager::Operation op, const QNetworkRequest &req, QIODevice *outgoingData=nullptr) override
 

Detailed Description

network access manager for QGIS

This class implements the QGIS network access manager.

It's a singleton that can be used across QGIS.

Plugins can insert proxy factories and thereby redirect requests to individual proxies.

If no proxy factories are there or none returns a proxy for an URL a fallback proxy can be set. There's also a exclude list that defines URLs that the fallback proxy should not be used for, then no proxy will be used.

Since
1.5

Definition at line 47 of file qgsnetworkaccessmanager.h.

Constructor & Destructor Documentation

◆ QgsNetworkAccessManager()

QgsNetworkAccessManager::QgsNetworkAccessManager ( QObject *  parent = nullptr)

Definition at line 119 of file qgsnetworkaccessmanager.cpp.

Member Function Documentation

◆ cacheLoadControlFromName()

QNetworkRequest::CacheLoadControl QgsNetworkAccessManager::cacheLoadControlFromName ( const QString &  name)
static

Gets QNetworkRequest::CacheLoadControl from name.

Definition at line 263 of file qgsnetworkaccessmanager.cpp.

◆ cacheLoadControlName()

QString QgsNetworkAccessManager::cacheLoadControlName ( QNetworkRequest::CacheLoadControl  control)
static

Gets name for QNetworkRequest::CacheLoadControl.

Definition at line 245 of file qgsnetworkaccessmanager.cpp.

◆ createRequest()

QNetworkReply * QgsNetworkAccessManager::createRequest ( QNetworkAccessManager::Operation  op,
const QNetworkRequest &  req,
QIODevice *  outgoingData = nullptr 
)
overrideprotected

Definition at line 169 of file qgsnetworkaccessmanager.cpp.

◆ excludeList()

QStringList QgsNetworkAccessManager::excludeList ( ) const

retrieve exclude list (urls shouldn't use the fallback proxy)

Definition at line 140 of file qgsnetworkaccessmanager.cpp.

◆ fallbackProxy()

const QNetworkProxy & QgsNetworkAccessManager::fallbackProxy ( ) const

retrieve fall back proxy (for urls that no factory returned proxies for)

Definition at line 145 of file qgsnetworkaccessmanager.cpp.

◆ insertProxyFactory()

void QgsNetworkAccessManager::insertProxyFactory ( QNetworkProxyFactory *  factory)

insert a factory into the proxy factories list

Definition at line 125 of file qgsnetworkaccessmanager.cpp.

◆ instance()

QgsNetworkAccessManager * QgsNetworkAccessManager::instance ( Qt::ConnectionType  connectionType = Qt::BlockingQueuedConnection)
static

Returns a pointer to the active QgsNetworkAccessManager for the current thread.

With the connectionType parameter it is possible to setup the default connection type that is used to handle signals that might require user interaction and therefore need to be handled on the main thread. See in-depth discussion below.

Parameters
connectionTypeIn most cases the default of using a Qt::BlockingQueuedConnection is ok, to make a background thread wait for the main thread to answer such a request is fine and anything else is dangerous. However, in case the request was started on the main thread, one should execute a local event loop in a helper thread and freeze the main thread for the duration of the download. In this case, if an authentication request is sent from the background thread network access manager, the background thread should be blocked, the main thread be woken up, processEvents() executed once, the main thread frozen again and the background thread continued.

Definition at line 105 of file qgsnetworkaccessmanager.cpp.

◆ proxyFactories()

const QList< QNetworkProxyFactory * > QgsNetworkAccessManager::proxyFactories ( ) const

retrieve proxy factory list

Definition at line 135 of file qgsnetworkaccessmanager.cpp.

◆ removeProxyFactory()

void QgsNetworkAccessManager::removeProxyFactory ( QNetworkProxyFactory *  factory)

remove a factory from the proxy factories list

Definition at line 130 of file qgsnetworkaccessmanager.cpp.

◆ requestAboutToBeCreated

void QgsNetworkAccessManager::requestAboutToBeCreated ( QNetworkAccessManager::Operation  ,
const QNetworkRequest &  ,
QIODevice *   
)
signal

◆ requestCreated

void QgsNetworkAccessManager::requestCreated ( QNetworkReply *  )
signal

◆ requestTimedOut

void QgsNetworkAccessManager::requestTimedOut ( QNetworkReply *  )
signal

◆ setFallbackProxyAndExcludes()

void QgsNetworkAccessManager::setFallbackProxyAndExcludes ( const QNetworkProxy &  proxy,
const QStringList &  excludes 
)

Sets fallback proxy and URL that shouldn't use it.

Definition at line 150 of file qgsnetworkaccessmanager.cpp.

◆ setupDefaultProxyAndCache()

void QgsNetworkAccessManager::setupDefaultProxyAndCache ( Qt::ConnectionType  connectionType = Qt::BlockingQueuedConnection)

Setup the QgsNetworkAccessManager (NAM) according to the user's settings.

The connectionType sets up the default connection type that is used to handle signals that might require user interaction and therefore need to be handled on the main thread. See in-depth discussion in the documentation for the constructor of this class.

Definition at line 284 of file qgsnetworkaccessmanager.cpp.

◆ useSystemProxy()

bool QgsNetworkAccessManager::useSystemProxy ( ) const
inline

Returns whether the system proxy should be used.

Definition at line 109 of file qgsnetworkaccessmanager.h.


The documentation for this class was generated from the following files: