aboutsummaryrefslogtreecommitdiff
path: root/src/client/QXmppClient.cpp
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2019-12-14 22:47:28 +0100
committerLNJ <lnj@kaidan.im>2020-01-20 17:14:49 +0100
commit28411b5995553eb3a50c826c55517b4c610959c2 (patch)
treec22ea3b5bd5c1de2831cb3141940038180ce878e /src/client/QXmppClient.cpp
parent55966be2e3e80bd5ab2cc86da2492963dd8127ee (diff)
downloadqxmpp-28411b5995553eb3a50c826c55517b4c610959c2.tar.gz
Move TLS negotiation into new QXmppTlsManager
Diffstat (limited to 'src/client/QXmppClient.cpp')
-rw-r--r--src/client/QXmppClient.cpp45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/client/QXmppClient.cpp b/src/client/QXmppClient.cpp
index 523a9e79..db56776a 100644
--- a/src/client/QXmppClient.cpp
+++ b/src/client/QXmppClient.cpp
@@ -32,6 +32,7 @@
#include "QXmppMessage.h"
#include "QXmppUtils.h"
+#include "QXmppTlsManager.h"
#include "QXmppRosterManager.h"
#include "QXmppVCardManager.h"
#include "QXmppVersionManager.h"
@@ -146,6 +147,7 @@ QXmppClient::QXmppClient(QObject *parent)
// logging
setLogger(QXmppLogger::getLogger());
+ addExtension(new QXmppTlsManager);
addExtension(new QXmppRosterManager(this));
addExtension(new QXmppVCardManager);
addExtension(new QXmppVersionManager);
@@ -447,15 +449,54 @@ QAbstractSocket::SocketError QXmppClient::socketError()
}
/// Returns the human-readable description of the last socket error if error() is QXmppClient::SocketError.
-///
QString QXmppClient::socketErrorString() const
{
return d->stream->socket()->errorString();
}
-/// Returns the XMPP stream error if QXmppClient::Error is QXmppClient::XmppStreamError.
+/// Returns true, if the used socket supports SSL / TLS encryption.
+///
+/// This is useful for checking whether TLS can be enabled. It is used by the
+/// \c QXmppTlsManager.
///
+/// \since QXmpp 1.2
+
+bool QXmppClient::socketSupportsSsl() const
+{
+ return d->stream->socket()->supportsSsl();
+}
+
+/// Returns true, if the socket used for connection to the XMPP server
+/// currently uses SSL / TLS encryption.
+///
+/// When using STARTTLS, this is false at first and becomes true later.
+///
+/// \since QXmpp 1.2
+
+bool QXmppClient::isSocketEncrypted() const
+{
+ return d->stream->socket()->isEncrypted();
+}
+
+/// If the socket supports SSL / TLS encryption, this method can be used to
+/// enable it.
+///
+/// This is used by the \c QXmppTlsManager to enable SSL / TLS encryption for
+/// STARTTLS.
+///
+/// \note You should usually not use this method manually. If you want to
+/// enable or disable TLS encryption, you can set this in the
+/// \c QXmppConfiguration provided to \c connectToServer().
+///
+/// \since QXmpp 1.2
+
+void QXmppClient::startSocketEncryption()
+{
+ d->stream->socket()->startClientEncryption();
+}
+
+/// Returns the XMPP stream error if QXmppClient::Error is QXmppClient::XmppStreamError.
QXmppStanza::Error::Condition QXmppClient::xmppStreamError()
{