Skip to content

Commit

Permalink
MixManager: Improve comments and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
melvo committed Apr 22, 2024
1 parent acd49df commit 0b51549
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/client/QXmppMixManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1209,17 +1209,17 @@ void QXmppMixManager::handleDiscoInfo(const QXmppDiscoveryIq &iq)

const auto jid = iq.from().isEmpty() ? client()->configuration().domain() : iq.from();

// Search for a MIX service and check what it supports.
// if none can be found, remove them from the cache.
// If no MIX service is provided by the JID, remove it from the cache.
if (!iq.features().contains(ns_mix)) {
removeService(jid);
return;
}

const auto identities = iq.identities();

// Search for MIX features provided by the determined MIX service.
for (const QXmppDiscoveryIq::Identity &identity : identities) {
// ' || identity.type() == "text"' is a workaround for older ejabberd versions.
// ' || identity.type() == u"text"' is a workaround for older ejabberd versions.
if (identity.category() == u"conference" && (identity.type() == MIX_SERVICE_DISCOVERY_NODE || identity.type() == u"text")) {
Service service;
service.jid = iq.from().isEmpty() ? client()->configuration().domain() : iq.from();
Expand Down
18 changes: 15 additions & 3 deletions tests/qxmppmixmanager/tst_qxmppmixmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,23 @@ void tst_QXmppMixManager::testOnUnregistered()

manager.onUnregistered(&client);

QXmppDiscoveryIq iq;
iq.setFeatures({ QStringLiteral("urn:xmpp:mix:pam:2") });
Q_EMIT manager.client()->findExtension<QXmppDiscoveryManager>()->infoReceived(iq);
QVERIFY(!manager.supportedByServer());
QVERIFY(!manager.archivingSupportedByServer());
QVERIFY(manager.services().isEmpty());

QXmppDiscoveryIq::Identity identity;
identity.setCategory(QStringLiteral("conference"));
identity.setType(QStringLiteral("mix"));

QXmppDiscoveryIq iq;
iq.setFeatures({ QStringLiteral("urn:xmpp:mix:pam:2"),
QStringLiteral("urn:xmpp:mix:pam:2#archive"),
QStringLiteral("urn:xmpp:mix:core:1"),
QStringLiteral("urn:xmpp:mix:core:1#searchable"),
QStringLiteral("urn:xmpp:mix:core:1#create-channel") });
iq.setIdentities({ identity });

Q_EMIT manager.client()->findExtension<QXmppDiscoveryManager>()->infoReceived(iq);
QVERIFY(!manager.supportedByServer());
QVERIFY(!manager.archivingSupportedByServer());
QVERIFY(manager.services().isEmpty());
Expand Down

0 comments on commit 0b51549

Please sign in to comment.