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

#include <Fuoten/API/CreateFolder>

Inheritance diagram for CreateFolder:
Component

Properties

QString name
Properties inherited from Component
Fuoten::AbstractConfigurationconfiguration
Fuoten::Errorerror
bool inOperation
Fuoten::AbstractNotificatornotificator
quint16 requestTimeout
Fuoten::AbstractStoragestorage
bool useStorage
Fuoten::WipeManagerwipeManager

Public Member Functions

 CreateFolder (QObject *parent=nullptr)
 ~CreateFolder () override
Q_INVOKABLE void execute () override
QString name () const
void setName (const QString &nName)
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

Signals

void nameChanged (const QString &name)
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)

Protected Member Functions

bool checkInput () override
bool checkOutput () override
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)
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 }
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

Creates a new folder on the News App server.

To create a new folder, set the CreateFolder::name property to a valid string and set the Component::configuration to a valid object. Optionally set the Component::storage property to save the newly created folder in a local storage. After setting the mandatory properties, call execute() to perform the API request.

If a valid AbstractStorage object is set to the Component::storage property, AbstractStorage::folderCreated() will be called in the successCallback() to save the new folder in the local storage. If the request succeeded, the Component::succeeded() signal will be emitted, containing the JSON API reply. If something failed, the Component::failed() signal will be emitted and Component::error will contain a valid pointer to an Error object.

Mandatory properties
CreateFolder::name, Component::configuration
API route
/folders
Method
POST

Property Documentation

◆ name

QString name
readwrite

The name for the new folder.

When setting this property, the input string will be simplified. See QString::simplified().

This property can not be changed while Component::inOperation() returns true.

Access functions:
QStringname() const
voidsetName(const QString &nName)
Notifier signal:
voidnameChanged(const QString &name)

Constructor & Destructor Documentation

◆ CreateFolder()

CreateFolder ( QObject * parent = nullptr)
explicit

Constructs an API request object with the given parent to create a new folder on the remote server.

◆ ~CreateFolder()

~CreateFolder ( )
override

Destroys the CreateFolder object.

Member Function Documentation

◆ checkInput()

bool checkInput ( )
overrideprotectedvirtual

Checks for valid name property.

Will at first perform the checks of Component::checkInput(). Returns true if the checks pass, otherwise false.

Reimplemented from Component.

◆ checkOutput()

bool checkOutput ( )
overrideprotectedvirtual

Checks for a non-empty folders array in the replied JSON object.

Will at first perform the checks fo Component::checkOutput(). Returns true if the checks pass, otherwise false.

Reimplemented from Component.

◆ execute()

void execute ( )
overridevirtual

Executes the API request.

To perform a successful API request, CreateFolder::name has to be valid and there has to be a AbstractConfiguration object set to Component::configuration.

Execution will not run if Component::inOperation returns true and will itself set that property to true when start to perform the request.

Implements Component.

◆ extractError()

void extractError ( QNetworkReply * reply)
overrideprotectedvirtual

Extracts possible errors replied by the News App API.

Reimplemented from Component.

◆ name()

QString name ( ) const

Returns the name of the folder to create.

See also
name

◆ nameChanged

void nameChanged ( const QString & name)
signal

This signal is emitted when the name of the folder to create changes.

See also
name

◆ setName()

void setName ( const QString & nName)

Sets the name of the folder to create.

See also
name

◆ successCallback()

void successCallback ( )
overrideprotectedvirtual

Finishes the folder creation if the request was successful.

If Component::storage points to a valid object, it will use AbstractStorage::folderCreated() to store the created folder. Afterwards it will set Component::inOperation to false and will emit the Component::succeeded() signal.

Implements Component.