|
libfuoten 0.8.1
Qt based library to access the ownCloud/Nextcloud News App API
|
#include <Fuoten/API/ConvertToAppPassword>
Public Member Functions | |
| ConvertToAppPassword (QObject *parent=nullptr) | |
| ~ConvertToAppPassword () override | |
| Q_INVOKABLE void | execute () override |
| Public Member Functions inherited from Component | |
| Component (QObject *parent=nullptr) | |
| ~Component () override | |
| AbstractConfiguration * | configuration () const |
| Error * | error () const |
| bool | inOperation () const |
| bool | isUseStorageEnabled () const |
| AbstractNotificator * | notificator () const |
| quint16 | requestTimeout () const |
| void | setConfiguration (AbstractConfiguration *nAbstractConfiguration) |
| void | setNotificator (AbstractNotificator *notificator) |
| void | setRequestTimeout (quint16 seconds) |
| void | setStorage (AbstractStorage *localStorage) |
| void | setUseStorage (bool useStorage) |
| void | setWipeManager (WipeManager *wipeManager) |
| AbstractStorage * | storage () const |
| WipeManager * | wipeManager () const |
Protected Member Functions | |
| void | extractError (QNetworkReply *reply) override |
| void | successCallback () override |
| Protected Member Functions inherited from Component | |
| void | addRequestHeader (const QByteArray &headerName, const QByteArray &headerValue) |
| void | addRequestHeaders (const QHash< QByteArray, QByteArray > &headers) |
| virtual bool | checkInput () |
| virtual bool | checkOutput () |
| QJsonDocument | jsonResult () const |
| void | notify (AbstractNotificator::Type type, QtMsgType severity, const QVariant &data) const |
| void | notify (const Error *e) const |
| QHash< QByteArray, QByteArray > | requestHeaders () const |
| void | sendRequest () |
| void | setApiRoute (const QString &route) |
| void | setApiRoute (const QStringList &routeParts) |
| void | setError (Error *nError) |
| void | setExpectedJSONType (ExpectedJSONType type) |
| void | setInOperation (bool nInOperation) |
| void | setNetworkOperation (QNetworkAccessManager::Operation operation) |
| void | setPayload (const QByteArray &payload) |
| void | setPayload (const QJsonObject &payload) |
| void | setRequestHeaders (const QHash< QByteArray, QByteArray > &headers) |
| void | setRequiresAuth (bool reqAuth) |
| void | setUrlQuery (const QUrlQuery &query) |
Converts “normal“ passwords to application passwords.
Nextcloud’s OCS API supports the automatic upgrade from “normal“ passwords to application specific passwords. This class implements this API call. Running execute() will send a GET request to the /ocs/v2.php/core/getapppassword API endpoint with the currently configured username and password for authorization.
If a 403 HTTP status is returned, the current password is already an application password and Component::succeeded() will be emitted containing an empty QJsonDocument.
If a 200 HTTP status code is returned, the used password was not an application password and the response contains a newly generated application password that will be set to AbstractConfiguration::setPassword(). Also the Component::succeeded() signal will be emitted containing the returned JSON data.
If an error occured or the returned HTTP status is neither 200 or 403, Component::failed() will be emitted and Comonent::error() will contain information about the occured Error.
|
explicit |
Contructs a new ConvertToAppPassword object with the given parent.
|
override |
Destroys the ConvertToAppPassword object.
|
overridevirtual |
Executes the API request.
Implements Component.
|
overrideprotectedvirtual |
Extracts the error data from the API response.
If the API responded with a 403 HTTP status code, the used password is already an application password and all is fine and Component::succeeded() will be emitted with an empty QJsonDocument.
For all other errors Component::failed() will be emitted and Component::error() will contain the Error information.
Reimplemented from Component.
|
overrideprotectedvirtual |
Extracts the newly generated application password from the API response.
If the response contains a non-empty application password, it will be set to AbstractConfiguration::setPassword() and Component::succeeded() will be emitted, otherwise the error data from the response will be extracted and Component::failed() will be emitted while Component::error() will contain the Error information.
Implements Component.