summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Network')
-rw-r--r--Swiften/Network/NATTraversalForwardPortRequest.h3
-rw-r--r--Swiften/Network/NATTraversalGetPublicIPRequest.h3
-rw-r--r--Swiften/Network/NATTraversalRemovePortForwardingRequest.h3
-rw-r--r--Swiften/Network/NullNATTraverser.cpp15
-rw-r--r--Swiften/Network/PlatformNATTraversalWorker.cpp27
-rw-r--r--Swiften/Network/PlatformNATTraversalWorker.h3
6 files changed, 42 insertions, 12 deletions
diff --git a/Swiften/Network/NATTraversalForwardPortRequest.h b/Swiften/Network/NATTraversalForwardPortRequest.h
index 35b23c4..48f85ea 100644
--- a/Swiften/Network/NATTraversalForwardPortRequest.h
+++ b/Swiften/Network/NATTraversalForwardPortRequest.h
@@ -16,7 +16,8 @@ namespace Swift {
public:
virtual ~NATTraversalForwardPortRequest();
- virtual void run() = 0;
+ virtual void start() = 0;
+ virtual void stop() = 0;
boost::signal<void (boost::optional<NATPortMapping>)> onResult;
};
diff --git a/Swiften/Network/NATTraversalGetPublicIPRequest.h b/Swiften/Network/NATTraversalGetPublicIPRequest.h
index db1f005..1270db3 100644
--- a/Swiften/Network/NATTraversalGetPublicIPRequest.h
+++ b/Swiften/Network/NATTraversalGetPublicIPRequest.h
@@ -14,7 +14,8 @@ namespace Swift {
public:
virtual ~NATTraversalGetPublicIPRequest();
- virtual void run() = 0;
+ virtual void start() = 0;
+ virtual void stop() = 0;
boost::signal<void (boost::optional<HostAddress>)> onResult;
};
diff --git a/Swiften/Network/NATTraversalRemovePortForwardingRequest.h b/Swiften/Network/NATTraversalRemovePortForwardingRequest.h
index c82ae03..210cbcb 100644
--- a/Swiften/Network/NATTraversalRemovePortForwardingRequest.h
+++ b/Swiften/Network/NATTraversalRemovePortForwardingRequest.h
@@ -27,7 +27,8 @@ namespace Swift {
public:
virtual ~NATTraversalRemovePortForwardingRequest();
- virtual void run() = 0;
+ virtual void start() = 0;
+ virtual void stop() = 0;
boost::signal<void (boost::optional<bool> /* failure */)> onResult;
};
diff --git a/Swiften/Network/NullNATTraverser.cpp b/Swiften/Network/NullNATTraverser.cpp
index 8cb35cd..43fcd08 100644
--- a/Swiften/Network/NullNATTraverser.cpp
+++ b/Swiften/Network/NullNATTraverser.cpp
@@ -21,10 +21,13 @@ class NullNATTraversalGetPublicIPRequest : public NATTraversalGetPublicIPRequest
NullNATTraversalGetPublicIPRequest(EventLoop* eventLoop) : eventLoop(eventLoop) {
}
- virtual void run() {
+ virtual void start() {
eventLoop->postEvent(boost::bind(boost::ref(onResult), boost::optional<HostAddress>()));
}
+ virtual void stop() {
+ }
+
private:
EventLoop* eventLoop;
};
@@ -34,10 +37,13 @@ class NullNATTraversalForwardPortRequest : public NATTraversalForwardPortRequest
NullNATTraversalForwardPortRequest(EventLoop* eventLoop) : eventLoop(eventLoop) {
}
- virtual void run() {
+ virtual void start() {
eventLoop->postEvent(boost::bind(boost::ref(onResult), boost::optional<NATPortMapping>()));
}
+ virtual void stop() {
+ }
+
private:
EventLoop* eventLoop;
};
@@ -47,10 +53,13 @@ class NullNATTraversalRemovePortForwardingRequest : public NATTraversalRemovePor
NullNATTraversalRemovePortForwardingRequest(EventLoop* eventLoop) : eventLoop(eventLoop) {
}
- virtual void run() {
+ virtual void start() {
eventLoop->postEvent(boost::bind(boost::ref(onResult), boost::optional<bool>(true)));
}
+ virtual void stop() {
+ }
+
private:
EventLoop* eventLoop;
};
diff --git a/Swiften/Network/PlatformNATTraversalWorker.cpp b/Swiften/Network/PlatformNATTraversalWorker.cpp
index eeecb38..40d6da6 100644
--- a/Swiften/Network/PlatformNATTraversalWorker.cpp
+++ b/Swiften/Network/PlatformNATTraversalWorker.cpp
@@ -50,10 +50,14 @@ class PlatformNATTraversalGetPublicIPRequest : public NATTraversalGetPublicIPReq
PlatformNATTraversalGetPublicIPRequest(PlatformNATTraversalWorker* worker) : PlatformNATTraversalRequest(worker) {
}
- virtual void run() {
+ virtual void start() {
doRun();
}
+ virtual void stop() {
+ // TODO
+ }
+
virtual void runBlocking() {
onResult(getNATTraversalInterface()->getPublicIP());
}
@@ -64,10 +68,14 @@ class PlatformNATTraversalForwardPortRequest : public NATTraversalForwardPortReq
PlatformNATTraversalForwardPortRequest(PlatformNATTraversalWorker* worker, unsigned int localIP, unsigned int publicIP) : PlatformNATTraversalRequest(worker), localIP(localIP), publicIP(publicIP) {
}
- virtual void run() {
+ virtual void start() {
doRun();
}
+ virtual void stop() {
+ // TODO
+ }
+
virtual void runBlocking() {
onResult(getNATTraversalInterface()->addPortForward(boost::numeric_cast<int>(localIP), boost::numeric_cast<int>(publicIP)));
}
@@ -82,10 +90,14 @@ class PlatformNATTraversalRemovePortForwardingRequest : public NATTraversalRemov
PlatformNATTraversalRemovePortForwardingRequest(PlatformNATTraversalWorker* worker, const NATPortMapping& mapping) : PlatformNATTraversalRequest(worker), mapping(mapping) {
}
- virtual void run() {
+ virtual void start() {
doRun();
}
+ virtual void stop() {
+ // TODO
+ }
+
virtual void runBlocking() {
onResult(getNATTraversalInterface()->removePortForward(mapping));
}
@@ -96,7 +108,8 @@ class PlatformNATTraversalRemovePortForwardingRequest : public NATTraversalRemov
PlatformNATTraversalWorker::PlatformNATTraversalWorker(EventLoop* eventLoop) : eventLoop(eventLoop), stopRequested(false), natPMPSupported(boost::logic::indeterminate), natPMPInterface(NULL), miniUPnPSupported(boost::logic::indeterminate), miniUPnPInterface(NULL) {
nullNATTraversalInterface = new NullNATTraversalInterface();
- thread = new boost::thread(boost::bind(&PlatformNATTraversalWorker::run, this));
+ // 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));
}
PlatformNATTraversalWorker::~PlatformNATTraversalWorker() {
@@ -143,7 +156,7 @@ boost::shared_ptr<NATTraversalRemovePortForwardingRequest> PlatformNATTraversalW
return boost::make_shared<PlatformNATTraversalRemovePortForwardingRequest>(this, mapping);
}
-void PlatformNATTraversalWorker::run() {
+void PlatformNATTraversalWorker::start() {
while (!stopRequested) {
PlatformNATTraversalRequest::ref request;
{
@@ -162,6 +175,10 @@ void PlatformNATTraversalWorker::run() {
}
}
+void PlatformNATTraversalWorker::stop() {
+ // TODO
+}
+
void PlatformNATTraversalWorker::addRequestToQueue(PlatformNATTraversalRequest::ref request) {
{
boost::lock_guard<boost::mutex> lock(queueMutex);
diff --git a/Swiften/Network/PlatformNATTraversalWorker.h b/Swiften/Network/PlatformNATTraversalWorker.h
index 8060e31..6148705 100644
--- a/Swiften/Network/PlatformNATTraversalWorker.h
+++ b/Swiften/Network/PlatformNATTraversalWorker.h
@@ -43,7 +43,8 @@ namespace Swift {
private:
NATTraversalInterface* getNATTraversalInterface() const;
void addRequestToQueue(boost::shared_ptr<PlatformNATTraversalRequest>);
- void run();
+ void start();
+ void stop();
private:
EventLoop* eventLoop;