summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/FileTransfer')
-rw-r--r--Swiften/FileTransfer/ConnectivityManager.cpp18
-rw-r--r--Swiften/FileTransfer/ConnectivityManager.h11
-rw-r--r--Swiften/FileTransfer/FileTransferManagerImpl.cpp6
-rw-r--r--Swiften/FileTransfer/FileTransferManagerImpl.h6
-rw-r--r--Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp6
-rw-r--r--Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp2
-rw-r--r--Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp1
7 files changed, 27 insertions, 23 deletions
diff --git a/Swiften/FileTransfer/ConnectivityManager.cpp b/Swiften/FileTransfer/ConnectivityManager.cpp
index 174d6ab..cfb0729 100644
--- a/Swiften/FileTransfer/ConnectivityManager.cpp
+++ b/Swiften/FileTransfer/ConnectivityManager.cpp
@@ -6,17 +6,19 @@
#include "ConnectivityManager.h"
+#include <boost/bind.hpp>
+
#include <Swiften/Base/foreach.h>
#include <Swiften/Base/Log.h>
#include <Swiften/Network/NetworkInterface.h>
-#include <Swiften/Network/PlatformNATTraversalGetPublicIPRequest.h>
-#include <Swiften/Network/PlatformNATTraversalRemovePortForwardingRequest.h>
-#include <Swiften/Network/PlatformNATTraversalWorker.h>
+#include <Swiften/Network/NATTraversalGetPublicIPRequest.h>
+#include <Swiften/Network/NATTraversalRemovePortForwardingRequest.h>
+#include <Swiften/Network/NATTraverser.h>
#include <Swiften/Network/PlatformNetworkEnvironment.h>
namespace Swift {
-ConnectivityManager::ConnectivityManager(PlatformNATTraversalWorker* worker) : natTraversalWorker(worker) {
+ConnectivityManager::ConnectivityManager(NATTraverser* worker) : natTraversalWorker(worker) {
}
@@ -29,13 +31,13 @@ ConnectivityManager::~ConnectivityManager() {
void ConnectivityManager::addListeningPort(int port) {
ports.insert(port);
- boost::shared_ptr<PlatformNATTraversalGetPublicIPRequest> getIPRequest = natTraversalWorker->createGetPublicIPRequest();
+ boost::shared_ptr<NATTraversalGetPublicIPRequest> getIPRequest = natTraversalWorker->createGetPublicIPRequest();
if (getIPRequest) {
getIPRequest->onResult.connect(boost::bind(&ConnectivityManager::natTraversalGetPublicIPResult, this, _1));
getIPRequest->run();
}
- boost::shared_ptr<PlatformNATTraversalForwardPortRequest> forwardPortRequest = natTraversalWorker->createForwardPortRequest(port, port);
+ boost::shared_ptr<NATTraversalForwardPortRequest> forwardPortRequest = natTraversalWorker->createForwardPortRequest(port, port);
if (forwardPortRequest) {
forwardPortRequest->onResult.connect(boost::bind(&ConnectivityManager::natTraversalForwardPortResult, this, _1));
forwardPortRequest->run();
@@ -45,7 +47,7 @@ void ConnectivityManager::addListeningPort(int port) {
void ConnectivityManager::removeListeningPort(int port) {
SWIFT_LOG(debug) << "remove listening port " << port << std::endl;
ports.erase(port);
- boost::shared_ptr<PlatformNATTraversalRemovePortForwardingRequest> removePortForwardingRequest = natTraversalWorker->createRemovePortForwardingRequest(port, port);
+ boost::shared_ptr<NATTraversalRemovePortForwardingRequest> removePortForwardingRequest = natTraversalWorker->createRemovePortForwardingRequest(port, port);
if (removePortForwardingRequest) {
removePortForwardingRequest->run();
}
@@ -89,7 +91,7 @@ void ConnectivityManager::natTraversalGetPublicIPResult(boost::optional<HostAddr
}
}
-void ConnectivityManager::natTraversalForwardPortResult(boost::optional<PlatformNATTraversalForwardPortRequest::PortMapping> mapping) {
+void ConnectivityManager::natTraversalForwardPortResult(boost::optional<NATTraversalForwardPortRequest::PortMapping> mapping) {
if (mapping) {
SWIFT_LOG(debug) << "Mapping port was successful." << std::endl;
} else {
diff --git a/Swiften/FileTransfer/ConnectivityManager.h b/Swiften/FileTransfer/ConnectivityManager.h
index 87041b2..41e0ab6 100644
--- a/Swiften/FileTransfer/ConnectivityManager.h
+++ b/Swiften/FileTransfer/ConnectivityManager.h
@@ -12,15 +12,16 @@
#include <boost/optional.hpp>
#include <Swiften/Network/HostAddressPort.h>
-#include <Swiften/Network/PlatformNATTraversalForwardPortRequest.h>
+#include <Swiften/Network/NATTraverser.h>
+#include <Swiften/Network/NATTraversalForwardPortRequest.h>
namespace Swift {
-class PlatformNATTraversalWorker;
+class NATTraverser;
class ConnectivityManager {
public:
- ConnectivityManager(PlatformNATTraversalWorker*);
+ ConnectivityManager(NATTraverser*);
~ConnectivityManager();
public:
void addListeningPort(int port);
@@ -31,10 +32,10 @@ public:
private:
void natTraversalGetPublicIPResult(boost::optional<HostAddress> address);
- void natTraversalForwardPortResult(boost::optional<PlatformNATTraversalForwardPortRequest::PortMapping> mapping);
+ void natTraversalForwardPortResult(boost::optional<NATTraversalForwardPortRequest::PortMapping> mapping);
private:
- PlatformNATTraversalWorker* natTraversalWorker;
+ NATTraverser* natTraversalWorker;
std::set<int> ports;
boost::optional<HostAddress> publicAddress;
diff --git a/Swiften/FileTransfer/FileTransferManagerImpl.cpp b/Swiften/FileTransfer/FileTransferManagerImpl.cpp
index f89a3e9..a30aeed 100644
--- a/Swiften/FileTransfer/FileTransferManagerImpl.cpp
+++ b/Swiften/FileTransfer/FileTransferManagerImpl.cpp
@@ -25,14 +25,14 @@
#include <Swiften/Network/ConnectionFactory.h>
#include <Swiften/Network/ConnectionServerFactory.h>
#include <Swiften/Network/HostAddress.h>
-#include <Swiften/Network/PlatformNATTraversalWorker.h>
+#include <Swiften/Network/NATTraverser.h>
namespace Swift {
-FileTransferManagerImpl::FileTransferManagerImpl(const JID& ownFullJID, JingleSessionManager* jingleSessionManager, IQRouter* router, EntityCapsProvider* capsProvider, PresenceOracle* presOracle, ConnectionFactory* connectionFactory, ConnectionServerFactory* connectionServerFactory, TimerFactory* timerFactory, PlatformNATTraversalWorker* natTraversalWorker) : ownJID(ownFullJID), jingleSM(jingleSessionManager), iqRouter(router), capsProvider(capsProvider), presenceOracle(presOracle), timerFactory(timerFactory), connectionFactory(connectionFactory), connectionServerFactory(connectionServerFactory), natTraversalWorker(natTraversalWorker), bytestreamServer(NULL) {
+FileTransferManagerImpl::FileTransferManagerImpl(const JID& ownFullJID, JingleSessionManager* jingleSessionManager, IQRouter* router, EntityCapsProvider* capsProvider, PresenceOracle* presOracle, ConnectionFactory* connectionFactory, ConnectionServerFactory* connectionServerFactory, TimerFactory* timerFactory, NATTraverser* natTraverser) : ownJID(ownFullJID), jingleSM(jingleSessionManager), iqRouter(router), capsProvider(capsProvider), presenceOracle(presOracle), timerFactory(timerFactory), connectionFactory(connectionFactory), connectionServerFactory(connectionServerFactory), natTraverser(natTraverser), bytestreamServer(NULL) {
assert(!ownFullJID.isBare());
- connectivityManager = new ConnectivityManager(natTraversalWorker);
+ connectivityManager = new ConnectivityManager(natTraverser);
bytestreamRegistry = new SOCKS5BytestreamRegistry();
bytestreamProxy = new SOCKS5BytestreamProxy(connectionFactory, timerFactory);
diff --git a/Swiften/FileTransfer/FileTransferManagerImpl.h b/Swiften/FileTransfer/FileTransferManagerImpl.h
index b38eaea..d1c3786 100644
--- a/Swiften/FileTransfer/FileTransferManagerImpl.h
+++ b/Swiften/FileTransfer/FileTransferManagerImpl.h
@@ -32,7 +32,7 @@ class IncomingFileTransferManager;
class JingleSessionManager;
class LocalJingleTransportCandidateGeneratorFactory;
class OutgoingFileTransferManager;
-class PlatformNATTraversalWorker;
+class NATTraverser;
class PresenceOracle;
class ReadBytestream;
class RemoteJingleTransportCandidateSelectorFactory;
@@ -43,7 +43,7 @@ class TimerFactory;
class FileTransferManagerImpl : public FileTransferManager {
public:
- FileTransferManagerImpl(const JID& ownFullJID, JingleSessionManager* jingleSessionManager, IQRouter* router, EntityCapsProvider* capsProvider, PresenceOracle* presOracle, ConnectionFactory* connectionFactory, ConnectionServerFactory* connectionServerFactory, TimerFactory* timerFactory, PlatformNATTraversalWorker* natTraversalWorker);
+ FileTransferManagerImpl(const JID& ownFullJID, JingleSessionManager* jingleSessionManager, IQRouter* router, EntityCapsProvider* capsProvider, PresenceOracle* presOracle, ConnectionFactory* connectionFactory, ConnectionServerFactory* connectionServerFactory, TimerFactory* timerFactory, NATTraverser* natTraverser);
~FileTransferManagerImpl();
void startListeningOnPort(int port);
@@ -70,7 +70,7 @@ private:
TimerFactory* timerFactory;
ConnectionFactory* connectionFactory;
ConnectionServerFactory* connectionServerFactory;
- PlatformNATTraversalWorker* natTraversalWorker;
+ NATTraverser* natTraverser;
SOCKS5BytestreamRegistry* bytestreamRegistry;
SOCKS5BytestreamServer* bytestreamServer;
SOCKS5BytestreamProxy* bytestreamProxy;
diff --git a/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp b/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp
index 7407f44..4c6ae72 100644
--- a/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp
@@ -156,7 +156,7 @@ public:
void test_AcceptOnyIBBSendsSessionAccept() {
//1. create your test incoming file transfer
shared_ptr<JingleFileTransferDescription> desc = make_shared<JingleFileTransferDescription>();
- desc->addOffer(StreamInitiationFileInfo());
+ desc->addOffer(StreamInitiationFileInfo("foo.txt", "", 10));
jingleContentPayload->addDescription(desc);
JingleIBBTransportPayload::ref tpRef = make_shared<JingleIBBTransportPayload>();
tpRef->setSessionID("mysession");
@@ -175,7 +175,7 @@ public:
void test_OnlyIBBTransferReceiveWorks() {
//1. create your test incoming file transfer
shared_ptr<JingleFileTransferDescription> desc = make_shared<JingleFileTransferDescription>();
- desc->addOffer(StreamInitiationFileInfo());
+ desc->addOffer(StreamInitiationFileInfo("file.txt", "", 10));
jingleContentPayload->addDescription(desc);
JingleIBBTransportPayload::ref tpRef = make_shared<JingleIBBTransportPayload>();
tpRef->setSessionID("mysession");
@@ -235,7 +235,7 @@ public:
private:
void addFileTransferDescription() {
shared_ptr<JingleFileTransferDescription> desc = make_shared<JingleFileTransferDescription>();
- desc->addOffer(StreamInitiationFileInfo());
+ desc->addOffer(StreamInitiationFileInfo("file.txt", "", 10));
jingleContentPayload->addDescription(desc);
}
diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
index 35580bf..75b9faf 100644
--- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
@@ -189,7 +189,7 @@ public:
CPPUNIT_ASSERT_EQUAL(false, helper.sessionReadyError);
helper.unprocessedInput.clear();
- ByteArray transferData = generateRandomByteArray(1024 * 1024);
+ ByteArray transferData = generateRandomByteArray(1024);
boost::shared_ptr<ByteArrayReadBytestream> input = boost::make_shared<ByteArrayReadBytestream>(transferData);
clientSession->startSending(input);
eventLoop->processEvents();
diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp
index cd480f0..4fe72c0 100644
--- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp
@@ -96,6 +96,7 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture {
eventLoop->processEvents();
testling->startTransfer();
skipHeader("abcdef");
+ eventLoop->processEvents();
CPPUNIT_ASSERT(createByteArray("abcdefg") == receivedData);
CPPUNIT_ASSERT_EQUAL(2, receivedDataChunks);