Obsolete Members for QXmpp

The following members of class QXmpp are deprecated. They are provided to keep old source code working. We strongly advise against using them in new code.

Types

(since QXmpp 1.5, deprecated) enum EncryptionMethod { NoEncryption, UnknownEncryption, Otr, LegacyOpenPgp, Ox, …, OMEMO }

Functions

(since QXmpp 1.5, deprecated) bool handleIqRequests(const QDomElement &element, QXmppClient *client, Handler handler)
(since QXmpp 1.5, deprecated) bool handleIqRequests(const QDomElement &element, const std::optional<QXmppE2eeMetadata> &e2eeMetadata, QXmppClient *client, Handler handler)

Type Documentation

[since QXmpp 1.5, deprecated] enum QXmpp::EncryptionMethod

This enum is deprecated. We strongly advise against using it in new code.

This enum describes different end-to-end encryption methods. These can be used to mark a stanza as encrypted or decrypted with a specific algorithm (e.g., for XEP-0380: Explicit Message Encryption).

ConstantValueDescription
QXmpp::NoEncryption0No encryption.
QXmpp::UnknownEncryption1Unknown encryption.
QXmpp::Otr2XEP-0364: Current Off-the-Record Messaging Usage

.

ConstantValueDescription
QXmpp::LegacyOpenPgp3XEP-0027: Current Jabber OpenPGP Usage

.

ConstantValueDescription
QXmpp::Ox4XEP-0373: OpenPGP for XMPP

.

ConstantValueDescription
QXmpp::Omemo05XEP-0384: OMEMO Encryption

.

ConstantValueDescription
QXmpp::Omemo16XEP-0384: OMEMO Encryption

since version 0.4.

ConstantValueDescription
QXmpp::Omemo27XEP-0384: OMEMO Encryption

since version 0.8.

ConstantValueDescription
QXmpp::OTROtrXEP-0364: Current Off-the-Record Messaging Usage

This enum is deprecated since QXmpp 1.5. Use QXmpp::Otr instead.

ConstantValueDescription
QXmpp::LegacyOpenPGPLegacyOpenPgpXEP-0027: Current Jabber OpenPGP Usage

This enum is deprecated since QXmpp 1.5. Use QXmpp::LegacyOpenPgp instead.

ConstantValueDescription
QXmpp::OXOxXEP-0373: OpenPGP for XMPP

This enum is deprecated since QXmpp 1.5. Use QXmpp::Ox instead.

ConstantValueDescription
QXmpp::OMEMOOmemo0XEP-0384: OMEMO Encryption

This enum is deprecated since QXmpp 1.5. Use QXmpp::Omemo0 instead.

This enum was introduced in QXmpp 1.5.

Function Documentation

[since QXmpp 1.5, deprecated] template <typename... IqTypes, typename Handler> bool QXmpp::handleIqRequests(const QDomElement &element, QXmppClient *client, Handler handler)

This function is deprecated. We strongly advise against using it in new code.

Parses IQ requests, calls a handler and sends an IQ result or error.

It is the easiest to explain this function with a few examples.

auto handled = QXmpp::handleIqRequests<QXmppVersionIq>(element, client, [](QXmppVersionIq iq) -> std::variant<QXmppVersionIq, QXmppStanza::Error> {
    if (iq.type() == QXmppIq::Get) {
        QXmppVersionIq response;
        response.setName(u"MyApp"_s);
        response.setVersion(u"1.0"_s);
        // id, to and type of the IQ are set automatically.
        return response;
    }
    return QXmppStanza::Error(QXmppStanza::Error::Cancel, QXmppStanza::Error::BadRequest, u"IQ must be of type 'get'."_s);
});

It is also possible to handle multiple IQ types.

auto handled = QXmpp::handleIqRequests<QXmppVersionIq, QXmppVCardIq>(element, client, [](std::variant<QXmppVersionIq, QXmppVCardIq> iqVariant) {
    // ...
});

It doesn't need to be a std::variant, it's only important that the object is callable with all the IQ types. You can for example use different lambdas per type using this 'overloaded' helper.

template<class... Ts>
struct overloaded : Ts... {
    using Ts::operator()...;
};

auto handled = QXmpp::handleIqRequests<QXmppVersionIq, QXmppVCardIq>(element, client, overloaded {
    [](QXmppVersionIq iq) {
        // ...
    },
    [](QXmppVCardIq iq) {
        // ...
    },
});

Another option is to pass an object with handleIq() functions.

auto handled = QXmpp::handleIqRequests<QXmppVersionIq, QXmppVCardIq>(element, client, this);
// will call this->handleIq(QXmppVersionIq) or this->handleIq(QXmppVCardIq)

The return type of the handler function can be:

  1. a QXmppIq based type
  2. a std::variant of QXmppIq based types (multiple are possible) and optionally also QXmppStanza::Error
  3. a QXmppTask of 1. or 2.

You don't need to set the values for id or the to address on the IQ result because that's done automatically. Unless you want to return an error IQ you also don't need to set the IQ type.

If you return an QXmppStanza::Error, a normal QXmppIq with the error will be sent.

element is the DOM element that might contain an IQ. client is the client that should be used to send the response. handler is a function that can handle the IQ types from the template parameter or an object that has handleIq() functions for each of the IQ types.

Returns whether the IQ could be parsed, handled and a response was or will be sent.

since QXmpp 1.18, add a handler via QXmpp::Iq::Received, it is called directly for its IQ requests:

hooks().add<QXmpp::Iq::Received<QXmpp::Iq::Get<VersionQuery>>>([](auto &&) {
    return VersionQuery { u"MyApp"_s, u"1.0"_s };
});

This function was introduced in QXmpp 1.5.

[since QXmpp 1.5, deprecated] template <typename... IqTypes, typename Handler> bool QXmpp::handleIqRequests(const QDomElement &element, const std::optional<QXmppE2eeMetadata> &e2eeMetadata, QXmppClient *client, Handler handler)

This function is deprecated. We strongly advise against using it in new code.

Parses IQ requests, calls a handler and sends an IQ result or error.

It is the easiest to explain this function with a few examples.

auto handled = QXmpp::handleIqRequests<QXmppVersionIq>(element, e2eeMetadata, client, [](QXmppVersionIq iq) -> std::variant<QXmppVersionIq, QXmppStanza::Error> {
    if (iq.type() == QXmppIq::Get) {
        QXmppVersionIq response;
        response.setName(u"MyApp"_s);
        response.setVersion(u"1.0"_s);
        // id, to and type of the IQ are set automatically.
        return response;
    }
    return QXmppStanza::Error(QXmppStanza::Error::Cancel, QXmppStanza::Error::BadRequest, u"IQ must be of type 'get'."_s);
});

It is also possible to handle multiple IQ types.

auto handled = QXmpp::handleIqRequests<QXmppVersionIq, QXmppVCardIq>(element, e2eeMetadata, client, [](std::variant<QXmppVersionIq, QXmppVCardIq> iqVariant) {
    // ...
});

It doesn't need to be a std::variant, it's only important that the object is callable with all the IQ types. You can for example use different lambdas per type using this 'overloaded' helper.

template<class... Ts>
struct overloaded : Ts... {
    using Ts::operator()...;
};

auto handled = QXmpp::handleIqRequests<QXmppVersionIq, QXmppVCardIq>(element, e2eeMetadata, client, overloaded {
    [](QXmppVersionIq iq) {
        // ...
    },
    [](QXmppVCardIq iq) {
        // ...
    },
});

Another option is to pass an object with handleIq() functions.

auto handled = QXmpp::handleIqRequests<QXmppVersionIq, QXmppVCardIq>(element, e2eeMetadata, client, this);
// will call this->handleIq(QXmppVersionIq) or this->handleIq(QXmppVCardIq)

The return type of the handler function can be:

  1. a QXmppIq based type
  2. a std::variant of QXmppIq based types (multiple are possible) and optionally also QXmppStanza::Error
  3. a QXmppTask of 1. or 2.

You don't need to set the values for id or the to address on the IQ result because that's done automatically. Unless you want to return an error IQ you also don't need to set the IQ type.

If you return an QXmppStanza::Error, a normal QXmppIq with the error will be sent.

The provided optional QXmppE2eeMetadata is set on the parsed IQ and used to encrypt the IQ response like the request.

element is the DOM element that might contain an IQ. e2eeMetadata is the end-to-end encryption metadata that is used to encrypt the response correctly and to be set on the parsed IQ. client is the client that should be used to send the response. handler is a function that can handle the IQ types from the template parameter or an object that has handleIq() functions for each of the IQ types.

Returns whether the IQ could be parsed, handled and a response was or will be sent.

since QXmpp 1.18, add a handler via QXmpp::Iq::Received, it is called directly for its IQ requests:

hooks().add<QXmpp::Iq::Received<QXmpp::Iq::Get<VersionQuery>>>([](auto &&) {
    return VersionQuery { u"MyApp"_s, u"1.0"_s };
});

This function was introduced in QXmpp 1.5.