5#ifndef QXMPPDISCOVERYMANAGER_P_H
6#define QXMPPDISCOVERYMANAGER_P_H
8#include "QXmppDiscoveryManager.h"
9#include "QXmppPromise.h"
15using namespace QXmpp::Private;
17namespace QXmpp::Private {
19template<
typename Params,
typename Response>
20struct AttachableRequests {
23 std::vector<QXmppPromise<Response>> promises;
26 std::vector<Request> requests;
29 std::optional<QXmppTask<Response>> attach(
const Params &key)
31 auto itr = std::ranges::find(requests, key, &Request::params);
32 if (itr != requests.end()) {
35 itr->promises.push_back(std::move(p));
44 Q_ASSERT(!contains(requests, key, &Request::params));
48 requests.push_back(Request { key, { std::move(p) } });
52 void finish(
const Params &key, Response &&response)
54 auto itr = std::ranges::find(requests, key, &Request::params);
55 Q_ASSERT(itr != requests.end());
56 if (itr == requests.end()) {
60 auto promises = std::move(itr->promises);
63 for (
auto it = promises.begin(); it != promises.end(); ++it) {
65 it->finish(std::next(it) == promises.end() ? std::move(response) : response);
71 if (
auto task = attach(key)) {
74 auto task = makeNew(key);
75 requestFunction(key).then(context, [
this, key](
auto &&response) {
76 finish(key, std::move(response));
84class QXmppDiscoveryManagerPrivate
90 QString clientCapabilitiesNode;
91 QList<QXmppDiscoIdentity> identities;
92 QList<QXmppDataForm> dataForms;
96 QCache<std::tuple<QString, QString>, QList<QXmppDiscoItem>> itemsCache;
104 static QString defaultApplicationName();
107 std::variant<CompatIq<QXmppDiscoInfo>,
StanzaError> handleIq(GetIq<QXmppDiscoInfo> &&iq);
108 std::variant<CompatIq<QXmppDiscoItems>,
StanzaError> handleIq(GetIq<QXmppDiscoItems> &&iq);
Definition QXmppDiscoveryIq.h:83
Definition QXmppDiscoveryIq.h:142
The QXmppDiscoveryManager class makes it possible to discover information about other entities as def...
Definition QXmppDiscoveryManager.h:23
Create and update QXmppTask objects to communicate results of asynchronous operations.
Definition QXmppPromise.h:23
QXmppTask< T > task()
Definition QXmppPromise.h:86
The Error class represents a stanza error.
Definition QXmppStanza.h:96
Definition QXmppTask.h:46
std::variant< T, QXmppError > Result
Definition QXmppGlobal.h:205