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;
52 std::optional<QXmppResultSetReply> continuation;
55 using Result = std::variant<QXmpp::Success, QXmppError>;
68 using OptionsResult = std::variant<QXmppPubSubSubscribeOptions, QXmppError>;
77 QXmppTask<Result> createNode(
const QString &jid,
const QString &nodeName,
const QXmppPubSubNodeConfig &config);
82 template<
typename T = QXmppPubSubBaseItem>
84 template<
typename T = QXmppPubSubBaseItem>
86 template<
typename T = QXmppPubSubBaseItem>
88 template<
typename T = QXmppPubSubBaseItem>
93 QXmppTask<PublishItemResult> publishItem(
const QString &jid,
const QString &nodeName,
const T &item,
const QXmppPubSubPublishOptions &publishOptions);
97 QXmppTask<PublishItemsResult> publishItems(
const QString &jid,
const QString &nodeName,
const QVector<T> &items,
const QXmppPubSubPublishOptions &publishOptions);
98 QXmppTask<Result> retractItem(
const QString &jid,
const QString &nodeName,
const QString &itemId);
107 QXmppTask<OptionsResult> requestSubscribeOptions(
const QString &service,
const QString &nodeName,
const QString &subscriberJid);
108 QXmppTask<Result> setSubscribeOptions(
const QString &service,
const QString &nodeName,
const QXmppPubSubSubscribeOptions &options);
109 QXmppTask<Result> setSubscribeOptions(
const QString &service,
const QString &nodeName,
const QXmppPubSubSubscribeOptions &options,
const QString &subscriberJid);
111 QXmppTask<Result> configureNode(
const QString &service,
const QString &nodeName,
const QXmppPubSubNodeConfig &config);
112 QXmppTask<Result> cancelNodeConfiguration(
const QString &service,
const QString &nodeName);
113 QXmppTask<Result> subscribeToNode(
const QString &serviceJid,
const QString &nodeName,
const QString &subscriberJid);
114 QXmppTask<Result> unsubscribeFromNode(
const QString &serviceJid,
const QString &nodeName,
const QString &subscriberJid);
121 template<
typename T = QXmppPubSubBaseItem>
123 template<
typename T = QXmppPubSubBaseItem>
125 template<
typename T = QXmppPubSubBaseItem>
129 QXmppTask<PublishItemResult> publishOwnPepItem(
const QString &nodeName,
const T &item,
const QXmppPubSubPublishOptions &publishOptions);
133 QXmppTask<PublishItemsResult> publishOwnPepItems(
const QString &nodeName,
const QVector<T> &items,
const QXmppPubSubPublishOptions &publishOptions);
143 static QString standardItemIdToString(StandardItemId itemId);
152 friend class tst_QXmppPubSubManager;
153 friend class QXmppOmemoManagerPrivate;
160 static QXmpp::Private::PubSubIq<> requestItemsIq(
const QString &jid,
const QString &nodeName,
const QStringList &itemIds);
174 const QString &nodeName,
175 const QString &itemId)
177 using namespace QXmpp::Private;
178 return chainIq(
client()->sendIq(requestItemsIq(jid, nodeName, { itemId })),
this,
180 if (!iq.items().isEmpty()) {
181 return iq.items().constFirst();
183 return QXmppError { QStringLiteral(
"No such item has been found."), {} };
198 const QString &nodeName,
214 const QString &nodeName)
216 return requestItems<T>(jid, nodeName, {});
231 const QString &nodeName,
232 const QStringList &itemIds)
234 using namespace QXmpp::Private;
235 return chainIq(
client()->sendIq(requestItemsIq(jid, nodeName, itemIds)),
this,
239 iq.itemsContinuation(),
257 const QString &nodeName,
260 QXmpp::Private::PubSubIq<T> request;
262 request.setItems({ item });
263 request.setQueryNode(nodeName);
281 const QString &nodeName,
283 const QXmppPubSubPublishOptions &publishOptions)
285 QXmpp::Private::PubSubIq<T> request;
287 request.setItems({ item });
288 request.setQueryNode(nodeName);
289 request.setDataForm(publishOptions.toDataForm());
303 const QString &nodeName,
304 const QVector<T> &items)
306 QXmpp::Private::PubSubIq<T> request;
308 request.setItems(items);
309 request.setQueryNode(nodeName);
324 const QString &nodeName,
325 const QVector<T> &items,
326 const QXmppPubSubPublishOptions &publishOptions)
328 QXmpp::Private::PubSubIq<T> request;
330 request.setItems(items);
331 request.setQueryNode(nodeName);
332 request.setDataForm(publishOptions.toDataForm());
347 return publishItem(
client()->configuration().jidBare(), nodeName, item, publishOptions);
375 return publishItems(
client()->configuration().jidBare(), nodeName, items, publishOptions);
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition QXmppClientExtension.h:33
QXmppClient * client()
Definition QXmppClientExtension.cpp:78
virtual QStringList discoveryFeatures() const
Definition QXmppClientExtension.cpp:22
virtual bool handleStanza(const QDomElement &stanza)
You need to implement this method to process incoming XMPP stanzas.
Definition QXmppClientExtension.cpp:51
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:127
std::variant< QVector< QString >, InvalidServiceType, QXmppError > FeaturesResult
Definition QXmppPubSubManager.h:56
std::variant< QVector< QXmppPubSubAffiliation >, QXmppError > AffiliationsResult
Definition QXmppPubSubManager.h:67
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:68
QXmppTask< ItemResult< T > > requestOwnPepItem(const QString &nodeName, StandardItemId itemId)
Definition QXmppPubSubManager.h:124
QXmppTask< PublishItemResult > publishItem(const QString &jid, const QString &nodeName, const T &item)
Definition QXmppPubSubManager.h:256
QXmppTask< ItemResult< T > > requestOwnPepItem(const QString &nodeName, const QString &itemId)
Definition QXmppPubSubManager.h:122
std::variant< QVector< QString >, QXmppError > ItemIdsResult
Definition QXmppPubSubManager.h:63
QXmppTask< PublishItemResult > publishOwnPepItem(const QString &nodeName, const T &item, const QXmppPubSubPublishOptions &publishOptions)
Definition QXmppPubSubManager.h:345
QXmppTask< Result > configureOwnPepNode(const QString &nodeName, const QXmppPubSubNodeConfig &config)
Definition QXmppPubSubManager.h:140
QXmppTask< Result > retractOwnPepItem(const QString &nodeName, const QString &itemId)
Definition QXmppPubSubManager.h:136
std::variant< QXmppPubSubNodeConfig, QXmppError > NodeConfigResult
Definition QXmppPubSubManager.h:69
QXmppTask< Result > cancelOwnPepNodeConfiguration(const QString &nodeName)
Definition QXmppPubSubManager.h:141
std::variant< T, QXmppError > ItemResult
Definition QXmppPubSubManager.h:60
QXmppTask< NodesResult > requestOwnPepNodes()
Definition QXmppPubSubManager.h:117
std::variant< QString, QXmppError > PublishItemResult
Definition QXmppPubSubManager.h:64
std::variant< QString, QXmppError > InstantNodeResult
Definition QXmppPubSubManager.h:58
std::variant< QVector< QString >, QXmppError > PublishItemsResult
Definition QXmppPubSubManager.h:65
QXmppTask< Result > purgeOwnPepItems(const QString &nodeName)
Definition QXmppPubSubManager.h:138
std::variant< QXmpp::Success, QXmppError > Result
Definition QXmppPubSubManager.h:55
static QString standardItemIdToString(StandardItemId itemId)
Definition QXmppPubSubManager.cpp:958
std::variant< QVector< QXmppPubSubSubscription >, QXmppError > SubscriptionsResult
Definition QXmppPubSubManager.h:66
QXmppTask< NodeConfigResult > requestOwnPepNodeConfiguration(const QString &nodeName)
Definition QXmppPubSubManager.h:139
QXmppTask< Result > createOwnPepNode(const QString &nodeName, const QXmppPubSubNodeConfig &config)
Definition QXmppPubSubManager.h:119
std::variant< Items< T >, QXmppError > ItemsResult
Definition QXmppPubSubManager.h:62
QXmppTask< ItemsResult< T > > requestItems(const QString &jid, const QString &nodeName)
Definition QXmppPubSubManager.h:213
QXmppTask< PublishItemsResult > publishItems(const QString &jid, const QString &nodeName, const QVector< T > &items)
Definition QXmppPubSubManager.h:302
QXmppTask< ItemResult< T > > requestItem(const QString &jid, const QString &nodeName, const QString &itemId)
Definition QXmppPubSubManager.h:173
QXmppTask< ItemsResult< T > > requestOwnPepItems(const QString &nodeName)
Definition QXmppPubSubManager.h:126
QXmppTask< Result > deleteOwnPepNode(const QString &nodeName)
Definition QXmppPubSubManager.h:120
std::variant< QVector< QString >, QXmppError > NodesResult
Definition QXmppPubSubManager.h:57
QXmppTask< PublishItemsResult > publishOwnPepItems(const QString &nodeName, const QVector< T > &items, const QXmppPubSubPublishOptions &publishOptions)
Definition QXmppPubSubManager.h:373
StandardItemId
Definition QXmppPubSubManager.h:37
QXmppTask< Result > createOwnPepNode(const QString &nodeName)
Definition QXmppPubSubManager.h:118
QXmppTask< Result > retractOwnPepItem(const QString &nodeName, StandardItemId itemId)
Definition QXmppPubSubManager.h:137
Definition QXmppTask.h:62
Definition QXmppError.h:18
Definition QXmppPubSubManager.h:45