QXmppDiscoInfoWatch Class
Lightweight handle to a watch on the service discovery information of an entity. More...
| Header: | #include <QXmppDiscoveryManager.h> |
| Since: | QXmpp 1.17 |
Public Types
| enum class | State { Unknown, Loading, Loaded, Stale, Error } |
Public Functions
| QXmppDiscoInfoWatch() | |
| QBindable<bool> | changesTracked() const |
| QBindable<std::optional<QXmppDiscoInfo>> | info() const |
| void | refresh() |
| QBindable<QXmppDiscoInfoWatch::State> | state() const |
(since QXmpp 1.17) QXmppDiscoFeatureWatch | watchFeature(const QString &feature) const |
(since QXmpp 1.17) QXmppDiscoFeatureWatch | watchFeature(QXmpp::Namespace feature) const |
(since QXmpp 1.17) QXmppDiscoFeatureWatch | watchFeatures(const QStringList &features) const |
(since QXmpp 1.17) QXmppDiscoFeatureWatch | watchFeatures(const QList<QXmpp::Namespace> &features) const |
Detailed Description
Returned by QXmppDiscoveryManager::watchInfo(), QXmppDiscoveryManager::watchServerInfo() and QXmppDiscoveryManager::watchAccountInfo(). Cheap to copy — all copies and all other watches on the same entity share the same underlying state. When the last copy goes out of scope, the watch is automatically unregistered from the discovery manager.
Member Type Documentation
enum class QXmppDiscoInfoWatch::State
| Constant | Value | Description |
|---|---|---|
QXmppDiscoInfoWatch::State::Unknown | 0 | No information is available and no request is running, e.g. because the client is not connected or the entity is unavailable. |
QXmppDiscoInfoWatch::State::Loading | 1 | The information is being requested for the first time. |
QXmppDiscoInfoWatch::State::Loaded | 2 | The information is up to date. |
QXmppDiscoInfoWatch::State::Stale | 3 | The information is from an earlier point in time and may be outdated, e.g. after a new stream has been started. A new request is running or will be started once the client is connected or the presence of the entity has been received. |
QXmppDiscoInfoWatch::State::Error | 4 | The entity responded with an error, e.g. because it does not exist. |
The information is available exactly in the states Loaded and Stale. A watch that has information never goes back to Loading, so user interfaces can keep showing it while it is refreshed.
Member Function Documentation
QXmppDiscoInfoWatch::QXmppDiscoInfoWatch()
Constructs a watch that is not connected to any entity.
Its state stays Unknown and it never contains information.
QBindable<bool> QXmppDiscoInfoWatch::changesTracked() const
Returns whether changes of the information are tracked.
If changes are tracked, the information is requested again whenever it changes, so information in the state Loaded stays up to date. This is the case for MUC rooms that have been joined using QXmppMucManagerV2 and for available entities that announce XEP-0115: Entity Capabilities in their presence.
The information of full JIDs is dropped when the entity becomes unavailable or available again, as the JID may refer to another entity then, e.g. a MUC occupant. Unavailable entities are in the state Unknown until they become available again.
Otherwise the information is a snapshot from the time it has been requested. Use refresh() to request it again.
QBindable<std::optional<QXmppDiscoInfo>> QXmppDiscoInfoWatch::info() const
Returns the watched information.
Contains a value exactly if the state is Loaded or Stale.
void QXmppDiscoInfoWatch::refresh()
Requests the information again, even if it is up to date.
Existing information stays available with the state Stale until the response arrives.
QBindable<QXmppDiscoInfoWatch::State> QXmppDiscoInfoWatch::state() const
Returns the state of the watched information.
[since QXmpp 1.17] QXmppDiscoFeatureWatch QXmppDiscoInfoWatch::watchFeature(const QString &feature) const
Returns a watch on whether the entity supports feature.
This function was introduced in QXmpp 1.17.
[since QXmpp 1.17] QXmppDiscoFeatureWatch QXmppDiscoInfoWatch::watchFeature(QXmpp::Namespace feature) const
Returns a watch on whether the entity supports feature.
This is an overloaded function.
This function was introduced in QXmpp 1.17.
[since QXmpp 1.17] QXmppDiscoFeatureWatch QXmppDiscoInfoWatch::watchFeatures(const QStringList &features) const
Returns a watch on whether the entity supports all of features.
The feature watch shares the information of this watch and does not cause any requests on its own.
This function was introduced in QXmpp 1.17.
[since QXmpp 1.17] QXmppDiscoFeatureWatch QXmppDiscoInfoWatch::watchFeatures(const QList<QXmpp::Namespace> &features) const
Returns a watch on whether the entity supports all of features.
This is an overloaded function.
This function was introduced in QXmpp 1.17.