Skip to content

Commit

Permalink
Fix pep discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
Ri0n committed Apr 14, 2024
1 parent b44b56d commit 0437105
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
43 changes: 30 additions & 13 deletions src/xmpp/xmpp-im/xmpp_serverinfomanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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<JT_DiscoInfo *>(sender());
if (jt->success()) {
Expand All @@ -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()) {
Expand All @@ -284,4 +286,19 @@ void ServerInfoManager::disco_finished()
emit featuresChanged();
}
}

void ServerInfoManager::account_disco_finished()
{
JT_DiscoInfo *jt = static_cast<JT_DiscoInfo *>(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
3 changes: 2 additions & 1 deletion src/xmpp/xmpp-im/xmpp_serverinfomanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 0437105

Please sign in to comment.