|
libfuoten 0.8.2
Qt based library to access the Nextcloud News App API.
|
Stars or unstars an item/article on the remote News App. More...
#include <Fuoten/API/StarItem>
Properties | |
| qint64 | feedId |
| ID of the feed the item/article to star/unstar belongs to. | |
| QString | guidHash |
| GUID hash of the item/article to star/unstar. | |
| bool | starred |
| True if the item/article should be starred, otherwise false. | |
| Properties inherited from Fuoten::Component | |
| Fuoten::AbstractConfiguration * | configuration |
| Pointer to an AbstractConfiguration derived object. | |
| Fuoten::Error * | error |
| Pointer to an error object, if any error occurred. | |
| bool | inOperation |
| Returns true while the request is in operation. | |
| Fuoten::AbstractNotificator * | notificator |
| Pointer to an object derived from AbstractNotificator. | |
| quint16 | requestTimeout |
| Timeout in seconds for network requests. | |
| Fuoten::AbstractStorage * | storage |
| 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::WipeManager * | wipeManager |
| Pointer to a WipeManager to handle remote wipe requests. | |
Public Member Functions | |
| StarItem (qint64 feedId, const QString &guidHash, bool starred, QObject *parent=nullptr) | |
| Constructs a new StarItem object with the given arguments and parent. | |
| StarItem (QObject *parent=nullptr) | |
| Constructs a new StarItem object with default values and the given parent. | |
| ~StarItem () override | |
| Destroys the StarItem object. | |
| Q_INVOKABLE void | execute () override |
| Executes the API request. | |
| qint64 | feedId () const |
| Getter function for the feedId property. | |
| QString | guidHash () const |
| Getter function for the guidHash property. | |
| void | setFeedId (qint64 nFeedId) |
| Setter function for the feedId property. Emits the feedIdChanged() signal if nFeedId is not equal to the stored value. Can not be changed while Component::inOperation returns true. | |
| void | setGuidHash (const QString &nGuidHash) |
| Setter function for the guidHash property. Emits the guidHashChanged() signal if nGuidHash is not equal to the stored value. Can not be changed while Component::inOperation returns true. | |
| void | setStarred (bool nStarred) |
| Setter function for the starred property. Emits the starredChanged() signal if nStarred is not equal to the stored value. Can not be changed while Component::inOperation returns true. | |
| bool | starred () const |
| Getter function for the starred 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. | |
| AbstractConfiguration * | configuration () const |
| Returns a pointer to the AbstractConfiguration that is currently set. | |
| Error * | error () 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. | |
| AbstractNotificator * | notificator () 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. | |
| AbstractStorage * | storage () const |
| Getter function for the storage property. | |
| WipeManager * | wipeManager () const |
| Getter function for the wipeManager property. | |
Signals | |
| void | feedIdChanged (qint64 feedId) |
| This is emitted if the value of the feedId property changes. | |
| void | guidHashChanged (const QString &guidHash) |
| This is emitted if the value of the guidHash property changes. | |
| void | starredChanged (bool starred) |
| This is emitted if the value of the starred property changes. | |
| void | succeeded (qint64 feedId, const QString &guidHash, bool starred) |
| This signal is emitted if the request to star/unstar an item/article was successful. | |
| 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 |
| Will check for valid feedId and non-empty guidHash. | |
| void | extractError (QNetworkReply *reply) override |
| Extracts possible errors replied by the News App API. | |
| void | successCallback () override |
| Finishes the article starring/unstarring 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 bool | checkOutput () |
| Performs basic output checks. | |
| 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, QByteArray > | requestHeaders () 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 AbstractConfiguration * | defaultConfiguration () |
| Returns the global default configuration. | |
| static QNetworkAccessManager * | defaultNam () |
| Returns the global network access manager. | |
| static AbstractNotificator * | defaultNotificator () |
| Returns the global default notificator. | |
| static AbstractStorage * | defaultStorage () |
| Returns the global default storage. | |
| static WipeManager * | defaultWipeManager () |
| Returns the global default wipe manager. | |
| static AbstractNamFactory * | networkAccessManagerFactory () |
| 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. | |
Stars or unstars an item/article on the remote News App.
To star or unstar an item/article, you have to set StarItem::feedId to a valid feed ID, StarItem::guidHash to a valid item/article guid hash and Component::configuration to a valid AbstractConfiguration derived object that provides the authentication credentials and server information. 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::itemStarred() will be called in the successCallback() to update the local storage. If the request succeeded, the StarItem::succeeded() signal will be emitted, containing the feedId, the guidHash 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.
|
readwrite |
ID of the feed the item/article to star/unstar belongs to.
This property can not be changed while Component::inOperation() returns true.
| qint64 | feedId() const |
| void | setFeedId(qint64 nFeedId) |
| void | feedIdChanged(qint64 feedId) |
|
readwrite |
GUID hash of the item/article to star/unstar.
This property can not be changed while Component::inOperation() returns true.
| QString | guidHash() const |
| void | setGuidHash(const QString &nGuidHash) |
| void | guidHashChanged(const QString &guidHash) |
|
readwrite |
True if the item/article should be starred, otherwise false.
This property can not be changed while Component::inOperation() returns true.
| bool | starred() const |
| void | setStarred(bool nStarred) |
| void | starredChanged(bool starred) |
|
explicit |
Constructs a new StarItem object with default values and the given parent.
| StarItem::StarItem | ( | qint64 | feedId, |
| const QString & | guidHash, | ||
| bool | starred, | ||
| QObject * | parent = nullptr ) |
Constructs a new StarItem object with the given arguments and parent.
|
override |
Destroys the StarItem object.
|
overrideprotectedvirtual |
Will check for valid feedId and non-empty guidHash.
Will at first perform the checks of Component::checkInput(). Will than simply check if the feedId is not lower or equal to 0 and if the guidHash is not empty.
Reimplemented from Fuoten::Component.
|
overridevirtual |
Executes the API request.
To perform a successful API request to star or unstar an article/item, StarItem::feedId has to be a valid feed ID, StarItem::guidHash has to be an valid item/article guid hash 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 Fuoten::Component.
|
overrideprotectedvirtual |
Extracts possible errors replied by the News App API.
Reimplemented from Fuoten::Component.
| qint64 StarItem::feedId | ( | ) | const |
Getter function for the feedId property.
|
signal |
This is emitted if the value of the feedId property changes.
| feedId | ID of the feed the item that should be starred/unstarred belongs to |
| QString StarItem::guidHash | ( | ) | const |
Getter function for the guidHash property.
|
signal |
This is emitted if the value of the guidHash property changes.
| guidHash | the GUID hash of the article that should be starred/unstarred |
| void StarItem::setFeedId | ( | qint64 | nFeedId | ) |
Setter function for the feedId property. Emits the feedIdChanged() signal if nFeedId is not equal to the stored value. Can not be changed while Component::inOperation returns true.
| nFeedId | ID of the feed the item that should be starred/unstarred belongs to |
| void StarItem::setGuidHash | ( | const QString & | nGuidHash | ) |
Setter function for the guidHash property. Emits the guidHashChanged() signal if nGuidHash is not equal to the stored value. Can not be changed while Component::inOperation returns true.
| nGuidHash | the GUID hash of the article that should be starred/unstarred |
| void StarItem::setStarred | ( | bool | nStarred | ) |
Setter function for the starred property. Emits the starredChanged() signal if nStarred is not equal to the stored value. Can not be changed while Component::inOperation returns true.
| nStarred | true if the article should be starred, false if it should be unstarred |
| bool StarItem::starred | ( | ) | const |
Getter function for the starred property.
true if the item/article should be starred, false if it should be unstarred
|
signal |
This is emitted if the value of the starred property changes.
| starred | true if the article should be starred, false if it should be unstarred |
|
signal |
This signal is emitted if the request to star/unstar an item/article was successful.
| feedId | ID of the feed the starred/unstarred item/article belongs to |
| guidHash | GUID hash of the item/article that has been starred/unstarred |
| starred | true if the article has been starred, false if it has been unstarred |
|
overrideprotectedvirtual |
Finishes the article starring/unstarring if the request was successful.
If Component::storage contains a valid pointer, the AbstractStorage::itemStarred() 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 Fuoten::Component.