QXmpp::Iq::Stanza Struct

template <QXmpp::Iq::Type T, typename Payload> struct QXmpp::Iq::Stanza

An IQ stanza of type T with a typed payload. More...

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

Public Functions

void toXml(QXmlStreamWriter *writer) const

Public Variables

QXmpp::Jid from
QString id
QString lang
Payload payload
QXmpp::Jid to

Static Public Members

std::optional<QXmpp::Iq::Stanza<T, Payload>> fromDom(const QDomElement &el)

Detailed Description

Use the aliases QXmpp::Iq::Get, QXmpp::Iq::Set, QXmpp::Iq::Result and QXmpp::Iq::Error.

Requests (get and set) always have exactly one payload. Results may have a payload, errors may contain the payload of the request in addition to the error (RFC 6120, section 8.2.3). Parsing rejects IQs violating these rules or without an id.

The stanzas are aggregates, so only the needed fields can be set via designated initializers:

QXmpp::Iq::Get<VersionQuery> iq { .to = jid, .payload = VersionQuery {} };

The payload needs a static XmlTag, needs to be parsable from a QDomElement and serializable to a QXmlStreamWriter, like the elements of QXmpp::Xml::Registry.

Member Function Documentation

[static] std::optional<QXmpp::Iq::Stanza<T, Payload>> Stanza::fromDom(const QDomElement &el)

Parses the IQ from el.

Returns nothing if the type or the payload does not match, the id is empty, an address is not a valid JID or the IQ does not contain exactly one child element (RFC 6120, section 8.2.3).

void Stanza::toXml(QXmlStreamWriter *writer) const

Serializes the IQ to writer.

Member Variable Documentation

QXmpp::Jid Stanza::from

JID of the sender

QString Stanza::id

Id of the IQ, required for serialization

QString Stanza::lang

Language of the IQ (xml:lang)

Payload Stanza::payload

Payload of the IQ

QXmpp::Jid Stanza::to

JID of the recipient

Related Non-Members

[alias] template <typename Payload = void> Error

IQ response of type error, optionally with the payload Payload of the request.

[alias] template <typename Payload> Get

IQ request of type get with the payload Payload.

[alias] template <typename Payload = void> Result

IQ response of type result with the payload Payload, by default without payload.

[alias] template <typename Payload> Set

IQ request of type set with the payload Payload.