Description: Several changes required to fix compilation with packaged swiften.
Author: Tobias Frost <tobi@debian.org>
Last-Update: 2022-11-21 <YYYY-MM-DD, last update of the meta-information, optional>
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
diff --git a/include/Swiften/Network/DummyConnectionServer.cpp b/include/Swiften/Network/DummyConnectionServer.cpp
deleted file mode 100644
index ca52312..0000000
--- a/include/Swiften/Network/DummyConnectionServer.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#include <Swiften/Network/DummyConnectionServer.h>
-
-#include <boost/bind.hpp>
-#include <boost/system/system_error.hpp>
-#include <boost/asio/placeholders.hpp>
-
-#include <Swiften/EventLoop/EventLoop.h>
-
-namespace Swift {
-
-DummyConnectionServer::DummyConnectionServer(EventLoop* eventLoop) : eventLoop(eventLoop) {
-}
-
-void DummyConnectionServer::start() {
-}
-
-
-void DummyConnectionServer::stop() {
-	
-}
-
-void DummyConnectionServer::acceptConnection(std::shared_ptr<Swift::Connection> connection) {
-		eventLoop->postEvent(
-				boost::bind(boost::ref(onNewConnection), connection));
-// 		connection->listen();
-}
-
-
-HostAddressPort DummyConnectionServer::getAddressPort() const {
-	return HostAddressPort();
-}
-
-}
diff --git a/include/Swiften/Network/DummyConnectionServer.h b/include/Swiften/Network/DummyConnectionServer.h
deleted file mode 100644
index f71ca0c..0000000
--- a/include/Swiften/Network/DummyConnectionServer.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include <boost/asio/io_service.hpp>
-#include <boost/asio/ip/tcp.hpp>
-#include <boost/enable_shared_from_this.hpp>
-#include <boost/signals2.hpp>
-
-#include <Swiften/Network/DummyConnection.h>
-#include <Swiften/Network/ConnectionServer.h>
-#include <Swiften/EventLoop/EventOwner.h>
-#include <Swiften/Version.h>
-
-namespace Swift {
-	class DummyConnectionServer : public ConnectionServer {
-		public:
-			enum Error {
-				Conflict,
-				UnknownError
-			};
-
-			static std::shared_ptr<Swift::DummyConnectionServer> create(EventLoop* eventLoop) {
-				return std::shared_ptr<Swift::DummyConnectionServer>(new DummyConnectionServer(eventLoop));
-			}
-
-			void acceptConnection(std::shared_ptr<Swift::Connection> connection);
-
-			virtual boost::optional<ConnectionServer::Error> tryStart() {
-				return boost::optional<ConnectionServer::Error>();
-			}
-
-			virtual void start();
-			virtual void stop();
-
-			virtual HostAddressPort getAddressPort() const;
-
-
-		private:
-			DummyConnectionServer(EventLoop* eventLoop);
-
-
-		private:
-			HostAddress address_;
-			EventLoop* eventLoop;
-	};
-}
diff --git a/include/Swiften/Network/DummyConnectionServerFactory.cpp b/include/Swiften/Network/DummyConnectionServerFactory.cpp
deleted file mode 100644
index b3b8dfe..0000000
--- a/include/Swiften/Network/DummyConnectionServerFactory.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2011 Jan Kaluza
- * Licensed under the Simplified BSD license.
- * See Documentation/Licenses/BSD-simplified.txt for more information.
- */
-
-#include <Swiften/Network/DummyConnectionServerFactory.h>
-#include <Swiften/Network/DummyConnectionServer.h>
-
-namespace Swift {
-
-DummyConnectionServerFactory::DummyConnectionServerFactory(EventLoop* eventLoop) : eventLoop(eventLoop) {
-}
-
-std::shared_ptr<ConnectionServer> DummyConnectionServerFactory::createConnectionServer(int port) {
-	return DummyConnectionServer::create(eventLoop);
-}
-
-std::shared_ptr<ConnectionServer> DummyConnectionServerFactory::createConnectionServer(const Swift::HostAddress &hostAddress, int port) {
-	return DummyConnectionServer::create(eventLoop);
-}
-
-}
diff --git a/include/Swiften/Network/DummyConnectionServerFactory.h b/include/Swiften/Network/DummyConnectionServerFactory.h
deleted file mode 100644
index 527d2d3..0000000
--- a/include/Swiften/Network/DummyConnectionServerFactory.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2011 Jan Kaluza
- * Licensed under the Simplified BSD license.
- * See Documentation/Licenses/BSD-simplified.txt for more information.
- */
-
-#pragma once
-
-#include <boost/asio/io_service.hpp>
-
-#include <Swiften/Network/ConnectionServerFactory.h>
-#include <Swiften/Network/DummyConnectionServer.h>
-
-namespace Swift {
-	class ConnectionServer;
-
-	class DummyConnectionServerFactory : public ConnectionServerFactory {
-		public:
-			DummyConnectionServerFactory(EventLoop* eventLoop);
-
-			virtual std::shared_ptr<ConnectionServer> createConnectionServer(int port);
-
-			virtual std::shared_ptr<ConnectionServer> createConnectionServer(const Swift::HostAddress &hostAddress, int port);
-
-		private:
-			EventLoop* eventLoop;
-	};
-}
diff --git a/include/Swiften/Server/ServerFromClientSession.cpp b/include/Swiften/Server/ServerFromClientSession.cpp
index 0087790..c9dc8df 100644
--- a/include/Swiften/Server/ServerFromClientSession.cpp
+++ b/include/Swiften/Server/ServerFromClientSession.cpp
@@ -46,15 +46,12 @@ ServerFromClientSession::ServerFromClientSession(
 			authenticated_(false),
 			initialized(false),
 			allowSASLEXTERNAL(false),
-			tlsLayer(0),
 			tlsConnected(false) {
 				setRemoteJID(remoteJID);
 }
 
 ServerFromClientSession::~ServerFromClientSession() {
-	if (tlsLayer) {
-		delete tlsLayer;
-	}
+	tlsLayer.reset();
 }
 
 void ServerFromClientSession::handlePasswordValid() {
@@ -102,8 +99,9 @@ void ServerFromClientSession::handleElement(std::shared_ptr<ToplevelElement> ele
 		}
 		else if (dynamic_cast<StartTLSRequest*>(element.get()) != NULL) {
 			getXMPPLayer()->writeElement(std::shared_ptr<TLSProceed>(new TLSProceed));
-			getStreamStack()->addLayer(tlsLayer);
-			tlsLayer->connect();
+			auto ptls = tlsLayer.get();  // retain pointer for connect call.
+			getStreamStack()->addLayer(std::move(tlsLayer));
+			ptls->connect();
 			getXMPPLayer()->resetParser();
 		}
 		else if (IQ* iq = dynamic_cast<IQ*>(element.get())) {
@@ -165,7 +163,7 @@ void ServerFromClientSession::handleSessionFinished(const boost::optional<Sessio
 }
 
 void ServerFromClientSession::addTLSEncryption(TLSServerContextFactory* tlsContextFactory, CertificateWithKey::ref cert) {
-	tlsLayer = new TLSServerLayer(tlsContextFactory);
+	tlsLayer.reset(new TLSServerLayer(tlsContextFactory));
 	if (!tlsLayer->setServerCertificate(cert)) {
 // 		std::cout << "error\n";
 		// TODO:
diff --git a/include/Swiften/Server/ServerFromClientSession.h b/include/Swiften/Server/ServerFromClientSession.h
index 44ea366..5548fef 100644
--- a/include/Swiften/Server/ServerFromClientSession.h
+++ b/include/Swiften/Server/ServerFromClientSession.h
@@ -9,6 +9,7 @@
 #include <boost/signals2.hpp>
 
 #include <string>
+#include <memory>
 #include <Swiften/Session/Session.h>
 #include <Swiften/JID/JID.h>
 #include <Swiften/Network/Connection.h>
@@ -77,7 +78,7 @@ namespace Swift {
 			bool initialized;
 			bool allowSASLEXTERNAL;
 			std::string user_;
-			TLSServerLayer* tlsLayer;
+			std::unique_ptr<TLSServerLayer> tlsLayer;
 			bool tlsConnected;
 	};
 }
