summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/StreamStack')
-rw-r--r--Swiften/StreamStack/TLSLayer.cpp30
-rw-r--r--Swiften/StreamStack/TLSLayer.h8
2 files changed, 19 insertions, 19 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();
}
diff --git a/Swiften/StreamStack/TLSLayer.h b/Swiften/StreamStack/TLSLayer.h
index 415a3f0..89588e3 100644
--- a/Swiften/StreamStack/TLSLayer.h
+++ b/Swiften/StreamStack/TLSLayer.h
@@ -1,3 +1,3 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
@@ -25,3 +25,3 @@ namespace Swift {
public:
- TLSLayer(TLSContextFactory*, const TLSOptions&);
+ TLSLayer(std::unique_ptr<TLSContext> tlsContext);
virtual ~TLSLayer();
@@ -39,3 +39,3 @@ namespace Swift {
TLSContext* getContext() const {
- return context;
+ return context_.get();
}
@@ -47,3 +47,3 @@ namespace Swift {
private:
- TLSContext* context;
+ std::unique_ptr<TLSContext> context_;
};