QXmpp::Messages::Context Class

class QXmpp::Messages::Context
Header: #include <QXmppMessageContext.h>
Since: QXmpp 1.18

Public Functions

Context(QXmppMessage &&message, QXmpp::Messages::Origin origin)
T &attach(T value)
T *attachment()
const T *attachment() const
const QString &conversationJid() const
const std::optional<QXmppError> &decryptionError() const
QXmpp::Messages::DecryptionState decryptionState() const
const std::optional<QXmppE2eeMetadata> &e2eeMetadata() const
QXmppMessage &message()
const QXmppMessage &message() const
QXmpp::Messages::Origin origin() const
const QString &senderJid() const
void setConversationJid(const QString &jid)
void setSenderJid(const QString &jid)

Detailed Description

State of an incoming message while it is processed.

Member Function Documentation

Context::Context(QXmppMessage &&message, QXmpp::Messages::Origin origin)

Creates a context for message from origin.

The sender is the bare JID of 'from'. The conversation is the bare JID of 'to' for Origin::CarbonSent and the one of 'from' otherwise.

template <typename T> T &Context::attach(T value)

Attaches value, replacing an attached value of the same type, and returns it.

template <typename T> T *Context::attachment()

Returns the attached value of type T or nullptr.

template <typename T> const T *Context::attachment() const

This is an overloaded function.

const QString &Context::conversationJid() const

Returns the bare JID of the conversation, i.e. of the contact or the room.

See also setConversationJid().

const std::optional<QXmppError> &Context::decryptionError() const

Returns the error if the decryption failed.

QXmpp::Messages::DecryptionState Context::decryptionState() const

Returns the result of the decryption.

const std::optional<QXmppE2eeMetadata> &Context::e2eeMetadata() const

Returns the metadata of the end-to-end encryption if the message was decrypted.

QXmppMessage &Context::message()

Returns the message.

const QXmppMessage &Context::message() const

This is an overloaded function.

QXmpp::Messages::Origin Context::origin() const

Returns where the message came from.

const QString &Context::senderJid() const

Returns the bare JID of the real sender.

For messages from a MUC room, it is set by the QXmpp::Messages::ResolveSender handler of the MUC manager if the real JID is known. The decryption uses it to look up the keys.

See also setSenderJid().

void Context::setConversationJid(const QString &jid)

Sets the bare JID of the conversation to jid.

See also conversationJid().

void Context::setSenderJid(const QString &jid)

Sets the bare JID of the real sender to jid.

See also senderJid().