QXmppRosterStorage Class
Storage backend used by QXmppRosterManager to cache the roster between sessions (RFC 6121 §2.6 Roster Versioning). More...
| Header: | #include <QXmppRosterStorage.h> |
| Since: | QXmpp 1.16 |
| Inherited By: |
- List of all members, including inherited members
- QXmppRosterStorage is part of Managers.
Public Types
| struct | RosterCache |
Public Functions
| virtual QXmppTask<void> | clear() = 0 |
| virtual QXmppTask<QXmppRosterStorage::RosterCache> | load() = 0 |
| virtual QXmppTask<void> | removeItem(const QString &version, const QString &bareJid) = 0 |
| virtual QXmppTask<void> | replaceAll(const QString &version, const std::vector<QXmppRosterIq::Item> &items) = 0 |
| virtual QXmppTask<void> | upsertItem(const QString &version, const QXmppRosterIq::Item &item) = 0 |
Detailed Description
Implementations are responsible for persisting the version string returned by the server together with the current set of roster items. QXmppRosterManager owns a default in-memory implementation (QXmppRosterMemoryStorage); callers that want real persistence implement this interface and pass an instance via QXmppRosterManager::setStorage() before connecting to the server.
All operations are asynchronous so that disk- or network-backed implementations can run off the GUI thread. Each mutating operation carries the new roster version so that the backend can persist the item change and the version atomically.
Ordering
Implementations MUST apply mutations to persistent state in the order they are invoked on a given instance. The returned QXmppTask values may complete in any order — only the visible side effect needs to be ordered. This is because consecutive operations are not commutative: a later upsert for the same JID, or a later version, must not be overwritten by an earlier one landing afterwards. A typical implementation funnels all writes through a single worker / serialized queue.
The storage instance is scoped to a single account. Multi-account applications should either instantiate one storage object per QXmppRosterManager or implement their own JID-scoped backend.
Member Function Documentation
[pure virtual] QXmppTask<void> QXmppRosterStorage::clear()
Wipes all persisted data (items and version). Used on account switch or explicit logout.
[pure virtual] QXmppTask<QXmppRosterStorage::RosterCache> QXmppRosterStorage::load()
Loads the persisted roster.
[pure virtual] QXmppTask<void> QXmppRosterStorage::removeItem(const QString &version, const QString &bareJid)
Removes the item with the given bareJid (if present) and stores the new version. Called for roster pushes with subscription == Remove.
[pure virtual] QXmppTask<void> QXmppRosterStorage::replaceAll(const QString &version, const std::vector<QXmppRosterIq::Item> &items)
Replaces every persisted item with the given list of items and stores the new version. Called when the server returns a full roster snapshot.
[pure virtual] QXmppTask<void> QXmppRosterStorage::upsertItem(const QString &version, const QXmppRosterIq::Item &item)
Inserts or replaces a single item and stores the new version. Called for roster pushes with subscription != Remove.