QXmppPubSubManager Class

The QXmppPubSubManager aims to provide publish-subscribe functionality as specified in XEP-0060: Publish-Subscribe (PubSub). More...

Header: #include <QXmppPubSubManager>
Since: QXmpp 1.5
Inherits: QXmppClientExtension

Public Types

Public Functions

QXmppPubSubManager()
virtual ~QXmppPubSubManager()
QXmppTask<QXmppPubSubManager::Result> cancelNodeConfiguration(const QString &service, const QString &nodeName)
QXmppTask<QXmppPubSubManager::Result> cancelOwnPepNodeConfiguration(const QString &nodeName)
QXmppTask<QXmppPubSubManager::Result> configureNode(const QString &service, const QString &nodeName, const QXmppPubSubNodeConfig &config)
QXmppTask<QXmppPubSubManager::Result> configureOwnPepNode(const QString &nodeName, const QXmppPubSubNodeConfig &config)
QXmppTask<QXmppPubSubManager::InstantNodeResult> createInstantNode(const QString &jid)
QXmppTask<QXmppPubSubManager::InstantNodeResult> createInstantNode(const QString &jid, const QXmppPubSubNodeConfig &config)
QXmppTask<QXmppPubSubManager::Result> createNode(const QString &jid, const QString &nodeName)
QXmppTask<QXmppPubSubManager::Result> createNode(const QString &jid, const QString &nodeName, const QXmppPubSubNodeConfig &config)
QXmppTask<QXmppPubSubManager::Result> createOwnPepNode(const QString &nodeName)
QXmppTask<QXmppPubSubManager::Result> createOwnPepNode(const QString &nodeName, const QXmppPubSubNodeConfig &config)
QXmppTask<QXmppPubSubManager::Result> deleteNode(const QString &jid, const QString &nodeName)
QXmppTask<QXmppPubSubManager::Result> deleteOwnPepNode(const QString &nodeName)
QXmppTask<QXmppPubSubManager::Result> purgeItems(const QString &jid, const QString &nodeName)
QXmppTask<QXmppPubSubManager::Result> purgeOwnPepItems(const QString &nodeName)
QXmppTask<QXmppPubSubManager::AffiliationsResult> requestAffiliations(const QString &jid)
QXmppTask<QXmppPubSubManager::AffiliationsResult> requestAffiliations(const QString &jid, const QString &nodeName)
QXmppTask<QXmppPubSubManager::ItemIdsResult> requestItemIds(const QString &serviceJid, const QString &nodeName)
QXmppTask<QXmppPubSubManager::AffiliationsResult> requestNodeAffiliations(const QString &jid, const QString &nodeName)
QXmppTask<QXmppPubSubManager::NodeConfigResult> requestNodeConfiguration(const QString &service, const QString &nodeName)
QXmppTask<QXmppPubSubManager::NodesResult> requestNodes(const QString &jid)
QXmppTask<QXmppPubSubManager::ItemResult<T>> requestOwnPepItem(const QString &nodeName, QXmppPubSubManager::StandardItemId itemId)
QXmppTask<QXmppPubSubManager::ItemResult<T>> requestOwnPepItem(const QString &nodeName, const QString &itemId)
QXmppTask<QXmppPubSubManager::ItemIdsResult> requestOwnPepItemIds(const QString &nodeName)
QXmppTask<QXmppPubSubManager::ItemsResult<T>> requestOwnPepItems(const QString &nodeName)
QXmppTask<QXmppPubSubManager::NodeConfigResult> requestOwnPepNodeConfiguration(const QString &nodeName)
QXmppTask<QXmppPubSubManager::NodesResult> requestOwnPepNodes()
QXmppTask<QXmppPubSubManager::OptionsResult> requestSubscribeOptions(const QString &service, const QString &nodeName)
QXmppTask<QXmppPubSubManager::OptionsResult> requestSubscribeOptions(const QString &service, const QString &nodeName, const QString &subscriberJid)
QXmppTask<QXmppPubSubManager::SubscriptionsResult> requestSubscriptions(const QString &jid)
QXmppTask<QXmppPubSubManager::SubscriptionsResult> requestSubscriptions(const QString &jid, const QString &nodeName)
QXmppTask<QXmppPubSubManager::Result> retractItem(const QString &jid, const QString &nodeName, QXmppPubSubManager::StandardItemId itemId, bool notify = false)
QXmppTask<QXmppPubSubManager::Result> retractItem(const QString &jid, const QString &nodeName, const QString &itemId, bool notify = false)
QXmppTask<QXmppPubSubManager::Result> retractOwnPepItem(const QString &nodeName, QXmppPubSubManager::StandardItemId itemId, bool notify = false)
QXmppTask<QXmppPubSubManager::Result> retractOwnPepItem(const QString &nodeName, const QString &itemId, bool notify = false)
QXmppTask<QXmppPubSubManager::Result> setSubscribeOptions(const QString &service, const QString &nodeName, const QXmppPubSubSubscribeOptions &options)
QXmppTask<QXmppPubSubManager::Result> setSubscribeOptions(const QString &service, const QString &nodeName, const QXmppPubSubSubscribeOptions &options, const QString &subscriberJid)
QXmppTask<QXmppPubSubManager::Result> subscribeToNode(const QString &serviceJid, const QString &nodeName, const QString &subscriberJid)
QXmppTask<QXmppPubSubManager::Result> unsubscribeFromNode(const QString &serviceJid, const QString &nodeName, const QString &subscriberJid)

Static Public Members

QString standardItemIdToString(QXmppPubSubManager::StandardItemId itemId)

Detailed Description

However, it currently only supports a few PubSub use cases but all of the XEP-0060: Personal Eventing Protocol (PEP) ones. PEP allows a standard XMPP user account to function as a virtual PubSub service.

To make use of this manager, you need to instantiate it and load it into the QXmppClient instance as follows:

 QXmppPubSubManager *manager = new QXmppPubSubManager;
 client->addExtension(manager);

Note: To subscribe to PEP event notifications use the QXmppClientExtension::discoveryFeatures method of your client extension according to section 9.2 of XEP-0060: Publish-Subscribe. For example:

 QStringList YourExtension::discoveryFeatures() const
 {
 return { "http://jabber.org/protocol/tune+notify" };
 }
  • Item pagination: requesting a continuation
  • Requesting most recent items (max_items=x): https://xmpp.org/extensions/xep-0060.html#subscriber-retrieve-requestrecent
  • subscribe()/unsubscribe():
  • return subscription on success
  • correctly handle configuration required (and other) cases

Member Type Documentation

[alias] QXmppPubSubManager::AffiliationsResult

Contains the list of affiliations with the node(s) (QVector<QXmppPubSubAffiliation>) or the returned IQ error (QXmppStanza::Error).

[alias] QXmppPubSubManager::FeaturesResult

Type containing service discovery features, InvalidServiceType if the service is not of the desired type or the returned IQ error (QXmppStanza::Error).

[alias] QXmppPubSubManager::InstantNodeResult

Contains the name of the new node (QString) or the returned IQ error (QXmppStanza::Error).

[alias] QXmppPubSubManager::ItemIdsResult

Contains all item IDs that have been found (QVector<QString>) or the returned IQ error (QXmppStanza::Error).

[alias] template <typename T> QXmppPubSubManager::ItemResult

Contains the item if it has been found (std::optional<T>) or the returned IQ error (QXmppStanza::Error).

[alias] template <typename T> QXmppPubSubManager::ItemsResult

Contains all items that have been found (QVector<T>) or the returned IQ error (QXmppStanza::Error).

[alias] QXmppPubSubManager::NodeConfigResult

Contains a node configuration (QXmppPubSubNodeConfig) or the returned IQ error (QXmppStanza::Error).

[alias] QXmppPubSubManager::NodesResult

Type containing a list of node names or the returned IQ error (QXmppStanza::Error).

[alias] QXmppPubSubManager::OptionsResult

Contains the current subscribe options (QXmppPubSubSubscribeOptions) or the returned IQ error (QXmppStanza::Error).

[alias] QXmppPubSubManager::PublishItemResult

Contains the ID of the item, if no ID was set in the request (QString) or the returned IQ error (QXmppStanza::Error).

[alias] QXmppPubSubManager::PublishItemsResult

Contains the IDs of the items, if no IDs were set in the request (QVector<QString>) or the returned IQ error (QXmppStanza::Error).

[alias] QXmppPubSubManager::Result

Result of a generic request without a return value. Contains Success in case everything went well. If the returned IQ contained an error a QXmppStanza::Error is reported.

[alias] QXmppPubSubManager::SubscriptionsResult

Contains a list of active subscriptions (QVector<QXmppPubSubSubscription>) or the returned IQ error (QXmppStanza::Error).

Member Function Documentation

QXmppPubSubManager::QXmppPubSubManager()

Default constructor.

[virtual noexcept] QXmppPubSubManager::~QXmppPubSubManager()

Default destructor.

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::cancelNodeConfiguration(const QString &service, const QString &nodeName)

Cancels the configuration process for the pubsub node nodeName on the service with JID service and uses the default or existing configuration.

See also requestNodeConfiguration().

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::cancelOwnPepNodeConfiguration(const QString &nodeName)

Cancels the configuration process for the PEP node nodeName.

This is a convenience method equivalent to calling cancelNodeConfiguration() the current account's bare JID.

See also requestOwnPepNodeConfiguration().

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::configureNode(const QString &service, const QString &nodeName, const QXmppPubSubNodeConfig &config)

Sets the node configuration config for the pubsub node nodeName on the service with JID service.

Requires owner privileges. You can use requestNodeConfiguration() to receive a data form with all valid options and default values.

See also requestNodeConfiguration().

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::configureOwnPepNode(const QString &nodeName, const QXmppPubSubNodeConfig &config)

Sets the node configuration config for the PEP node nodeName.

This is a convenience method equivalent to calling configureNode() the current account's bare JID.

See also requestOwnPepNodeConfiguration().

QXmppTask<QXmppPubSubManager::InstantNodeResult> QXmppPubSubManager::createInstantNode(const QString &jid)

Creates an instant pubsub node on the pubsub service with JID jid using the default configuration. jid is the Jabber ID of the entity hosting the pubsub service.

The pubsub service automatically generates a random node name. On success it is returned via the QFuture.

QXmppTask<QXmppPubSubManager::InstantNodeResult> QXmppPubSubManager::createInstantNode(const QString &jid, const QXmppPubSubNodeConfig &config)

Creates an instant pubsub node on the pubsub service with JID jid using the custom configuration config. jid is the Jabber ID of the entity hosting the pubsub service.

The pubsub service automatically generates a random node name. On success it is returned via the QFuture.

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::createNode(const QString &jid, const QString &nodeName)

Creates an empty pubsub node nodeName on the pubsub service with JID jid using the default configuration. jid is the Jabber ID of the entity hosting the pubsub service.

Calling this before QXmppPubSubManager::publishItems is usually not necessary when publishing to a node for the first time if the service suppports the auto-create feature (Section 7.1.4 of XEP-0060: Publish-Subscribe).

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::createNode(const QString &jid, const QString &nodeName, const QXmppPubSubNodeConfig &config)

Creates an empty pubsub node nodeName on the pubsub service with JID jid using the custom configuration config. jid is the Jabber ID of the entity hosting the pubsub service.

Calling this before QXmppPubSubManager::publishItems is usually not necessary when publishing to a node for the first time if the service suppports the auto-create feature (Section 7.1.4 of XEP-0060: Publish-Subscribe).

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::createOwnPepNode(const QString &nodeName)

Creates an empty PEP node nodeName with the default configuration.

This is a convenience method equivalent to calling QXmppPubSubManager::createNode on the current account's bare JID.

Calling this before QXmppPubSubManager::publishOwnPepItems is usually not necessary when publishing to a node for the first time if the service suppports the auto-create feature (Section 7.1.4 of XEP-0060: Publish-Subscribe).

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::createOwnPepNode(const QString &nodeName, const QXmppPubSubNodeConfig &config)

Creates an empty PEP node nodeName with the custom configuration config.

This is a convenience method equivalent to calling QXmppPubSubManager::createNode on the current account's bare JID.

Calling this before QXmppPubSubManager::publishOwnPepItems is usually not necessary when publishing to a node for the first time if the service suppports the auto-create feature (Section 7.1.4 of XEP-0060: Publish-Subscribe).

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::deleteNode(const QString &jid, const QString &nodeName)

Deletes the pubsub node nodeName, along with all of its items, on the pubsub service with JID jid. jid is the Jabber ID of the entity hosting the pubsub service.

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::deleteOwnPepNode(const QString &nodeName)

Deletes the PEP node nodeName, along with all of its items.

This is a convenience method equivalent to calling QXmppPubSubManager::deleteNode on the current account's bare JID.

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::purgeItems(const QString &jid, const QString &nodeName)

Purges all items from the node nodeName on the pubsub service with JID jid. jid is the Jabber ID of the entity hosting the pubsub service.

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::purgeOwnPepItems(const QString &nodeName)

Purges all items from the PEP node nodeName.

This is a convenience method equivalent to calling QXmppPubSubManager::purgeItems on the current account's bare JID.

QXmppTask<QXmppPubSubManager::AffiliationsResult> QXmppPubSubManager::requestAffiliations(const QString &jid)

Requests the user's affiliations with all PubSub nodes on the PubSub service with JID jid.

QXmppTask<QXmppPubSubManager::AffiliationsResult> QXmppPubSubManager::requestAffiliations(const QString &jid, const QString &nodeName)

Requests the user's affiliations with the PubSub node nodeName on the service with JID jid.

QXmppTask<QXmppPubSubManager::ItemIdsResult> QXmppPubSubManager::requestItemIds(const QString &serviceJid, const QString &nodeName)

Requests the IDs of all items of the pubsub node nodeName on the service with JID serviceJid via service discovery. serviceJid is the JID of the entity hosting the pubsub service.

This uses a XEP-0030: Service Discovery items request to get a list of items.

QXmppTask<QXmppPubSubManager::AffiliationsResult> QXmppPubSubManager::requestNodeAffiliations(const QString &jid, const QString &nodeName)

Requests the affiliations of all users on the PubSub node nodeName of the service with JID jid.

This can be used to view and manage affiliations of other users with a node. Owner privileges are required.

QXmppTask<QXmppPubSubManager::NodeConfigResult> QXmppPubSubManager::requestNodeConfiguration(const QString &service, const QString &nodeName)

Requests the node configuration and starts the configuration process.

Requires owner privileges. If the result is successful (a node config form has been returned) this starts the configuration process. The next step is to call configureNode() or cancelNodeConfiguration().

service is the JID of the pubsub service. nodeName is the name of the pubsub node on the service.

See also configureNode() and cancelNodeConfiguration().

QXmppTask<QXmppPubSubManager::NodesResult> QXmppPubSubManager::requestNodes(const QString &jid)

Requests all listed nodes of the pubsub service with JID jid via service discovery. jid is the Jabber ID of the entity hosting the pubsub service.

This uses a XEP-0030: Service Discovery items request to get a list of nodes.

template <typename T = QXmppPubSubBaseItem> QXmppTask<QXmppPubSubManager::ItemResult<T>> QXmppPubSubManager::requestOwnPepItem(const QString &nodeName, QXmppPubSubManager::StandardItemId itemId)

Requests the item with standard ID itemId from the PEP node nodeName.

This is a convenience method equivalent to calling QXmppPubSubManager::requestItem on the current account's bare JID.

template <typename T = QXmppPubSubBaseItem> QXmppTask<QXmppPubSubManager::ItemResult<T>> QXmppPubSubManager::requestOwnPepItem(const QString &nodeName, const QString &itemId)

Requests the item with ID itemId from the PEP node nodeName.

This is a convenience method equivalent to calling QXmppPubSubManager::requestItem on the current account's bare JID.

QXmppTask<QXmppPubSubManager::ItemIdsResult> QXmppPubSubManager::requestOwnPepItemIds(const QString &nodeName)

Requests the IDs of all items of the PEP node nodeName via service discovery.

This is a convenience method equivalent to calling QXmppPubSubManager::requestItemIds on the current account's bare JID.

template <typename T = QXmppPubSubBaseItem> QXmppTask<QXmppPubSubManager::ItemsResult<T>> QXmppPubSubManager::requestOwnPepItems(const QString &nodeName)

Requests all items of the PEP node nodeName.

This is a convenience method equivalent to calling QXmppPubSubManager::requestItems on the current account's bare JID.

QXmppTask<QXmppPubSubManager::NodeConfigResult> QXmppPubSubManager::requestOwnPepNodeConfiguration(const QString &nodeName)

Requests the node configuration of the PEP node nodeName and starts the configuration process.

This is a convenience method equivalent to calling requestNodeConfiguration() the current account's bare JID.

See also configureOwnPepNode() and cancelOwnPepNodeConfiguration().

QXmppTask<QXmppPubSubManager::NodesResult> QXmppPubSubManager::requestOwnPepNodes()

Requests all listed nodes of the own PEP service via service discovery.

This is a convenience method equivalent to calling QXmppPubSubManager::fetchNodes on the current account's bare JID.

QXmppTask<QXmppPubSubManager::OptionsResult> QXmppPubSubManager::requestSubscribeOptions(const QString &service, const QString &nodeName)

Requests the subscribe options form of the own subscription to the node nodeName on the pubsub service with JID service.

QXmppTask<QXmppPubSubManager::OptionsResult> QXmppPubSubManager::requestSubscribeOptions(const QString &service, const QString &nodeName, const QString &subscriberJid)

Requests the subscribe options form of the subscription of the user with JID subscriberJid to the node nodeName on the pubsub service with JID service.

QXmppTask<QXmppPubSubManager::SubscriptionsResult> QXmppPubSubManager::requestSubscriptions(const QString &jid)

Requests all subscriptions with the PubSub service with JID jid.

QXmppTask<QXmppPubSubManager::SubscriptionsResult> QXmppPubSubManager::requestSubscriptions(const QString &jid, const QString &nodeName)

Requests the subscription(s) with the PubSub node nodeName on the service with JID jid.

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::retractItem(const QString &jid, const QString &nodeName, QXmppPubSubManager::StandardItemId itemId, bool notify = false)

Deletes the item with standard ID itemId from the pubsub node nodeName on the service with JID jid. jid is the Jabber ID of the entity hosting the pubsub service. notify specifies whether to generate retraction notifications for subscribers (since QXmpp 1.11, default: false).

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::retractItem(const QString &jid, const QString &nodeName, const QString &itemId, bool notify = false)

Deletes the item with ID itemId from the pubsub node nodeName on the service with JID jid. jid is the Jabber ID of the entity hosting the pubsub service. notify specifies whether to generate retraction notifications for subscribers (since QXmpp 1.11, default: false).

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::retractOwnPepItem(const QString &nodeName, QXmppPubSubManager::StandardItemId itemId, bool notify = false)

Deletes the item with standard ID itemId from the PEP node nodeName. notify specifies whether to generate retraction notifications for subscribers (since QXmpp 1.13, default: false).

This is a convenience method equivalent to calling QXmppPubSubManager::retractItem on the current account's bare JID.

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::retractOwnPepItem(const QString &nodeName, const QString &itemId, bool notify = false)

Deletes the item with ID itemId from the PEP node nodeName. notify specifies whether to generate retraction notifications for subscribers (since QXmpp 1.13, default: false).

This is a convenience method equivalent to calling QXmppPubSubManager::retractItem on the current account's bare JID.

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::setSubscribeOptions(const QString &service, const QString &nodeName, const QXmppPubSubSubscribeOptions &options)

Sets the subscription options options for our own account on the node nodeName of the pubsub service with JID service.

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::setSubscribeOptions(const QString &service, const QString &nodeName, const QXmppPubSubSubscribeOptions &options, const QString &subscriberJid)

Sets the subscription options options for another user's account identified by subscriberJid on the node nodeName of the pubsub service with JID service.

[static] QString QXmppPubSubManager::standardItemIdToString(QXmppPubSubManager::StandardItemId itemId)

Returns the item ID string for the standard item ID itemId, or a default-constructed string if there is no corresponding one.

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::subscribeToNode(const QString &serviceJid, const QString &nodeName, const QString &subscriberJid)

Subscribes the user with JID subscriberJid to the pubsub node nodeName on the service with JID serviceJid. subscriberJid is the bare or full JID of the subscriber.

QXmppTask<QXmppPubSubManager::Result> QXmppPubSubManager::unsubscribeFromNode(const QString &serviceJid, const QString &nodeName, const QString &subscriberJid)

Unsubscribes the user with JID subscriberJid from the pubsub node nodeName on the service with JID serviceJid. subscriberJid is the bare or full JID of the subscriber.