From 0437105de6e9a544d25f230e30000c18bac0d67c Mon Sep 17 00:00:00 2001 From: Sergei Ilinykh Date: Sun, 14 Apr 2024 21:06:52 +0300 Subject: [PATCH] Fix pep discovery --- src/xmpp/xmpp-im/xmpp_serverinfomanager.cpp | 43 ++++++++++++++------- src/xmpp/xmpp-im/xmpp_serverinfomanager.h | 3 +- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/xmpp/xmpp-im/xmpp_serverinfomanager.cpp b/src/xmpp/xmpp-im/xmpp_serverinfomanager.cpp index 5db2e3af..d40ab4fc 100644 --- a/src/xmpp/xmpp-im/xmpp_serverinfomanager.cpp +++ b/src/xmpp/xmpp-im/xmpp_serverinfomanager.cpp @@ -43,12 +43,21 @@ void ServerInfoManager::reset() void ServerInfoManager::initialize() { - connect(_client, SIGNAL(disconnected()), SLOT(deinitialize())); - JT_DiscoInfo *jt = new JT_DiscoInfo(_client->rootTask()); - connect(jt, SIGNAL(finished()), SLOT(disco_finished())); - jt->get(_client->jid().domain()); - jt->go(true); + connect(_client, &XMPP::Client::disconnected, this, &ServerInfoManager::deinitialize); + { + JT_DiscoInfo *jt = new JT_DiscoInfo(_client->rootTask()); + connect(jt, &JT_DiscoInfo::finished, this, &ServerInfoManager::server_disco_finished); + jt->get(_client->jid().domain()); + jt->go(true); + } + + { + JT_DiscoInfo *jt = new JT_DiscoInfo(_client->rootTask()); + connect(jt, &JT_DiscoInfo::finished, this, &ServerInfoManager::account_disco_finished); + jt->get(_client->jid().bare()); + jt->go(true); + } queryServicesList(); } @@ -253,7 +262,7 @@ QVariant ServerInfoManager::serviceMeta(const Jid &service, const QString &key) return QVariant(); } -void ServerInfoManager::disco_finished() +void ServerInfoManager::server_disco_finished() { JT_DiscoInfo *jt = static_cast(sender()); if (jt->success()) { @@ -264,13 +273,6 @@ void ServerInfoManager::disco_finished() _canMessageCarbons = _features.hasMessageCarbons(); - // Identities - DiscoItem::Identities is = jt->item().identities(); - for (const DiscoItem::Identity &i : is) { - if (i.category == "pubsub" && i.type == "pep") - _hasPEP = true; - } - auto servInfo = jt->item().findExtension(XData::Data_Result, QLatin1String("http://jabber.org/network/serverinfo")); if (servInfo.isValid()) { @@ -284,4 +286,19 @@ void ServerInfoManager::disco_finished() emit featuresChanged(); } } + +void ServerInfoManager::account_disco_finished() +{ + JT_DiscoInfo *jt = static_cast(sender()); + if (jt->success()) { + // Identities + DiscoItem::Identities is = jt->item().identities(); + for (const DiscoItem::Identity &i : is) { + if (i.category == "pubsub" && i.type == "pep") + _hasPEP = true; + } + + emit featuresChanged(); + } +} } // namespace XMPP diff --git a/src/xmpp/xmpp-im/xmpp_serverinfomanager.h b/src/xmpp/xmpp-im/xmpp_serverinfomanager.h index 8a6a795a..3c816e8e 100644 --- a/src/xmpp/xmpp-im/xmpp_serverinfomanager.h +++ b/src/xmpp/xmpp-im/xmpp_serverinfomanager.h @@ -112,7 +112,8 @@ class ServerInfoManager : public QObject { void servicesChanged(); private slots: - void disco_finished(); + void server_disco_finished(); + void account_disco_finished(); void initialize(); void deinitialize(); void reset();