summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Examples')
-rw-r--r--Swiften/Examples/BenchTool/BenchTool.cpp10
-rw-r--r--Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp22
-rw-r--r--Swiften/Examples/ConnectivityTest/SConscript4
-rw-r--r--Swiften/Examples/LinkLocalTool/SConscript12
-rw-r--r--Swiften/Examples/NetworkTool/main.cpp16
-rw-r--r--Swiften/Examples/ParserTester/ParserTester.cpp4
-rw-r--r--Swiften/Examples/ParserTester/SConscript8
-rw-r--r--Swiften/Examples/SendFile/ReceiveFile.cpp35
-rw-r--r--Swiften/Examples/SendFile/SConscript4
-rw-r--r--Swiften/Examples/SendFile/SendFile.cpp20
-rw-r--r--Swiften/Examples/SendMessage/SConscript4
-rw-r--r--Swiften/Examples/SendMessage/SendMessage.cpp22
12 files changed, 71 insertions, 90 deletions
diff --git a/Swiften/Examples/BenchTool/BenchTool.cpp b/Swiften/Examples/BenchTool/BenchTool.cpp
index ba6cf84..9725b7e 100644
--- a/Swiften/Examples/BenchTool/BenchTool.cpp
+++ b/Swiften/Examples/BenchTool/BenchTool.cpp
@@ -21,11 +21,11 @@
using namespace Swift;
-SimpleEventLoop eventLoop;
-BoostNetworkFactories networkFactories(&eventLoop);
-int numberOfConnectedClients = 0;
-int numberOfInstances = 100;
+static SimpleEventLoop eventLoop;
+static BoostNetworkFactories networkFactories(&eventLoop);
+static int numberOfConnectedClients = 0;
+static int numberOfInstances = 100;
-void handleConnected() {
+static void handleConnected() {
numberOfConnectedClients++;
std::cout << "Connected " << numberOfConnectedClients << std::endl;
diff --git a/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp b/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp
index c957481..df2a23d 100644
--- a/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp
+++ b/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp
@@ -22,13 +22,13 @@ using namespace Swift;
enum ExitCodes {OK = 0, CANNOT_CONNECT, CANNOT_AUTH, NO_RESPONSE, DISCO_ERROR};
-SimpleEventLoop eventLoop;
-BoostNetworkFactories networkFactories(&eventLoop);
+static SimpleEventLoop eventLoop;
+static BoostNetworkFactories networkFactories(&eventLoop);
-Client* client = 0;
-JID recipient;
-int exitCode = CANNOT_CONNECT;
-boost::bsignals::connection errorConnection;
+static Client* client = 0;
+static JID recipient;
+static int exitCode = CANNOT_CONNECT;
+static boost::bsignals::connection errorConnection;
-void handleServerDiscoInfoResponse(boost::shared_ptr<DiscoInfo> /*info*/, ErrorPayload::ref error) {
+static void handleServerDiscoInfoResponse(boost::shared_ptr<DiscoInfo> /*info*/, ErrorPayload::ref error) {
if (!error) {
errorConnection.disconnect();
@@ -42,5 +42,5 @@ void handleServerDiscoInfoResponse(boost::shared_ptr<DiscoInfo> /*info*/, ErrorP
}
-void handleConnected() {
+static void handleConnected() {
exitCode = NO_RESPONSE;
GetDiscoInfoRequest::ref discoInfoRequest = GetDiscoInfoRequest::create(JID(), client->getIQRouter());
@@ -49,5 +49,5 @@ void handleConnected() {
}
-void handleDisconnected(const boost::optional<ClientError>&) {
+static void handleDisconnected(const boost::optional<ClientError>&) {
exitCode = CANNOT_AUTH;
eventLoop.stop();
@@ -80,5 +80,7 @@ int main(int argc, char* argv[]) {
if (!connectHost.empty()) {
std::cout << connectHost << std::endl;
- client->connect(connectHost);
+ ClientOptions options;
+ options.manualHostname = connectHost;
+ client->connect(options);
} else {
std::cout << " Default" << std::endl;
diff --git a/Swiften/Examples/ConnectivityTest/SConscript b/Swiften/Examples/ConnectivityTest/SConscript
index 7bc3892..55a0821 100644
--- a/Swiften/Examples/ConnectivityTest/SConscript
+++ b/Swiften/Examples/ConnectivityTest/SConscript
@@ -2,6 +2,6 @@ Import("env")
myenv = env.Clone()
-myenv.MergeFlags(myenv["SWIFTEN_FLAGS"])
-myenv.MergeFlags(myenv["SWIFTEN_DEP_FLAGS"])
+myenv.UseFlags(myenv["SWIFTEN_FLAGS"])
+myenv.UseFlags(myenv["SWIFTEN_DEP_FLAGS"])
tester = myenv.Program("ConnectivityTest", ["ConnectivityTest.cpp"])
diff --git a/Swiften/Examples/LinkLocalTool/SConscript b/Swiften/Examples/LinkLocalTool/SConscript
index 8318515..18eb91f 100644
--- a/Swiften/Examples/LinkLocalTool/SConscript
+++ b/Swiften/Examples/LinkLocalTool/SConscript
@@ -2,14 +2,6 @@ Import("env")
myenv = env.Clone()
-myenv.MergeFlags(myenv["SWIFTEN_FLAGS"])
-myenv.MergeFlags(myenv["LIBIDN_FLAGS"])
-myenv.MergeFlags(myenv["BOOST_FLAGS"])
-myenv.MergeFlags(myenv["ZLIB_FLAGS"])
-myenv.MergeFlags(myenv["OPENSSL_FLAGS"])
-myenv.MergeFlags(myenv.get("SQLITE_FLAGS", {}))
-myenv.MergeFlags(myenv.get("LIBXML_FLAGS", {}))
-myenv.MergeFlags(myenv.get("EXPAT_FLAGS", {}))
-myenv.MergeFlags(myenv.get("AVAHI_FLAGS", {}))
-myenv.MergeFlags(myenv["PLATFORM_FLAGS"])
+myenv.UseFlags(myenv["SWIFTEN_FLAGS"])
+myenv.UseFlags(myenv["SWIFTEN_DEP_FLAGS"])
linkLocalTool = myenv.Program("LinkLocalTool", [
diff --git a/Swiften/Examples/NetworkTool/main.cpp b/Swiften/Examples/NetworkTool/main.cpp
index 00c12d2..77ba3f6 100644
--- a/Swiften/Examples/NetworkTool/main.cpp
+++ b/Swiften/Examples/NetworkTool/main.cpp
@@ -17,7 +17,7 @@
using namespace Swift;
-SimpleEventLoop eventLoop;
+static SimpleEventLoop eventLoop;
-void handleGetPublicIPRequestResponse(const boost::optional<HostAddress>& result) {
+static void handleGetPublicIPRequestResponse(const boost::optional<HostAddress>& result) {
if (result) {
std::cerr << "Result: " << result->toString() << std::endl;;
@@ -29,5 +29,5 @@ void handleGetPublicIPRequestResponse(const boost::optional<HostAddress>& result
}
-void handleGetForwardPortRequestResponse(const boost::optional<NATPortMapping>& result) {
+static void handleGetForwardPortRequestResponse(const boost::optional<NATPortMapping>& result) {
if (result) {
std::cerr << "Result: " << result->getPublicPort() << " -> " << result->getLocalPort() << std::endl;;
@@ -39,6 +39,6 @@ void handleGetForwardPortRequestResponse(const boost::optional<NATPortMapping>&
}
-void handleRemovePortForwardingRequestResponse(bool result) {
- if (result) {
+static void handleRemovePortForwardingRequestResponse(const boost::optional<bool> result) {
+ if (result && result.get()) {
std::cerr << "Result: OK" << std::endl;
}
@@ -59,5 +59,5 @@ int main(int argc, char* argv[]) {
boost::shared_ptr<NATTraversalGetPublicIPRequest> query = natTraverser.createGetPublicIPRequest();
query->onResult.connect(boost::bind(&handleGetPublicIPRequestResponse, _1));
- query->run();
+ query->start();
eventLoop.run();
}
@@ -68,5 +68,5 @@ int main(int argc, char* argv[]) {
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->run();
+ query->start();
eventLoop.run();
}
@@ -77,5 +77,5 @@ int main(int argc, char* argv[]) {
boost::shared_ptr<NATTraversalRemovePortForwardingRequest> query = natTraverser.createRemovePortForwardingRequest(boost::lexical_cast<int>(argv[2]), boost::lexical_cast<int>(argv[3]));
query->onResult.connect(boost::bind(&handleRemovePortForwardingRequestResponse, _1));
- query->run();
+ query->start();
eventLoop.run();
}
diff --git a/Swiften/Examples/ParserTester/ParserTester.cpp b/Swiften/Examples/ParserTester/ParserTester.cpp
index 009eef4..5ce44ef 100644
--- a/Swiften/Examples/ParserTester/ParserTester.cpp
+++ b/Swiften/Examples/ParserTester/ParserTester.cpp
@@ -1,4 +1,4 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2014 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
@@ -22,5 +22,5 @@ class MyXMPPParserClient : public XMPPParserClient {
std::cout << "-> Stream start" << std::endl;
}
- virtual void handleElement(boost::shared_ptr<Element> element) {
+ virtual void handleElement(boost::shared_ptr<ToplevelElement> element) {
std::cout << "-> Element " << typeid(*element.get()).name() << std::endl;
}
diff --git a/Swiften/Examples/ParserTester/SConscript b/Swiften/Examples/ParserTester/SConscript
index e3df0ba..5c93552 100644
--- a/Swiften/Examples/ParserTester/SConscript
+++ b/Swiften/Examples/ParserTester/SConscript
@@ -2,10 +2,6 @@ Import("env")
myenv = env.Clone()
-myenv.MergeFlags(myenv["SWIFTEN_FLAGS"])
-myenv.MergeFlags(myenv["LIBIDN_FLAGS"])
-myenv.MergeFlags(myenv["BOOST_FLAGS"])
-myenv.MergeFlags(myenv.get("LIBXML_FLAGS", ""))
-myenv.MergeFlags(myenv.get("EXPAT_FLAGS", ""))
-myenv.MergeFlags(myenv["PLATFORM_FLAGS"])
+myenv.UseFlags(myenv["SWIFTEN_FLAGS"])
+myenv.UseFlags(myenv["SWIFTEN_DEP_FLAGS"])
myenv.Program("ParserTester", ["ParserTester.cpp"])
diff --git a/Swiften/Examples/SendFile/ReceiveFile.cpp b/Swiften/Examples/SendFile/ReceiveFile.cpp
index f80f03a..c777fee 100644
--- a/Swiften/Examples/SendFile/ReceiveFile.cpp
+++ b/Swiften/Examples/SendFile/ReceiveFile.cpp
@@ -1,4 +1,4 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
@@ -11,4 +11,5 @@
#include <Swiften/Elements/Presence.h>
+#include <Swiften/Base/Log.h>
#include <Swiften/Base/foreach.h>
#include <Swiften/Client/Client.h>
@@ -21,6 +22,4 @@
#include <Swiften/FileTransfer/FileWriteBytestream.h>
#include <Swiften/Jingle/JingleSessionManager.h>
-#include <Swiften/FileTransfer/DefaultLocalJingleTransportCandidateGeneratorFactory.h>
-#include <Swiften/FileTransfer/DefaultRemoteJingleTransportCandidateSelectorFactory.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamRegistry.h>
#include <Swiften/FileTransfer/FileTransferManager.h>
@@ -28,8 +27,8 @@
using namespace Swift;
-SimpleEventLoop eventLoop;
-BoostNetworkFactories networkFactories(&eventLoop);
+static SimpleEventLoop eventLoop;
+static BoostNetworkFactories networkFactories(&eventLoop);
-int exitCode = 2;
+static int exitCode = 2;
static const std::string CLIENT_NAME = "Swiften FT Test";
@@ -38,5 +37,5 @@ static const std::string CLIENT_NODE = "http://swift.im";
class FileReceiver {
public:
- FileReceiver(const JID& jid, const std::string& password) : jid(jid), password(password), jingleSessionManager(NULL), incomingFileTransferManager(NULL) {
+ FileReceiver(const JID& jid, const std::string& password) : jid(jid), password(password) {
client = new Swift::Client(jid, password, &networkFactories);
client->onConnected.connect(boost::bind(&FileReceiver::handleConnected, this));
@@ -65,6 +64,5 @@ class FileReceiver {
private:
void handleConnected() {
- Swift::logging = true;
- client->getFileTransferManager()->startListeningOnPort(9999);
+ Log::setLogLevel(Log::debug);
client->getFileTransferManager()->onIncomingFileTransfer.connect(boost::bind(&FileReceiver::handleIncomingFileTransfer, this, _1));
@@ -84,7 +82,7 @@ class FileReceiver {
SWIFT_LOG(debug) << "foo" << std::endl;
incomingFileTransfers.push_back(transfer);
- transfer->accept(boost::make_shared<FileWriteBytestream>("out"));
- //transfer->onFinished.connect(boost::bind(&FileReceiver::handleFileTransferFinished, this, _1));
- //transfer->start();
+ boost::shared_ptr<FileWriteBytestream> out = boost::make_shared<FileWriteBytestream>("out");
+ transfer->onFinished.connect(boost::bind(&FileReceiver::handleFileTransferFinished, this, _1, out));
+ transfer->accept(out);
}
@@ -94,7 +92,9 @@ class FileReceiver {
}
- /*
- void handleFileTransferFinished(const boost::optional<FileTransferError>& error) {
+ void handleFileTransferFinished(
+ const boost::optional<FileTransferError>& error,
+ boost::shared_ptr<FileWriteBytestream> out) {
std::cout << "File transfer finished" << std::endl;
+ out->close();
if (error) {
exit(-1);
@@ -103,5 +103,5 @@ class FileReceiver {
exit(0);
}
- }*/
+ }
void exit(int code) {
@@ -116,10 +116,5 @@ class FileReceiver {
Client* client;
ClientXMLTracer* tracer;
- JingleSessionManager* jingleSessionManager;
- IncomingFileTransferManager* incomingFileTransferManager;
std::vector<IncomingFileTransfer::ref> incomingFileTransfers;
- DefaultLocalJingleTransportCandidateGeneratorFactory *localFactory;
- DefaultRemoteJingleTransportCandidateSelectorFactory *remoteFactory;
- SOCKS5BytestreamRegistry* bytestreamRegistry;
};
diff --git a/Swiften/Examples/SendFile/SConscript b/Swiften/Examples/SendFile/SConscript
index d335513..e0f1256 100644
--- a/Swiften/Examples/SendFile/SConscript
+++ b/Swiften/Examples/SendFile/SConscript
@@ -2,6 +2,6 @@ Import("env")
myenv = env.Clone()
-myenv.MergeFlags(myenv["SWIFTEN_FLAGS"])
-myenv.MergeFlags(myenv["SWIFTEN_DEP_FLAGS"])
+myenv.UseFlags(myenv["SWIFTEN_FLAGS"])
+myenv.UseFlags(myenv["SWIFTEN_DEP_FLAGS"])
myenv.Program("SendFile", ["SendFile.cpp"])
diff --git a/Swiften/Examples/SendFile/SendFile.cpp b/Swiften/Examples/SendFile/SendFile.cpp
index df3cea4..b056842 100644
--- a/Swiften/Examples/SendFile/SendFile.cpp
+++ b/Swiften/Examples/SendFile/SendFile.cpp
@@ -1,4 +1,4 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
@@ -12,4 +12,5 @@
#include <Swiften/Client/Client.h>
#include <Swiften/Elements/Presence.h>
+#include <Swiften/Base/Log.h>
#include <Swiften/Network/BoostTimer.h>
#include <Swiften/Network/TimerFactory.h>
@@ -26,9 +27,5 @@
#include <Swiften/Jingle/JingleSessionManager.h>
#include <Swiften/Disco/EntityCapsManager.h>
-#include <Swiften/FileTransfer/DefaultLocalJingleTransportCandidateGeneratorFactory.h>
-#include <Swiften/FileTransfer/DefaultRemoteJingleTransportCandidateSelectorFactory.h>
#include <Swiften/Base/ByteArray.h>
-#include <Swiften/StringCodecs/MD5.h>
-#include <Swiften/StringCodecs/SHA1.h>
#include <Swiften/StringCodecs/Hexify.h>
#include <Swiften/FileTransfer/FileTransferManager.h>
@@ -36,8 +33,8 @@
using namespace Swift;
-SimpleEventLoop eventLoop;
-BoostNetworkFactories networkFactories(&eventLoop);
+static SimpleEventLoop eventLoop;
+static BoostNetworkFactories networkFactories(&eventLoop);
-int exitCode = 2;
+static int exitCode = 2;
class FileSender {
@@ -67,7 +64,6 @@ class FileSender {
client->sendPresence(Presence::create());
- client->getFileTransferManager()->startListeningOnPort(19999);
//ByteArray fileData;
- //readByteArrayFromFile(fileData, file.string());
+ //readByteArrayFromFile(fileData, file);
// gather file information
@@ -126,6 +122,4 @@ class FileSender {
private:
BoostConnectionServer::ref connectionServer;
- SOCKS5BytestreamServer* socksBytestreamServer;
- SOCKS5BytestreamRegistry* registry;
OutgoingFileTransfer::ref outgoingFileTransfer;
JID jid;
@@ -146,5 +140,5 @@ int main(int argc, char* argv[]) {
JID sender(argv[1]);
JID recipient(argv[3]);
- Swift::logging = true;
+ Log::setLogLevel(Log::debug);
FileSender fileSender(sender, std::string(argv[2]), recipient, boost::filesystem::path(argv[4]));
fileSender.start();
diff --git a/Swiften/Examples/SendMessage/SConscript b/Swiften/Examples/SendMessage/SConscript
index 8907d25..0466187 100644
--- a/Swiften/Examples/SendMessage/SConscript
+++ b/Swiften/Examples/SendMessage/SConscript
@@ -2,6 +2,6 @@ Import("env")
myenv = env.Clone()
-myenv.MergeFlags(myenv["SWIFTEN_FLAGS"])
-myenv.MergeFlags(myenv["SWIFTEN_DEP_FLAGS"])
+myenv.UseFlags(myenv["SWIFTEN_FLAGS"])
+myenv.UseFlags(myenv["SWIFTEN_DEP_FLAGS"])
tester = myenv.Program("SendMessage", ["SendMessage.cpp"])
diff --git a/Swiften/Examples/SendMessage/SendMessage.cpp b/Swiften/Examples/SendMessage/SendMessage.cpp
index f4dbf53..2a3170f 100644
--- a/Swiften/Examples/SendMessage/SendMessage.cpp
+++ b/Swiften/Examples/SendMessage/SendMessage.cpp
@@ -19,15 +19,15 @@
using namespace Swift;
-SimpleEventLoop eventLoop;
-BoostNetworkFactories networkFactories(&eventLoop);
+static SimpleEventLoop eventLoop;
+static BoostNetworkFactories networkFactories(&eventLoop);
-Client* client = 0;
-JID recipient;
-std::string messageBody;
-int exitCode = 2;
-boost::bsignals::connection errorConnection;
+static Client* client = 0;
+static JID recipient;
+static std::string messageBody;
+static int exitCode = 2;
+static boost::bsignals::connection errorConnection;
-void handleConnected() {
+static void handleConnected() {
boost::shared_ptr<Message> message(new Message());
message->setBody(messageBody);
@@ -40,5 +40,5 @@ void handleConnected() {
}
-void handleDisconnected(const boost::optional<ClientError>&) {
+static void handleDisconnected(const boost::optional<ClientError>&) {
std::cerr << "Error!" << std::endl;
exitCode = 1;
@@ -70,5 +70,7 @@ int main(int argc, char* argv[]) {
errorConnection = client->onDisconnected.connect(&handleDisconnected);
if (!connectHost.empty()) {
- client->connect(connectHost);
+ ClientOptions options;
+ options.manualHostname = connectHost;
+ client->connect(options);
} else {
client->connect();