QXmppDiscoFeatureWatch Class

Lightweight handle to a watch on whether an entity supports features. More...

Header: #include <QXmppDiscoveryManager.h>
Since: QXmpp 1.17

Public Functions

QXmppDiscoFeatureWatch()
(since QXmpp 1.17) QXmppTask<bool> resolve() const
QBindable<QXmppDiscoInfoWatch::State> state() const
QBindable<bool> supported() const

Detailed Description

Returned by QXmppDiscoInfoWatch::watchFeature() and QXmppDiscoInfoWatch::watchFeatures(). Cheap to copy — all copies share the same underlying state. The feature watch keeps the info watch it has been created from alive.

Member Function Documentation

QXmppDiscoFeatureWatch::QXmppDiscoFeatureWatch()

Constructs a watch that is not connected to any entity.

Its state stays Unknown and the features are never supported.

[since QXmpp 1.17] QXmppTask<bool> QXmppDiscoFeatureWatch::resolve() const

Returns whether the entity supports all watched features, as soon as that is known.

If the information is Loaded or Stale, the task finishes immediately with the current value. Otherwise it finishes once the information has been received, with false if the entity responded with an error. Until then the information is requested, also after reconnections, even if no other copy of the watch exists anymore.

If the watch is not connected to a QXmppDiscoveryManager, the task finishes immediately with false. If the manager is destroyed before the information is known, the task is cancelled.

if (co_await manager->watchServerSupport().resolve()) {
    // use the feature
}

This function was introduced in QXmpp 1.17.

QBindable<QXmppDiscoInfoWatch::State> QXmppDiscoFeatureWatch::state() const

Returns the state of the information the support is based on.

QBindable<bool> QXmppDiscoFeatureWatch::supported() const

Returns whether the entity supports all watched features.

As long as the information has not been received, this is false. Check state() to distinguish missing support from missing information, e.g. before telling the user that a feature is unsupported.

The information may be outdated in the state QXmppDiscoInfoWatch::State::Stale. If the entity responded with an error, no feature is supported.