summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2012-12-13 13:35:53 (GMT)
committerRemko Tronçon <git@el-tramo.be>2013-04-06 20:22:02 (GMT)
commit9eff25182d1bea576d1910200909384ce79d90fe (patch)
treef5dadbce5fa2c37c34fcc6bb32550e6930abce14 /Swiften/Network
parente9f2f7675b11ce36b3f66250156b78fae524a351 (diff)
downloadswift-9eff25182d1bea576d1910200909384ce79d90fe.zip
swift-9eff25182d1bea576d1910200909384ce79d90fe.tar.bz2
Make IDN implementation abstract.
Change-Id: I4c64f954ddeca7147d729b8be07237baa15c1795
Diffstat (limited to 'Swiften/Network')
-rw-r--r--Swiften/Network/BoostNetworkFactories.cpp8
-rw-r--r--Swiften/Network/BoostNetworkFactories.h24
-rw-r--r--Swiften/Network/NetworkFactories.h2
-rw-r--r--Swiften/Network/PlatformDomainNameResolver.cpp10
-rw-r--r--Swiften/Network/PlatformDomainNameResolver.h7
5 files changed, 32 insertions, 19 deletions
diff --git a/Swiften/Network/BoostNetworkFactories.cpp b/Swiften/Network/BoostNetworkFactories.cpp
index 488e519..41646c6 100644
--- a/Swiften/Network/BoostNetworkFactories.cpp
+++ b/Swiften/Network/BoostNetworkFactories.cpp
@@ -14,13 +14,14 @@
#include <Swiften/Network/NullNATTraverser.h>
#include <Swiften/TLS/PlatformTLSFactories.h>
#include <Swiften/Network/PlatformProxyProvider.h>
+#include <Swiften/IDN/PlatformIDNConverter.h>
+#include <Swiften/IDN/IDNConverter.h>
namespace Swift {
BoostNetworkFactories::BoostNetworkFactories(EventLoop* eventLoop) : eventLoop(eventLoop){
timerFactory = new BoostTimerFactory(ioServiceThread.getIOService(), eventLoop);
connectionFactory = new BoostConnectionFactory(ioServiceThread.getIOService(), eventLoop);
- domainNameResolver = new PlatformDomainNameResolver(eventLoop);
connectionServerFactory = new BoostConnectionServerFactory(ioServiceThread.getIOService(), eventLoop);
#ifdef SWIFT_EXPERIMENTAL_FT
natTraverser = new PlatformNATTraversalWorker(eventLoop);
@@ -30,15 +31,18 @@ BoostNetworkFactories::BoostNetworkFactories(EventLoop* eventLoop) : eventLoop(e
xmlParserFactory = new PlatformXMLParserFactory();
tlsFactories = new PlatformTLSFactories();
proxyProvider = new PlatformProxyProvider();
+ idnConverter = PlatformIDNConverter::create();
+ domainNameResolver = new PlatformDomainNameResolver(idnConverter, eventLoop);
}
BoostNetworkFactories::~BoostNetworkFactories() {
+ delete domainNameResolver;
+ delete idnConverter;
delete proxyProvider;
delete tlsFactories;
delete xmlParserFactory;
delete natTraverser;
delete connectionServerFactory;
- delete domainNameResolver;
delete connectionFactory;
delete timerFactory;
}
diff --git a/Swiften/Network/BoostNetworkFactories.h b/Swiften/Network/BoostNetworkFactories.h
index 1968acd..11797c6 100644
--- a/Swiften/Network/BoostNetworkFactories.h
+++ b/Swiften/Network/BoostNetworkFactories.h
@@ -7,6 +7,7 @@
#pragma once
#include <Swiften/Base/API.h>
+#include <Swiften/Base/Override.h>
#include <Swiften/Network/NetworkFactories.h>
#include <Swiften/Network/BoostIOServiceThread.h>
@@ -20,11 +21,11 @@ namespace Swift {
BoostNetworkFactories(EventLoop* eventLoop);
~BoostNetworkFactories();
- virtual TimerFactory* getTimerFactory() const {
+ virtual TimerFactory* getTimerFactory() const SWIFTEN_OVERRIDE {
return timerFactory;
}
- virtual ConnectionFactory* getConnectionFactory() const {
+ virtual ConnectionFactory* getConnectionFactory() const SWIFTEN_OVERRIDE {
return connectionFactory;
}
@@ -32,32 +33,36 @@ namespace Swift {
return &ioServiceThread;
}
- DomainNameResolver* getDomainNameResolver() const {
+ DomainNameResolver* getDomainNameResolver() const SWIFTEN_OVERRIDE {
return domainNameResolver;
}
- ConnectionServerFactory* getConnectionServerFactory() const {
+ ConnectionServerFactory* getConnectionServerFactory() const SWIFTEN_OVERRIDE {
return connectionServerFactory;
}
- NATTraverser* getNATTraverser() const {
+ NATTraverser* getNATTraverser() const SWIFTEN_OVERRIDE {
return natTraverser;
}
- virtual XMLParserFactory* getXMLParserFactory() const {
+ virtual XMLParserFactory* getXMLParserFactory() const SWIFTEN_OVERRIDE {
return xmlParserFactory;
}
- virtual TLSContextFactory* getTLSContextFactory() const;
+ virtual TLSContextFactory* getTLSContextFactory() const SWIFTEN_OVERRIDE;
- virtual ProxyProvider* getProxyProvider() const {
+ virtual ProxyProvider* getProxyProvider() const SWIFTEN_OVERRIDE {
return proxyProvider;
}
- virtual EventLoop* getEventLoop() const {
+ virtual EventLoop* getEventLoop() const SWIFTEN_OVERRIDE {
return eventLoop;
}
+ virtual IDNConverter* getIDNConverter() const SWIFTEN_OVERRIDE {
+ return idnConverter;
+ }
+
private:
BoostIOServiceThread ioServiceThread;
TimerFactory* timerFactory;
@@ -69,5 +74,6 @@ namespace Swift {
PlatformTLSFactories* tlsFactories;
ProxyProvider* proxyProvider;
EventLoop* eventLoop;
+ IDNConverter* idnConverter;
};
}
diff --git a/Swiften/Network/NetworkFactories.h b/Swiften/Network/NetworkFactories.h
index c8009a6..f24f493 100644
--- a/Swiften/Network/NetworkFactories.h
+++ b/Swiften/Network/NetworkFactories.h
@@ -17,6 +17,7 @@ namespace Swift {
class CertificateFactory;
class ProxyProvider;
class EventLoop;
+ class IDNConverter;
/**
* An interface collecting network factories.
@@ -34,5 +35,6 @@ namespace Swift {
virtual TLSContextFactory* getTLSContextFactory() const = 0;
virtual ProxyProvider* getProxyProvider() const = 0;
virtual EventLoop* getEventLoop() const = 0;
+ virtual IDNConverter* getIDNConverter() const = 0;
};
}
diff --git a/Swiften/Network/PlatformDomainNameResolver.cpp b/Swiften/Network/PlatformDomainNameResolver.cpp
index 63f7404..677f1d5 100644
--- a/Swiften/Network/PlatformDomainNameResolver.cpp
+++ b/Swiften/Network/PlatformDomainNameResolver.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -16,7 +16,7 @@
#include <algorithm>
#include <string>
-#include <Swiften/IDN/IDNA.h>
+#include <Swiften/IDN/IDNConverter.h>
#include <Swiften/Network/HostAddress.h>
#include <Swiften/EventLoop/EventLoop.h>
#include <Swiften/Network/HostAddressPort.h>
@@ -27,7 +27,7 @@ using namespace Swift;
namespace Swift {
-PlatformDomainNameResolver::PlatformDomainNameResolver(EventLoop* eventLoop) : eventLoop(eventLoop), stopRequested(false) {
+PlatformDomainNameResolver::PlatformDomainNameResolver(IDNConverter* idnConverter, EventLoop* eventLoop) : idnConverter(idnConverter), eventLoop(eventLoop), stopRequested(false) {
thread = new boost::thread(boost::bind(&PlatformDomainNameResolver::run, this));
}
@@ -39,11 +39,11 @@ PlatformDomainNameResolver::~PlatformDomainNameResolver() {
}
boost::shared_ptr<DomainNameServiceQuery> PlatformDomainNameResolver::createServiceQuery(const std::string& name) {
- return boost::shared_ptr<DomainNameServiceQuery>(new PlatformDomainNameServiceQuery(IDNA::getEncoded(name), eventLoop, this));
+ return boost::shared_ptr<DomainNameServiceQuery>(new PlatformDomainNameServiceQuery(idnConverter->getIDNAEncoded(name), eventLoop, this));
}
boost::shared_ptr<DomainNameAddressQuery> PlatformDomainNameResolver::createAddressQuery(const std::string& name) {
- return boost::shared_ptr<DomainNameAddressQuery>(new PlatformDomainNameAddressQuery(IDNA::getEncoded(name), eventLoop, this));
+ return boost::shared_ptr<DomainNameAddressQuery>(new PlatformDomainNameAddressQuery(idnConverter->getIDNAEncoded(name), eventLoop, this));
}
void PlatformDomainNameResolver::run() {
diff --git a/Swiften/Network/PlatformDomainNameResolver.h b/Swiften/Network/PlatformDomainNameResolver.h
index 0617d9e..25d87cf 100644
--- a/Swiften/Network/PlatformDomainNameResolver.h
+++ b/Swiften/Network/PlatformDomainNameResolver.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -18,12 +18,12 @@
#include <Swiften/Network/DomainNameAddressQuery.h>
namespace Swift {
-
+ class IDNConverter;
class EventLoop;
class SWIFTEN_API PlatformDomainNameResolver : public DomainNameResolver {
public:
- PlatformDomainNameResolver(EventLoop* eventLoop);
+ PlatformDomainNameResolver(IDNConverter* idnConverter, EventLoop* eventLoop);
~PlatformDomainNameResolver();
virtual DomainNameServiceQuery::ref createServiceQuery(const std::string& name);
@@ -36,6 +36,7 @@ namespace Swift {
private:
friend class PlatformDomainNameServiceQuery;
friend class PlatformDomainNameAddressQuery;
+ IDNConverter* idnConverter;
EventLoop* eventLoop;
bool stopRequested;
boost::thread* thread;