10#include "QXmppPubSubBaseItem.h"
15#include <QSharedDataPointer>
22namespace QXmpp::Private {
26class QXMPP_EXPORT PubSubIqBase :
public QXmppIq
30 enum QueryType : uint8_t {
51 PubSubIqBase(
const PubSubIqBase &other);
54 PubSubIqBase &operator=(
const PubSubIqBase &other);
56 QueryType queryType()
const;
57 void setQueryType(QueryType queryType);
59 QString queryJid()
const;
60 void setQueryJid(
const QString &queryJid);
62 QString queryNode()
const;
63 void setQueryNode(
const QString &queryNode);
65 QString subscriptionId()
const;
66 void setSubscriptionId(
const QString &subscriptionId);
68 QVector<QXmppPubSubSubscription> subscriptions()
const;
69 void setSubscriptions(
const QVector<QXmppPubSubSubscription> &);
71 std::optional<QXmppPubSubSubscription> subscription()
const;
72 void setSubscription(
const std::optional<QXmppPubSubSubscription> &);
74 QVector<QXmppPubSubAffiliation> affiliations()
const;
75 void setAffiliations(
const QVector<QXmppPubSubAffiliation> &);
77 std::optional<uint32_t> maxItems()
const;
78 void setMaxItems(std::optional<uint32_t>);
80 std::optional<QXmppDataForm> dataForm()
const;
81 void setDataForm(
const std::optional<QXmppDataForm> &);
83 std::optional<QXmppResultSetReply> itemsContinuation()
const;
84 void setItemsContinuation(
const std::optional<QXmppResultSetReply> &itemsContinuation);
87 static bool isPubSubIq(
const QDomElement &element);
90 static bool isPubSubIq(
const QDomElement &element,
91 bool (*isItemValid)(
const QDomElement &));
93 void parseElementFromChild(
const QDomElement &)
override;
94 void toXmlElementFromChild(QXmlStreamWriter *writer)
const override;
96 virtual void parseItems(
const QDomElement &queryElement) = 0;
97 virtual void serializeItems(QXmlStreamWriter *writer)
const = 0;
101 static std::optional<QueryType> queryTypeFromDomElement(
const QDomElement &element);
102 static bool queryTypeIsOwnerIq(QueryType type);
104 QSharedDataPointer<PubSubIqPrivate> d;
107template<
typename T = QXmppPubSubBaseItem>
108class PubSubIq :
public PubSubIqBase
111 QVector<T> items()
const;
112 void setItems(
const QVector<T> &items);
114 static bool isPubSubIq(
const QDomElement &element);
118 void parseItems(
const QDomElement &queryElement)
override;
119 void serializeItems(QXmlStreamWriter *writer)
const override;
127QVector<T> PubSubIq<T>::items()
const
133void PubSubIq<T>::setItems(
const QVector<T> &items)
139bool PubSubIq<T>::isPubSubIq(
const QDomElement &element)
141 return PubSubIqBase::isPubSubIq(element, [](
const QDomElement &item) ->
bool {
142 return T::isItem(item);
148void PubSubIq<T>::parseItems(
const QDomElement &queryElement)
150 for (
auto childElement = queryElement.firstChildElement(QStringLiteral(
"item"));
151 !childElement.isNull();
152 childElement = childElement.nextSiblingElement(QStringLiteral(
"item"))) {
154 item.parse(childElement);
155 m_items.push_back(std::move(item));
160void PubSubIq<T>::serializeItems(QXmlStreamWriter *writer)
const
162 for (
const auto &item : std::as_const(m_items)) {
The QXmppIq class is the base class for all IQs.
Definition: QXmppIq.h:23
Definition: QXmppPubSubAffiliation.h:18
Definition: QXmppPubSubSubscription.h:19
The QXmppResultSetReply class represents a set element in a reply as defined by XEP-0059: Result Set ...
Definition: QXmppResultSet.h:50