mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-10-30 00:07:09 -04:00 
			
		
		
		
	by setting the timout to 0 This can be interesting to overcome the limitations of the timeout functionality by replacing it with QNetworkAccessManager::setTransferTimeout. E.g. to have more than 6 downloads running in parallel.
		
			
				
	
	
		
			475 lines
		
	
	
		
			16 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			475 lines
		
	
	
		
			16 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| /************************************************************************
 | |
|  * This file has been generated automatically from                      *
 | |
|  *                                                                      *
 | |
|  * src/core/qgsnetworkaccessmanager.h                                   *
 | |
|  *                                                                      *
 | |
|  * Do not edit manually ! Edit header and run scripts/sipify.pl again   *
 | |
|  ************************************************************************/
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| class QgsNetworkRequestParameters
 | |
| {
 | |
| %Docstring
 | |
| Encapsulates parameters and properties of a network request.
 | |
| 
 | |
| .. versionadded:: 3.6
 | |
| %End
 | |
| 
 | |
| %TypeHeaderCode
 | |
| #include "qgsnetworkaccessmanager.h"
 | |
| %End
 | |
|   public:
 | |
| 
 | |
|     enum RequestAttributes
 | |
|     {
 | |
|       AttributeInitiatorClass,
 | |
|       AttributeInitiatorRequestId,
 | |
|     };
 | |
| 
 | |
|     QgsNetworkRequestParameters();
 | |
| %Docstring
 | |
| Default constructor.
 | |
| %End
 | |
| 
 | |
|     QgsNetworkRequestParameters( QNetworkAccessManager::Operation operation,
 | |
|                                  const QNetworkRequest &request,
 | |
|                                  int requestId,
 | |
|                                  const QByteArray &content = QByteArray() );
 | |
| %Docstring
 | |
| Constructor for QgsNetworkRequestParameters, with the specified network
 | |
| ``operation`` and original ``request``.
 | |
| %End
 | |
| 
 | |
|     QNetworkAccessManager::Operation operation() const;
 | |
| %Docstring
 | |
| Returns the request operation, e.g. GET or POST.
 | |
| %End
 | |
| 
 | |
|     QNetworkRequest request() const;
 | |
| %Docstring
 | |
| Returns the network request.
 | |
| 
 | |
| This is the original network request sent to :py:class:`QgsNetworkAccessManager`, but with QGIS specific
 | |
| configuration options such as proxy handling and SSL exceptions applied.
 | |
| %End
 | |
| 
 | |
|     QString originatingThreadId() const;
 | |
| %Docstring
 | |
| Returns a string identifying the thread which the request originated from.
 | |
| %End
 | |
| 
 | |
|     int requestId() const;
 | |
| %Docstring
 | |
| Returns a unique ID identifying the request.
 | |
| %End
 | |
| 
 | |
|     QByteArray content() const;
 | |
| %Docstring
 | |
| Returns the request's content. This is only used for POST or PUT operation
 | |
| requests.
 | |
| %End
 | |
| 
 | |
|     QString initiatorClassName() const;
 | |
| %Docstring
 | |
| Returns the class name of the object which initiated this request.
 | |
| 
 | |
| This is only available for QNetworkRequests which have had the
 | |
| QgsNetworkRequestParameters.AttributeInitiatorClass attribute set.
 | |
| 
 | |
| .. seealso:: :py:func:`initiatorRequestId`
 | |
| %End
 | |
| 
 | |
|     QVariant initiatorRequestId() const;
 | |
| %Docstring
 | |
| Returns the internal ID used by the object which initiated this request to identify
 | |
| individual requests.
 | |
| 
 | |
| This is only available for QNetworkRequests which have had the
 | |
| QgsNetworkRequestParameters.AttributeInitiatorRequestId attribute set.
 | |
| 
 | |
| .. seealso:: :py:func:`initiatorClassName`
 | |
| %End
 | |
| 
 | |
| };
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| class QgsNetworkAccessManager : QNetworkAccessManager
 | |
| {
 | |
| %Docstring
 | |
| 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.
 | |
| 
 | |
| .. versionadded:: 1.5
 | |
| %End
 | |
| 
 | |
| %TypeHeaderCode
 | |
| #include "qgsnetworkaccessmanager.h"
 | |
| %End
 | |
|   public:
 | |
| 
 | |
|     static QgsNetworkAccessManager *instance( Qt::ConnectionType connectionType = Qt::BlockingQueuedConnection );
 | |
| %Docstring
 | |
| 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.
 | |
| 
 | |
| :param connectionType: In 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, :py:func:`~QgsNetworkAccessManager.processEvents` executed once, the main thread frozen again and the background thread
 | |
|                        continued.
 | |
| %End
 | |
| 
 | |
|     QgsNetworkAccessManager( QObject *parent = 0 );
 | |
| 
 | |
| 
 | |
|     void insertProxyFactory( QNetworkProxyFactory *factory /Transfer/ );
 | |
| %Docstring
 | |
| Inserts a ``factory`` into the proxy factories list.
 | |
| 
 | |
| Ownership of ``factory`` is transferred to the manager.
 | |
| 
 | |
| .. seealso:: :py:func:`removeProxyFactory`
 | |
| 
 | |
| .. seealso:: :py:func:`proxyFactories`
 | |
| %End
 | |
| 
 | |
|     void removeProxyFactory( QNetworkProxyFactory *factory /TransferBack/ );
 | |
| %Docstring
 | |
| Removes a ``factory`` from the proxy factories list.
 | |
| 
 | |
| .. seealso:: :py:func:`insertProxyFactory`
 | |
| 
 | |
| .. seealso:: :py:func:`proxyFactories`
 | |
| %End
 | |
| 
 | |
|     const QList<QNetworkProxyFactory *> proxyFactories() const;
 | |
| %Docstring
 | |
| Returns a list of proxy factories used by the manager.
 | |
| 
 | |
| .. seealso:: :py:func:`insertProxyFactory`
 | |
| 
 | |
| .. seealso:: :py:func:`proxyFactories`
 | |
| %End
 | |
| 
 | |
|     const QNetworkProxy &fallbackProxy() const;
 | |
| %Docstring
 | |
| Returns the fallback proxy used by the manager.
 | |
| 
 | |
| The fallback proxy is used for URLs which no other proxy factory returned proxies for.
 | |
| 
 | |
| .. seealso:: :py:func:`proxyFactories`
 | |
| 
 | |
| .. seealso:: :py:func:`setFallbackProxyAndExcludes`
 | |
| %End
 | |
| 
 | |
|     QStringList excludeList() const;
 | |
| %Docstring
 | |
| Returns the proxy exclude list.
 | |
| 
 | |
| This list consists of the beginning of URL strings which will not use the fallback proxy.
 | |
| 
 | |
| .. seealso:: :py:func:`noProxyList`
 | |
| 
 | |
| .. seealso:: :py:func:`fallbackProxy`
 | |
| 
 | |
| .. seealso:: :py:func:`setFallbackProxyAndExcludes`
 | |
| %End
 | |
| 
 | |
|     QStringList noProxyList() const;
 | |
| %Docstring
 | |
| Returns the no proxy list.
 | |
| 
 | |
| This list consists of the beginning of URL strings which will not use any proxy at all
 | |
| 
 | |
| .. seealso:: :py:func:`excludeList`
 | |
| 
 | |
| .. seealso:: :py:func:`fallbackProxy`
 | |
| 
 | |
| .. seealso:: :py:func:`setFallbackProxyAndExcludes`
 | |
| %End
 | |
| 
 | |
|     void setFallbackProxyAndExcludes( const QNetworkProxy &proxy, const QStringList &excludes, const QStringList &noProxyURLs );
 | |
| %Docstring
 | |
| Sets the fallback ``proxy`` and URLs which shouldn't use it.
 | |
| 
 | |
| The fallback proxy is used for URLs which no other proxy factory returned proxies for.
 | |
| The ``excludes`` list specifies the beginning of URL strings which will not use this fallback proxy.
 | |
| The ``noProxyURLs`` list specifies the beginning of URL strings which will not use any proxy at all
 | |
| 
 | |
| .. seealso:: :py:func:`fallbackProxy`
 | |
| 
 | |
| .. seealso:: :py:func:`excludeList`
 | |
| 
 | |
| .. seealso:: :py:func:`noProxyList`
 | |
| %End
 | |
| 
 | |
|     static QString cacheLoadControlName( QNetworkRequest::CacheLoadControl control );
 | |
| %Docstring
 | |
| Returns the name for QNetworkRequest.CacheLoadControl.
 | |
| 
 | |
| .. seealso:: :py:func:`cacheLoadControlFromName`
 | |
| %End
 | |
| 
 | |
|     static QNetworkRequest::CacheLoadControl cacheLoadControlFromName( const QString &name );
 | |
| %Docstring
 | |
| Returns QNetworkRequest.CacheLoadControl from a ``name``.
 | |
| 
 | |
| .. seealso:: :py:func:`cacheLoadControlName`
 | |
| %End
 | |
| 
 | |
|     void setupDefaultProxyAndCache( Qt::ConnectionType connectionType = Qt::BlockingQueuedConnection );
 | |
| %Docstring
 | |
| 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.
 | |
| %End
 | |
| 
 | |
|     bool useSystemProxy() const;
 | |
| %Docstring
 | |
| Returns whether the system proxy should be used.
 | |
| %End
 | |
| 
 | |
|     static int timeout();
 | |
| %Docstring
 | |
| Returns the network timeout length, in milliseconds.
 | |
| 
 | |
| .. seealso:: :py:func:`setTimeout`
 | |
| 
 | |
| .. versionadded:: 3.6
 | |
| %End
 | |
| 
 | |
|     static void setTimeout( int time );
 | |
| %Docstring
 | |
| Sets the maximum timeout ``time`` for network requests, in milliseconds.
 | |
| If set to 0, no timeout is set.
 | |
| 
 | |
| .. seealso:: :py:func:`timeout`
 | |
| 
 | |
| .. versionadded:: 3.6
 | |
| %End
 | |
| 
 | |
|     static QgsNetworkReplyContent blockingGet( QNetworkRequest &request, const QString &authCfg = QString(), bool forceRefresh = false, QgsFeedback *feedback = 0 );
 | |
| %Docstring
 | |
| Posts a GET request to obtain the contents of the target request and returns a new QgsNetworkReplyContent object for reading.
 | |
| The current thread will be blocked until the request is returned.
 | |
| 
 | |
| This method is safe to call in either the main thread or a worker thread.
 | |
| 
 | |
| If ``forceRefresh`` is ``False`` then previously cached replies may be used for the request. If
 | |
| it is set to ``True`` then a new query is always performed.
 | |
| 
 | |
| If an ``authCfg`` has been specified, then that authentication configuration required will automatically be applied to
 | |
| ``request``. There is no need to manually apply the authentication to the request prior to calling
 | |
| this method.
 | |
| 
 | |
| The optional ``feedback`` argument can be used to abort ongoing requests.
 | |
| 
 | |
| The contents of the reply will be returned after the request is completed or an error occurs.
 | |
| 
 | |
| .. seealso:: :py:func:`blockingPost`
 | |
| 
 | |
| .. versionadded:: 3.6
 | |
| %End
 | |
| 
 | |
|     static QgsNetworkReplyContent blockingPost( QNetworkRequest &request, const QByteArray &data, const QString &authCfg = QString(), bool forceRefresh = false, QgsFeedback *feedback = 0 );
 | |
| %Docstring
 | |
| Posts a POST request to obtain the contents of the target ``request``, using the given ``data``, and returns a new
 | |
| QgsNetworkReplyContent object for reading. The current thread will be blocked until the request is returned.
 | |
| 
 | |
| This method is safe to call in either the main thread or a worker thread.
 | |
| 
 | |
| If ``forceRefresh`` is ``False`` then previously cached replies may be used for the request. If
 | |
| it is set to ``True`` then a new query is always performed.
 | |
| 
 | |
| If an ``authCfg`` has been specified, then that authentication configuration required will automatically be applied to
 | |
| ``request``. There is no need to manually apply the authentication to the request prior to calling
 | |
| this method.
 | |
| 
 | |
| The optional ``feedback`` argument can be used to abort ongoing requests.
 | |
| 
 | |
| The contents of the reply will be returned after the request is completed or an error occurs.
 | |
| 
 | |
| .. seealso:: :py:func:`blockingGet`
 | |
| 
 | |
| .. versionadded:: 3.6
 | |
| %End
 | |
| 
 | |
|   signals:
 | |
| 
 | |
|  void requestAboutToBeCreated( QNetworkAccessManager::Operation, const QNetworkRequest &, QIODevice * ) /Deprecated/;
 | |
| %Docstring
 | |
| 
 | |
| .. deprecated::
 | |
|    Use the thread-safe requestAboutToBeCreated( QgsNetworkRequestParameters ) signal instead.
 | |
| %End
 | |
| 
 | |
|     void requestAboutToBeCreated( QgsNetworkRequestParameters request );
 | |
| %Docstring
 | |
| Emitted when a network request is about to be created.
 | |
| 
 | |
| This signal is propagated to the main thread QgsNetworkAccessManager instance, so it is necessary
 | |
| only to connect to the main thread's signal in order to receive notifications about requests
 | |
| created in any thread.
 | |
| 
 | |
| .. seealso:: :py:func:`finished`
 | |
| 
 | |
| .. seealso:: :py:func:`requestTimedOut`
 | |
| 
 | |
| .. versionadded:: 3.6
 | |
| %End
 | |
| 
 | |
|     void finished( QgsNetworkReplyContent reply );
 | |
| %Docstring
 | |
| Emitted whenever a pending network reply is finished.
 | |
| 
 | |
| The ``reply`` parameter will contain a QgsNetworkReplyContent object, containing all the useful
 | |
| information relating to the reply, including headers and reply content.
 | |
| 
 | |
| This signal is propagated to the main thread QgsNetworkAccessManager instance, so it is necessary
 | |
| only to connect to the main thread's signal in order to receive notifications about requests
 | |
| created in any thread.
 | |
| 
 | |
| .. seealso:: :py:func:`requestAboutToBeCreated`
 | |
| 
 | |
| .. seealso:: :py:func:`requestTimedOut`
 | |
| 
 | |
| .. versionadded:: 3.6
 | |
| %End
 | |
| 
 | |
|     void requestTimedOut( QgsNetworkRequestParameters request );
 | |
| %Docstring
 | |
| Emitted when a network request has timed out.
 | |
| 
 | |
| This signal is propagated to the main thread QgsNetworkAccessManager instance, so it is necessary
 | |
| only to connect to the main thread's signal in order to receive notifications about requests
 | |
| created in any thread.
 | |
| 
 | |
| .. seealso:: :py:func:`requestAboutToBeCreated`
 | |
| 
 | |
| .. seealso:: :py:func:`finished`
 | |
| 
 | |
| .. versionadded:: 3.6
 | |
| %End
 | |
| 
 | |
|     void downloadProgress( int requestId, qint64 bytesReceived, qint64 bytesTotal );
 | |
| %Docstring
 | |
| Emitted when a network reply receives a progress report.
 | |
| 
 | |
| The ``requestId`` argument reflects the unique ID identifying the original request which the progress report relates to.
 | |
| 
 | |
| The ``bytesReceived`` parameter indicates the number of bytes received, while ``bytesTotal`` indicates the total number
 | |
| of bytes expected to be downloaded. If the number of bytes to be downloaded is not known, ``bytesTotal`` will be -1.
 | |
| 
 | |
| This signal is propagated to the main thread QgsNetworkAccessManager instance, so it is necessary
 | |
| only to connect to the main thread's signal in order to receive notifications about requests
 | |
| created in any thread.
 | |
| 
 | |
| .. versionadded:: 3.6
 | |
| %End
 | |
| 
 | |
|     void requestRequiresAuth( int requestId, const QString &realm );
 | |
| %Docstring
 | |
| Emitted when a network request prompts an authentication request.
 | |
| 
 | |
| The ``requestId`` argument reflects the unique ID identifying the original request which the authentication relates to.
 | |
| 
 | |
| This signal is propagated to the main thread QgsNetworkAccessManager instance, so it is necessary
 | |
| only to connect to the main thread's signal in order to receive notifications about authentication requests
 | |
| from any thread.
 | |
| 
 | |
| This signal is for debugging and logging purposes only, and cannot be used to respond to the
 | |
| requests. See QgsNetworkAuthenticationHandler for details on how to handle authentication requests.
 | |
| 
 | |
| .. seealso:: :py:func:`requestAuthDetailsAdded`
 | |
| 
 | |
| .. versionadded:: 3.6
 | |
| %End
 | |
| 
 | |
|     void requestAuthDetailsAdded( int requestId, const QString &realm, const QString &user, const QString &password );
 | |
| %Docstring
 | |
| Emitted when network authentication details have been added to a request.
 | |
| 
 | |
| The ``requestId`` argument reflects the unique ID identifying the original request which the authentication relates to.
 | |
| 
 | |
| This signal is always sent from the main thread QgsNetworkAccessManager instance, so it is necessary
 | |
| only to connect to the main thread's signal in order to receive notifications about authentication requests
 | |
| from any thread.
 | |
| 
 | |
| This signal is for debugging and logging purposes only, and should not be used to respond to the
 | |
| requests. See QgsNetworkAuthenticationHandler for details on how to handle authentication requests.
 | |
| 
 | |
| .. seealso:: :py:func:`requestRequiresAuth`
 | |
| 
 | |
| .. versionadded:: 3.6
 | |
| %End
 | |
| 
 | |
| 
 | |
|     void requestEncounteredSslErrors( int requestId, const QList<QSslError> &errors );
 | |
| %Docstring
 | |
| Emitted when a network request encounters SSL ``errors``.
 | |
| 
 | |
| The ``requestId`` argument reflects the unique ID identifying the original request which the SSL error relates to.
 | |
| 
 | |
| This signal is propagated to the main thread QgsNetworkAccessManager instance, so it is necessary
 | |
| only to connect to the main thread's signal in order to receive notifications about SSL errors
 | |
| from any thread.
 | |
| 
 | |
| This signal is for debugging and logging purposes only, and cannot be used to respond to the errors.
 | |
| See QgsSslErrorHandler for details on how to handle SSL errors and potentially ignore them.
 | |
| 
 | |
| .. versionadded:: 3.6
 | |
| %End
 | |
| 
 | |
| 
 | |
| 
 | |
|  void requestCreated( QNetworkReply * ) /Deprecated/;
 | |
| %Docstring
 | |
| 
 | |
| .. deprecated::
 | |
|    Use the thread-safe requestAboutToBeCreated( QgsNetworkRequestParameters ) signal instead.
 | |
| %End
 | |
| 
 | |
|     void requestTimedOut( QNetworkReply * );
 | |
| 
 | |
| 
 | |
| 
 | |
|   protected:
 | |
|     virtual QNetworkReply *createRequest( QNetworkAccessManager::Operation op, const QNetworkRequest &req, QIODevice *outgoingData = 0 );
 | |
| 
 | |
| 
 | |
| };
 | |
| 
 | |
| /************************************************************************
 | |
|  * This file has been generated automatically from                      *
 | |
|  *                                                                      *
 | |
|  * src/core/qgsnetworkaccessmanager.h                                   *
 | |
|  *                                                                      *
 | |
|  * Do not edit manually ! Edit header and run scripts/sipify.pl again   *
 | |
|  ************************************************************************/
 |