5 #include <QXmppPubSubEvent.h> 6 #include <QXmppPubSubManager.h> 8 #include "StringLiterals.h" 13 using GetResult = std::variant<T, QXmppError>;
14 using PublishResult = std::variant<QString, QXmppError>;
16 template<
typename ItemT>
19 auto result = co_await pubSub->
requestItems<ItemT>(jid, nodeName);
22 if (!
getValue(result).items.isEmpty()) {
23 co_return
getValue(result).items.constFirst();
25 co_return
QXmppError { u
"User has no published items."_s, {} };
27 co_return
getError(std::move(result));
33 template<
typename ItemT,
typename NodeName,
typename Manager,
typename ReceivedSignal>
34 inline bool handlePubSubEvent(
const QDomElement &element,
const QString &pubSubService,
const QString &eventNode, NodeName nodeName,
Manager *manager, ReceivedSignal itemReceived)
40 if (event.
eventType() == QXmppPubSubEventBase::Items) {
41 if (!event.
items().isEmpty()) {
42 (manager->*itemReceived)(pubSubService, event.
items().constFirst());
44 (manager->*itemReceived)(pubSubService, {});
47 }
else if (event.
eventType() == QXmppPubSubEventBase::Retract) {
48 (manager->*itemReceived)(pubSubService, {});
const T & getValue(const Result< T > &r)
Definition: QXmppGlobal.h:232
Definition: QXmppPep_p.h:10
Definition: QXmppError.h:17
Definition: QXmppTask.h:67
virtual void parse(const QDomElement &)=0
QVector< T > items() const
Definition: QXmppPubSubEvent.h:99
QXmppTask< ItemsResult< T > > requestItems(const QString &jid, const QString &nodeName)
Definition: QXmppPubSubManager.h:209
const QXmppError & getError(const Result< T > &r)
Definition: QXmppError.h:68
EventType eventType() const
Definition: QXmppPubSubEvent.cpp:109
Definition: QXmppOmemoManager.h:68
bool hasValue(const Result< T > &r)
Definition: QXmppGlobal.h:216
The QXmppPubSubEvent class represents a PubSub event notification as defined by XEP-0060: Publish-Sub...
Definition: QXmppPubSubEvent.h:77
The QXmppPubSubManager aims to provide publish-subscribe functionality as specified in XEP-0060: Publ...
Definition: QXmppPubSubManager.h:20