|
| 1 | +/************************************************************************ |
| 2 | + * This file has been generated automatically from * |
| 3 | + * * |
| 4 | + * src/core/qgsblockingnetworkrequest.h * |
| 5 | + * * |
| 6 | + * Do not edit manually ! Edit header and run scripts/sipify.pl again * |
| 7 | + ************************************************************************/ |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +class QgsBlockingNetworkRequest : QObject |
| 12 | +{ |
| 13 | +%Docstring |
| 14 | +A thread safe class for performing blocking (sync) network requests, with full support for QGIS proxy |
| 15 | +and authentication settings. |
| 16 | + |
| 17 | +This class should be used whenever a blocking network request is required. Unlike implementations |
| 18 | +which rely on QApplication.processEvents() or creation of a QEventLoop, this class is completely |
| 19 | +thread safe and can be used on either the main thread or background threads without issue. |
| 20 | + |
| 21 | +Redirects are automatically handled by the class. |
| 22 | + |
| 23 | +After completion of a request, the reply content should be retrieved by calling getReplyContent(). |
| 24 | +This method returns a QgsNetworkReplyContent container, which is safe and cheap to copy and pass |
| 25 | +between threads without issue. |
| 26 | + |
| 27 | +.. versionadded:: 3.6 |
| 28 | +%End |
| 29 | + |
| 30 | +%TypeHeaderCode |
| 31 | +#include "qgsblockingnetworkrequest.h" |
| 32 | +%End |
| 33 | + public: |
| 34 | + |
| 35 | + enum ErrorCode |
| 36 | + { |
| 37 | + NoError, |
| 38 | + NetworkError, |
| 39 | + TimeoutError, |
| 40 | + ServerExceptionError, |
| 41 | + }; |
| 42 | + |
| 43 | + explicit QgsBlockingNetworkRequest(); |
| 44 | +%Docstring |
| 45 | +Constructor for QgsBlockingNetworkRequest |
| 46 | +%End |
| 47 | + |
| 48 | + ~QgsBlockingNetworkRequest(); |
| 49 | + |
| 50 | + ErrorCode get( QNetworkRequest &request, bool forceRefresh = false, QgsFeedback *feedback = 0 ); |
| 51 | +%Docstring |
| 52 | +Performs a "get" operation on the specified ``request``. |
| 53 | + |
| 54 | +If ``forceRefresh`` is false then previously cached replies may be used for the request. If |
| 55 | +it is set to true then a new query is always performed. |
| 56 | + |
| 57 | +If an authCfg() has been set, then any authentication configuration required will automatically be applied to |
| 58 | +``request``. There is no need to manually apply the authentication to the request prior to calling |
| 59 | +this method. |
| 60 | + |
| 61 | +The optional ``feedback`` argument can be used to abort ongoing requests. |
| 62 | + |
| 63 | +The method will return NoError if the get operation was successful. The contents of the reply can be retrieved |
| 64 | +by calling reply(). |
| 65 | + |
| 66 | +If an error was encountered then a specific ErrorCode will be returned, and a detailed error message |
| 67 | +can be retrieved by calling errorMessage(). |
| 68 | + |
| 69 | +.. seealso:: :py:func:`post` |
| 70 | +%End |
| 71 | + |
| 72 | + ErrorCode post( QNetworkRequest &request, const QByteArray &data, bool forceRefresh = false, QgsFeedback *feedback = 0 ); |
| 73 | +%Docstring |
| 74 | +Performs a "post" operation on the specified ``request``, using the given ``data``. |
| 75 | + |
| 76 | +If ``forceRefresh`` is false then previously cached replies may be used for the request. If |
| 77 | +it is set to true then a new query is always performed. |
| 78 | + |
| 79 | +If an authCfg() has been set, then any authentication configuration required will automatically be applied to |
| 80 | +``request``. There is no need to manually apply the authentication to the request prior to calling |
| 81 | +this method. |
| 82 | + |
| 83 | +The optional ``feedback`` argument can be used to abort ongoing requests. |
| 84 | + |
| 85 | +The method will return NoError if the get operation was successful. The contents of the reply can be retrieved |
| 86 | +by calling reply(). |
| 87 | + |
| 88 | +If an error was encountered then a specific ErrorCode will be returned, and a detailed error message |
| 89 | +can be retrieved by calling errorMessage(). |
| 90 | + |
| 91 | +.. seealso:: :py:func:`get` |
| 92 | +%End |
| 93 | + |
| 94 | + QString errorMessage() const; |
| 95 | +%Docstring |
| 96 | +Returns the error message string, after a get() or post() request has been made.\ |
| 97 | +%End |
| 98 | + |
| 99 | + QgsNetworkReplyContent reply() const; |
| 100 | +%Docstring |
| 101 | +Returns the content of the network reply, after a get() or post() request has been made. |
| 102 | +%End |
| 103 | + |
| 104 | + QString authCfg() const; |
| 105 | +%Docstring |
| 106 | +Returns the authentication config id which will be used during the request. |
| 107 | + |
| 108 | +.. seealso:: :py:func:`setAuthCfg` |
| 109 | +%End |
| 110 | + |
| 111 | + void setAuthCfg( const QString &authCfg ); |
| 112 | +%Docstring |
| 113 | +Sets the authentication config id which should be used during the request. |
| 114 | + |
| 115 | +.. seealso:: :py:func:`authCfg` |
| 116 | +%End |
| 117 | + |
| 118 | + public slots: |
| 119 | + |
| 120 | + void abort(); |
| 121 | +%Docstring |
| 122 | +Aborts the network request immediately. |
| 123 | +%End |
| 124 | + |
| 125 | + signals: |
| 126 | + |
| 127 | + void downloadProgress( qint64, qint64 ); |
| 128 | +%Docstring |
| 129 | +Emitted when when data arrives during a request. |
| 130 | +%End |
| 131 | + |
| 132 | + void downloadFinished(); |
| 133 | +%Docstring |
| 134 | +Emitted once a request has finished downloading. |
| 135 | +%End |
| 136 | + |
| 137 | +}; |
| 138 | + |
| 139 | + |
| 140 | +/************************************************************************ |
| 141 | + * This file has been generated automatically from * |
| 142 | + * * |
| 143 | + * src/core/qgsblockingnetworkrequest.h * |
| 144 | + * * |
| 145 | + * Do not edit manually ! Edit header and run scripts/sipify.pl again * |
| 146 | + ************************************************************************/ |
0 commit comments