diff options
Diffstat (limited to 'Swiften/Network')
-rw-r--r-- | Swiften/Network/BoostConnectionServer.cpp | 8 | ||||
-rw-r--r-- | Swiften/Network/BoostIOServiceThread.cpp | 2 | ||||
-rw-r--r-- | Swiften/Network/EnvironmentProxyProvider.cpp | 6 | ||||
-rw-r--r-- | Swiften/Network/MacOSXProxyProvider.cpp | 18 | ||||
-rw-r--r-- | Swiften/Network/MiniUPnPInterface.cpp | 6 | ||||
-rw-r--r-- | Swiften/Network/NATPMPInterface.cpp | 6 | ||||
-rw-r--r-- | Swiften/Network/PlatformNATTraversalWorker.cpp | 8 | ||||
-rw-r--r-- | Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp | 4 | ||||
-rw-r--r-- | Swiften/Network/UnitTest/BOSHConnectionTest.cpp | 4 | ||||
-rw-r--r-- | Swiften/Network/UnixNetworkEnvironment.cpp | 10 | ||||
-rw-r--r-- | Swiften/Network/UnixProxyProvider.cpp | 8 |
11 files changed, 49 insertions, 31 deletions
diff --git a/Swiften/Network/BoostConnectionServer.cpp b/Swiften/Network/BoostConnectionServer.cpp index 0b20a7f..99fe9b6 100644 --- a/Swiften/Network/BoostConnectionServer.cpp +++ b/Swiften/Network/BoostConnectionServer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2015 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -19,10 +19,10 @@ namespace Swift { -BoostConnectionServer::BoostConnectionServer(int port, boost::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop) : port_(port), ioService_(ioService), eventLoop(eventLoop), acceptor_(NULL) { +BoostConnectionServer::BoostConnectionServer(int port, boost::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop) : port_(port), ioService_(ioService), eventLoop(eventLoop), acceptor_(nullptr) { } -BoostConnectionServer::BoostConnectionServer(const HostAddress &address, int port, boost::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop) : address_(address), port_(port), ioService_(ioService), eventLoop(eventLoop), acceptor_(NULL) { +BoostConnectionServer::BoostConnectionServer(const HostAddress &address, int port, boost::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop) : address_(address), port_(port), ioService_(ioService), eventLoop(eventLoop), acceptor_(nullptr) { } void BoostConnectionServer::start() { @@ -70,7 +70,7 @@ void BoostConnectionServer::stop(boost::optional<Error> e) { if (acceptor_) { acceptor_->close(); delete acceptor_; - acceptor_ = NULL; + acceptor_ = nullptr; } eventLoop->postEvent(boost::bind(boost::ref(onStopped), e), shared_from_this()); } diff --git a/Swiften/Network/BoostIOServiceThread.cpp b/Swiften/Network/BoostIOServiceThread.cpp index ba9dd5b..79112d8 100644 --- a/Swiften/Network/BoostIOServiceThread.cpp +++ b/Swiften/Network/BoostIOServiceThread.cpp @@ -13,7 +13,7 @@ namespace Swift { BoostIOServiceThread::BoostIOServiceThread(boost::shared_ptr<boost::asio::io_service> ioService) { if (!!ioService) { ioService_ = ioService; - thread_ = NULL; + thread_ = nullptr; } else { ioService_ = boost::make_shared<boost::asio::io_service>(); diff --git a/Swiften/Network/EnvironmentProxyProvider.cpp b/Swiften/Network/EnvironmentProxyProvider.cpp index aa8027f..faf2e5b 100644 --- a/Swiften/Network/EnvironmentProxyProvider.cpp +++ b/Swiften/Network/EnvironmentProxyProvider.cpp @@ -36,15 +36,15 @@ HostAddressPort EnvironmentProxyProvider::getSOCKS5Proxy() const { } HostAddressPort EnvironmentProxyProvider::getFromEnv(const char* envVarName, std::string proxyProtocol) { - char* envVar = NULL; + char* envVar = nullptr; std::string address; int port = 0; envVar = getenv(envVarName); proxyProtocol += "://"; - address = envVar != NULL ? envVar : "0.0.0.0"; - if(envVar != NULL && address.compare(0, proxyProtocol.length(), proxyProtocol) == 0) { + address = envVar != nullptr ? envVar : "0.0.0.0"; + if(envVar != nullptr && address.compare(0, proxyProtocol.length(), proxyProtocol) == 0) { address = address.substr(proxyProtocol.length(), address.length()); port = atoi(address.substr(address.find(':') + 1, address.length()).c_str()); address = address.substr(0, address.find(':')); diff --git a/Swiften/Network/MacOSXProxyProvider.cpp b/Swiften/Network/MacOSXProxyProvider.cpp index 858d568..69c6335 100644 --- a/Swiften/Network/MacOSXProxyProvider.cpp +++ b/Swiften/Network/MacOSXProxyProvider.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2013 Isode Limited. + * Copyright (c) 2013-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -29,13 +29,13 @@ using namespace Swift; #ifndef SWIFTEN_PLATFORM_IPHONE static HostAddressPort getFromDictionary(CFDictionaryRef dict, CFStringRef enabledKey, CFStringRef hostKey, CFStringRef portKey) { - CFNumberRef numberValue = NULL; + CFNumberRef numberValue = nullptr; HostAddressPort ret = HostAddressPort(HostAddress(), 0); if(CFDictionaryGetValueIfPresent(dict, reinterpret_cast<const void*> (enabledKey), reinterpret_cast<const void**> (&numberValue)) == true) { const int i = 0; CFNumberRef zero = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &i); - CFComparisonResult result = CFNumberCompare(numberValue, zero, NULL); + CFComparisonResult result = CFNumberCompare(numberValue, zero, nullptr); CFRelease(zero); if(result != kCFCompareEqualTo) { @@ -44,12 +44,12 @@ static HostAddressPort getFromDictionary(CFDictionaryRef dict, CFStringRef enabl try { CFNumberRef numberValue = reinterpret_cast<CFNumberRef> (CFDictionaryGetValue(dict, portKey)); - if(numberValue != NULL) { + if(numberValue != nullptr) { CFNumberGetValue(numberValue, kCFNumberIntType, &port); } CFStringRef stringValue = reinterpret_cast<CFStringRef> (CFDictionaryGetValue(dict, hostKey)); - if(stringValue != NULL) { + if(stringValue != nullptr) { std::vector<char> buffer; // length must be +1 for the ending zero; and the Docu of CFStringGetCString tells it like // if the string is toby the length must be at least 5. @@ -82,8 +82,8 @@ MacOSXProxyProvider::MacOSXProxyProvider() { HostAddressPort MacOSXProxyProvider::getHTTPConnectProxy() const { HostAddressPort result; #ifndef SWIFTEN_PLATFORM_IPHONE - CFDictionaryRef proxies = SCDynamicStoreCopyProxies(NULL); - if(proxies != NULL) { + CFDictionaryRef proxies = SCDynamicStoreCopyProxies(nullptr); + if(proxies != nullptr) { result = getFromDictionary(proxies, kSCPropNetProxiesHTTPEnable, kSCPropNetProxiesHTTPProxy, kSCPropNetProxiesHTTPPort); CFRelease(proxies); } @@ -94,8 +94,8 @@ HostAddressPort MacOSXProxyProvider::getHTTPConnectProxy() const { HostAddressPort MacOSXProxyProvider::getSOCKS5Proxy() const { HostAddressPort result; #ifndef SWIFTEN_PLATFORM_IPHONE - CFDictionaryRef proxies = SCDynamicStoreCopyProxies(NULL); - if(proxies != NULL) { + CFDictionaryRef proxies = SCDynamicStoreCopyProxies(nullptr); + if(proxies != nullptr) { result = getFromDictionary(proxies, kSCPropNetProxiesSOCKSEnable, kSCPropNetProxiesSOCKSProxy, kSCPropNetProxiesSOCKSPort); CFRelease(proxies); } diff --git a/Swiften/Network/MiniUPnPInterface.cpp b/Swiften/Network/MiniUPnPInterface.cpp index 3da6572..b298fc6 100644 --- a/Swiften/Network/MiniUPnPInterface.cpp +++ b/Swiften/Network/MiniUPnPInterface.cpp @@ -34,7 +34,7 @@ struct MiniUPnPInterface::Private { MiniUPnPInterface::MiniUPnPInterface() : p(boost::make_shared<Private>()) { p->isValid = false; int error = 0; - p->deviceList = upnpDiscover(1500 /* timeout in ms */, 0, 0, 0, 0 /* do IPv6? */, &error); + p->deviceList = upnpDiscover(1500 /* timeout in ms */, nullptr, nullptr, 0, 0 /* do IPv6? */, &error); if (!p->deviceList) { return; } @@ -87,7 +87,7 @@ boost::optional<NATPortMapping> MiniUPnPInterface::addPortForward(int actualLoca p->localAddress.c_str(), "Swift", mapping.getProtocol() == NATPortMapping::TCP ? "TCP" : "UDP", - 0, + nullptr, leaseSeconds.c_str()); if (ret == UPNPCOMMAND_SUCCESS) { return mapping; @@ -106,7 +106,7 @@ bool MiniUPnPInterface::removePortForward(const NATPortMapping& mapping) { std::string localPort = boost::lexical_cast<std::string>(mapping.getLocalPort()); std::string leaseSeconds = boost::lexical_cast<std::string>(mapping.getLeaseInSeconds()); - int ret = UPNP_DeletePortMapping(p->urls.controlURL, p->data.first.servicetype, publicPort.c_str(), mapping.getProtocol() == NATPortMapping::TCP ? "TCP" : "UDP", 0); + int ret = UPNP_DeletePortMapping(p->urls.controlURL, p->data.first.servicetype, publicPort.c_str(), mapping.getProtocol() == NATPortMapping::TCP ? "TCP" : "UDP", nullptr); return ret == UPNPCOMMAND_SUCCESS; } diff --git a/Swiften/Network/NATPMPInterface.cpp b/Swiften/Network/NATPMPInterface.cpp index 4818170..3782f75 100644 --- a/Swiften/Network/NATPMPInterface.cpp +++ b/Swiften/Network/NATPMPInterface.cpp @@ -60,7 +60,7 @@ boost::optional<HostAddress> NATPMPInterface::getPublicIP() { timeout.tv_sec = 10; timeout.tv_usec = 0; - select(FD_SETSIZE, &fds, NULL, NULL, &timeout); + select(FD_SETSIZE, &fds, nullptr, nullptr, &timeout); r = readnatpmpresponseorretry(&p->natpmp, &response); } while (false /*r == NATPMP_TRYAGAIN*/); @@ -98,7 +98,7 @@ boost::optional<NATPortMapping> NATPMPInterface::addPortForward(int localPort, i timeout.tv_sec = 10; timeout.tv_usec = 0; - select(FD_SETSIZE, &fds, NULL, NULL, &timeout); + select(FD_SETSIZE, &fds, nullptr, nullptr, &timeout); r = readnatpmpresponseorretry(&p->natpmp, &response); } while(false /*r == NATPMP_TRYAGAIN*/); @@ -126,7 +126,7 @@ bool NATPMPInterface::removePortForward(const NATPortMapping& mapping) { FD_ZERO(&fds); FD_SET(p->natpmp.s, &fds); getnatpmprequesttimeout(&p->natpmp, &timeout); - select(FD_SETSIZE, &fds, NULL, NULL, &timeout); + select(FD_SETSIZE, &fds, nullptr, nullptr, &timeout); r = readnatpmpresponseorretry(&p->natpmp, &response); } while(r == NATPMP_TRYAGAIN); diff --git a/Swiften/Network/PlatformNATTraversalWorker.cpp b/Swiften/Network/PlatformNATTraversalWorker.cpp index e6fb05f..cb5758e 100644 --- a/Swiften/Network/PlatformNATTraversalWorker.cpp +++ b/Swiften/Network/PlatformNATTraversalWorker.cpp @@ -4,6 +4,12 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2016 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #include "PlatformNATTraversalWorker.h" #include <boost/smart_ptr/make_shared.hpp> @@ -125,7 +131,7 @@ class PlatformNATTraversalRemovePortForwardingRequest : public NATTraversalRemov NATPortMapping mapping; }; -PlatformNATTraversalWorker::PlatformNATTraversalWorker(EventLoop* eventLoop) : eventLoop(eventLoop), stopRequested(false), natPMPSupported(boost::logic::indeterminate), natPMPInterface(NULL), miniUPnPSupported(boost::logic::indeterminate), miniUPnPInterface(NULL) { +PlatformNATTraversalWorker::PlatformNATTraversalWorker(EventLoop* eventLoop) : eventLoop(eventLoop), stopRequested(false), natPMPSupported(boost::logic::indeterminate), natPMPInterface(nullptr), miniUPnPSupported(boost::logic::indeterminate), miniUPnPInterface(nullptr) { nullNATTraversalInterface = new NullNATTraversalInterface(); // FIXME: This should be done from start(), and the current start() should be an internal method thread = new boost::thread(boost::bind(&PlatformNATTraversalWorker::start, this)); diff --git a/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp b/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp index e781742..12b48a9 100644 --- a/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp +++ b/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015 Isode Limited. + * Copyright (c) 2011-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -322,7 +322,7 @@ class BOSHConnectionPoolTest : public CppUnit::TestFixture { PoolRef createTestling() { // make_shared is limited to 9 arguments; instead new is used here. - PoolRef pool = PoolRef(new BOSHConnectionPool(boshURL, resolver, connectionFactory, &parserFactory, static_cast<TLSContextFactory*>(NULL), timerFactory, eventLoop, to, initialRID, URL(), SafeString(""), SafeString(""), TLSOptions())); + PoolRef pool = PoolRef(new BOSHConnectionPool(boshURL, resolver, connectionFactory, &parserFactory, static_cast<TLSContextFactory*>(nullptr), timerFactory, eventLoop, to, initialRID, URL(), SafeString(""), SafeString(""), TLSOptions())); pool->open(); pool->onXMPPDataRead.connect(boost::bind(&BOSHConnectionPoolTest::handleXMPPDataRead, this, _1)); pool->onBOSHDataRead.connect(boost::bind(&BOSHConnectionPoolTest::handleBOSHDataRead, this, _1)); diff --git a/Swiften/Network/UnitTest/BOSHConnectionTest.cpp b/Swiften/Network/UnitTest/BOSHConnectionTest.cpp index bae84fd..abd020f 100644 --- a/Swiften/Network/UnitTest/BOSHConnectionTest.cpp +++ b/Swiften/Network/UnitTest/BOSHConnectionTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015 Isode Limited. + * Copyright (c) 2011-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -48,7 +48,7 @@ class BOSHConnectionTest : public CppUnit::TestFixture { connectionFactory = new MockConnectionFactory(eventLoop); resolver = new StaticDomainNameResolver(eventLoop); timerFactory = new DummyTimerFactory(); - tlsContextFactory = NULL; + tlsContextFactory = nullptr; connectFinished = false; disconnected = false; disconnectedError = false; diff --git a/Swiften/Network/UnixNetworkEnvironment.cpp b/Swiften/Network/UnixNetworkEnvironment.cpp index 3239448..91754ae 100644 --- a/Swiften/Network/UnixNetworkEnvironment.cpp +++ b/Swiften/Network/UnixNetworkEnvironment.cpp @@ -4,6 +4,12 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2016 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #include <Swiften/Network/UnixNetworkEnvironment.h> #include <string> @@ -28,13 +34,13 @@ namespace Swift { std::vector<NetworkInterface> UnixNetworkEnvironment::getNetworkInterfaces() const { std::map<std::string, NetworkInterface> interfaces; #ifndef __ANDROID__ - ifaddrs* addrs = 0; + ifaddrs* addrs = nullptr; int ret = getifaddrs(&addrs); if (ret != 0) { return std::vector<NetworkInterface>(); } - for (ifaddrs* a = addrs; a != 0; a = a->ifa_next) { + for (ifaddrs* a = addrs; a != nullptr; a = a->ifa_next) { std::string name(a->ifa_name); boost::optional<HostAddress> address; if (a->ifa_addr->sa_family == PF_INET) { diff --git a/Swiften/Network/UnixProxyProvider.cpp b/Swiften/Network/UnixProxyProvider.cpp index aa86c04..848de52 100644 --- a/Swiften/Network/UnixProxyProvider.cpp +++ b/Swiften/Network/UnixProxyProvider.cpp @@ -4,6 +4,12 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2016 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #include <stdio.h> #include <stdlib.h> #include <iostream> @@ -17,7 +23,7 @@ namespace Swift { UnixProxyProvider::UnixProxyProvider() : - gconfProxyProvider(0), + gconfProxyProvider(nullptr), environmentProxyProvider() { #if defined(HAVE_GCONF) |