6#ifndef QXMPPPUBSUBMANAGER_H
7#define QXMPPPUBSUBMANAGER_H
9#include "QXmppClient.h"
10#include "QXmppClientExtension.h"
11#include "QXmppFutureUtils_p.h"
12#include "QXmppMessage.h"
13#include "QXmppPubSubIq_p.h"
14#include "QXmppPubSubPublishOptions.h"
15#include "QXmppResultSet.h"
17class QXmppPubSubPublishOptions;
18class QXmppPubSubSubscribeOptions;
49 std::optional<QXmppResultSetReply> continuation;
52 using Result = std::variant<QXmpp::Success, QXmppError>;
65 using OptionsResult = std::variant<QXmppPubSubSubscribeOptions, QXmppError>;
74 QXmppTask<Result> createNode(
const QString &jid,
const QString &nodeName,
const QXmppPubSubNodeConfig &config);
79 template<
typename T = QXmppPubSubBaseItem>
81 template<
typename T = QXmppPubSubBaseItem>
83 template<
typename T = QXmppPubSubBaseItem>
85 template<
typename T = QXmppPubSubBaseItem>
90 QXmppTask<PublishItemResult> publishItem(
const QString &jid,
const QString &nodeName,
const T &item,
const QXmppPubSubPublishOptions &publishOptions);
94 QXmppTask<PublishItemsResult> publishItems(
const QString &jid,
const QString &nodeName,
const QVector<T> &items,
const QXmppPubSubPublishOptions &publishOptions);
95 QXmppTask<Result> retractItem(
const QString &jid,
const QString &nodeName,
const QString &itemId);
104 QXmppTask<OptionsResult> requestSubscribeOptions(
const QString &service,
const QString &nodeName,
const QString &subscriberJid);
105 QXmppTask<Result> setSubscribeOptions(
const QString &service,
const QString &nodeName,
const QXmppPubSubSubscribeOptions &options);
106 QXmppTask<Result> setSubscribeOptions(
const QString &service,
const QString &nodeName,
const QXmppPubSubSubscribeOptions &options,
const QString &subscriberJid);
108 QXmppTask<Result> configureNode(
const QString &service,
const QString &nodeName,
const QXmppPubSubNodeConfig &config);
109 QXmppTask<Result> cancelNodeConfiguration(
const QString &service,
const QString &nodeName);
110 QXmppTask<Result> subscribeToNode(
const QString &serviceJid,
const QString &nodeName,
const QString &subscriberJid);
111 QXmppTask<Result> unsubscribeFromNode(
const QString &serviceJid,
const QString &nodeName,
const QString &subscriberJid);
118 template<
typename T = QXmppPubSubBaseItem>
120 template<
typename T = QXmppPubSubBaseItem>
122 template<
typename T = QXmppPubSubBaseItem>
126 QXmppTask<PublishItemResult> publishOwnPepItem(
const QString &nodeName,
const T &item,
const QXmppPubSubPublishOptions &publishOptions);
130 QXmppTask<PublishItemsResult> publishOwnPepItems(
const QString &nodeName,
const QVector<T> &items,
const QXmppPubSubPublishOptions &publishOptions);
140 static QString standardItemIdToString(StandardItemId itemId);
149 friend class tst_QXmppPubSubManager;
150 friend class QXmppOmemoManagerPrivate;
157 static QXmpp::Private::PubSubIq<> requestItemsIq(
const QString &jid,
const QString &nodeName,
const QStringList &itemIds);
171 const QString &nodeName,
172 const QString &itemId)
174 using namespace QXmpp::Private;
175 return chainIq(
client()->sendIq(requestItemsIq(jid, nodeName, { itemId })),
this,
177 if (!iq.items().isEmpty()) {
178 return iq.items().constFirst();
180 return QXmppError { QStringLiteral(
"No such item has been found."), {} };
195 const QString &nodeName,
211 const QString &nodeName)
213 return requestItems<T>(jid, nodeName, {});
228 const QString &nodeName,
229 const QStringList &itemIds)
231 using namespace QXmpp::Private;
232 return chainIq(
client()->sendIq(requestItemsIq(jid, nodeName, itemIds)),
this,
236 iq.itemsContinuation(),
254 const QString &nodeName,
257 QXmpp::Private::PubSubIq<T> request;
259 request.setItems({ item });
260 request.setQueryNode(nodeName);
278 const QString &nodeName,
280 const QXmppPubSubPublishOptions &publishOptions)
282 QXmpp::Private::PubSubIq<T> request;
284 request.setItems({ item });
285 request.setQueryNode(nodeName);
286 request.setDataForm(publishOptions.toDataForm());
300 const QString &nodeName,
301 const QVector<T> &items)
303 QXmpp::Private::PubSubIq<T> request;
305 request.setItems(items);
306 request.setQueryNode(nodeName);
321 const QString &nodeName,
322 const QVector<T> &items,
323 const QXmppPubSubPublishOptions &publishOptions)
325 QXmpp::Private::PubSubIq<T> request;
327 request.setItems(items);
328 request.setQueryNode(nodeName);
329 request.setDataForm(publishOptions.toDataForm());
344 return publishItem(
client()->configuration().jidBare(), nodeName, item, publishOptions);
372 return publishItems(
client()->configuration().jidBare(), nodeName, items, publishOptions);
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition: QXmppClientExtension.h:32
virtual QStringList discoveryFeatures() const
Definition: QXmppClientExtension.cpp:22
QXmppClient * client() const
Definition: QXmppClientExtension.cpp:57
virtual bool handleStanza(const QDomElement &stanza)
You need to implement this method to process incoming XMPP stanzas.
Definition: client/compat/removed_api.cpp:26
The QXmppPubSubManager aims to provide publish-subscribe functionality as specified in XEP-0060: Publ...
Definition: QXmppPubSubManager.h:21
QXmppTask< ItemIdsResult > requestOwnPepItemIds(const QString &nodeName)
Definition: QXmppPubSubManager.h:124
std::variant< QVector< QString >, InvalidServiceType, QXmppError > FeaturesResult
Definition: QXmppPubSubManager.h:53
std::variant< QVector< QXmppPubSubAffiliation >, QXmppError > AffiliationsResult
Definition: QXmppPubSubManager.h:64
ServiceType
Definition: QXmppPubSubManager.h:28
@ PubSubOrPep
PubSub service or PEP service.
Definition: QXmppPubSubManager.h:29
@ PubSub
PubSub service only.
Definition: QXmppPubSubManager.h:30
std::variant< QXmppPubSubSubscribeOptions, QXmppError > OptionsResult
Definition: QXmppPubSubManager.h:65
QXmppTask< ItemResult< T > > requestOwnPepItem(const QString &nodeName, StandardItemId itemId)
Definition: QXmppPubSubManager.h:121
QXmppTask< PublishItemResult > publishItem(const QString &jid, const QString &nodeName, const T &item)
Definition: QXmppPubSubManager.h:253
QXmppTask< ItemResult< T > > requestOwnPepItem(const QString &nodeName, const QString &itemId)
Definition: QXmppPubSubManager.h:119
std::variant< QVector< QString >, QXmppError > ItemIdsResult
Definition: QXmppPubSubManager.h:60
QXmppTask< PublishItemResult > publishOwnPepItem(const QString &nodeName, const T &item, const QXmppPubSubPublishOptions &publishOptions)
Definition: QXmppPubSubManager.h:342
QXmppTask< Result > configureOwnPepNode(const QString &nodeName, const QXmppPubSubNodeConfig &config)
Definition: QXmppPubSubManager.h:137
QXmppTask< Result > retractOwnPepItem(const QString &nodeName, const QString &itemId)
Definition: QXmppPubSubManager.h:133
std::variant< QXmppPubSubNodeConfig, QXmppError > NodeConfigResult
Definition: QXmppPubSubManager.h:66
QXmppTask< Result > cancelOwnPepNodeConfiguration(const QString &nodeName)
Definition: QXmppPubSubManager.h:138
std::variant< T, QXmppError > ItemResult
Definition: QXmppPubSubManager.h:57
QXmppTask< NodesResult > requestOwnPepNodes()
Definition: QXmppPubSubManager.h:114
std::variant< QString, QXmppError > PublishItemResult
Definition: QXmppPubSubManager.h:61
std::variant< QString, QXmppError > InstantNodeResult
Definition: QXmppPubSubManager.h:55
std::variant< QVector< QString >, QXmppError > PublishItemsResult
Definition: QXmppPubSubManager.h:62
QXmppTask< Result > purgeOwnPepItems(const QString &nodeName)
Definition: QXmppPubSubManager.h:135
std::variant< QXmpp::Success, QXmppError > Result
Definition: QXmppPubSubManager.h:52
static QString standardItemIdToString(StandardItemId itemId)
Definition: QXmppPubSubManager.cpp:962
std::variant< QVector< QXmppPubSubSubscription >, QXmppError > SubscriptionsResult
Definition: QXmppPubSubManager.h:63
QXmppTask< NodeConfigResult > requestOwnPepNodeConfiguration(const QString &nodeName)
Definition: QXmppPubSubManager.h:136
QXmppTask< Result > createOwnPepNode(const QString &nodeName, const QXmppPubSubNodeConfig &config)
Definition: QXmppPubSubManager.h:116
std::variant< Items< T >, QXmppError > ItemsResult
Definition: QXmppPubSubManager.h:59
QXmppTask< ItemsResult< T > > requestItems(const QString &jid, const QString &nodeName)
Definition: QXmppPubSubManager.h:210
QXmppTask< PublishItemsResult > publishItems(const QString &jid, const QString &nodeName, const QVector< T > &items)
Definition: QXmppPubSubManager.h:299
QXmppTask< ItemResult< T > > requestItem(const QString &jid, const QString &nodeName, const QString &itemId)
Definition: QXmppPubSubManager.h:170
QXmppTask< ItemsResult< T > > requestOwnPepItems(const QString &nodeName)
Definition: QXmppPubSubManager.h:123
QXmppTask< Result > deleteOwnPepNode(const QString &nodeName)
Definition: QXmppPubSubManager.h:117
std::variant< QVector< QString >, QXmppError > NodesResult
Definition: QXmppPubSubManager.h:54
QXmppTask< PublishItemsResult > publishOwnPepItems(const QString &nodeName, const QVector< T > &items, const QXmppPubSubPublishOptions &publishOptions)
Definition: QXmppPubSubManager.h:370
StandardItemId
Definition: QXmppPubSubManager.h:37
QXmppTask< Result > createOwnPepNode(const QString &nodeName)
Definition: QXmppPubSubManager.h:115
QXmppTask< Result > retractOwnPepItem(const QString &nodeName, StandardItemId itemId)
Definition: QXmppPubSubManager.h:134
Definition: QXmppTask.h:62
Definition: QXmppError.h:17
Definition: QXmppPubSubManager.h:44