summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2014-09-16 13:23:24 (GMT)
committerKevin Smith <git@kismith.co.uk>2014-09-16 13:23:37 (GMT)
commitdc48cc3f34e3e229172202717520e77233c37ed7 (patch)
treedd4b6562a806aa9b11f800e91ed93546fce23f35 /Swiften/Examples
parent381b22fc365c27b9cd585f4b78f53ebc698d9f54 (diff)
downloadswift-contrib-dc48cc3f34e3e229172202717520e77233c37ed7.zip
swift-contrib-dc48cc3f34e3e229172202717520e77233c37ed7.tar.bz2
Fix boost::optional abuses that stop compilation with latest boost
Test-Information: Compiles and unit tests pass with boost 1.56 Change-Id: I6525399babc5f6c88fb499af80e9f07c1c4d0cdb
Diffstat (limited to 'Swiften/Examples')
-rw-r--r--Swiften/Examples/NetworkTool/main.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Swiften/Examples/NetworkTool/main.cpp b/Swiften/Examples/NetworkTool/main.cpp
index 10a0aa6..77ba3f6 100644
--- a/Swiften/Examples/NetworkTool/main.cpp
+++ b/Swiften/Examples/NetworkTool/main.cpp
@@ -6,72 +6,72 @@
#include <iostream>
#include <boost/lexical_cast.hpp>
#include <Swiften/EventLoop/SimpleEventLoop.h>
#include <Swiften/Network/PlatformNATTraversalWorker.h>
#include <Swiften/Network/NATTraversalGetPublicIPRequest.h>
#include <Swiften/Network/NATTraversalForwardPortRequest.h>
#include <Swiften/Network/NATTraversalRemovePortForwardingRequest.h>
#include <Swiften/Network/PlatformNetworkEnvironment.h>
using namespace Swift;
static SimpleEventLoop eventLoop;
static void handleGetPublicIPRequestResponse(const boost::optional<HostAddress>& result) {
if (result) {
std::cerr << "Result: " << result->toString() << std::endl;;
}
else {
std::cerr << "No result" << std::endl;
}
eventLoop.stop();
}
static void handleGetForwardPortRequestResponse(const boost::optional<NATPortMapping>& result) {
if (result) {
std::cerr << "Result: " << result->getPublicPort() << " -> " << result->getLocalPort() << std::endl;;
}
else {
std::cerr << "No result" << std::endl;
}
eventLoop.stop();
}
-static void handleRemovePortForwardingRequestResponse(bool result) {
- if (result) {
+static void handleRemovePortForwardingRequestResponse(const boost::optional<bool> result) {
+ if (result && result.get()) {
std::cerr << "Result: OK" << std::endl;
}
else {
std::cerr << "Result: ERROR" << std::endl;
}
eventLoop.stop();
}
int main(int argc, char* argv[]) {
if (argc < 2) {
std::cerr << "Invalid parameters" << std::endl;
return -1;
}
PlatformNATTraversalWorker natTraverser(&eventLoop);
if (std::string(argv[1]) == "get-public-ip") {
boost::shared_ptr<NATTraversalGetPublicIPRequest> query = natTraverser.createGetPublicIPRequest();
query->onResult.connect(boost::bind(&handleGetPublicIPRequestResponse, _1));
query->start();
eventLoop.run();
}
else if (std::string(argv[1]) == "add-port-forward") {
if (argc < 4) {
std::cerr << "Invalid parameters" << std::endl;
}
boost::shared_ptr<NATTraversalForwardPortRequest> query = natTraverser.createForwardPortRequest(boost::lexical_cast<int>(argv[2]), boost::lexical_cast<int>(argv[3]));
query->onResult.connect(boost::bind(&handleGetForwardPortRequestResponse, _1));
query->start();
eventLoop.run();
}
else if (std::string(argv[1]) == "remove-port-forward") {
if (argc < 4) {
std::cerr << "Invalid parameters" << std::endl;
}
boost::shared_ptr<NATTraversalRemovePortForwardingRequest> query = natTraverser.createRemovePortForwardingRequest(boost::lexical_cast<int>(argv[2]), boost::lexical_cast<int>(argv[3]));