summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swiften/IDN/PlatformIDNConverter.cpp10
-rw-r--r--Swiften/IDN/PlatformIDNConverter.h6
-rw-r--r--Swiften/Network/BoostNetworkFactories.cpp7
-rw-r--r--Swiften/Network/BoostNetworkFactories.h8
4 files changed, 17 insertions, 14 deletions
diff --git a/Swiften/IDN/PlatformIDNConverter.cpp b/Swiften/IDN/PlatformIDNConverter.cpp
index c6104fb..3564bb9 100644
--- a/Swiften/IDN/PlatformIDNConverter.cpp
+++ b/Swiften/IDN/PlatformIDNConverter.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2018 Isode Limited.
+ * Copyright (c) 2012-2019 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -13,16 +13,16 @@
namespace Swift {
-IDNConverter* PlatformIDNConverter::create() {
+std::unique_ptr<IDNConverter> PlatformIDNConverter::create() {
#if defined(HAVE_LIBIDN)
- return new LibIDNConverter();
+ return std::make_unique<LibIDNConverter>();
#elif defined(HAVE_ICU)
- return new ICUConverter();
+ return std::make_unique<ICUConverter>();
#else
#if defined(NEED_IDN)
#error "No IDN implementation"
#else
- return nullptr;
+ return {};
#endif
#endif
}
diff --git a/Swiften/IDN/PlatformIDNConverter.h b/Swiften/IDN/PlatformIDNConverter.h
index 704f7a7..3b9a275 100644
--- a/Swiften/IDN/PlatformIDNConverter.h
+++ b/Swiften/IDN/PlatformIDNConverter.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012 Isode Limited.
+ * Copyright (c) 2012-2019 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -8,10 +8,12 @@
#include <Swiften/Base/API.h>
+#include <memory>
+
namespace Swift {
class IDNConverter;
namespace PlatformIDNConverter {
- SWIFTEN_API IDNConverter* create();
+ SWIFTEN_API std::unique_ptr<IDNConverter> create();
}
}
diff --git a/Swiften/Network/BoostNetworkFactories.cpp b/Swiften/Network/BoostNetworkFactories.cpp
index 9fef73c..13a7960 100644
--- a/Swiften/Network/BoostNetworkFactories.cpp
+++ b/Swiften/Network/BoostNetworkFactories.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2019 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -44,9 +44,9 @@ BoostNetworkFactories::BoostNetworkFactories(EventLoop* eventLoop, std::shared_p
idnConverter = PlatformIDNConverter::create();
#ifdef USE_UNBOUND
// TODO: What to do about idnConverter.
- domainNameResolver = new UnboundDomainNameResolver(idnConverter, ioServiceThread.getIOService(), eventLoop);
+ domainNameResolver = new UnboundDomainNameResolver(idnConverter.get(), ioServiceThread.getIOService(), eventLoop);
#else
- domainNameResolver = new PlatformDomainNameResolver(idnConverter, eventLoop);
+ domainNameResolver = new PlatformDomainNameResolver(idnConverter.get(), eventLoop);
#endif
cryptoProvider = PlatformCryptoProvider::create();
}
@@ -54,7 +54,6 @@ BoostNetworkFactories::BoostNetworkFactories(EventLoop* eventLoop, std::shared_p
BoostNetworkFactories::~BoostNetworkFactories() {
delete cryptoProvider;
delete domainNameResolver;
- delete idnConverter;
delete proxyProvider;
delete tlsFactories;
delete xmlParserFactory;
diff --git a/Swiften/Network/BoostNetworkFactories.h b/Swiften/Network/BoostNetworkFactories.h
index 2bf8d33..33a3584 100644
--- a/Swiften/Network/BoostNetworkFactories.h
+++ b/Swiften/Network/BoostNetworkFactories.h
@@ -1,11 +1,13 @@
/*
- * Copyright (c) 2010-2017 Isode Limited.
+ * Copyright (c) 2010-2019 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
+#include <memory>
+
#include <Swiften/Base/API.h>
#include <Swiften/Network/BoostIOServiceThread.h>
#include <Swiften/Network/NetworkFactories.h>
@@ -68,7 +70,7 @@ namespace Swift {
}
virtual IDNConverter* getIDNConverter() const override {
- return idnConverter;
+ return idnConverter.get();
}
virtual CryptoProvider* getCryptoProvider() const override {
@@ -87,7 +89,7 @@ namespace Swift {
PlatformTLSFactories* tlsFactories;
ProxyProvider* proxyProvider;
EventLoop* eventLoop;
- IDNConverter* idnConverter;
+ std::unique_ptr<IDNConverter> idnConverter;
CryptoProvider* cryptoProvider;
};
}