|
libfuoten 0.8.1
Qt based library to access the ownCloud/Nextcloud News App API
|
#include <Fuoten/Storage/AbstractStorage>
Properties | |
| AbstractConfiguration * | configuration |
| Fuoten::Error * | error |
| bool | inOperation |
| Fuoten::AbstractNotificator * | notificator |
| bool | ready |
| int | starred |
| int | totalUnread |
Public Member Functions | |
| AbstractStorage (QObject *parent=nullptr) | |
| ~AbstractStorage () override | |
| virtual void | clearQueue () |
| virtual Q_INVOKABLE void | clearStorage () |
| AbstractConfiguration * | configuration () const |
| virtual bool | enqueueItem (FuotenEnums::QueueAction action, Article *article) |
| virtual Q_INVOKABLE bool | enqueueMarkAllItemsRead () |
| virtual bool | enqueueMarkFeedRead (qint64 feedId, qint64 newestItemId) |
| virtual bool | enqueueMarkFolderRead (qint64 folderId, qint64 newestItemId) |
| Error * | error () const |
| virtual Article * | getArticle (qint64 id, int bodyLimit=0)=0 |
| virtual Q_INVOKABLE QString | getArticleBody (qint64 id)=0 |
| virtual QList< Article * > | getArticles (const QueryArgs &args)=0 |
| virtual void | getArticlesAsync (const QueryArgs &args) |
| virtual Feed * | getFeed (qint64 id)=0 |
| virtual QList< Feed * > | getFeeds (const QueryArgs &args)=0 |
| virtual QList< Folder * > | getFolders (FuotenEnums::SortingRole sortingRole=FuotenEnums::Name, Qt::SortOrder sortOrder=Qt::AscendingOrder, const IdList &ids=IdList(), FuotenEnums::Type idType=FuotenEnums::Folder, int limit=0)=0 |
| virtual qint64 | getNewestItemId (FuotenEnums::Type type=FuotenEnums::All, qint64 id=-1)=0 |
| virtual void | init ()=0 |
| bool | inOperation () const |
| AbstractNotificator * | notificator () const |
| bool | ready () const |
| void | setConfiguration (AbstractConfiguration *nConfiguration) |
| void | setNotificator (AbstractNotificator *notificator) |
| virtual int | starred () const |
| virtual int | totalUnread () const |
Public Slots | |
| virtual void | allItemsMarkedRead (qint64 newestItemId)=0 |
| virtual void | feedCreated (const QJsonDocument &json)=0 |
| virtual void | feedDeleted (qint64 id)=0 |
| virtual void | feedMarkedRead (qint64 id, qint64 newestItem)=0 |
| virtual void | feedMoved (qint64 id, qint64 targetFolder)=0 |
| virtual void | feedRenamed (qint64 id, const QString &newTitle)=0 |
| virtual void | feedsRequested (const QJsonDocument &json)=0 |
| virtual void | folderCreated (const QJsonDocument &json)=0 |
| virtual void | folderDeleted (qint64 id)=0 |
| virtual void | folderMarkedRead (qint64 id, qint64 newestItem)=0 |
| virtual void | folderRenamed (qint64 id, const QString &newName)=0 |
| virtual void | foldersRequested (const QJsonDocument &json)=0 |
| virtual void | itemMarked (qint64 itemId, bool unread)=0 |
| virtual void | itemsMarked (const Fuoten::IdList &itemIds, bool unread)=0 |
| virtual void | itemsRequested (const QJsonDocument &json)=0 |
| virtual void | itemsStarred (const QList< QPair< qint64, QString > > &articles, bool star)=0 |
| virtual void | itemStarred (qint64 feedId, const QString &guidHash, bool star)=0 |
Signals | |
| void | configurationChanged (Fuoten::AbstractConfiguration *configuration) |
| void | createdFeed (qint64 id, qint64 folderId) |
| void | createdFolder (qint64 id, const QString &name) |
| void | deletedFeed (qint64 id) |
| void | deletedFolder (qint64 id) |
| void | errorChanged (Fuoten::Error *error) |
| void | gotArticlesAsync (const Fuoten::ArticleList &articles) |
| void | inOperationChanged (bool inOperation) |
| void | markedAllItemsRead (qint64 newestItemId) |
| void | markedAllItemsReadInQueue () |
| void | markedItem (qint64 itemId, bool unread) |
| void | markedItems (const Fuoten::IdList &itemIds, bool unread) |
| void | markedReadFeed (qint64 id, qint64 newestItem) |
| void | markedReadFeedInQueue (qint64 feedId, qint64 newestItemId) |
| void | markedReadFolder (qint64 id, qint64 newestItem) |
| void | markedReadFolderInQueue (qint64 folderId, qint64 newestItemId) |
| void | movedFeed (qint64 id, qint64 targetFolder) |
| void | notificatorChanged (Fuoten::AbstractNotificator *notificator) |
| void | queueCleared () |
| void | readyChanged (bool ready) |
| void | renamedFeed (qint64 id, const QString &newName) |
| void | renamedFolder (qint64 id, const QString &newName) |
| void | requestedFeeds (const Fuoten::IdList &updatedFeeds, const Fuoten::IdList &newFeeds, const Fuoten::IdList &deletedFeeds) |
| void | requestedFolders (const QList< QPair< qint64, QString > > &updatedFolders, const QList< QPair< qint64, QString > > &newFolders, const Fuoten::IdList &deletedFolders) |
| void | requestedItems (const Fuoten::IdList &updatedItems, const Fuoten::IdList &newItems, const Fuoten::IdList &deletedItems) |
| void | starredChanged (int starred) |
| void | starredItem (qint64 feedId, const QString &guidHash, bool starred) |
| void | starredItems (const QList< QPair< qint64, QString > > &articles, bool star) |
| void | storageCleared () |
| void | totalUnreadChanged (int totalUnread) |
Protected Slots | |
| virtual void | setStarred (int nStarred) |
| virtual void | setTotalUnread (int nTotalUnread) |
Protected Member Functions | |
| void | notify (AbstractNotificator::Type type, QtMsgType severity, const QVariant &data) const |
| void | notify (const Error *e) const |
| void | setError (Error *nError) |
| void | setInOperation (bool nInOperation) |
| void | setReady (bool nReady) |
Abstract class to handle the storage of requested News App data.
Reimplement this class to store the data requested from the News App API. You can set your derived class to the Component::storage property, that all classes use that derive from Component. Also BaseItem hast the BaseItem::storage property for derived classes, that is used to set the storage handler to API classes that perfrom API actions.
If you derive from AbstractStorage, initialize the storage in init() and set setReady() to true when your storage is ready to handle data.
|
readwrite |
Pointer to an AbstractConfiguration derived class.
| AbstractConfiguration* | configuration() const |
| void | setConfiguration(AbstractConfiguration *nConfiguration) |
| void | configurationChanged(AbstractConfiguration *configuration) |
|
read |
Returns a pointer to an Error object, if any error occures, otherwise a nullptr.
| Error* | error() const |
| void | errorChanged(Error *error) |
|
read |
Returns true while the storage is in operation.
This will only be set to true by pure storage functions (like queue functions), not when processing requested data.
| bool | inOperation() const |
| void | inOperationChanged(bool inOperation) |
|
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).
|
read |
Returns true when the storage handler has finished its initialization.
| bool | ready() const |
| void | readyChanged(bool ready) |
|
read |
Amount of starred items.
| int | starred() const |
| void | starredChanged(int starred) |
|
read |
Total amount of unread items in the storage.
| int | totalUnread() const |
| void | totalUnreadChanged(int totalUnread) |
|
explicit |
Constructs a new abstract local storage with the given parent.
|
override |
Deconstructs the AbstractStorage object.
|
pure virtualslot |
Receives the reply data from the MarkAllItemsRead request.
Will mark all items in the local database as read which have an ID lower or equal to newestItemId.
|
virtual |
Clears the local queue. Does not revert the action itself.
The default implementation does nothing. When reimplementing this function, only remove the queue entry but do not revert the action already done locally. It will be called after working the queue.
Reimplemented in SQLiteStorage.
|
virtual |
Removes all data from the storage.
The default implementation does nothing. When reimplementing this, emit storageCleared() after successfully clear all stored data. Do not forget to also reset last sync time with AbstractConfiguration::setLastSync().
Reimplemented in SQLiteStorage.
| AbstractConfiguration * configuration | ( | ) | const |
Getter function for the configuration property.
|
signal |
This is emitted if the value of the configuration property changes.
|
signal |
Emit this after a new feed has been created.
Best loaction to emit this signal is your implementation of feedCreated(). The signal has to contain the id of the new feed it's parent folderId.
|
signal |
Emit this after a new folder has been created.
Best loaction to emit this signal is your implementation of folderCreated(). The signal has to contain the id and the name of the new folder.
|
signal |
Emit this after a feed has been deleted.
Best location to emit this signal is your implementation of feedDeleted(). The signal has to contain the id fo the deleted feed.
|
signal |
Emit this after a folder has been deleted.
Best location to emit this signal is your implementation of folderDeleted(). The signal has to contain the id fo the deleted folder.
|
virtual |
Enqueues an action for the given article.
When enqueueing an article, the performed action should already be saved in the local storage together with the queue action. If the article is marked as read for example, add the action to your local queue and also mark the article as read in your local storage.
The default implementation does nothing and returns false.
| action | the action that should be enqueued |
| article | pointer to the Article object that should be enqueued |
true if the enqueue was successful, otherwise false Reimplemented in SQLiteStorage.
|
virtual |
Adds all local articles that are unread to the queue and marks them as read.
After successfully addint the items/articles to the local queue, emit the markedAllItemsReadInQueue() signal. The default implementation does nothing and returns false.
true on success, otherwise false Reimplemented in SQLiteStorage.
|
virtual |
Adds all articles older than newestItemId in the feed identified by feedId as read to the local queue.
After successfully adding the items/articles to the local queue, emit the markedReadFeedInQueue() signal. The default implementation does nothing and returns false.
| feedId | ID of the feed to be marked as read |
| newestItemId | ID of the newest item in the feed |
true on success, otherwise false Reimplemented in SQLiteStorage.
|
virtual |
Adds all articles older than newestItemId in the folder identified folderId as read to the local queue.
After successfully adding the items/articles to the local queue, emit the markedReadFolderInQueue() signal. The default implementation does nothing and returns false.
| folderId | ID of the folder to be marked as read |
| newestItemId | ID of the newest item in the folder |
true on success, otherwise false Reimplemented in SQLiteStorage.
| Error * error | ( | ) | const |
Retruns a pointer to an Error object, if any error occures, otherwise returns a nullptr.
|
signal |
Emitted whenever the error property changes.
|
pure virtualslot |
Receives the reply data of the CreateFeed request.
Implement this in a derived class to store new feed data, for example in a local SQL databse. You my want to emit createdFeed() in your implementation after you processed the data.
|
pure virtualslot |
Receives the reply data of the DeleteFeed request.
Will delete the feed identified by id in the local storage and emits the deletedFeed() signal.
|
pure virtualslot |
Receives the reply data of the MarkFeedRead request.
Will mark all items in the feed identified by id that have a lower ID than newestItem as read in the local storage. Will than emit the markedReadFeed() signal.
|
pure virtualslot |
Receives the reply data of the MoveFeed request.
Will move the feed identified by id to the targetFolder id and emits the movedFeed() signal.
|
pure virtualslot |
Receives the reply data of the RenameFeed request.
Will rename the feed identified by id to the newTitle and emits the renamedFeed() signal.
|
pure virtualslot |
Receives the reply data of the GetFeeds request.
Implement this in a derived class to store feed data, for example in a local SQL database. You may want to emit requestedFeeds() in your implementation after you processed the data.
|
pure virtualslot |
Receives the reply data of the CreateFolder request.
Implement this in a derived class to store new folder data, for example in a local SQL databse. You my want to emit createdFolder() in your implementation after you processed the data.
|
pure virtualslot |
Receives the reply data of the DeleteFolder request.
Will delete the folder identified by id in the local storage and emits the deletedFolder() signal.
|
pure virtualslot |
Receives the reply data of the MarkFolderRead request.
Will mark all items in the folder identified by id that have a lower ID than newestItem as read in the local storage. Will than emit the markedReadFolder() signal.
|
pure virtualslot |
Receives the reply data of the RenameFolder request.
Will rename the folder identified by id in the local storage to newName and emits the renamedFolder() signal.
|
pure virtualslot |
Receives the reply data of the GetFolders request.
Implement this in a derived class to store folder data, for example in a local SQL database. You may want to emit requestedFolders() in your implementation after you processed the data.
|
pure virtual |
Returns the Article identified by id.
bodyLimit limits the size of the body text in number of characters. Values lower than 0 will return no body text, 0 will return the full body text, any other positive value will return a body stripped from HTML tags and limited to the amount of characters.
Returns a nullptr if the Article can not be found.
Implemented in SQLiteStorage.
|
pure virtual |
Returns the full body of an Article identified by id.
Implemented in SQLiteStorage.
Returns a list of Article objects from the local storage.
See QueryArgs for a list of possible query arguments.
Implemented in SQLiteStorage.
|
virtual |
Invokes a query for Article objects from the local storage, limited by args.
This should emit the gotArticlesAsync() signal containing a list of Article objects. The default implementation is not really asynchronous, it simply calls getArticles() and emits gotArticlesSync() with the return value of that function.
When reimplementing this and connecting to the gotArticlesSync() signal, be aware that the Article objects in the list might have been created in a different thread.
Reimplemented in SQLiteStorage.
|
pure virtual |
Returns the Feed identified by id.
Returns a nullptr if the Feed can not be found.
Implemented in SQLiteStorage.
Returns a list of Feed objects from the local storage.
See QueryArgs for a list of possible query arguments.
Implemented in SQLiteStorage.
|
pure virtual |
Returns a list of Folder objects from the local storage.
The returned list will be sorted by sortingRole and sortOrder. If ids is not empty, only folders with IDs of idType from the list will be returned. The idType specifies the id the folder is compared with. If the idType is not one of out of the table below, it will be treated as FuotenEnums::Folder.
| FuotenEnums::Folder | Only folders with an ID in ids will be returned |
| FuotenEnums::Feed | Only folders will be returned that contain feeds with an ID in ids |
| FuotenEnums::Item | Only folders will be returned that contain items with an ID in ids |
Setting limit > 0 returns only the amount of items up to that limit.
The Folder objects in the returned list will have their parent set to nullptr.
Implemented in SQLiteStorage.
|
pure virtual |
Returns the newest item/article ID for the given type.
Supported Types: FuotenEnums::Feed, FuotenEnums::Folder, FuotenEnums::All. For folder and feed type a valid id has to be provided that identifieds the folder or feed.
If the type does not match one of the supported or if there are not items, -1 is returned.
Implemented in SQLiteStorage.
|
signal |
Emit this after getArticlesAsync() has been called and articles have been queried.
Be aware that the objects in the list might have been created in a different thread when you connect to this signal.
| articles | list of Article objects |
|
pure virtual |
Initializes the storage handler.
For example, create your database layout. When finished set setReady() to true.
Implemented in SQLiteStorage.
| bool inOperation | ( | ) | const |
Getter function for the inOperation property.
|
signal |
This is emitted if the value of the inOperation property changes.
|
pure virtualslot |
Receives the reply data for the MarkItem request.
Will mark the item identified by itemId in the local storage as read or unread.
| itemId | ID of the item/article that has been marked |
| unread | true if the item has been marked as unread, false if marked as read |
|
pure virtualslot |
Receives the reply data for the MarkItems request.
Will mark the items identified by their ID in the itemIds as read if unread is set to false, otherwise it will mark them as unread. You should emit markedItems() in your implementation after you processed the data to update connected models.
| itemIds | IDs of articles that have been marked as read or unread |
| unread | true if the articles have been marked as unread, false if marked as read |
|
pure virtualslot |
Receives the reply data of the GetItems request.
Implement this in a derived class to store item data, for example in a local SQL database. You may want to emit requestedItems() in your implementation after you processed the data.
|
pure virtualslot |
Receives the reply data for the StarItems request.
The lists contains the item/article IDs and the guid hash of the items/articles that have been either starred or unstarred. You should emit starredItems() in your implementation after you processed the data to update connected models.
| articles | list of pairs of feed ID and guid hash of starred/unstarred articles |
| star | true if the articles have been starred, false if they have been unstarred |
|
pure virtualslot |
Receives the reply data from the StarItem request.
Will star or unstar the item/article identified by itemId and guidHash in the local storage.
| feedId | ID of the feed the item/article that has been starred or unstarred belongs to |
| guidHash | global unique ID hash of the item/article that has been starred or unstarred |
| star | true if the article has been starred, false if it has been unstarred |
|
signal |
Emit this signal after all items/articles have been marked as read.
Best location to emit this signal is your implementation of allItemsMarkedRead().
| newestItemId | highest/newest ID of the local available items/articles |
|
signal |
Emit this signal after all items/articles have been marked as read in the local queue.
Best location to emit this signal is your implemetation of enqueueMarkAllItemsRead().
|
signal |
Emit this after an item/article has been marked read or unread.
Best location to emit this signal is your implementation of itemMarked().
| itemId | the ID of the item/article that has been marked as read or unread |
| unread | true if the article has been marked as unread, false if marked as read |
|
signal |
Emit this after items/articles have been marked as read or unread.
Best location to emit this signal is your implementation of itemsMarked().
The lists have to conatin the item/article IDs that haven been marked as read or unread.
| itemIds | IDs of articles that have been marked as read or unread |
| unread | true if the articles have been marked as unread, false if marked as read |
|
signal |
Emit this after a feed has been marked as read.
Best location to emit this signal is your implementation of feedMarkedRead(). The signal has to contain the id of the feed that has been marked as read as well as the ID of the newestItem that has been marked as read.
|
signal |
Emit this after a feed has been marked as read in the local queue.
| feedId | ID of the feed that has been marked as read |
| newestItemId | ID of the newest item in the feed |
|
signal |
Emit this after a folder has been marked as read.
Best location to emit this signal is your implementation of folderMarkedRead(). The signal has to contain the id of the folder that has been marked as read as well as the ID of the newestItem that has been marked as read.
|
signal |
Emit this after a folder has been marked as read in the local queue.
Best location to emit this signal is your implementation of enqueueMarkFolderRead().
| folderId | ID of the folder that has been marked as read in the local queue |
| newestItemId | ID of the newest item in folder that has been marked as read in the local queue |
|
signal |
Emit this signal after a feed has been moved to another folder.
Best location to emit this signal is your implementation of feedMoved(). The signal has to contain the id of the moved feed and the targetFolder id.
| AbstractNotificator * notificator | ( | ) | const |
Getter function for the notificator property.
|
signal |
Notifier signal for the notificator property.
|
protected |
Checks if a notificator has been set and will use it to notify the user.
|
protected |
Checks if a notificator has been set and will use it to notify about an occured error.
|
signal |
This is emitted after the local queue has been cleared.
Emit this in your implementation of clearQueue().
| bool ready | ( | ) | const |
Returns true when the storage is ready to handle data, otherwise false.
|
signal |
Emitted whenever the ready property changes.
|
signal |
Emit this signal after a feed has been renamed.
Best location to emit this signal is your implementation of feedRename(). The signal has to contain the id of the renamed feed and the newName.
|
signal |
Emit this after a folder has been renamed.
Best location to emit this signal is your implementation of folderRenamed(). The signal has to contain the id and the newName of the folder.
|
signal |
Emit this after feeds have been received and processed.
Best location to emit this signal is your implementation of feedsRequested().
Every argument of the signal should contain a list of feed IDs that are either updated, new or deleted.
|
signal |
Emit this after folders have been received and processed.
Best location to emit this signal is your implementation of foldersRequested().
updatedFolders should contain a list of the database IDs and names of updated folders, newFolders should contain a list of databaes IDs and names of new folders, and deletedFolders should contain a list of database IDs of deleted folders.
|
signal |
Emit this after items/articles have been received and processed.
Best location to emit this signal is your implementation of itemsRequested().
Every argument of the signal should contain a list of item IDs that are either updated, new or deleted.
| updatedItems | list of IDs from items that have been updated |
| newItems | list of IDs from items that are new in the local storage |
| deletedItems | list of IDs from items that have been remove from the local storage |
| void setConfiguration | ( | AbstractConfiguration * | nConfiguration | ) |
Setter function for the configuration property. Emits the configurationChanged() signal if nConfiguration is not equal to the stored value.
|
protected |
Setter function for the inOperation property. Emits the inOperationChanged() signal if nInOperation is not equal to the stored value.
| void setNotificator | ( | AbstractNotificator * | notificator | ) |
Setter function for the notificator property.
|
protected |
Set this to true when the storage has finished it's initialization.
|
protectedvirtualslot |
Sets the total number of starred articles.
|
protectedvirtualslot |
Sets the total number of unread articles.
|
virtual |
Returns the total number of starred articles.
|
signal |
This signal is emitted if the amount of total starred articles changes.
|
signal |
Emit this after an item/article has been starred or unstarred.
Best location to emit this signal is your implementation of itemStarred().
| feedId | the ID of the feed the item/article that has been starred or unstarred belongs to |
| guidHash | the global unique ID hash of the article that has been starred or unstarred |
| starred | true if the article has been starred, false if it has been unstarred |
|
signal |
Emit this after items/articles have been starred or unstarred.
Best location to emit this signal is your implementation of itemsStarred().
| articles | list of pairs of feed ID and guid hash of starred/unstarred articles |
| star | true if the articles have been starred, false if they have been unstarred |
|
signal |
This is emitted after the local storage has been cleared.
Emit this in your implementation of clearStorage() after all local data has been deleted successfully.
|
virtual |
Returns the total number of unread articles.
|
signal |
This signal is emitted if the amount of total unread articles changes.