summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2012-12-25 14:39:48 (GMT)
committerRemko Tronçon <git@el-tramo.be>2013-05-11 10:22:56 (GMT)
commit927d62cc54c8a5087dba6b61afa9ad30dc528a23 (patch)
treee67dc911bd30c0519d31a542d8e085bbb209879d /Swiften/Examples
parent17b188343e7208b875af7af30d94f0bf948f6b93 (diff)
downloadswift-927d62cc54c8a5087dba6b61afa9ad30dc528a23.zip
swift-927d62cc54c8a5087dba6b61afa9ad30dc528a23.tar.bz2
File Transfer refactoring.
Allocate S5B server lazily. Forward forts lazily. Various state machine fixes. Temporarily disabling S5B proxy support. Change-Id: I3145e85a99b15a7e457306bbfbe9c0eb570191e4
Diffstat (limited to 'Swiften/Examples')
-rw-r--r--Swiften/Examples/SendFile/ReceiveFile.cpp21
-rw-r--r--Swiften/Examples/SendFile/SendFile.cpp3
2 files changed, 9 insertions, 15 deletions
diff --git a/Swiften/Examples/SendFile/ReceiveFile.cpp b/Swiften/Examples/SendFile/ReceiveFile.cpp
index 7b361ef..c777fee 100644
--- a/Swiften/Examples/SendFile/ReceiveFile.cpp
+++ b/Swiften/Examples/SendFile/ReceiveFile.cpp
@@ -21,8 +21,6 @@
#include <Swiften/FileTransfer/IncomingFileTransferManager.h>
#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>
@@ -38,7 +36,7 @@ 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));
client->onDisconnected.connect(boost::bind(&FileReceiver::handleDisconnected, this, _1));
@@ -66,7 +64,6 @@ class FileReceiver {
private:
void handleConnected() {
Log::setLogLevel(Log::debug);
- client->getFileTransferManager()->startListeningOnPort(9999);
client->getFileTransferManager()->onIncomingFileTransfer.connect(boost::bind(&FileReceiver::handleIncomingFileTransfer, this, _1));
DiscoInfo discoInfo;
@@ -84,9 +81,9 @@ class FileReceiver {
void handleIncomingFileTransfer(IncomingFileTransfer::ref transfer) {
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);
}
void handleDisconnected(const boost::optional<ClientError>&) {
@@ -94,16 +91,18 @@ class FileReceiver {
exit(-1);
}
- /*
- 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);
}
else {
exit(0);
}
- }*/
+ }
void exit(int code) {
exitCode = code;
@@ -116,8 +115,6 @@ class FileReceiver {
std::string password;
Client* client;
ClientXMLTracer* tracer;
- JingleSessionManager* jingleSessionManager;
- IncomingFileTransferManager* incomingFileTransferManager;
std::vector<IncomingFileTransfer::ref> incomingFileTransfers;
};
diff --git a/Swiften/Examples/SendFile/SendFile.cpp b/Swiften/Examples/SendFile/SendFile.cpp
index 1e4fc14..ff49149 100644
--- a/Swiften/Examples/SendFile/SendFile.cpp
+++ b/Swiften/Examples/SendFile/SendFile.cpp
@@ -26,8 +26,6 @@
#include <Swiften/FileTransfer/OutgoingFileTransfer.h>
#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/Hexify.h>
#include <Swiften/FileTransfer/FileTransferManager.h>
@@ -65,7 +63,6 @@ class FileSender {
void handleConnected() {
client->sendPresence(Presence::create());
- client->getFileTransferManager()->startListeningOnPort(19999);
//ByteArray fileData;
//readByteArrayFromFile(fileData, file.string());