QXmpp::Omemo::DeviceWatch Class

Handle to the devices of a JID, returned by OmemoManager::watchDevices(). More...

Header: #include <QXmppOmemoManager.h>
Since: QXmpp 1.18

Public Types

enum class State { Loading, Stale, Loaded, Error }

Public Functions

DeviceWatch()
QBindable<QString> authenticationUri() const
QBindable<QList<QXmpp::Omemo::Device>> devices() const
QXmpp::Jid jid() const
QBindable<QXmpp::Omemo::DeviceWatch::State> state() const
QBindable<QList<QXmpp::Omemo::Version>> supportedVersions() const
QBindable<QList<QXmpp::Omemo::Version>> usableVersions() const

Detailed Description

Cheap to copy: all copies share the same state. While a copy exists, the devices are kept up to date, see OmemoManager::watchDevices().

Member Type Documentation

enum class DeviceWatch::State

ConstantValueDescription
QXmpp::Omemo::DeviceWatch::State::Loading0The devices are being loaded from the storage or the device lists are being requested.
QXmpp::Omemo::DeviceWatch::State::Stale1The known devices are available, but the device lists have not been requested in the current session or notifications may have been missed while being disconnected. They are requested on the next login.
QXmpp::Omemo::DeviceWatch::State::Loaded2The device lists have been requested and are kept up to date.
QXmpp::Omemo::DeviceWatch::State::Error3A device list could not be requested. The known devices are still available.

Member Function Documentation

DeviceWatch::DeviceWatch()

Constructs a watch without a JID.

QBindable<QString> DeviceWatch::authenticationUri() const

Returns an xmpp: URI with the keys of the JID that the user has authenticated or distrusted, e.g. to be shown as a QR code for authenticating them by scanning it with another device (see OmemoManager::authenticate()). For the own JID, the keys of this device are included.

The keys of OMEMO 2 are contained in a trust message (XEP-0434: Trust Messages), the authenticated keys of OMEMO 0 as fingerprints in the format of Conversations (omemo-sid-<device ID>=<fingerprint>), which clients only supporting OMEMO 0 read. Without such keys, it contains only the JID.

QBindable<QList<QXmpp::Omemo::Device>> DeviceWatch::devices() const

Returns the devices listed in the device lists of all versions, the devices only using OMEMO 0 first, each sorted by ID. A device using both versions is listed once with OMEMO 2 and its key of OMEMO 0 (Device::omemo0KeyId) as soon as its key of OMEMO 2 is known. For the own JID, this device is not included.

QXmpp::Jid DeviceWatch::jid() const

Returns the bare JID whose devices are watched.

QBindable<QXmpp::Omemo::DeviceWatch::State> DeviceWatch::state() const

Returns whether the device lists have been requested.

QBindable<QList<QXmpp::Omemo::Version>> DeviceWatch::supportedVersions() const

Returns the versions with listed devices, also versions that are not enabled. It can be used to choose the version for a chat.

QBindable<QList<QXmpp::Omemo::Version>> DeviceWatch::usableVersions() const

Returns the enabled versions with at least one device that messages would be encrypted for, i.e. with an accepted trust level (the default ones of QXmppSendStanzaParams) and still responding. A device whose key is not known yet is usable after the watch has fetched it.

It tells whether a message to the JID can be encrypted. For a group chat, a message can be encrypted if a version is usable for any of its participants. Otherwise, sending fails with QXmpp::SendError::NoEncryptionRecipients. The message should not be sent unencrypted without asking the user: the server could hide the devices.

It is computed from the stored data, so it is also available while being disconnected.