diff options
Diffstat (limited to 'Swiften/StreamStack/TLSLayer.cpp')
-rw-r--r-- | Swiften/StreamStack/TLSLayer.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/Swiften/StreamStack/TLSLayer.cpp b/Swiften/StreamStack/TLSLayer.cpp index ced879e..9f84889 100644 --- a/Swiften/StreamStack/TLSLayer.cpp +++ b/Swiften/StreamStack/TLSLayer.cpp @@ -1,3 +1,3 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. @@ -8,2 +8,4 @@ +#include <memory> + #include <boost/bind.hpp> @@ -15,8 +17,7 @@ namespace Swift { -TLSLayer::TLSLayer(TLSContextFactory* factory, const TLSOptions& tlsOptions) { - context = factory->createTLSContext(tlsOptions); - context->onDataForNetwork.connect(boost::bind(&TLSLayer::writeDataToChildLayer, this, _1)); - context->onDataForApplication.connect(boost::bind(&TLSLayer::writeDataToParentLayer, this, _1)); - context->onConnected.connect(onConnected); - context->onError.connect(onError); +TLSLayer::TLSLayer(std::unique_ptr<TLSContext> tlsContext) : context_(std::move(tlsContext)) { + context_->onDataForNetwork.connect(boost::bind(&TLSLayer::writeDataToChildLayer, this, _1)); + context_->onDataForApplication.connect(boost::bind(&TLSLayer::writeDataToParentLayer, this, _1)); + context_->onConnected.connect(onConnected); + context_->onError.connect(onError); } @@ -24,3 +25,2 @@ TLSLayer::TLSLayer(TLSContextFactory* factory, const TLSOptions& tlsOptions) { TLSLayer::~TLSLayer() { - delete context; } @@ -28,3 +28,3 @@ TLSLayer::~TLSLayer() { void TLSLayer::connect() { - context->connect(); + context_->connect(); } @@ -32,3 +32,3 @@ void TLSLayer::connect() { void TLSLayer::writeData(const SafeByteArray& data) { - context->handleDataFromApplication(data); + context_->handleDataFromApplication(data); } @@ -36,3 +36,3 @@ void TLSLayer::writeData(const SafeByteArray& data) { void TLSLayer::handleDataRead(const SafeByteArray& data) { - context->handleDataFromNetwork(data); + context_->handleDataFromNetwork(data); } @@ -40,3 +40,3 @@ void TLSLayer::handleDataRead(const SafeByteArray& data) { bool TLSLayer::setClientCertificate(CertificateWithKey::ref certificate) { - return context->setClientCertificate(certificate); + return context_->setClientCertificate(certificate); } @@ -44,3 +44,3 @@ bool TLSLayer::setClientCertificate(CertificateWithKey::ref certificate) { Certificate::ref TLSLayer::getPeerCertificate() const { - return context->getPeerCertificate(); + return context_->getPeerCertificate(); } @@ -48,3 +48,3 @@ Certificate::ref TLSLayer::getPeerCertificate() const { std::vector<Certificate::ref> TLSLayer::getPeerCertificateChain() const { - return context->getPeerCertificateChain(); + return context_->getPeerCertificateChain(); } @@ -52,3 +52,3 @@ std::vector<Certificate::ref> TLSLayer::getPeerCertificateChain() const { std::shared_ptr<CertificateVerificationError> TLSLayer::getPeerCertificateVerificationError() const { - return context->getPeerCertificateVerificationError(); + return context_->getPeerCertificateVerificationError(); } |