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

Requests items/articles from the News App API. More...

#include <Fuoten/API/GetItems>

Inheritance diagram for Fuoten::GetItems:
Fuoten::Component QObject

Properties

int batchSize
 The number of items/articles that should be returned.
bool getRead
 If true, it returns all items, false returns only unread items.
qint64 offset
 Only return older (lower than equal that ID) items.
bool oldestFirst
 If true, it reverses the sort order.
qint64 parentId
 ID of the folder or feed, 0 for starred and all.
Fuoten::FuotenEnums::Type type
 Type of the query.
Properties inherited from Fuoten::Component
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

 GetItems (int batchSize, qint64 offset, FuotenEnums::Type type, qint64 parentId, bool getRead, bool oldestFirst, QObject *parent=nullptr)
 Constructs an API request object with the given parameters and parent to query items from the remote server.
 GetItems (QObject *parent=nullptr)
 Constructs an API request object with the given parent to query items from the remote server.
 ~GetItems () override
 Destroys the GetItems object.
int batchSize () const
 Getter function for the batchSize property.
Q_INVOKABLE void execute () override
 Executes the API request.
bool getRead () const
 Getter function for the getRead property.
qint64 offset () const
 Getter function for the offset property.
bool oldestFirst () const
 Getter function for the oldestFirst property.
qint64 parentId () const
 Getter function for the parentId property.
void setBatchSize (int nBatchSize)
 Setter function for the batchSize property. Emits the batchSizeChanged() signal if nBatchSize is not equal to the stored value.
void setGetRead (bool nGetRead)
 Setter function for the getRead property. Emits the getReadChanged() signal if nGetRead is not equal to the stored value.
void setOffset (qint64 nOffset)
 Setter function for the offset property. Emits the offsetChanged() signal if nOffset is not equal to the stored value.
void setOldestFirst (bool nOldestFirst)
 Setter function for the oldestFirst property. Emits the oldestFirstChanged() signal if nOldestFirst is not equal to the stored value.
void setParentId (qint64 nParentId)
 Setter function for the parentId property. Emits the parentIdChanged() signal if nParentId is not equal to the stored value.
void setType (FuotenEnums::Type nType)
 Setter function for the type property. Emits the typeChanged() signal if nType is not equal to the stored value.
FuotenEnums::Type type () const
 Getter function for the type property.
Public Member Functions inherited from Fuoten::Component
 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.
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 batchSizeChanged (int batchSize)
 This is emitted if the value of the batchSize property changes.
void getReadChanged (bool getRead)
 This is emitted if the value of the getRead property changes.
void offsetChanged (qint64 offset)
 This is emitted if the value of the offset property changes.
void oldestFirstChanged (bool oldestFirst)
 This is emitted if the value of the oldestFirst property changes.
void parentIdChanged (qint64 parentId)
 This is emitted if the value of the parentId property changes.
void typeChanged (FuotenEnums::Type type)
 This is emitted if the value of the type property changes.
Signals inherited from Fuoten::Component
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.

Protected Member Functions

bool checkInput () override
 Checks for valid input values.
bool checkOutput () override
 Checks for an items array in the JSON API reply.
void successCallback () override
 Finishes the the operation if the request was successful.
Protected Member Functions inherited from Fuoten::Component
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 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.

Additional Inherited Members

Public Types inherited from Fuoten::Component
enum  ExpectedJSONType : quint8 { Empty = 0 , Array = 1 , Object = 2 }
 Defines the expected JSON type. More...
Static Public Member Functions inherited from Fuoten::Component
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.

Detailed Description

Requests items/articles from the News App API.

To request the items/articles, the Component::configuration property has to be set to a valid AbstractConfiguration object. After setting it, call execute() to perform the API request.

If a valid AbstractStorage object is set to the Component::storage property, AbstractStorage::itemsRequested will be called in the successCallback() to save the requested items in the local storage. If the request succeeded, the Component::succeeded() signal will be emitted, containing the JSON api reply.

If something failed, Component::failed() will be emitted and the Component::error property will contain a valid pointer to an Error object.

Mandatory properties
Component::configuration
API route
/items
Method
GET
See also
Synchronizer

Property Documentation

◆ batchSize

int Fuoten::GetItems::batchSize
readwrite

The number of items/articles that should be returned.

Defaults to -1, -1 returns all items. This property can not be changed while Component::inOperation() returns true.

Access functions:
intbatchSize() const
voidsetBatchSize(int nBatchSize)
Notifier signal:
voidbatchSizeChanged(int batchSize)

◆ getRead

bool Fuoten::GetItems::getRead
readwrite

If true, it returns all items, false returns only unread items.

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

Access functions:
boolgetRead() const
voidsetGetRead(bool nGetRead)
Notifier signal:
voidgetReadChanged(bool getRead)

◆ offset

qint64 Fuoten::GetItems::offset
readwrite

Only return older (lower than equal that ID) items.

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

Access functions:
qint64offset() const
voidsetOffset(qint64 nOffset)
Notifier signal:
voidoffsetChanged(qint64 offset)

◆ oldestFirst

bool Fuoten::GetItems::oldestFirst
readwrite

If true, it reverses the sort order.

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

Access functions:
boololdestFirst() const
voidsetOldestFirst(bool nOldestFirst)
Notifier signal:
voidoldestFirstChanged(bool oldestFirst)

◆ parentId

qint64 Fuoten::GetItems::parentId
readwrite

ID of the folder or feed, 0 for starred and all.

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

Access functions:
qint64parentId() const
voidsetParentId(qint64 nParentId)
Notifier signal:
voidparentIdChanged(qint64 parentId)

◆ type

Fuoten::FuotenEnums::Type Fuoten::GetItems::type
readwrite

Type of the query.

Defines for which parent items/articles should be queried. Defaults to FuotenEnums::All.

Possible values:
This property can not be changed while Component::inOperation() returns true.
Access functions:
FuotenEnums::Typetype() const
voidsetType(FuotenEnums::Type nType)
Notifier signal:
voidtypeChanged(FuotenEnums::Type type)

Constructor & Destructor Documentation

◆ GetItems() [1/2]

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

Constructs an API request object with the given parent to query items from the remote server.

◆ GetItems() [2/2]

GetItems::GetItems ( int batchSize,
qint64 offset,
FuotenEnums::Type type,
qint64 parentId,
bool getRead,
bool oldestFirst,
QObject * parent = nullptr )

Constructs an API request object with the given parameters and parent to query items from the remote server.

◆ ~GetItems()

GetItems::~GetItems ( )
override

Destroys the GetItems object.

Member Function Documentation

◆ batchSize()

int GetItems::batchSize ( ) const

Getter function for the batchSize property.

See also
GetItems::setBatchSize(), GetItems::batchSizeChanged()

◆ batchSizeChanged

void Fuoten::GetItems::batchSizeChanged ( int batchSize)
signal

This is emitted if the value of the batchSize property changes.

See also
GetItems::batchSize(), GetItems::setBatchSize()

◆ checkInput()

bool GetItems::checkInput ( )
overrideprotectedvirtual

Checks for valid input values.

Will at first perfrom the checks from Component::checkInput() and will than check if the values of the properties are in valid ranges.

Reimplemented from Fuoten::Component.

◆ checkOutput()

bool GetItems::checkOutput ( )
overrideprotectedvirtual

Checks for an items array in the JSON API reply.

Will at first perform the checks from Component::checkOutput() and will than check if the items array is present. Will not check if the array is empty.

Reimplemented from Fuoten::Component.

◆ execute()

void GetItems::execute ( )
overridevirtual

Executes the API request.

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

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

Implements Fuoten::Component.

◆ getRead()

bool GetItems::getRead ( ) const

Getter function for the getRead property.

See also
GetItems::setGetRead(), GetItems::getReadChanged()

◆ getReadChanged

void Fuoten::GetItems::getReadChanged ( bool getRead)
signal

This is emitted if the value of the getRead property changes.

See also
GetItems::getRead(), GetItems::setGetRead()

◆ offset()

qint64 GetItems::offset ( ) const

Getter function for the offset property.

See also
GetItems::setOffset(), GetItems::offsetChanged()

◆ offsetChanged

void Fuoten::GetItems::offsetChanged ( qint64 offset)
signal

This is emitted if the value of the offset property changes.

See also
GetItems::offset(), GetItems::setOffset()

◆ oldestFirst()

bool GetItems::oldestFirst ( ) const

Getter function for the oldestFirst property.

See also
GetItems::setOldestFirst(), GetItems::oldestFirstChanged()

◆ oldestFirstChanged

void Fuoten::GetItems::oldestFirstChanged ( bool oldestFirst)
signal

This is emitted if the value of the oldestFirst property changes.

See also
GetItems::oldestFirst(), GetItems::setOldestFirst()

◆ parentId()

qint64 GetItems::parentId ( ) const

Getter function for the parentId property.

See also
GetItems::setParentId(), GetItems::parentIdChanged()

◆ parentIdChanged

void Fuoten::GetItems::parentIdChanged ( qint64 parentId)
signal

This is emitted if the value of the parentId property changes.

See also
GetItems::parentId(), GetItems::setParentId()

◆ setBatchSize()

void GetItems::setBatchSize ( int nBatchSize)

Setter function for the batchSize property. Emits the batchSizeChanged() signal if nBatchSize is not equal to the stored value.

See also
GetItems::batchSize(), GetItems::batchSizeChanged()

◆ setGetRead()

void GetItems::setGetRead ( bool nGetRead)

Setter function for the getRead property. Emits the getReadChanged() signal if nGetRead is not equal to the stored value.

See also
GetItems::getRead(), GetItems::getReadChanged()

◆ setOffset()

void GetItems::setOffset ( qint64 nOffset)

Setter function for the offset property. Emits the offsetChanged() signal if nOffset is not equal to the stored value.

See also
GetItems::offset(), GetItems::offsetChanged()

◆ setOldestFirst()

void GetItems::setOldestFirst ( bool nOldestFirst)

Setter function for the oldestFirst property. Emits the oldestFirstChanged() signal if nOldestFirst is not equal to the stored value.

See also
GetItems::oldestFirst(), GetItems::oldestFirstChanged()

◆ setParentId()

void GetItems::setParentId ( qint64 nParentId)

Setter function for the parentId property. Emits the parentIdChanged() signal if nParentId is not equal to the stored value.

See also
GetItems::parentId(), GetItems::parentIdChanged()

◆ setType()

void GetItems::setType ( FuotenEnums::Type nType)

Setter function for the type property. Emits the typeChanged() signal if nType is not equal to the stored value.

See also
GetItems::type(), GetItems::typeChanged()

◆ successCallback()

void GetItems::successCallback ( )
overrideprotectedvirtual

Finishes the the operation if the request was successful.

If Component::storage points to a valid object, it will use AbstractStorage::itemsRequested() to store, update and delete the items in the local storage according to the server reply. Afterwards it will set Component::inOperation to false and will emit the Component::succeeded() signal.

Implements Fuoten::Component.

◆ type()

FuotenEnums::Type GetItems::type ( ) const

Getter function for the type property.

See also
GetItems::setType(), GetItems::typeChanged()

◆ typeChanged

void Fuoten::GetItems::typeChanged ( FuotenEnums::Type type)
signal

This is emitted if the value of the type property changes.

See also
GetItems::type(), GetItems::setType()

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