QXmppClientExtension Class

The QXmppClientExtension class is the base class for QXmppClient extensions. More...

Public Functions

Protected Functions

QXmppClient *client() const
(since QXmpp 1.18) QXmpp::Hooks hooks() const
(since QXmpp 1.5) void injectIq(const QDomElement &element, const std::optional<QXmppE2eeMetadata> &e2eeMetadata)
(since QXmpp 1.5) bool injectMessage(QXmppMessage &&message)
virtual void onRegistered(QXmppClient *client)
virtual void onUnregistered(QXmppClient *client)
virtual void setClient(QXmppClient *client)

Detailed Description

If you want to extend QXmppClient, for instance to support an IQ type which is not natively supported, you can subclass QXmppClientExtension and add handlers to hooks, e.g. QXmpp::Client::StanzaReceived for incoming stanzas or QXmpp::Messages::Received for incoming messages. You can then add your extension to the client instance using QXmppClient::addExtension().

Member Function Documentation

QXmppClientExtension::QXmppClientExtension()

Constructs a QXmppClient extension.

[protected] QXmppClient *QXmppClientExtension::client() const

Returns the client which loaded this extension.

See also setClient().

[protected, since QXmpp 1.18] QXmpp::Hooks QXmppClientExtension::hooks() const

Returns the hooks of the client with this extension as the owner of added handlers.

Handlers can already be added in the constructor of the extension. All handlers, whenever they were added, are active from the time the extension is added to a client until it is removed or destroyed. An extension can only be added to one client. Hooks can only be run while the extension is added to a client.

This function was introduced in QXmpp 1.18.

[protected, since QXmpp 1.5] void QXmppClientExtension::injectIq(const QDomElement &element, const std::optional<QXmppE2eeMetadata> &e2eeMetadata)

Injects the IQ element into the client.

The IQ is handled like any other stanza received via the XMPP stream.

e2eeMetadata is the end-to-end encryption metadata for the IQ. It should be set if the stanza has been decrypted with an end-to-end encryption.

This function was introduced in QXmpp 1.5.

[protected, since QXmpp 1.5] bool QXmppClientExtension::injectMessage(QXmppMessage &&message)

Injects a message stanza into the client. Returns whether the stanza was handled.

The stanza is processed by the client with all extensions implementing MessageHandler.

message.

This function was introduced in QXmpp 1.5.

[virtual protected] void QXmppClientExtension::onRegistered(QXmppClient *client)

Called after the extension has been added to the QXmppClient client.

[virtual protected] void QXmppClientExtension::onUnregistered(QXmppClient *client)

Called after the extension has been removed from the QXmppClient client.

[virtual protected] void QXmppClientExtension::setClient(QXmppClient *client)

Sets the client which loaded this extension.

See also client().