From 97cb75b28b2a3c5825b55a0541dccaf50e45b35d Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Tue, 28 Jan 2020 18:26:46 +0100 Subject: Make QXmppTlsManager an internal client extension This removes the QXmppTlsManager from the public API and makes it an internal client extension. It was not of any use for the end user and was configured via the QXmppClient (as before). This way we can obsolete some public methods of the QXmppClient, that also have been added with the new TLS manager. This can be done without any concerns because the manager was not part of the public API in any release, yet. --- src/client/QXmppClient.cpp | 2 +- src/client/QXmppTlsManager.cpp | 15 +++++++---- src/client/QXmppTlsManager.h | 45 -------------------------------- src/client/QXmppTlsManager_p.h | 58 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 51 deletions(-) delete mode 100644 src/client/QXmppTlsManager.h create mode 100644 src/client/QXmppTlsManager_p.h (limited to 'src/client') diff --git a/src/client/QXmppClient.cpp b/src/client/QXmppClient.cpp index 7763676b..5fb1b869 100644 --- a/src/client/QXmppClient.cpp +++ b/src/client/QXmppClient.cpp @@ -33,7 +33,7 @@ #include "QXmppMessage.h" #include "QXmppUtils.h" -#include "QXmppTlsManager.h" +#include "QXmppTlsManager_p.h" #include "QXmppRosterManager.h" #include "QXmppVCardManager.h" #include "QXmppVersionManager.h" diff --git a/src/client/QXmppTlsManager.cpp b/src/client/QXmppTlsManager.cpp index 061a3cba..683d6ec2 100644 --- a/src/client/QXmppTlsManager.cpp +++ b/src/client/QXmppTlsManager.cpp @@ -21,27 +21,31 @@ * */ -#include "QXmppTlsManager.h" +#include "QXmppTlsManager_p.h" #include "QXmppConstants_p.h" #include "QXmppClient.h" +#include "QXmppClient_p.h" +#include "QXmppOutgoingClient.h" #include "QXmppStreamFeatures.h" #include "QXmppStartTlsPacket.h" #include +#include +/// \cond QXmppTlsManager::QXmppTlsManager() = default; bool QXmppTlsManager::handleStanza(const QDomElement &stanza) { - if (QXmppStreamFeatures::isStreamFeatures(stanza) && !client()->isSocketEncrypted()) { + if (QXmppStreamFeatures::isStreamFeatures(stanza) && !clientStream()->socket()->isEncrypted()) { QXmppStreamFeatures features; features.parse(stanza); // determine TLS mode to use const QXmppConfiguration::StreamSecurityMode localSecurity = client()->configuration().streamSecurityMode(); const QXmppStreamFeatures::Mode remoteSecurity = features.tlsMode(); - if (!client()->socketSupportsSsl() && + if (!clientStream()->socket()->supportsSsl() && (localSecurity == QXmppConfiguration::TLSRequired || remoteSecurity == QXmppStreamFeatures::Required)) { warning("Disconnecting since TLS is required, but SSL support is not available"); @@ -55,7 +59,7 @@ bool QXmppTlsManager::handleStanza(const QDomElement &stanza) return true; } - if (client()->socketSupportsSsl() && + if (clientStream()->socket()->supportsSsl() && localSecurity != QXmppConfiguration::TLSDisabled && remoteSecurity != QXmppStreamFeatures::Disabled) { // enable TLS since it is supported by both parties @@ -66,9 +70,10 @@ bool QXmppTlsManager::handleStanza(const QDomElement &stanza) if (QXmppStartTlsPacket::isStartTlsPacket(stanza, QXmppStartTlsPacket::Proceed)) { debug("Starting encryption"); - client()->startSocketEncryption(); + clientStream()->socket()->startClientEncryption(); return true; } return false; } +/// \endcond diff --git a/src/client/QXmppTlsManager.h b/src/client/QXmppTlsManager.h deleted file mode 100644 index 086bfdf7..00000000 --- a/src/client/QXmppTlsManager.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2008-2020 The QXmpp developers - * - * Authors: - * Linus Jahn - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - -#ifndef QXMPPTLSMANAGER_H -#define QXMPPTLSMANAGER_H - -#include "QXmppClientExtension.h" - -/// \brief The QXmppTlsManager enables the QXmppClient to use STARTTLS. It is -/// added to the client by default and can be configured using the -/// \c QXmppConfiguration class. -/// -/// \ingroup Managers - -class QXMPP_EXPORT QXmppTlsManager : public QXmppClientExtension -{ - Q_OBJECT - -public: - QXmppTlsManager(); - - bool handleStanza(const QDomElement &stanza) override; -}; - -#endif // QXMPPTLSMANAGER_H diff --git a/src/client/QXmppTlsManager_p.h b/src/client/QXmppTlsManager_p.h new file mode 100644 index 00000000..562ac273 --- /dev/null +++ b/src/client/QXmppTlsManager_p.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2008-2020 The QXmpp developers + * + * Authors: + * Linus Jahn + * + * Source: + * https://github.com/qxmpp-project/qxmpp + * + * This file is a part of QXmpp library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the QXmpp API. +// +// This header file may change from version to version without notice, +// or even be removed. +// +// We mean it. +// + +#ifndef QXMPPTLSMANAGER_H +#define QXMPPTLSMANAGER_H + +#include "QXmppInternalClientExtension_p.h" + +/// +/// \brief The QXmppTlsManager enables the QXmppClient to use STARTTLS. It is +/// added to the client by default and can be configured using the +/// \c QXmppConfiguration class. +/// +/// \ingroup Managers +/// +class QXmppTlsManager : public QXmppInternalClientExtension +{ + Q_OBJECT + +public: + QXmppTlsManager(); + + bool handleStanza(const QDomElement &stanza) override; +}; + +#endif // QXMPPTLSMANAGER_H -- cgit v1.2.3