1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/network/qgsnetworkcontentfetchertask.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class QgsNetworkContentFetcherTask : QgsTask
{
%Docstring(signature="appended")
Handles HTTP network content fetching in a background task.
Provides a simple method for fetching remote HTTP content in a
:py:class:`QgsTask`. Url redirects are automatically handled.
After constructing a :py:class:`QgsNetworkContentFetcherTask`, callers
should connect to the :py:class:`QgsNetworkContentFetcherTask`.fetched
signal. They can then safely access the network :py:func:`~reply` from
the connected slot without danger of the task being first removed by the
:py:class:`QgsTaskManager`.
.. seealso:: :py:class:`QgsNetworkContentFetcher`
.. versionadded:: 3.2
%End
%TypeHeaderCode
#include "qgsnetworkcontentfetchertask.h"
%End
public:
QgsNetworkContentFetcherTask( const QUrl &url, const QString &authcfg = QString(), QgsTask::Flags flags = QgsTask::CanCancel,
const QString &description = QString() );
%Docstring
Constructor for a QgsNetworkContentFetcherTask which fetches the
specified ``url``.
Optionally, authentication configuration can be set via the ``authcfg``
argument.
Since QGIS 3.28 the optional ``description`` can be explicitly set. If
not specified, a default task description will be generated.
%End
QgsNetworkContentFetcherTask( const QNetworkRequest &request, const QString &authcfg = QString(), QgsTask::Flags flags = QgsTask::CanCancel,
const QString &description = QString() );
%Docstring
Constructor for a QgsNetworkContentFetcherTask which fetches the
specified network ``request``.
Optionally, authentication configuration can be set via the ``authcfg``
argument.
Since QGIS 3.28 the optional ``description`` can be explicitly set. If
not specified, a default task description will be generated.
%End
~QgsNetworkContentFetcherTask();
virtual bool run();
virtual void cancel();
QNetworkReply *reply();
%Docstring
Returns the network reply. Ownership is not transferred.
May return ``None`` if the request has not yet completed.
.. warning::
This should only be accessed from a slot connected directly to
the :py:func:`QgsNetworkContentFetcherTask.fetched()` signal.
%End
QString contentDispositionFilename() const;
%Docstring
Returns the associated filename from the reply's content disposition
header, if present.
.. versionadded:: 3.28
%End
QString contentAsString() const;
%Docstring
Returns the fetched content as a string
.. warning::
This should only be accessed from a slot connected directly to
the :py:func:`QgsNetworkContentFetcherTask.fetched()` signal.
.. versionadded:: 3.10
%End
signals:
void fetched();
%Docstring
Emitted when the network content has been fetched, regardless of whether
the fetch was successful or not.
Users of QgsNetworkContentFetcherTask should connect to this signal, and
from the associated slot they can then safely access the network
:py:func:`~QgsNetworkContentFetcherTask.reply` without danger of the
task being first removed by the :py:class:`QgsTaskManager`.
%End
void errorOccurred( QNetworkReply::NetworkError code, const QString &errorMsg );
%Docstring
Emitted when an error with ``code`` error occurred while processing the
request ``errorMsg`` is a textual description of the error
.. versionadded:: 3.22
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/network/qgsnetworkcontentfetchertask.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
|