libfuoten 0.8.2
Qt based library to access the Nextcloud News App API.
Loading...
Searching...
No Matches
Fuoten::Component Class Referenceabstract

Base class for all API requests. More...

#include <Fuoten/API/Component>

Inheritance diagram for Fuoten::Component:
QObject Fuoten::ConvertToAppPassword Fuoten::CreateFeed Fuoten::CreateFolder Fuoten::DeleteAppPassword Fuoten::DeleteFeed Fuoten::DeleteFolder Fuoten::GetFeeds Fuoten::GetFolders Fuoten::GetItems Fuoten::GetServerStatus Fuoten::GetStatus Fuoten::GetUpdatedItems Fuoten::GetUser Fuoten::GetVersion Fuoten::GetWipeStatus Fuoten::LoginFlowV2 Fuoten::MarkAllItemsRead Fuoten::MarkFeedRead Fuoten::MarkFolderRead Fuoten::MarkItem Fuoten::MarkMultipleItems Fuoten::MoveFeed Fuoten::PostWipeSuccess Fuoten::RenameFeed Fuoten::RenameFolder Fuoten::StarItem Fuoten::StarMultipleItems

Public Types

enum  ExpectedJSONType : quint8 { Empty = 0 , Array = 1 , Object = 2 }
 Defines the expected JSON type. More...

Properties

Fuoten::AbstractConfigurationconfiguration
 Pointer to an AbstractConfiguration derived object.
Fuoten::Errorerror
 Pointer to an error object, if any error occurred.
bool inOperation
 Returns true while the request is in operation.
Fuoten::AbstractNotificatornotificator
 Pointer to an object derived from AbstractNotificator.
quint16 requestTimeout
 Timeout in seconds for network requests.
Fuoten::AbstractStoragestorage
 Pointer to an AbstractStorage derived object.
bool useStorage
 If true (the default), a local storage should be used in the successCallback() function to further process the request results.
Fuoten::WipeManagerwipeManager
 Pointer to a WipeManager to handle remote wipe requests.

Public Member Functions

 Component (QObject *parent=nullptr)
 Constructs a component with the given parent.
 ~Component () override
 Destroys the Component object.
AbstractConfigurationconfiguration () const
 Returns a pointer to the AbstractConfiguration that is currently set.
Errorerror () const
 Returns a pointer to an Error object, if any error occurred.
virtual Q_INVOKABLE void execute ()=0
 Executes the API request.
bool inOperation () const
 Returns true while the API request is running.
bool isUseStorageEnabled () const
 Getter function for the useStorage property.
AbstractNotificatornotificator () const
 Getter function for the notificator property.
quint16 requestTimeout () const
 Returns the currently set request timeout.
void setConfiguration (AbstractConfiguration *nAbstractConfiguration)
 Sets a pointer to a AbstractConfiguration to use for the API request.
void setNotificator (AbstractNotificator *notificator)
 Setter function for the notificator property.
void setRequestTimeout (quint16 seconds)
 Sets the timeout for the API request in seconds.
void setStorage (AbstractStorage *localStorage)
 Setter function for the storage property.
void setUseStorage (bool useStorage)
 Setter function for the useStorage property.
void setWipeManager (WipeManager *wipeManager)
 Setter function for the wipeManager property.
AbstractStoragestorage () const
 Getter function for the storage property.
WipeManagerwipeManager () const
 Getter function for the wipeManager property.

Signals

void configurationChanged (Fuoten::AbstractConfiguration *configuration)
 This signal is emitted when the pointer to the AbstractConfiguration object changes.
void errorChanged (Fuoten::Error *error)
 This signal is emitted when the pointer to the Error object changes. error will be a nullptr if no error occurred or the current error has been reset.
void failed (Fuoten::Error *error)
 Emit this signal in a subclass when the request failed for some reason.
void inOperationChanged (bool inOperation)
 This signal is emitted when the in operation status changes.
void notificatorChanged (Fuoten::AbstractNotificator *notificator)
 Notifier signal for the notificator property.
void requestTimeoutChanged (quint16 requestTimeout)
 This signal is emitte when the timeout for the request changes.
void sslErrors (QNetworkReply *reply, const QList< QSslError > &errors)
 This signal is emitted if the SSL/TLS session encountered errors during the set up.
void storageChanged (Fuoten::AbstractStorage *storage)
 Notifier signal for the storage property.
void succeeded (const QJsonDocument &result)
 Emit this signal in a subclass when the request was successful.
void useStorageChanged (bool useStorage)
 Notifier signal for the useStorage property.
void wipeManagerChanged (Fuoten::WipeManager *wipeManager)
 Notifier signal for the wipeManager property.

Static Public Member Functions

static AbstractConfigurationdefaultConfiguration ()
 Returns the global default configuration.
static QNetworkAccessManagerdefaultNam ()
 Returns the global network access manager.
static AbstractNotificatordefaultNotificator ()
 Returns the global default notificator.
static AbstractStoragedefaultStorage ()
 Returns the global default storage.
static WipeManagerdefaultWipeManager ()
 Returns the global default wipe manager.
static AbstractNamFactorynetworkAccessManagerFactory ()
 Returns the currently set network access manager factory.
static void setDefaultConfiguration (AbstractConfiguration *config)
 Sets the global default configuration.
static void setDefaultNam (QNetworkAccessManager *nam)
 Sets the global default network access manager.
static void setDefaultNotificator (AbstractNotificator *notificator)
 Sets the global default notificator.
static void setDefaultStorage (AbstractStorage *storage)
 Sets the global default storage.
static void setDefaultWipeManager (WipeManager *wipeManager)
 Sets the global default wipe manager.
static void setNetworkAccessManagerFactory (AbstractNamFactory *factory)
 Sets the network access manager factory. The factory will be used to create QNetworkAccessManager objects on demand. If no factory is set, a default QNetworkAccessManager object will be created. The Component class will take ownership of the created QNetworkAccessManager.

Protected Member Functions

void addRequestHeader (const QByteArray &headerName, const QByteArray &headerValue)
 Adds a header to the HTTP request.
void addRequestHeaders (const QHash< QByteArray, QByteArray > &headers)
 Adds headers to the HTTP request.
virtual bool checkInput ()
 Performs basic input checks.
virtual bool checkOutput ()
 Performs basic output checks.
virtual void extractError (QNetworkReply *reply)
 Extracts error data from the network reply.
QJsonDocument jsonResult () const
 Returns the JSON result document.
void notify (AbstractNotificator::Type type, QtMsgType severity, const QVariant &data) const
 Checks if a notificator has been set and will use it to notify the user.
void notify (const Error *e) const
 Checks if a notificator has been set and will use it to notify about an occured error.
QHash< QByteArray, QByteArrayrequestHeaders () const
 Returns the currently set HTTP headers for the request.
void sendRequest ()
 Sends the request to the server.
void setApiRoute (const QString &route)
 Sets the API route.
void setApiRoute (const QStringList &routeParts)
 Sets the API route constructed from a route part list.
void setError (Error *nError)
 Sets the pointer of the error property.
void setExpectedJSONType (ExpectedJSONType type)
 Sets the expected JSON type for initial output check.
void setInOperation (bool nInOperation)
 Sets the value of the inOperation property.
void setNetworkOperation (QNetworkAccessManager::Operation operation)
 Sets the operation the network manager should perform for this call.
void setPayload (const QByteArray &payload)
 Sets the payload for the request.
void setPayload (const QJsonObject &payload)
 Sets the payload for the request.
void setRequestHeaders (const QHash< QByteArray, QByteArray > &headers)
 Sets the headers to use for the HTTP request.
void setRequiresAuth (bool reqAuth)
 Set this to true if the request requires authentication.
void setUrlQuery (const QUrlQuery &query)
 Sets the URL query for the request.
virtual void successCallback ()=0
 Processes the request data if the request was successful.

Detailed Description

Base class for all API requests.

This is the base class for all other classes that implement API operations. Most important property to set when using this class or derived classes is the configuration property. This can either be done per instance direclty via the property or on a global scope via setDefaultConfiguration(). The storage property can be set on a global scope via setDefaultStorage(). Pointers to configuration and storage that are set directly to an instance of a Component subclass via the property setter functions setStorage() and setConfiguration() will take precedence over the default ones.

To modify the QNetworkAccessManager that will be used to perform the network requests, create a subclass of AbstractNamFactory and set it via Component::setNetworkAccessManagerFactory(). This will than be used to create new QNetworkAccessManager instances on the fly that will be children of the Component object.

When creating a subclass of Component, you have to reimplement successCallback(), extractError() and checkOutput(). Optionally you should reimplement checkInput() if your derived class provides own input properties that should be checked before starting the network request.

When reimplementing checkOutput() and checkInput() you have to call the implementations of the class from which you derive to also include their checks and perform some basic operations. In the function that starts the request, set setInOperation() to true and call sendRequest(). In your error handling and successCallback() functions you should afterwards set inOpeartion back to false.

In your reimplementation of successCallback() you should work on the content requested from the News App API that can be obtained by jsonResult(). The content returned by jsonResult() will be set by Component::checkOutput().

In the constructor of your class you should set the API route to use and the expected result, that will be checked by Component::checkOutput().

Component and its subclasses in libfuoten using a shared D-pointer.

Subclassing exmaple
#include <Fuoten/component.h>
#include <Fuoten/error.h>
class MyClass : public Fuoten::Component
{
public:
MyClass(QObject *parent = nullptr);
void get();
protected:
void successCallback() override;
void extractError(QNetworkReply *reply) override;
bool checkOutput() override;
private:
Q_DISABLE_COPY(MyClass)
};
MyClass::MyClass(QObject *parent) : Fuoten::Component(parent)
{
setApiRoute(QStringLiteral("/route"));
setExpectedJSONType(Component::Object);
};
void MyClass::execute()
{
if (inOperation()) {
return;
}
setInOperation(true);
sendRequest();
}
void MyClass::successCallback()
{
const QJsonDocument r = jsonResult();
// operate on the result
// or use a reimplementation of AbstractStorage
setInOperation(false);
emit succeeded(r);
}
void MyClass::extractError(QNetworkReply *reply)
{
setError(new Fuoten::Error(reply, this));
emit failed(error());
}
bool MyClass::checkOutput()
{
const QJsonObject o = jsonResult().object();
if (!o.contains(QStringLiteral("my_important_value"))) {
setError(new Fuoten::Error(Fuoten::Error::OutputError, Fuoten::Error::Critical, tr("Can not find that really important value in the server reply."), QString(), this));
emit failed(error());
return false;
} else {
return true;
}
} else {
return false;
}
}
Base class for all API requests.
Definition component.h:157
@ Object
Definition component.h:299
virtual void successCallback()=0
Processes the request data if the request was successful.
virtual void extractError(QNetworkReply *reply)
Extracts error data from the network reply.
Definition component.cpp:473
virtual bool checkOutput()
Performs basic output checks.
Definition component.cpp:540
Provides information about occurred errors.
Definition error.h:27
@ Critical
Definition error.h:89
@ OutputError
Definition error.h:74
bool contains(const QString &key) const const
QObject(QObject *parent)
Q_DISABLE_COPY(Class)
Q_OBJECTQ_OBJECT
QObject * parent() const const

Member Enumeration Documentation

◆ ExpectedJSONType

Defines the expected JSON type.

Enumerator
Empty 

Expects an empty body in the reply.

Array 

Expects a JSON array in the reply body.

Object 

Expects a JSON object in the reply body.

Property Documentation

◆ configuration

Fuoten::AbstractConfiguration * Fuoten::Component::configuration
readwrite

Pointer to an AbstractConfiguration derived object.

It is mandatory for all calls to set this property to a valid object that provides the authentication information for the server.

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

If no configuration object has been set via setConfiguration(), the one set via Component::setDefaultConfiguration() will be the value of this property (if a default one has been set). Configuration objects that are set per instance via setConfiguration() will take precedence over the default ones set via Component::setDefaultConfiguration().

Access functions:
AbstractConfiguration*configuration() const
voidsetConfiguration(AbstractConfiguration *nAbstractConfiguration)
Notifier signal:
voidconfigurationChanged(AbstractConfiguration *configuration)

◆ error

Fuoten::Error * Fuoten::Component::error
read

Pointer to an error object, if any error occurred.

If no error occurred, it will return a nullptr. The error is set internally by setError().

Access functions:
Error*error() const
Notifier signal:
voiderrorChanged(Error *error)

◆ inOperation

bool Fuoten::Component::inOperation
read

Returns true while the request is in operation.

See also
setInOperation()
Access functions:
boolinOperation() const
Notifier signal:
voidinOperationChanged(bool inOperation)

◆ notificator

Fuoten::AbstractNotificator * Fuoten::Component::notificator
readwrite

Pointer to an object derived from AbstractNotificator.

Set a notificator to notify users about errors and events. This is not mandatory. You have to derive your own notificator that uses the notification system of the target platform.

If no notificator has been set via setNotificator(), the one set via Component::setDefaultConfigurator() will be used - if any has been set. If you do not set a notificator either per instance or global, this property will hold a nullptr. If a notificator is set to an instance of this class via setNotificator(), this notificator will take precedence over the global default notificator object (if any set).

Access functions:
Notifier signal:
See also
notify()

◆ requestTimeout

quint16 Fuoten::Component::requestTimeout
readwrite

Timeout in seconds for network requests.

If you set the timeout to 0, it wil be disabled. Default value: 120 seconds

Access functions:
quint8requestTimeout() const
voidsetRequestTimeout(quint8 nRequestTimeout)
Notifier signal:
voidrequestTimeoutChanged(quint8 requestTimeout)

◆ storage

Fuoten::AbstractStorage * Fuoten::Component::storage
readwrite

Pointer to an AbstractStorage derived object.

Set a storage handler to store the results of API requests. You have to derive your own storage from AbstractStorage. Have a look at SQLiteStorage for an example implementation.

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

If no storage object has been set via setStorage() the one set via Component::setDefaultStorage() will be the value of this property. So if you do not set a storage object through one the methods, this property will hold a nullptr. If a storage object ist set to an instance of this class via setStorage(), this storage object will take precedence over the default storage object (if any set).

Together with the useStorage property, this can be used in the successCallback() function to determine if the API request result should be processed through the local storage object or not.

Access functions:
AbstractStorage*storage() const
voidsetStorage(AbstractStorage *nStorageHandler)
Notifier signal:
voidstorageChanged(AbstractStorage *storage)

◆ useStorage

bool Fuoten::Component::useStorage
readwrite

If true (the default), a local storage should be used in the successCallback() function to further process the request results.

Setting this property to false will omit possible usage of local storage objects in the successCallback() function. Even if a defaultStorage() has been set through setDefaultStorage(), it will not be used if this propery ist false.

Access functions:
Notifier signal:

◆ wipeManager

Fuoten::WipeManager * Fuoten::Component::wipeManager
readwrite

Pointer to a WipeManager to handle remote wipe requests.

Set a wipe manager to handle remote wipe requests. This is not mandatory. If no wipe manager has been set via setWipeManager(), the one set via Component::setDefaultWipeManager() will be used - if any has been set. If you do not set a wipe manager either per instance of global, this property will hold a nullptr as default. If a wipe manager is set to an instance of thsi class via setWipeManager(), this wipe manager will take precedence over the global default wipe manager object (if any set).

Access functions:
Notifier signal:

Constructor & Destructor Documentation

◆ Component()

Component::Component ( QObject * parent = nullptr)
explicit

Constructs a component with the given parent.

◆ ~Component()

Component::~Component ( )
override

Destroys the Component object.

Member Function Documentation

◆ addRequestHeader()

void Component::addRequestHeader ( const QByteArray & headerName,
const QByteArray & headerValue )
protected

Adds a header to the HTTP request.

See also
addRequestHeaders(), setRequestHeaders(), requestHeaders()
Parameters
headerNamethe name of the header entry
headerValuethe value of the header entry

◆ addRequestHeaders()

void Component::addRequestHeaders ( const QHash< QByteArray, QByteArray > & headers)
protected

Adds headers to the HTTP request.

See also
addRequestHeader(), setRequestHeaders(), requestHeaders()
Parameters
headersdictionary with key as header name and value as header value

◆ checkInput()

bool Component::checkInput ( )
protectedvirtual

◆ checkOutput()

bool Component::checkOutput ( )
protectedvirtual

Performs basic output checks.

Reimplement this in a subclass and call the parent's class implementation from there. The basic implementation extracts the JSON body, if there is data expected (setExpectedJSONType() is not set to Empty) and checks if the expected JSON data type can be found.

Reimplemented in Fuoten::CreateFeed, Fuoten::CreateFolder, Fuoten::GetFeeds, Fuoten::GetFolders, Fuoten::GetItems, Fuoten::GetStatus, Fuoten::GetUpdatedItems, Fuoten::GetUser, and Fuoten::GetVersion.

◆ configuration()

AbstractConfiguration * Component::configuration ( ) const

Returns a pointer to the AbstractConfiguration that is currently set.

See also
configuration

◆ configurationChanged

void Fuoten::Component::configurationChanged ( Fuoten::AbstractConfiguration * configuration)
signal

This signal is emitted when the pointer to the AbstractConfiguration object changes.

See also
configuration

◆ defaultConfiguration()

AbstractConfiguration * Component::defaultConfiguration ( )
static

Returns the global default configuration.

See also
setDefaultConfiguration()

◆ defaultNam()

QNetworkAccessManager * Component::defaultNam ( )
static

Returns the global network access manager.

See also
setDefaultNam()
Since
0.9.0

◆ defaultNotificator()

AbstractNotificator * Component::defaultNotificator ( )
static

Returns the global default notificator.

See also
setDefaultNotificator()

◆ defaultStorage()

AbstractStorage * Component::defaultStorage ( )
static

Returns the global default storage.

See also
setDefaultStorage()

◆ defaultWipeManager()

WipeManager * Component::defaultWipeManager ( )
static

Returns the global default wipe manager.

See also
setDefaultWipeManager()

◆ error()

Error * Component::error ( ) const

Returns a pointer to an Error object, if any error occurred.

Will return a nullptr if no error occurred.

See also
error

◆ errorChanged

void Fuoten::Component::errorChanged ( Fuoten::Error * error)
signal

This signal is emitted when the pointer to the Error object changes. error will be a nullptr if no error occurred or the current error has been reset.

See also
error

◆ execute()

virtual Q_INVOKABLE void Fuoten::Component::execute ( )
pure virtual

Executes the API request.

Reimplement this in a subclass to prepare the request and start it by calling sendRequest().

Implementation example
{
if (inOperation()) {
qWarning("Operation is still running.");
return;
}
QStringList routeParts;
routeParts << QStringLiteral("folders") << QString::number(folderId());
setApiRoute(routeParts);
QJsonObject jsonPayload;
jsonPayload.insert(QStringLiteral("name"), newFolderName());
setPayload(jsonPayload);
}
void sendRequest()
Sends the request to the server.
Definition component.cpp:289
void setPayload(const QByteArray &payload)
Sets the payload for the request.
Definition component.cpp:877
bool inOperation
Returns true while the request is in operation.
Definition component.h:169
void setApiRoute(const QString &route)
Sets the API route.
Definition component.cpp:808
void setInOperation(bool nInOperation)
Sets the value of the inOperation property.
Definition component.cpp:581
Q_INVOKABLE void execute() override
Executes the API request.
Definition renamefolder.cpp:45
iterator insert(const QString &key, const QJsonValue &value)
QString number(int n, int base)

Implemented in Fuoten::ConvertToAppPassword, Fuoten::CreateFeed, Fuoten::CreateFolder, Fuoten::DeleteAppPassword, Fuoten::DeleteFeed, Fuoten::DeleteFolder, Fuoten::GetFeeds, Fuoten::GetFolders, Fuoten::GetItems, Fuoten::GetServerStatus, Fuoten::GetStatus, Fuoten::GetUpdatedItems, Fuoten::GetUser, Fuoten::GetVersion, Fuoten::GetWipeStatus, Fuoten::LoginFlowV2, Fuoten::MarkAllItemsRead, Fuoten::MarkFeedRead, Fuoten::MarkFolderRead, Fuoten::MarkItem, Fuoten::MarkMultipleItems, Fuoten::MoveFeed, Fuoten::PostWipeSuccess, Fuoten::RenameFeed, Fuoten::RenameFolder, Fuoten::StarItem, and Fuoten::StarMultipleItems.

◆ extractError()

void Component::extractError ( QNetworkReply * reply)
protectedvirtual

Extracts error data from the network reply.

Reimplement this in a subclass to extract errors from the request result. The simplest implementation is to create a new Error object from the QNetworkReply and set it to the Component::error property. You should than also emit the failed() signal.

The basic implementation uses the overloaded Error constructor to extract reply errors, sets the new Error to the error property, sets inOperation to false and emits the failed() signal.

Implementation example
{
setError(new Error(reply, this));
}
void failed(Fuoten::Error *error)
Emit this signal in a subclass when the request failed for some reason.
Definition moc_component.cpp:462
void setError(Error *nError)
Sets the pointer of the error property.
Definition component.cpp:607
Fuoten::Error * error
Pointer to an error object, if any error occurred.
Definition component.h:191
Q_EMITQ_EMIT

Reimplemented in Fuoten::ConvertToAppPassword, Fuoten::CreateFeed, Fuoten::CreateFolder, Fuoten::DeleteFeed, Fuoten::DeleteFolder, Fuoten::MarkFeedRead, Fuoten::MarkFolderRead, Fuoten::MarkItem, Fuoten::MoveFeed, Fuoten::RenameFeed, Fuoten::RenameFolder, and Fuoten::StarItem.

◆ failed

void Fuoten::Component::failed ( Fuoten::Error * error)
signal

Emit this signal in a subclass when the request failed for some reason.

See also
error
Parameters
errorpointer to an Error object

◆ inOperation()

bool Component::inOperation ( ) const

Returns true while the API request is running.

This might also include the local storage operation, if Component::storage is set to a valid AbstractStorage sublcass.

See also
inOperation

◆ inOperationChanged

void Fuoten::Component::inOperationChanged ( bool inOperation)
signal

This signal is emitted when the in operation status changes.

See also
inOperation

◆ isUseStorageEnabled()

bool Component::isUseStorageEnabled ( ) const

Getter function for the useStorage property.

See also
setUseStorage(), useStorageChanged()

◆ jsonResult()

QJsonDocument Component::jsonResult ( ) const
protected

Returns the JSON result document.

◆ networkAccessManagerFactory()

AbstractNamFactory * Component::networkAccessManagerFactory ( )
static

Returns the currently set network access manager factory.

See also
setNetworkAccessManagerFactory()

◆ notificator()

AbstractNotificator * Component::notificator ( ) const

Getter function for the notificator property.

See also
setNotificator(), notificatorChanged()

◆ notificatorChanged

void Fuoten::Component::notificatorChanged ( Fuoten::AbstractNotificator * notificator)
signal

Notifier signal for the notificator property.

See also
setNotificator(), notificator()

◆ notify() [1/2]

void Component::notify ( AbstractNotificator::Type type,
QtMsgType severity,
const QVariant & data ) const
protected

Checks if a notificator has been set and will use it to notify the user.

See also
AbstractNotificator::notify(AbstractNotificator::Type type, QtMsgType severity, const QVariant &data)

◆ notify() [2/2]

void Component::notify ( const Error * e) const
protected

Checks if a notificator has been set and will use it to notify about an occured error.

See also
AbstractNotificator::notify(const Error *e)

◆ requestHeaders()

QHash< QByteArray, QByteArray > Component::requestHeaders ( ) const
protected

Returns the currently set HTTP headers for the request.

See also
setRequestHeaders(), addRequestHeader(), addRequestHeaders()

◆ requestTimeout()

quint16 Component::requestTimeout ( ) const

Returns the currently set request timeout.

See also
requestTimeout

◆ requestTimeoutChanged

void Fuoten::Component::requestTimeoutChanged ( quint16 requestTimeout)
signal

This signal is emitte when the timeout for the request changes.

See also
requestTimeout

◆ sendRequest()

void Component::sendRequest ( )
protected

Sends the request to the server.

◆ setApiRoute() [1/2]

void Component::setApiRoute ( const QString & route)
protected

Sets the API route.

See also
apiRoute()
Parameters
routecomplete API route starting with "/"

◆ setApiRoute() [2/2]

void Component::setApiRoute ( const QStringList & routeParts)
protected

Sets the API route constructed from a route part list.

The parts in the QStringList will be joind with a '/' into the API route path.

See also
apiRoute()
Parameters
routePartslist of route parts that will be joined with a '/'.

◆ setConfiguration()

void Component::setConfiguration ( AbstractConfiguration * nAbstractConfiguration)

Sets a pointer to a AbstractConfiguration to use for the API request.

See also
configuration

◆ setDefaultConfiguration()

void Component::setDefaultConfiguration ( AbstractConfiguration * config)
static

Sets the global default configuration.

See also
defaultConfiguration()

◆ setDefaultNam()

void Component::setDefaultNam ( QNetworkAccessManager * nam)
static

Sets the global default network access manager.

See also
defaultNam()
Since
0.9.0

◆ setDefaultNotificator()

void Component::setDefaultNotificator ( AbstractNotificator * notificator)
static

Sets the global default notificator.

See also
defaultNotificator()

◆ setDefaultStorage()

void Component::setDefaultStorage ( AbstractStorage * storage)
static

Sets the global default storage.

See also
defaultStorage()

◆ setDefaultWipeManager()

void Component::setDefaultWipeManager ( WipeManager * wipeManager)
static

Sets the global default wipe manager.

See also
defaultWipeManager()

◆ setError()

void Component::setError ( Error * nError)
protected

Sets the pointer of the error property.

If there was already an error set, the old Error will be deleted.

See also
error

◆ setExpectedJSONType()

void Component::setExpectedJSONType ( ExpectedJSONType type)
protected

Sets the expected JSON type for initial output check.

Default: Empty

See also
expetedJSONType()

◆ setInOperation()

void Component::setInOperation ( bool nInOperation)
protected

Sets the value of the inOperation property.

Use this in subclasses of Component to indicate, that the request is still running or has been finished.

See also
inOperation

◆ setNetworkAccessManagerFactory()

void Component::setNetworkAccessManagerFactory ( AbstractNamFactory * factory)
static

Sets the network access manager factory. The factory will be used to create QNetworkAccessManager objects on demand. If no factory is set, a default QNetworkAccessManager object will be created. The Component class will take ownership of the created QNetworkAccessManager.

This is deprectated since version 0.9.0, use setDefaultNam() to directly set a single global instance of QNetworkAccessManager to reuse it for every request.

See also
networkAccessManagerFactory()

◆ setNetworkOperation()

void Component::setNetworkOperation ( QNetworkAccessManager::Operation operation)
protected

Sets the operation the network manager should perform for this call.

Default: QNetworkAccessManager::GetOperation

Parameters
operationthe type of the nework operation

◆ setNotificator()

void Component::setNotificator ( AbstractNotificator * notificator)

Setter function for the notificator property.

See also
notificator(), notificatorChanged()

◆ setPayload() [1/2]

void Component::setPayload ( const QByteArray & payload)
protected

Sets the payload for the request.

Parameters
payloadthe JSON payload to send with the request

◆ setPayload() [2/2]

void Component::setPayload ( const QJsonObject & payload)
protected

Sets the payload for the request.

Parameters
payloadthe JSON payload to send with the request

◆ setRequestHeaders()

void Component::setRequestHeaders ( const QHash< QByteArray, QByteArray > & headers)
protected

Sets the headers to use for the HTTP request.

See also
requestHeaders(), addRequestHeader(), addRequestHeaders()
Parameters
headersdictionary with key as header name and value as header value

◆ setRequestTimeout()

void Component::setRequestTimeout ( quint16 seconds)

Sets the timeout for the API request in seconds.

See also
requestTimeout

◆ setRequiresAuth()

void Component::setRequiresAuth ( bool reqAuth)
protected

Set this to true if the request requires authentication.

Default: true

◆ setStorage()

void Component::setStorage ( AbstractStorage * localStorage)

Setter function for the storage property.

See also
storage(), setDefaultStorage(), storageChanged()

◆ setUrlQuery()

void Component::setUrlQuery ( const QUrlQuery & query)
protected

Sets the URL query for the request.

Parameters
querythe query to append to the request URL

◆ setUseStorage()

void Component::setUseStorage ( bool useStorage)

Setter function for the useStorage property.

See also
isUseStorageEnabled(), useStorageChanged()

◆ setWipeManager()

void Component::setWipeManager ( WipeManager * wipeManager)

Setter function for the wipeManager property.

See also
wipeManager(), wipeManagerChanged()

◆ sslErrors

void Fuoten::Component::sslErrors ( QNetworkReply * reply,
const QList< QSslError > & errors )
signal

This signal is emitted if the SSL/TLS session encountered errors during the set up.

Will only be emitted if AbstractConfiguration::getIgnoreSSLErrors() returns false (the default).

Parameters
replythe network reply that cause the SSL error
errorslist of occured SSL errors

◆ storage()

AbstractStorage * Component::storage ( ) const

Getter function for the storage property.

See also
setStorage(), setDefaultStorage(), storageChanged()

◆ storageChanged

void Fuoten::Component::storageChanged ( Fuoten::AbstractStorage * storage)
signal

Notifier signal for the storage property.

See also
storage(), setDefaultStorage(), setStorage()

◆ succeeded

void Fuoten::Component::succeeded ( const QJsonDocument & result)
signal

Emit this signal in a subclass when the request was successful.

Parameters
resultJSON data replied by the server as result of an API request

◆ successCallback()

virtual void Fuoten::Component::successCallback ( )
protectedpure virtual

Processes the request data if the request was successful.

Reimplement this in a subclass to extract the data from the JSON reply and optionally use the AbtractStorage provided by Component::storage property to store the requested data.

Setting the storage is optional, so you should check if it contains a valid pointer.

In the successCallback you should also set inOperation to false and emit the succeeded() signal (or a custom succeeded signal).

Implementation example
{
storage()->folderRenamed(folderId(), newName());
}
Q_EMIT succeeded(folderId(), newName());
}
virtual void folderRenamed(qint64 id, const QString &newName)=0
Receives the reply data of the RenameFolder request.
void succeeded(const QJsonDocument &result)
Emit this signal in a subclass when the request was successful.
Definition moc_component.cpp:455
Fuoten::AbstractStorage * storage
Pointer to an AbstractStorage derived object.
Definition component.h:229
bool isUseStorageEnabled() const
Getter function for the useStorage property.
Definition component.cpp:676
void successCallback() override
Finishes the renaming if it was successful.
Definition renamefolder.cpp:98

Implemented in Fuoten::ConvertToAppPassword, Fuoten::CreateFeed, Fuoten::CreateFolder, Fuoten::DeleteAppPassword, Fuoten::DeleteFeed, Fuoten::DeleteFolder, Fuoten::GetFeeds, Fuoten::GetFolders, Fuoten::GetItems, Fuoten::GetServerStatus, Fuoten::GetStatus, Fuoten::GetUpdatedItems, Fuoten::GetUser, Fuoten::GetVersion, Fuoten::GetWipeStatus, Fuoten::LoginFlowV2, Fuoten::MarkAllItemsRead, Fuoten::MarkFeedRead, Fuoten::MarkFolderRead, Fuoten::MarkItem, Fuoten::MarkMultipleItems, Fuoten::MoveFeed, Fuoten::PostWipeSuccess, Fuoten::RenameFeed, Fuoten::RenameFolder, Fuoten::StarItem, and Fuoten::StarMultipleItems.

◆ useStorageChanged

void Fuoten::Component::useStorageChanged ( bool useStorage)
signal

Notifier signal for the useStorage property.

See also
setUseStorage(), isUseStorageEnabled()

◆ wipeManager()

WipeManager * Component::wipeManager ( ) const

Getter function for the wipeManager property.

See also
setWipeManager(), wipeManagerChanged()

◆ wipeManagerChanged

void Fuoten::Component::wipeManagerChanged ( Fuoten::WipeManager * wipeManager)
signal

Notifier signal for the wipeManager property.

See also
setWipeManager(), wipeManager()

The documentation for this class was generated from the following files:
  • Fuoten/API/component.h
  • build/Fuoten/FuotenQt5_autogen/include/moc_component.cpp
  • Fuoten/API/component.cpp