summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2012-12-30 12:45:03 (GMT)
committerSwift Review <review@swift.im>2013-04-12 09:27:55 (GMT)
commit16f7c07cfce1879fa0319b4304bb6e11f9a6dd9a (patch)
treef991914e6e7e9648eb0bec3eba6af9e4444c36de /Swiften/FileTransfer
parent7aa4d8e04244d76e8f237f739c99a4e98e4ae5b8 (diff)
downloadswift-16f7c07cfce1879fa0319b4304bb6e11f9a6dd9a.zip
swift-16f7c07cfce1879fa0319b4304bb6e11f9a6dd9a.tar.bz2
File Transfer refactoring.
Rename run() to start(), and provide stop() placeholder. Change-Id: I44257a0fca89c9345054a5d6fa3c1b4768995081
Diffstat (limited to 'Swiften/FileTransfer')
-rw-r--r--Swiften/FileTransfer/ConnectivityManager.cpp6
-rw-r--r--Swiften/FileTransfer/DefaultLocalJingleTransportCandidateGenerator.cpp5
-rw-r--r--Swiften/FileTransfer/DefaultLocalJingleTransportCandidateGenerator.h3
-rw-r--r--Swiften/FileTransfer/IncomingJingleFileTransfer.cpp2
-rw-r--r--Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h4
-rw-r--r--Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp5
-rw-r--r--Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp15
-rw-r--r--Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp19
8 files changed, 36 insertions, 23 deletions
diff --git a/Swiften/FileTransfer/ConnectivityManager.cpp b/Swiften/FileTransfer/ConnectivityManager.cpp
index 7d25991..5ed500c 100644
--- a/Swiften/FileTransfer/ConnectivityManager.cpp
+++ b/Swiften/FileTransfer/ConnectivityManager.cpp
@@ -34,13 +34,13 @@ void ConnectivityManager::addListeningPort(int port) {
boost::shared_ptr<NATTraversalGetPublicIPRequest> getIPRequest = natTraversalWorker->createGetPublicIPRequest();
if (getIPRequest) {
getIPRequest->onResult.connect(boost::bind(&ConnectivityManager::natTraversalGetPublicIPResult, this, _1));
- getIPRequest->run();
+ getIPRequest->start();
}
boost::shared_ptr<NATTraversalForwardPortRequest> forwardPortRequest = natTraversalWorker->createForwardPortRequest(port, port);
if (forwardPortRequest) {
forwardPortRequest->onResult.connect(boost::bind(&ConnectivityManager::natTraversalForwardPortResult, this, _1));
- forwardPortRequest->run();
+ forwardPortRequest->start();
}
}
@@ -49,7 +49,7 @@ void ConnectivityManager::removeListeningPort(int port) {
ports.erase(port);
boost::shared_ptr<NATTraversalRemovePortForwardingRequest> removePortForwardingRequest = natTraversalWorker->createRemovePortForwardingRequest(port, port);
if (removePortForwardingRequest) {
- removePortForwardingRequest->run();
+ removePortForwardingRequest->start();
}
}
diff --git a/Swiften/FileTransfer/DefaultLocalJingleTransportCandidateGenerator.cpp b/Swiften/FileTransfer/DefaultLocalJingleTransportCandidateGenerator.cpp
index 4b205cb..988be7b 100644
--- a/Swiften/FileTransfer/DefaultLocalJingleTransportCandidateGenerator.cpp
+++ b/Swiften/FileTransfer/DefaultLocalJingleTransportCandidateGenerator.cpp
@@ -27,7 +27,7 @@ DefaultLocalJingleTransportCandidateGenerator::DefaultLocalJingleTransportCandid
DefaultLocalJingleTransportCandidateGenerator::~DefaultLocalJingleTransportCandidateGenerator() {
}
-void DefaultLocalJingleTransportCandidateGenerator::generateLocalTransportCandidates(JingleTransportPayload::ref transportPayload) {
+void DefaultLocalJingleTransportCandidateGenerator::start(JingleTransportPayload::ref transportPayload) {
if (boost::dynamic_pointer_cast<JingleIBBTransportPayload>(transportPayload)) {
JingleTransportPayload::ref payL = boost::make_shared<JingleTransportPayload>();
payL->setSessionID(transportPayload->getSessionID());
@@ -83,6 +83,9 @@ void DefaultLocalJingleTransportCandidateGenerator::generateLocalTransportCandid
}
+void DefaultLocalJingleTransportCandidateGenerator::stop() {
+}
+
bool DefaultLocalJingleTransportCandidateGenerator::isActualCandidate(JingleTransportPayload::ref transportPayload) {
if (!transportPayload.get()) return false;
return false;
diff --git a/Swiften/FileTransfer/DefaultLocalJingleTransportCandidateGenerator.h b/Swiften/FileTransfer/DefaultLocalJingleTransportCandidateGenerator.h
index 7d45491..b729d0d 100644
--- a/Swiften/FileTransfer/DefaultLocalJingleTransportCandidateGenerator.h
+++ b/Swiften/FileTransfer/DefaultLocalJingleTransportCandidateGenerator.h
@@ -22,7 +22,8 @@ public:
DefaultLocalJingleTransportCandidateGenerator(ConnectivityManager* connectivityManager, SOCKS5BytestreamRegistry* s5bRegistry, SOCKS5BytestreamProxy* s5bProxy, JID& ownJID);
virtual ~DefaultLocalJingleTransportCandidateGenerator();
- virtual void generateLocalTransportCandidates(JingleTransportPayload::ref);
+ virtual void start(JingleTransportPayload::ref);
+ virtual void stop();
virtual bool isActualCandidate(JingleTransportPayload::ref);
virtual int getPriority(JingleTransportPayload::ref);
diff --git a/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp b/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp
index c462381..0d576ac 100644
--- a/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp
+++ b/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp
@@ -112,7 +112,7 @@ void IncomingJingleFileTransfer::accept(WriteBytestream::ref stream) {
candidateSelector->addRemoteTransportCandidates(s5bTransport);
candidateSelector->setRequesterTarget(session->getInitiator(), ourJID);
s5bTransport->setSessionID(s5bSessionID);
- candidateGenerator->generateLocalTransportCandidates(s5bTransport);
+ candidateGenerator->start(s5bTransport);
}
else {
assert(false);
diff --git a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h
index 14c128a..474b01d 100644
--- a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h
+++ b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h
@@ -16,10 +16,12 @@ namespace Swift {
class SWIFTEN_API LocalJingleTransportCandidateGenerator {
public:
virtual ~LocalJingleTransportCandidateGenerator();
+
/**
* Should call onLocalTransportCandidatesGenerated if it has finished discovering local candidates.
*/
- virtual void generateLocalTransportCandidates(JingleTransportPayload::ref) = 0;
+ virtual void start(JingleTransportPayload::ref) = 0;
+ virtual void stop() = 0;
virtual bool isActualCandidate(JingleTransportPayload::ref) = 0;
virtual int getPriority(JingleTransportPayload::ref) = 0;
diff --git a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp
index 4da70ef..8229a2f 100644
--- a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp
+++ b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp
@@ -54,7 +54,8 @@ OutgoingJingleFileTransfer::OutgoingJingleFileTransfer(JingleSession::ref sessio
filename = fileInfo.getName();
localCandidateGenerator = localFactory->createCandidateGenerator();
- localCandidateGenerator->onLocalTransportCandidatesGenerated.connect(boost::bind(&OutgoingJingleFileTransfer::handleLocalTransportCandidatesGenerated, this, _1));
+ localCandidateGenerator->onLocalTransportCandidatesGenerated.connect(
+ boost::bind(&OutgoingJingleFileTransfer::handleLocalTransportCandidatesGenerated, this, _1));
remoteCandidateSelector = remoteFactory->createCandidateSelector();
remoteCandidateSelector->onRemoteTransportCandidateSelectFinished.connect(boost::bind(&OutgoingJingleFileTransfer::handleRemoteTransportCandidateSelectFinished, this, _1));
@@ -77,7 +78,7 @@ void OutgoingJingleFileTransfer::start() {
//s5bProxy->connectToProxies(s5bSessionID);
JingleS5BTransportPayload::ref transport = boost::make_shared<JingleS5BTransportPayload>();
- localCandidateGenerator->generateLocalTransportCandidates(transport);
+ localCandidateGenerator->start(transport);
}
void OutgoingJingleFileTransfer::stop() {
diff --git a/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp b/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp
index 4c6ae72..9d180a0 100644
--- a/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/IncomingJingleFileTransferTest.cpp
@@ -10,6 +10,7 @@
#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Base/ByteArray.h>
+#include <Swiften/Base/Override.h>
#include <Swiften/Base/Log.h>
#include <Swiften/Client/DummyStanzaChannel.h>
#include <Swiften/Elements/IBB.h>
@@ -80,12 +81,6 @@ public:
class FakeLocalJingleTransportCandidateGenerator : public LocalJingleTransportCandidateGenerator {
public:
- virtual void generateLocalTransportCandidates(JingleTransportPayload::ref payload) {
- JingleS5BTransportPayload::ref payL = make_shared<JingleS5BTransportPayload>();
- payL->setSessionID(payload->getSessionID());
- onLocalTransportCandidatesGenerated(payL);
- }
-
void emitonLocalTransportCandidatesGenerated(JingleTransportPayload::ref payload) {
onLocalTransportCandidatesGenerated(payload);
}
@@ -101,6 +96,14 @@ public:
virtual JingleTransport::ref selectTransport(JingleTransportPayload::ref) {
return JingleTransport::ref();
}
+
+ virtual void start(JingleTransportPayload::ref payload) SWIFTEN_OVERRIDE {
+ JingleS5BTransportPayload::ref payL = make_shared<JingleS5BTransportPayload>();
+ payL->setSessionID(payload->getSessionID());
+ onLocalTransportCandidatesGenerated(payL);
+ }
+
+ virtual void stop() SWIFTEN_OVERRIDE {}
};
class FakeLocalJingleTransportCandidateGeneratorFactory : public LocalJingleTransportCandidateGeneratorFactory {
diff --git a/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp b/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp
index 0c324bf..73b496a 100644
--- a/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp
@@ -28,6 +28,7 @@
#include <Swiften/Elements/JingleFileTransferDescription.h>
#include <Swiften/Elements/IBB.h>
#include <Swiften/Base/ByteArray.h>
+#include <Swiften/Base/Override.h>
#include <Swiften/Base/IDGenerator.h>
#include <Swiften/EventLoop/DummyEventLoop.h>
#include <Swiften/Network/PlatformNATTraversalWorker.h>
@@ -87,14 +88,6 @@ public:
class OFakeLocalJingleTransportCandidateGenerator : public LocalJingleTransportCandidateGenerator {
public:
- virtual void generateLocalTransportCandidates(JingleTransportPayload::ref /* payload */) {
- //JingleTransportPayload::ref payL = make_shared<JingleTransportPayload>();
- //payL->setSessionID(payload->getSessionID());
- JingleS5BTransportPayload::ref payL = boost::make_shared<JingleS5BTransportPayload>();
-
- onLocalTransportCandidatesGenerated(payL);
- }
-
void emitonLocalTransportCandidatesGenerated(JingleTransportPayload::ref payload) {
onLocalTransportCandidatesGenerated(payload);
}
@@ -110,6 +103,16 @@ public:
virtual JingleTransport::ref selectTransport(JingleTransportPayload::ref) {
return JingleTransport::ref();
}
+
+ virtual void start(JingleTransportPayload::ref /* payload */) SWIFTEN_OVERRIDE {
+ //JingleTransportPayload::ref payL = make_shared<JingleTransportPayload>();
+ //payL->setSessionID(payload->getSessionID());
+ JingleS5BTransportPayload::ref payL = boost::make_shared<JingleS5BTransportPayload>();
+
+ onLocalTransportCandidatesGenerated(payL);
+ }
+
+ virtual void stop() SWIFTEN_OVERRIDE {}
};
class OFakeLocalJingleTransportCandidateGeneratorFactory : public LocalJingleTransportCandidateGeneratorFactory {