From 0b5154955d6de61f7f2c21c6d3beb295a01a968a Mon Sep 17 00:00:00 2001 From: Melvin Keskin Date: Mon, 22 Apr 2024 19:27:12 +0200 Subject: [PATCH] MixManager: Improve comments and tests --- src/client/QXmppMixManager.cpp | 6 +++--- tests/qxmppmixmanager/tst_qxmppmixmanager.cpp | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/client/QXmppMixManager.cpp b/src/client/QXmppMixManager.cpp index 5460dc9a3..7fb961656 100644 --- a/src/client/QXmppMixManager.cpp +++ b/src/client/QXmppMixManager.cpp @@ -1209,8 +1209,7 @@ 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; @@ -1218,8 +1217,9 @@ void QXmppMixManager::handleDiscoInfo(const QXmppDiscoveryIq &iq) 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(); diff --git a/tests/qxmppmixmanager/tst_qxmppmixmanager.cpp b/tests/qxmppmixmanager/tst_qxmppmixmanager.cpp index 038e09f58..e9ec74186 100644 --- a/tests/qxmppmixmanager/tst_qxmppmixmanager.cpp +++ b/tests/qxmppmixmanager/tst_qxmppmixmanager.cpp @@ -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()->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()->infoReceived(iq); QVERIFY(!manager.supportedByServer()); QVERIFY(!manager.archivingSupportedByServer()); QVERIFY(manager.services().isEmpty());