libfuoten  0.8.1
Qt based library to access the ownCloud/Nextcloud News App API
Properties | Public Member Functions | Signals | Protected Member Functions | List of all members
StarMultipleItems Class Reference

#include <Fuoten/API/MarkFeedRead>

Inheritance diagram for StarMultipleItems:
Component

Properties

bool starred
 
- Properties inherited from Component
Fuoten::AbstractConfiguration configuration
 
Fuoten::Error error
 
bool inOperation
 
Fuoten::AbstractNotificator notificator
 
quint16 requestTimeout
 
Fuoten::AbstractStorage storage
 
bool useStorage
 
Fuoten::WipeManager wipeManager
 

Public Member Functions

 StarMultipleItems (QObject *parent=nullptr)
 
 StarMultipleItems (bool starred, QObject *parent=nullptr)
 
 ~StarMultipleItems () override
 
Q_INVOKABLE void addItem (qint64 feedId, const QString &guidHash)
 
Q_INVOKABLE void execute () override
 
QList< QPair< qint64, QString > > itemsToStar () const
 
void setItemsToStar (const QList< QPair< qint64, QString >> &items)
 
void setStarred (bool nStarred)
 
bool starred () const
 
- 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 starredChanged (bool starred)
 
void succeeded (const QList< QPair< qint64, QString >> &items, bool star)
 
- 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
 
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 checkOutput ()
 
virtual void extractError (QNetworkReply *reply)
 
QJsonDocument jsonResult () const
 
void notify (const Error *e) const
 
void notify (AbstractNotificator::Type type, QtMsgType severity, const QVariant &data) 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

Star/unstar multiple items/articles in on request on the News App server.

To star multiple items/articles in one request, you have to set a list of feed ID and item guid hash combinations via setItemsToStar(), or add single combinations via addItem(). You need also to set a valid AbstractConfiguration derived class to Component::configurtion to provide the necessary authentication credentials and server settings. After setting the mandatory propeties, call execute() to perform the API request.

If a valid AbstractStorage object is set to the Component::storage property, AbstractStorage::itemsStarred() will be called in the successCallback() to update the local storage. If the request succeeded, the StarMultipleItems::succeeded() signal will be emitted, containing the the list of articles and the starred status. If something failed, the Component::failed() signal will be emitted and Component::error will contain a valid pointer to an Error object.

Mandatory properties
Component::configuration
API route
/itesm/{star|unstar}/multiple
Method
PUT

Property Documentation

◆ starred

bool starred
readwrite

Set to true if the items/articles should be marked as starred, set to false to mark them as unstarred.

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

Access functions:
boolstarred() const
voidsetStarred(bool nStarred)
Notifier signal:
voidstarredChanged(bool starred)

Constructor & Destructor Documentation

◆ StarMultipleItems() [1/2]

StarMultipleItems ( QObject *  parent = nullptr)
explicit

Constructs a new StarMultipleItems object with default values and the given parent.

◆ StarMultipleItems() [2/2]

StarMultipleItems ( bool  starred,
QObject *  parent = nullptr 
)
explicit

Constructs a new StarMultipleItems object with the given arguments and parent.

◆ ~StarMultipleItems()

~StarMultipleItems ( )
override

Destroys the StarMultipleItems object.

Member Function Documentation

◆ addItem()

void addItem ( qint64  feedId,
const QString &  guidHash 
)

Adds a new article to the list of articles to star/unstar.

Items can not be added while Component::inOperation() returns true.

Parameters
feedIdID of the feed the article belongs to
guidHashGUID hash of the article

◆ checkInput()

bool checkInput ( )
overrideprotectedvirtual

Will check if the list of articles/items is not empty.

Will at first perform the checks of Component::checkInput(). Will than simply check if list of articles is not empty.

Reimplemented from Component.

◆ execute()

void execute ( )
overridevirtual

Executes the API request.

To perform a successful API request to star/unstar a list of articles/items, you have to setItemsToStar() and there has to be an AbstractConfiguration object set to Component::configuration.

Execution will not run while Component::inOperation returns true and will itself set that property to true when the request starts.

Implements Component.

◆ itemsToStar()

QList< QPair< qint64, QString > > itemsToStar ( ) const

Returns the list of feed IDs and article GUID hashes that should be starred/unstarred.

◆ setItemsToStar()

void setItemsToStar ( const QList< QPair< qint64, QString >> &  items)

Sets the list of feed IDs and article GUID hashes that shoul be starred/unstarred.

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

Parameters
itemslist containing a set of feed ID as first and article guid hash as second

◆ setStarred()

void setStarred ( bool  nStarred)

Setter function for the starred property. Emits the starredChanged() signal if nStarred is not equal to the stored value.

See also
StarMultipleItems::starred(), StarMultipleItems::starredChanged()

◆ starred()

bool starred ( ) const

◆ starredChanged

void starredChanged ( bool  starred)
signal

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

See also
StarMultipleItems::starred(), StarMultipleItems::setStarred()

◆ succeeded

void succeeded ( const QList< QPair< qint64, QString >> &  items,
bool  star 
)
signal

This signal is emitted if the request to star/unstar items was successful.

Parameters
itemslist of feed IDs and article/item GUID hashes that have been starred/unstarred
startrue if the articles/items have been starred, false if they have been unstarred

◆ successCallback()

void successCallback ( )
overrideprotectedvirtual

Finishes the article/items starring/unstarring if the request was successful.

If Component::storage contains a valid pointer, the AbstractStorage::itemsStarred() function will be called to update the local storage. After that the Component::inOperation property will be set to false and the succeeded() signal will be emitted.

Implements Component.