summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/FileTransfer')
-rw-r--r--Swiften/FileTransfer/IBBReceiveSession.cpp4
-rw-r--r--Swiften/FileTransfer/IBBReceiveSession.h10
-rw-r--r--Swiften/FileTransfer/IBBRequest.h6
-rw-r--r--Swiften/FileTransfer/IBBSendSession.cpp8
-rw-r--r--Swiften/FileTransfer/IBBSendSession.h11
-rw-r--r--Swiften/FileTransfer/IncomingJingleFileTransfer.cpp2
-rw-r--r--Swiften/FileTransfer/JingleIncomingIBBTransport.cpp2
-rw-r--r--Swiften/FileTransfer/JingleIncomingIBBTransport.h2
-rw-r--r--Swiften/FileTransfer/OutgoingFileTransferManager.cpp2
-rw-r--r--Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp7
-rw-r--r--Swiften/FileTransfer/OutgoingJingleFileTransfer.h4
-rw-r--r--Swiften/FileTransfer/OutgoingSIFileTransfer.cpp2
-rw-r--r--Swiften/FileTransfer/UnitTest/IBBReceiveSessionTest.cpp2
-rw-r--r--Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp2
-rw-r--r--Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp2
15 files changed, 45 insertions, 21 deletions
diff --git a/Swiften/FileTransfer/IBBReceiveSession.cpp b/Swiften/FileTransfer/IBBReceiveSession.cpp
index 43c26be..1a2bb3a 100644
--- a/Swiften/FileTransfer/IBBReceiveSession.cpp
+++ b/Swiften/FileTransfer/IBBReceiveSession.cpp
@@ -69,10 +69,12 @@ class IBBReceiveSession::IBBResponder : public SetResponder<IBB> {
IBBReceiveSession::IBBReceiveSession(
const std::string& id,
const JID& from,
+ const JID& to,
size_t size,
IQRouter* router) :
id(id),
from(from),
+ to(to),
size(size),
router(router),
active(false) {
@@ -99,7 +101,7 @@ void IBBReceiveSession::stop() {
responder->stop();
if (active) {
if (router->isAvailable()) {
- IBBRequest::create(from, IBB::createIBBClose(id), router)->send();
+ IBBRequest::create(to, from, IBB::createIBBClose(id), router)->send();
}
finish(boost::optional<FileTransferError>());
}
diff --git a/Swiften/FileTransfer/IBBReceiveSession.h b/Swiften/FileTransfer/IBBReceiveSession.h
index 02d5ab8..d1c47bf 100644
--- a/Swiften/FileTransfer/IBBReceiveSession.h
+++ b/Swiften/FileTransfer/IBBReceiveSession.h
@@ -23,6 +23,7 @@ namespace Swift {
IBBReceiveSession(
const std::string& id,
const JID& from,
+ const JID& to,
size_t size,
IQRouter* router);
~IBBReceiveSession();
@@ -30,6 +31,14 @@ namespace Swift {
void start();
void stop();
+ const JID& getSender() const {
+ return from;
+ }
+
+ const JID& getReceiver() const {
+ return to;
+ }
+
boost::signal<void (const std::vector<unsigned char>&)> onDataReceived;
boost::signal<void (boost::optional<FileTransferError>)> onFinished;
@@ -43,6 +52,7 @@ namespace Swift {
std::string id;
JID from;
+ JID to;
size_t size;
IQRouter* router;
IBBResponder* responder;
diff --git a/Swiften/FileTransfer/IBBRequest.h b/Swiften/FileTransfer/IBBRequest.h
index 828027c..58be173 100644
--- a/Swiften/FileTransfer/IBBRequest.h
+++ b/Swiften/FileTransfer/IBBRequest.h
@@ -15,12 +15,12 @@ namespace Swift {
public:
typedef boost::shared_ptr<IBBRequest> ref;
- static ref create(const JID& jid, boost::shared_ptr<IBB> payload, IQRouter* router) {
- return ref(new IBBRequest(jid, payload, router));
+ static ref create(const JID& from, const JID& to, boost::shared_ptr<IBB> payload, IQRouter* router) {
+ return ref(new IBBRequest(from, to, payload, router));
}
private:
- IBBRequest(const JID& jid, boost::shared_ptr<IBB> payload, IQRouter* router) : GenericRequest<IBB>(IQ::Set, jid, payload, router) {
+ IBBRequest(const JID& from, const JID& to, boost::shared_ptr<IBB> payload, IQRouter* router) : GenericRequest<IBB>(IQ::Set, from, to, payload, router) {
}
};
}
diff --git a/Swiften/FileTransfer/IBBSendSession.cpp b/Swiften/FileTransfer/IBBSendSession.cpp
index a434cfb..b925c5f 100644
--- a/Swiften/FileTransfer/IBBSendSession.cpp
+++ b/Swiften/FileTransfer/IBBSendSession.cpp
@@ -14,14 +14,14 @@
namespace Swift {
-IBBSendSession::IBBSendSession(const std::string& id, const JID& to, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* router) : id(id), to(to), bytestream(bytestream), router(router), blockSize(4096), sequenceNumber(0), active(false) {
+IBBSendSession::IBBSendSession(const std::string& id, const JID& from, const JID& to, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* router) : id(id), from(from), to(to), bytestream(bytestream), router(router), blockSize(4096), sequenceNumber(0), active(false) {
}
IBBSendSession::~IBBSendSession() {
}
void IBBSendSession::start() {
- IBBRequest::ref request = IBBRequest::create(to, IBB::createIBBOpen(id, blockSize), router);
+ IBBRequest::ref request = IBBRequest::create(from, to, IBB::createIBBOpen(id, blockSize), router);
request->onResponse.connect(boost::bind(&IBBSendSession::handleIBBResponse, this, _1, _2));
active = true;
request->send();
@@ -29,7 +29,7 @@ void IBBSendSession::start() {
void IBBSendSession::stop() {
if (active && router->isAvailable()) {
- IBBRequest::create(to, IBB::createIBBClose(id), router)->send();
+ IBBRequest::create(from, to, IBB::createIBBClose(id), router)->send();
}
finish(boost::optional<FileTransferError>());
}
@@ -39,7 +39,7 @@ void IBBSendSession::handleIBBResponse(IBB::ref, ErrorPayload::ref error) {
if (!bytestream->isFinished()) {
try {
std::vector<unsigned char> data = bytestream->read(blockSize);
- IBBRequest::ref request = IBBRequest::create(to, IBB::createIBBData(id, sequenceNumber, data), router);
+ IBBRequest::ref request = IBBRequest::create(from, to, IBB::createIBBData(id, sequenceNumber, data), router);
sequenceNumber++;
request->onResponse.connect(boost::bind(&IBBSendSession::handleIBBResponse, this, _1, _2));
request->send();
diff --git a/Swiften/FileTransfer/IBBSendSession.h b/Swiften/FileTransfer/IBBSendSession.h
index 325f66c..8e5ace1 100644
--- a/Swiften/FileTransfer/IBBSendSession.h
+++ b/Swiften/FileTransfer/IBBSendSession.h
@@ -21,12 +21,20 @@ namespace Swift {
class IBBSendSession {
public:
- IBBSendSession(const std::string& id, const JID& to, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* router);
+ IBBSendSession(const std::string& id, const JID& from, const JID& to, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* router);
~IBBSendSession();
void start();
void stop();
+ const JID& getSender() const {
+ return from;
+ }
+
+ const JID& getReceiver() const {
+ return to;
+ }
+
void setBlockSize(int blockSize) {
this->blockSize = blockSize;
}
@@ -39,6 +47,7 @@ namespace Swift {
private:
std::string id;
+ JID from;
JID to;
boost::shared_ptr<ReadBytestream> bytestream;
IQRouter* router;
diff --git a/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp b/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp
index ab6b5e5..0871568 100644
--- a/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp
+++ b/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp
@@ -498,7 +498,7 @@ void IncomingJingleFileTransfer::stopActiveTransport() {
JingleIncomingIBBTransport::ref IncomingJingleFileTransfer::createIBBTransport(JingleIBBTransportPayload::ref ibbTransport) {
// TODO: getOffer() -> getOffers correction
- return boost::make_shared<JingleIncomingIBBTransport>(session->getInitiator(), ibbTransport->getSessionID(), description->getOffers()[0].getSize(), router);
+ return boost::make_shared<JingleIncomingIBBTransport>(session->getInitiator(), getRecipient(), ibbTransport->getSessionID(), description->getOffers()[0].getSize(), router);
}
JingleContentID IncomingJingleFileTransfer::getContentID() const {
diff --git a/Swiften/FileTransfer/JingleIncomingIBBTransport.cpp b/Swiften/FileTransfer/JingleIncomingIBBTransport.cpp
index 9b5c354..ccca641 100644
--- a/Swiften/FileTransfer/JingleIncomingIBBTransport.cpp
+++ b/Swiften/FileTransfer/JingleIncomingIBBTransport.cpp
@@ -8,7 +8,7 @@
namespace Swift {
-JingleIncomingIBBTransport::JingleIncomingIBBTransport(const JID& from, const std::string& id, size_t size, IQRouter* router) : ibbSession(id, from, size, router) {
+JingleIncomingIBBTransport::JingleIncomingIBBTransport(const JID& from, const JID& to, const std::string& id, size_t size, IQRouter* router) : ibbSession(id, from, to, size, router) {
ibbSession.onDataReceived.connect(boost::ref(onDataReceived));
ibbSession.onFinished.connect(boost::ref(onFinished));
}
diff --git a/Swiften/FileTransfer/JingleIncomingIBBTransport.h b/Swiften/FileTransfer/JingleIncomingIBBTransport.h
index e2fa485..be18a2d 100644
--- a/Swiften/FileTransfer/JingleIncomingIBBTransport.h
+++ b/Swiften/FileTransfer/JingleIncomingIBBTransport.h
@@ -16,7 +16,7 @@ namespace Swift {
public:
typedef boost::shared_ptr<JingleIncomingIBBTransport> ref;
- JingleIncomingIBBTransport(const JID& from, const std::string& id, size_t size, IQRouter* router);
+ JingleIncomingIBBTransport(const JID& from, const JID& to, const std::string& id, size_t size, IQRouter* router);
virtual void start();
virtual void stop();
diff --git a/Swiften/FileTransfer/OutgoingFileTransferManager.cpp b/Swiften/FileTransfer/OutgoingFileTransferManager.cpp
index e27d411..6f23bb7 100644
--- a/Swiften/FileTransfer/OutgoingFileTransferManager.cpp
+++ b/Swiften/FileTransfer/OutgoingFileTransferManager.cpp
@@ -34,7 +34,7 @@ boost::shared_ptr<OutgoingFileTransfer> OutgoingFileTransferManager::createOutgo
//jsManager->getSession(receipient, idGenerator->generateID());
assert(jingleSession);
jsManager->registerOutgoingSession(from, jingleSession);
- boost::shared_ptr<OutgoingJingleFileTransfer> jingleFT = boost::shared_ptr<OutgoingJingleFileTransfer>(new OutgoingJingleFileTransfer(jingleSession, remoteFactory, localFactory, iqRouter, idGenerator, receipient, readBytestream, fileInfo, bytestreamRegistry, bytestreamProxy));
+ boost::shared_ptr<OutgoingJingleFileTransfer> jingleFT = boost::shared_ptr<OutgoingJingleFileTransfer>(new OutgoingJingleFileTransfer(jingleSession, remoteFactory, localFactory, iqRouter, idGenerator, from, receipient, readBytestream, fileInfo, bytestreamRegistry, bytestreamProxy));
// otherwise try SI
diff --git a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp
index 9b71165..5e2a1c3 100644
--- a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp
+++ b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp
@@ -39,12 +39,13 @@ OutgoingJingleFileTransfer::OutgoingJingleFileTransfer(JingleSession::ref sessio
LocalJingleTransportCandidateGeneratorFactory* localFactory,
IQRouter* router,
IDGenerator *idGenerator,
+ const JID& fromJID,
const JID& toJID,
boost::shared_ptr<ReadBytestream> readStream,
const StreamInitiationFileInfo &fileInfo,
SOCKS5BytestreamRegistry* bytestreamRegistry,
SOCKS5BytestreamProxy* bytestreamProxy) :
- session(session), remoteFactory(remoteFactory), localFactory(localFactory), router(router), idGenerator(idGenerator), toJID(toJID), readStream(readStream), fileInfo(fileInfo), s5bRegistry(bytestreamRegistry), s5bProxy(bytestreamProxy), serverSession(NULL), contentID(JingleContentID(idGenerator->generateID(), JingleContentPayload::InitiatorCreator)), canceled(false) {
+ session(session), remoteFactory(remoteFactory), localFactory(localFactory), router(router), idGenerator(idGenerator), fromJID(fromJID), toJID(toJID), readStream(readStream), fileInfo(fileInfo), s5bRegistry(bytestreamRegistry), s5bProxy(bytestreamProxy), serverSession(NULL), contentID(JingleContentID(idGenerator->generateID(), JingleContentPayload::InitiatorCreator)), canceled(false) {
session->onSessionAcceptReceived.connect(boost::bind(&OutgoingJingleFileTransfer::handleSessionAcceptReceived, this, _1, _2, _3));
session->onSessionTerminateReceived.connect(boost::bind(&OutgoingJingleFileTransfer::handleSessionTerminateReceived, this, _1));
session->onTransportInfoReceived.connect(boost::bind(&OutgoingJingleFileTransfer::handleTransportInfoReceived, this, _1, _2));
@@ -109,7 +110,7 @@ void OutgoingJingleFileTransfer::handleSessionAcceptReceived(const JingleContent
JingleIBBTransportPayload::ref ibbPayload;
JingleS5BTransportPayload::ref s5bPayload;
if ((ibbPayload = boost::dynamic_pointer_cast<JingleIBBTransportPayload>(transportPayload))) {
- ibbSession = boost::make_shared<IBBSendSession>(ibbPayload->getSessionID(), toJID, readStream, router);
+ ibbSession = boost::make_shared<IBBSendSession>(ibbPayload->getSessionID(), fromJID, toJID, readStream, router);
ibbSession->setBlockSize(ibbPayload->getBlockSize());
ibbSession->onBytesSent.connect(boost::bind(boost::ref(onProcessedBytes), _1));
ibbSession->onFinished.connect(boost::bind(&OutgoingJingleFileTransfer::handleTransferFinished, this, _1));
@@ -163,7 +164,7 @@ void OutgoingJingleFileTransfer::handleTransportAcceptReceived(const JingleConte
}
if (JingleIBBTransportPayload::ref ibbPayload = boost::dynamic_pointer_cast<JingleIBBTransportPayload>(transport)) {
- ibbSession = boost::make_shared<IBBSendSession>(ibbPayload->getSessionID(), toJID, readStream, router);
+ ibbSession = boost::make_shared<IBBSendSession>(ibbPayload->getSessionID(), fromJID, toJID, readStream, router);
ibbSession->setBlockSize(ibbPayload->getBlockSize());
ibbSession->onBytesSent.connect(boost::bind(boost::ref(onProcessedBytes), _1));
ibbSession->onFinished.connect(boost::bind(&OutgoingJingleFileTransfer::handleTransferFinished, this, _1));
diff --git a/Swiften/FileTransfer/OutgoingJingleFileTransfer.h b/Swiften/FileTransfer/OutgoingJingleFileTransfer.h
index fecfbdb..ff7bfc7 100644
--- a/Swiften/FileTransfer/OutgoingJingleFileTransfer.h
+++ b/Swiften/FileTransfer/OutgoingJingleFileTransfer.h
@@ -41,7 +41,8 @@ public:
LocalJingleTransportCandidateGeneratorFactory*,
IQRouter*,
IDGenerator*,
- const JID&,
+ const JID& from,
+ const JID& to,
boost::shared_ptr<ReadBytestream>,
const StreamInitiationFileInfo&,
SOCKS5BytestreamRegistry*,
@@ -90,6 +91,7 @@ private:
IQRouter* router;
IDGenerator* idGenerator;
+ JID fromJID;
JID toJID;
boost::shared_ptr<ReadBytestream> readStream;
StreamInitiationFileInfo fileInfo;
diff --git a/Swiften/FileTransfer/OutgoingSIFileTransfer.cpp b/Swiften/FileTransfer/OutgoingSIFileTransfer.cpp
index dfcf028..8a8237a 100644
--- a/Swiften/FileTransfer/OutgoingSIFileTransfer.cpp
+++ b/Swiften/FileTransfer/OutgoingSIFileTransfer.cpp
@@ -48,7 +48,7 @@ void OutgoingSIFileTransfer::handleStreamInitiationRequestResponse(StreamInitiat
request->send();
}
else if (response->getRequestedMethod() == "http://jabber.org/protocol/ibb") {
- ibbSession = boost::shared_ptr<IBBSendSession>(new IBBSendSession(id, to, bytestream, iqRouter));
+ ibbSession = boost::shared_ptr<IBBSendSession>(new IBBSendSession(id, from, to, bytestream, iqRouter));
ibbSession->onFinished.connect(boost::bind(&OutgoingSIFileTransfer::handleIBBSessionFinished, this, _1));
ibbSession->start();
}
diff --git a/Swiften/FileTransfer/UnitTest/IBBReceiveSessionTest.cpp b/Swiften/FileTransfer/UnitTest/IBBReceiveSessionTest.cpp
index e759624..c62636d 100644
--- a/Swiften/FileTransfer/UnitTest/IBBReceiveSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/IBBReceiveSessionTest.cpp
@@ -161,7 +161,7 @@ class IBBReceiveSessionTest : public CppUnit::TestFixture {
}
IBBReceiveSession* createSession(const std::string& from, const std::string& id, size_t size = 0x1000) {
- IBBReceiveSession* session = new IBBReceiveSession(id, JID(from), size, iqRouter);
+ IBBReceiveSession* session = new IBBReceiveSession(id, JID(from), JID(), size, iqRouter);
session->onDataReceived.connect(boost::bind(&IBBReceiveSessionTest::handleDataReceived, this, _1));
session->onFinished.connect(boost::bind(&IBBReceiveSessionTest::handleFinished, this, _1));
return session;
diff --git a/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp b/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp
index 5b43f69..c88635f 100644
--- a/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp
@@ -144,7 +144,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture {
private:
boost::shared_ptr<IBBSendSession> createSession(const std::string& to) {
- boost::shared_ptr<IBBSendSession> session(new IBBSendSession("myid", JID(to), bytestream, iqRouter));
+ boost::shared_ptr<IBBSendSession> session(new IBBSendSession("myid", JID(), JID(to), bytestream, iqRouter));
session->onFinished.connect(boost::bind(&IBBSendSessionTest::handleFinished, this, _1));
return session;
}
diff --git a/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp b/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp
index 582c3e5..0c324bf 100644
--- a/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/OutgoingJingleFileTransferTest.cpp
@@ -144,7 +144,7 @@ public:
fileInfo.setName("test.bin");
fileInfo.setHash("asdjasdas");
fileInfo.setSize(1024 * 1024);
- return boost::shared_ptr<OutgoingJingleFileTransfer>(new OutgoingJingleFileTransfer(boost::shared_ptr<JingleSession>(fakeJingleSession), fakeRJTCSF.get(), fakeLJTCF.get(), iqRouter, idGen, to, stream, fileInfo, s5bRegistry, s5bProxy));
+ return boost::shared_ptr<OutgoingJingleFileTransfer>(new OutgoingJingleFileTransfer(boost::shared_ptr<JingleSession>(fakeJingleSession), fakeRJTCSF.get(), fakeLJTCF.get(), iqRouter, idGen, JID(), to, stream, fileInfo, s5bRegistry, s5bProxy));
}
IQ::ref createIBBRequest(IBB::ref ibb, const JID& from, const std::string& id) {