diff options
author | Tobias Markmann <tm@ayena.de> | 2018-07-28 11:45:35 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2018-07-30 13:27:15 (GMT) |
commit | 798f8ec3331043a92f6ca3bc810b9477c3f8261e (patch) | |
tree | 868bde2ddcbad1a66d4256edd6050f486860eb2b /Swiften/TLS/SecureTransport | |
parent | 48596613cfe0f45c0916beabbcc3a27e01752c4b (diff) | |
download | swift-798f8ec3331043a92f6ca3bc810b9477c3f8261e.zip swift-798f8ec3331043a92f6ca3bc810b9477c3f8261e.tar.bz2 |
Use std::unique_ptr to have TLS classes own the TLSContext
TLSLayer and TLSConnection now own the TLSContext they use.
The TLSContextFactory interface is adjusted to use
std::unique_ptr.
Test-Information:
Builds and all tests pass on macOS with clang-7-master.
Change-Id: I14e33c98b48445094f404b73ea41af0a51d2dde6
Diffstat (limited to 'Swiften/TLS/SecureTransport')
-rw-r--r-- | Swiften/TLS/SecureTransport/SecureTransportContextFactory.cpp | 4 | ||||
-rw-r--r-- | Swiften/TLS/SecureTransport/SecureTransportContextFactory.h | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/Swiften/TLS/SecureTransport/SecureTransportContextFactory.cpp b/Swiften/TLS/SecureTransport/SecureTransportContextFactory.cpp index dfb9d67..cc10987 100644 --- a/Swiften/TLS/SecureTransport/SecureTransportContextFactory.cpp +++ b/Swiften/TLS/SecureTransport/SecureTransportContextFactory.cpp @@ -26,10 +26,10 @@ bool SecureTransportContextFactory::canCreate() const { return true; } -TLSContext* SecureTransportContextFactory::createTLSContext(const TLSOptions& /* tlsOptions */, TLSContext::Mode mode) { +std::unique_ptr<TLSContext> SecureTransportContextFactory::createTLSContext(const TLSOptions& /* tlsOptions */, TLSContext::Mode mode) { // TLS server mode is not supported for the SecureTransport backend yet. assert(mode == TLSContext::Mode::Client); - return new SecureTransportContext(checkCertificateRevocation_); + return std::unique_ptr<TLSContext>(new SecureTransportContext(checkCertificateRevocation_)); } void SecureTransportContextFactory::setCheckCertificateRevocation(bool b) { diff --git a/Swiften/TLS/SecureTransport/SecureTransportContextFactory.h b/Swiften/TLS/SecureTransport/SecureTransportContextFactory.h index 5962424..b86639a 100644 --- a/Swiften/TLS/SecureTransport/SecureTransportContextFactory.h +++ b/Swiften/TLS/SecureTransport/SecureTransportContextFactory.h @@ -6,6 +6,8 @@ #pragma once +#include <memory> + #include <Swiften/TLS/TLSContextFactory.h> namespace Swift { @@ -17,7 +19,7 @@ class SecureTransportContextFactory : public TLSContextFactory { virtual bool canCreate() const; - virtual TLSContext* createTLSContext(const TLSOptions& tlsOptions, TLSContext::Mode mode = TLSContext::Mode::Client); + virtual std::unique_ptr<TLSContext> createTLSContext(const TLSOptions& tlsOptions, TLSContext::Mode mode = TLSContext::Mode::Client); virtual void setCheckCertificateRevocation(bool b); virtual void setDisconnectOnCardRemoval(bool b); |