aboutsummaryrefslogtreecommitdiff
path: root/src/client/QXmppPubSubManager.cpp
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2021-09-29 15:45:52 +0200
committerLinus Jahn <lnj@kaidan.im>2021-09-29 16:37:41 +0200
commit1654f24a1af4f96f2f1a06a2308bd05ad6f9c978 (patch)
tree898701a74cc1977cb0d1781beb75a8c86ef1dddb /src/client/QXmppPubSubManager.cpp
parent9b21bef379d94876908cbb706c9ba2438779bf54 (diff)
downloadqxmpp-1654f24a1af4f96f2f1a06a2308bd05ad6f9c978.tar.gz
PubSubManager: Add create node requests with config
Diffstat (limited to 'src/client/QXmppPubSubManager.cpp')
-rw-r--r--src/client/QXmppPubSubManager.cpp67
1 files changed, 66 insertions, 1 deletions
diff --git a/src/client/QXmppPubSubManager.cpp b/src/client/QXmppPubSubManager.cpp
index 08fe75e7..c4a9107f 100644
--- a/src/client/QXmppPubSubManager.cpp
+++ b/src/client/QXmppPubSubManager.cpp
@@ -234,6 +234,30 @@ auto QXmppPubSubManager::createNode(const QString &jid, const QString &nodeName)
}
///
+/// Creates an empty pubsub node with a custom configuration.
+///
+/// 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}).
+///
+/// \param jid Jabber ID of the entity hosting the pubsub service
+/// \param nodeName the name of the node to be created
+/// \param config The configuration for the node
+/// \return
+///
+auto QXmppPubSubManager::createNode(const QString &jid, const QString &nodeName, const QXmppPubSubNodeConfig &config) -> QFuture<Result>
+{
+ QXmppPubSubIq request;
+ request.setType(QXmppIq::Set);
+ request.setQueryType(QXmppPubSubIq<>::Create);
+ request.setQueryNode(nodeName);
+ request.setTo(jid);
+ request.setDataForm(config);
+
+ return client()->sendGenericIq(std::move(request));
+}
+
+///
/// Creates an instant pubsub node with the default configuration.
///
/// The pubsub service automatically generates a random node name. On success
@@ -256,6 +280,30 @@ QFuture<QXmppPubSubManager::InstantNodeResult> QXmppPubSubManager::createInstant
}
///
+/// Creates an instant pubsub node with a custom configuration.
+///
+/// The pubsub service automatically generates a random node name. On success
+/// it is returned via the QFuture.
+///
+/// \param jid Jabber ID of the entity hosting the pubsub service
+/// \param config The configuration for the node
+/// \return
+///
+auto QXmppPubSubManager::createInstantNode(const QString &jid, const QXmppPubSubNodeConfig &config) -> QFuture<InstantNodeResult>
+{
+ QXmppPubSubIq request;
+ request.setType(QXmppIq::Set);
+ request.setQueryType(QXmppPubSubIq<>::Create);
+ request.setTo(jid);
+ request.setDataForm(config);
+
+ return chainIq(client()->sendIq(std::move(request)), this,
+ [](const QXmppPubSubIq<> &iq) -> InstantNodeResult {
+ return iq.queryNode();
+ });
+}
+
+///
/// Deletes a pubsub node.
///
/// \param jid Jabber ID of the entity hosting the pubsub service
@@ -561,7 +609,7 @@ QFuture<QXmppPubSubManager::Result> QXmppPubSubManager::cancelNodeConfiguration(
}
///
-/// \fn QXmppPubSubManager::createPepNode
+/// \fn QFuture<Result> QXmppPubSubManager::createPepNode(const QString &nodeName)
///
/// Creates an empty PEP node with the default configuration.
///
@@ -577,6 +625,23 @@ QFuture<QXmppPubSubManager::Result> QXmppPubSubManager::cancelNodeConfiguration(
///
///
+/// \fn QFuture<Result> QXmppPubSubManager::createPepNode(const QString &nodeName, const QXmppPubSubNodeConfig &config)
+///
+/// Creates an empty PEP node with a custom configuration.
+///
+/// This is a convenience method equivalent to calling
+/// QXmppPubSubManager::createNode on the current account's bare JID.
+///
+/// Calling this before QXmppPubSubManager::publishPepItems 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}).
+///
+/// \param nodeName the name of the PEP node to be created
+/// \param config The configuration for the node
+/// \return
+///
+
+///
/// \fn QXmppPubSubManager::deletePepNode
///
/// Deletes a PEP node.