QXmpp::Messages Namespace

namespace QXmpp::Messages
Header: #include <QXmppClient.h>
Since: QXmpp 1.18

Classes

(since QXmpp 1.18) class ArchiveInfo
(since QXmpp 1.18) class BodyOnlyMessage
struct ConfirmDelivery
(since QXmpp 1.18) struct Confirmation
(since QXmpp 1.18) class Context
class EncryptionSelection
class OutgoingMessage
struct Prepare
struct PrepareBodyOnly
struct Received
struct ResolveRecipients
struct ResolveSender
struct SelectEncryption
(since QXmpp 1.18) class Sent

Types

enum class DecryptionState { NotEncrypted, Decrypted, NoEnvelope, SentByThisDevice, Failed, …, AlreadyDecrypted }
(since QXmpp 1.18) enum class DeliveryState { Written, ServerAcknowledged, Confirmed }
enum class Origin { Stream, CarbonReceived, CarbonSent, Mam, Injected }

Detailed Description

Processing of incoming and outgoing messages.

Incoming messages run through these phases:

  1. Unwrap: the stream, carbons and MAM create a Context with their Origin.
  2. ResolveSender: asynchronous, e.g. MUC sets the real sender.
  3. Decrypt: asynchronous, via the provider of the encryption method (QXmpp::E2ee::Provider).
  4. Received: synchronous, handlers consume the message.
  5. Deliver: QXmppClient::messageReceived() if no handler consumed the message.

Messages of archive queries skip the last two phases. QXmppMamManager::retrieve() returns their contexts to the caller of the query.

Messages of the same conversation are processed in the order in which they were received, also across the asynchronous decryption.

Messages sent via QXmppClient::sendMessage() and send() (and the deprecated QXmppClient::sendSensitive() and QXmppClient::reply()) run through these phases:

  1. SelectEncryption: asynchronous, usually the application selects the encryption with its policy per contact.
  2. Prepare: synchronous, handlers add elements or cancel sending.
  3. ResolveRecipients: asynchronous, only for encrypted messages, e.g. MUC sets the members of the room.
  4. Encrypt: asynchronous, via the provider of the selected encryption (QXmpp::E2ee::Provider). The public part of Explicit Message Encryption (XEP-0380: Explicit Message Encryption) and a fallback body are added for messages with a body. PrepareBodyOnly: synchronous, only if the provider encrypts the message for recipients of an encryption protecting only the body (e.g. OMEMO 0).
  5. Send.
  6. ConfirmDelivery: asynchronous, e.g. MUC waits for the reflection of the room. The task returned by QXmppClient::sendMessage() or send() finishes afterwards.

Outgoing messages to the same JID are sent in the order in which they were passed, also across the asynchronous phases. Waiting for the confirmation of the delivery does not block the next message.

The encryption of IQs is selected via QXmpp::Iq::SelectEncryption.

Type Documentation

enum class Messages::DecryptionState

ConstantValueDescription
QXmpp::Messages::DecryptionState::NotEncrypted0The message was not end-to-end encrypted.
QXmpp::Messages::DecryptionState::Decrypted1The message was decrypted.
QXmpp::Messages::DecryptionState::NoEnvelope2The message is encrypted, but not for this device.
QXmpp::Messages::DecryptionState::SentByThisDevice3The message is encrypted and has been sent by this device, which does not encrypt for itself, e.g. an own message reflected by a MUC room or MIX channel or retrieved via MAM. The application can match it with the sent message, e.g. via its origin ID.
QXmpp::Messages::DecryptionState::Failed4The decryption failed, see Context::decryptionError().
QXmpp::Messages::DecryptionState::Unsupported5There is no provider for the encryption method.
QXmpp::Messages::DecryptionState::AlreadyDecrypted6The message has already been decrypted before, e.g. it has been received twice or retrieved again via MAM. The application should ignore it without showing an error, as required by XEP-0384: OMEMO Encryption.

[since QXmpp 1.18] enum class Messages::DeliveryState

How far the delivery of a message sent via QXmppClient::sendMessage() has been confirmed.

ConstantValueDescription
QXmpp::Messages::DeliveryState::Written0The message has been written to the stream. Without Stream Management, it is unknown whether the server has received it.
QXmpp::Messages::DeliveryState::ServerAcknowledged1The own server has acknowledged the message via XEP-0198: Stream Management. It may not have reached the recipient yet.
QXmpp::Messages::DeliveryState::Confirmed2A handler of ConfirmDelivery has confirmed that the recipient has accepted the message, e.g. a MUC room by reflecting it.

This enum was introduced in QXmpp 1.18.

enum class Messages::Origin

Where an incoming message came from.

ConstantValueDescription
QXmpp::Messages::Origin::Stream0Received directly from the server.
QXmpp::Messages::Origin::CarbonReceived1Copy of a message received by another own device.
QXmpp::Messages::Origin::CarbonSent2Copy of a message sent by another own device.
QXmpp::Messages::Origin::Mam3Result of an archive query, only returned by QXmppMamManager::retrieve(). The context has a QXmpp::Messages::ArchiveInfo attachment.
QXmpp::Messages::Origin::Injected4Injected by an extension via QXmppClientExtension::injectMessage().