libfuoten 0.8.1
Qt based library to access the ownCloud/Nextcloud News App API
Loading...
Searching...
No Matches
ConvertToAppPassword Class Reference

#include <Fuoten/API/ConvertToAppPassword>

Inheritance diagram for ConvertToAppPassword:
Component

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
AbstractConfigurationconfiguration () const
Errorerror () const
bool inOperation () const
bool isUseStorageEnabled () const
AbstractNotificatornotificator () 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)
AbstractStoragestorage () const
WipeManagerwipeManager () 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)

Additional Inherited Members

Public Types inherited from Component
enum  ExpectedJSONType : quint8 { Empty = 0 , Array = 1 , Object = 2 }
Properties inherited from Component
Fuoten::AbstractConfigurationconfiguration
Fuoten::Errorerror
bool inOperation
Fuoten::AbstractNotificatornotificator
quint16 requestTimeout
Fuoten::AbstractStoragestorage
bool useStorage
Fuoten::WipeManagerwipeManager
Signals inherited from Component
void configurationChanged (Fuoten::AbstractConfiguration *configuration)
void errorChanged (Fuoten::Error *error)
void failed (Fuoten::Error *error)
void inOperationChanged (bool inOperation)
void notificatorChanged (Fuoten::AbstractNotificator *notificator)
void requestTimeoutChanged (quint16 requestTimeout)
void sslErrors (QNetworkReply *reply, const QList< QSslError > &errors)
void storageChanged (Fuoten::AbstractStorage *storage)
void succeeded (const QJsonDocument &result)
void useStorageChanged (bool useStorage)
void wipeManagerChanged (Fuoten::WipeManager *wipeManager)
Static Public Member Functions inherited from Component
static AbstractConfigurationdefaultConfiguration ()
static AbstractNotificatordefaultNotificator ()
static AbstractStoragedefaultStorage ()
static WipeManagerdefaultWipeManager ()
static AbstractNamFactorynetworkAccessManagerFactory ()
static void setDefaultConfiguration (AbstractConfiguration *config)
static void setDefaultNotificator (AbstractNotificator *notificator)
static void setDefaultStorage (AbstractStorage *storage)
static void setDefaultWipeManager (WipeManager *wipeManager)
static void setNetworkAccessManagerFactory (AbstractNamFactory *factory)

Detailed Description

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.

Note
This API call will use AbstractConfiguration::getLoginFlowUserAgent() to set the User-Agent header of the request to generate a user friendly application name user agent that will be shown in the configuration backend of the Nextcloud.
Since
0.8.0
Mandatory properties
Component::configuration
API route
Not part of the News App API, uses general Nextcloud OCS API at /ocs/v2.php/core/getapppassword
Method
GET

Constructor & Destructor Documentation

◆ ConvertToAppPassword()

ConvertToAppPassword ( QObject * parent = nullptr)
explicit

Contructs a new ConvertToAppPassword object with the given parent.

◆ ~ConvertToAppPassword()

~ConvertToAppPassword ( )
override

Destroys the ConvertToAppPassword object.

Member Function Documentation

◆ execute()

void execute ( )
overridevirtual

Executes the API request.

Implements Component.

◆ extractError()

void extractError ( QNetworkReply * reply)
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.

◆ successCallback()

void successCallback ( )
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.