From 7b0d7e727052119d40854b621f7da775ac2fea4c Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Mon, 4 Apr 2022 17:28:28 +0200 Subject: Client: Refactor: Use new 'StanzaPipeline' This is going to become useful when the other pipelines (messages, IQs) will follow. --- src/client/QXmppClient.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'src/client/QXmppClient.cpp') diff --git a/src/client/QXmppClient.cpp b/src/client/QXmppClient.cpp index 0b14bc68..b1c60233 100644 --- a/src/client/QXmppClient.cpp +++ b/src/client/QXmppClient.cpp @@ -107,6 +107,20 @@ QStringList QXmppClientPrivate::discoveryFeatures() } /// \endcond +namespace QXmpp::Private::StanzaPipeline { + +bool process(const QList &extensions, const QDomElement &element, const std::optional &e2eeMetadata) +{ + for (auto *extension : extensions) { + if (extension->handleStanza(element, e2eeMetadata) || extension->handleStanza(element)) { + return true; + } + } + return false; +} + +} + /// /// \typedef QXmppClient::IqResult /// @@ -765,20 +779,14 @@ QXmppVersionManager &QXmppClient::versionManager() return *findExtension(); } +/// /// Give extensions a chance to handle incoming stanzas. /// -/// \param element -/// \param handled - void QXmppClient::_q_elementReceived(const QDomElement &element, bool &handled) { - const std::optional e2eeMetadata; - for (auto *extension : std::as_const(d->extensions)) { - if (extension->handleStanza(element, e2eeMetadata) || extension->handleStanza(element)) { - handled = true; - return; - } - } + // The stanza comes directly from the XMPP stream, so it's not end-to-end + // encrypted and there's no e2ee metadata (std::nullopt). + handled = StanzaPipeline::process(d->extensions, element, std::nullopt); } void QXmppClient::_q_reconnect() -- cgit v1.2.3