QXmpp::Messages::SelectEncryption Struct

struct QXmpp::Messages::SelectEncryption
Header: #include <QXmppMessages.h>

Detailed Description

Asynchronous hook selecting the end-to-end encryption of an outgoing message.

It runs for every message, also for messages sent by managers on their own (e.g. receipts), except for messages that already contain encrypted elements, e.g. a key exchange created by a provider. They are sent as they are. Messages of managers that are only meaningful with a specific encryption, e.g. the trust messages of QXmppAtmManager, are encrypted with it and do not run through this hook either. Handlers run in order and may override the encryption set by earlier ones. Handlers that need to wait, e.g. for a database, return a QXmppTask, others can return void:

client->hooks(this).add<QXmpp::Messages::SelectEncryption>([this](QXmpp::Messages::EncryptionSelection &selection) {
    if (isEncryptionEnabled(selection.to())) {
        selection.setEncryption(QXmpp::E2ee::Omemo2);
    }
});

If no encryption is selected, sensitive stanzas sent by QXmpp's managers (and via the deprecated QXmppClient::sendSensitive()) are encrypted with the deprecated encryption extension (QXmppClient::setEncryptionExtension()) as in earlier versions.