summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/FileTransfer')
-rw-r--r--Swiften/FileTransfer/ByteArrayReadBytestream.cpp33
-rw-r--r--Swiften/FileTransfer/ByteArrayReadBytestream.h21
-rw-r--r--Swiften/FileTransfer/DefaultRemoteJingleTransportCandidateSelector.cpp4
-rw-r--r--Swiften/FileTransfer/DefaultRemoteJingleTransportCandidateSelector.h17
-rw-r--r--Swiften/FileTransfer/FileReadBytestream.cpp7
-rw-r--r--Swiften/FileTransfer/FileTransfer.h2
-rw-r--r--Swiften/FileTransfer/FileTransferManager.h2
-rw-r--r--Swiften/FileTransfer/FileTransferManagerImpl.cpp2
-rw-r--r--Swiften/FileTransfer/FileTransferManagerImpl.h2
-rw-r--r--Swiften/FileTransfer/FileWriteBytestream.cpp5
-rw-r--r--Swiften/FileTransfer/IBBSendSession.cpp5
-rw-r--r--Swiften/FileTransfer/IBBSendSession.h8
-rw-r--r--Swiften/FileTransfer/IncomingJingleFileTransfer.cpp5
-rw-r--r--Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp2
-rw-r--r--Swiften/FileTransfer/OutgoingSIFileTransfer.cpp4
-rw-r--r--Swiften/FileTransfer/OutgoingSIFileTransfer.h6
-rw-r--r--Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h2
-rw-r--r--Swiften/FileTransfer/SConscript1
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp5
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamClientSession.h4
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp7
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamServerSession.h4
-rw-r--r--Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h2
-rw-r--r--Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp14
-rw-r--r--Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp8
25 files changed, 100 insertions, 72 deletions
diff --git a/Swiften/FileTransfer/ByteArrayReadBytestream.cpp b/Swiften/FileTransfer/ByteArrayReadBytestream.cpp
new file mode 100644
index 0000000..4ba791f
--- /dev/null
+++ b/Swiften/FileTransfer/ByteArrayReadBytestream.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2010-2013 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <Swiften/FileTransfer/ByteArrayReadBytestream.h>
+
+#include <boost/smart_ptr/make_shared.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+
+#include <Swiften/Base/Algorithm.h>
+
+using namespace Swift;
+
+boost::shared_ptr<ByteArray> ByteArrayReadBytestream::read(size_t size) {
+ size_t readSize = size;
+ if (position + readSize > data.size()) {
+ readSize = data.size() - position;
+ }
+ boost::shared_ptr<ByteArray> result = boost::make_shared<ByteArray>(
+ data.begin() + boost::numeric_cast<long long>(position),
+ data.begin() + boost::numeric_cast<long long>(position) + boost::numeric_cast<long long>(readSize));
+
+ onRead(*result);
+ position += readSize;
+ return result;
+}
+
+void ByteArrayReadBytestream::addData(const std::vector<unsigned char>& moreData) {
+ append(data, moreData);
+ onDataAvailable();
+}
diff --git a/Swiften/FileTransfer/ByteArrayReadBytestream.h b/Swiften/FileTransfer/ByteArrayReadBytestream.h
index 9311099..664698a 100644
--- a/Swiften/FileTransfer/ByteArrayReadBytestream.h
+++ b/Swiften/FileTransfer/ByteArrayReadBytestream.h
@@ -1,5 +1,5 @@
/*
- * 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.
*/
@@ -7,9 +7,7 @@
#pragma once
#include <vector>
-#include <boost/smart_ptr/make_shared.hpp>
-#include <Swiften/Base/Algorithm.h>
#include <Swiften/FileTransfer/ReadBytestream.h>
#include <Swiften/Base/ByteArray.h>
@@ -19,17 +17,7 @@ namespace Swift {
ByteArrayReadBytestream(const std::vector<unsigned char>& data) : data(data), position(0), dataComplete(true) {
}
- virtual boost::shared_ptr<ByteArray> read(size_t size) {
- size_t readSize = size;
- if (position + readSize > data.size()) {
- readSize = data.size() - position;
- }
- boost::shared_ptr<ByteArray> result = boost::make_shared<ByteArray>(data.begin() + position, data.begin() + position + readSize);
-
- onRead(*result);
- position += readSize;
- return result;
- }
+ virtual boost::shared_ptr<ByteArray> read(size_t size);
virtual bool isFinished() const {
return position >= data.size() && dataComplete;
@@ -39,10 +27,7 @@ namespace Swift {
dataComplete = b;
}
- void addData(const std::vector<unsigned char>& moreData) {
- append(data, moreData);
- onDataAvailable();
- }
+ void addData(const std::vector<unsigned char>& moreData);
private:
std::vector<unsigned char> data;
diff --git a/Swiften/FileTransfer/DefaultRemoteJingleTransportCandidateSelector.cpp b/Swiften/FileTransfer/DefaultRemoteJingleTransportCandidateSelector.cpp
index 32b4df8..4a6b61f 100644
--- a/Swiften/FileTransfer/DefaultRemoteJingleTransportCandidateSelector.cpp
+++ b/Swiften/FileTransfer/DefaultRemoteJingleTransportCandidateSelector.cpp
@@ -4,7 +4,7 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
-#include "DefaultRemoteJingleTransportCandidateSelector.h"
+#include <Swiften/FileTransfer/DefaultRemoteJingleTransportCandidateSelector.h>
#include <boost/smart_ptr/make_shared.hpp>
#include <boost/bind.hpp>
@@ -97,7 +97,7 @@ void DefaultRemoteJingleTransportCandidateSelector::setMinimumPriority(int prior
SWIFT_LOG(debug) << "priority: " << priority << std::endl;
}
-void DefaultRemoteJingleTransportCandidateSelector::setRequesterTargtet(const JID& requester, const JID& target) {
+void DefaultRemoteJingleTransportCandidateSelector::setRequesterTarget(const JID& requester, const JID& target) {
this->requester = requester;
this->target = target;
}
diff --git a/Swiften/FileTransfer/DefaultRemoteJingleTransportCandidateSelector.h b/Swiften/FileTransfer/DefaultRemoteJingleTransportCandidateSelector.h
index 255acd9..073c51f 100644
--- a/Swiften/FileTransfer/DefaultRemoteJingleTransportCandidateSelector.h
+++ b/Swiften/FileTransfer/DefaultRemoteJingleTransportCandidateSelector.h
@@ -11,6 +11,7 @@
#include <boost/shared_ptr.hpp>
+#include <Swiften/Base/Override.h>
#include <Swiften/JID/JID.h>
#include <Swiften/Network/Connection.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamClientSession.h>
@@ -28,15 +29,15 @@ public:
DefaultRemoteJingleTransportCandidateSelector(ConnectionFactory*, TimerFactory*);
virtual ~DefaultRemoteJingleTransportCandidateSelector();
- virtual void addRemoteTransportCandidates(JingleTransportPayload::ref);
- virtual void selectCandidate();
- virtual void setMinimumPriority(int);
- void setRequesterTargtet(const JID& requester, const JID& target);
- virtual SOCKS5BytestreamClientSession::ref getS5BSession();
+ virtual void addRemoteTransportCandidates(JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
+ virtual void selectCandidate() SWIFTEN_OVERRIDE;
+ virtual void setMinimumPriority(int) SWIFTEN_OVERRIDE;
+ virtual void setRequesterTarget(const JID& requester, const JID& target) SWIFTEN_OVERRIDE;
+ virtual SOCKS5BytestreamClientSession::ref getS5BSession() SWIFTEN_OVERRIDE;
- virtual bool isActualCandidate(JingleTransportPayload::ref);
- virtual int getPriority(JingleTransportPayload::ref);
- virtual JingleTransport::ref selectTransport(JingleTransportPayload::ref);
+ virtual bool isActualCandidate(JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
+ virtual int getPriority(JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
+ virtual JingleTransport::ref selectTransport(JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
private:
void tryNextCandidate(bool error);
diff --git a/Swiften/FileTransfer/FileReadBytestream.cpp b/Swiften/FileTransfer/FileReadBytestream.cpp
index a8946a0..4257f8b 100644
--- a/Swiften/FileTransfer/FileReadBytestream.cpp
+++ b/Swiften/FileTransfer/FileReadBytestream.cpp
@@ -1,5 +1,5 @@
/*
- * 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.
*/
@@ -7,6 +7,7 @@
#include <boost/filesystem/fstream.hpp>
#include <cassert>
#include <boost/smart_ptr/make_shared.hpp>
+#include <boost/numeric/conversion/cast.hpp>
#include <Swiften/FileTransfer/FileReadBytestream.h>
#include <Swiften/Base/ByteArray.h>
@@ -30,8 +31,8 @@ boost::shared_ptr<ByteArray> FileReadBytestream::read(size_t size) {
boost::shared_ptr<ByteArray> result = boost::make_shared<ByteArray>();
result->resize(size);
assert(stream->good());
- stream->read(reinterpret_cast<char*>(vecptr(*result)), size);
- result->resize(stream->gcount());
+ stream->read(reinterpret_cast<char*>(vecptr(*result)), boost::numeric_cast<std::streamsize>(size));
+ result->resize(boost::numeric_cast<size_t>(stream->gcount()));
onRead(*result);
return result;
}
diff --git a/Swiften/FileTransfer/FileTransfer.h b/Swiften/FileTransfer/FileTransfer.h
index 336c51c..01c9449 100644
--- a/Swiften/FileTransfer/FileTransfer.h
+++ b/Swiften/FileTransfer/FileTransfer.h
@@ -48,7 +48,7 @@ public:
virtual void cancel() = 0;
public:
- boost::signal<void (int /* proccessedBytes */)> onProcessedBytes;
+ boost::signal<void (size_t /* proccessedBytes */)> onProcessedBytes;
boost::signal<void (State)> onStateChange;
boost::signal<void (boost::optional<FileTransferError>)> onFinished;
diff --git a/Swiften/FileTransfer/FileTransferManager.h b/Swiften/FileTransfer/FileTransferManager.h
index 30d9faf..68f3d0d 100644
--- a/Swiften/FileTransfer/FileTransferManager.h
+++ b/Swiften/FileTransfer/FileTransferManager.h
@@ -7,7 +7,7 @@
#pragma once
#include <string>
-#include <boost/filesystem.hpp>
+#include <boost/filesystem/path.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <Swiften/Base/API.h>
diff --git a/Swiften/FileTransfer/FileTransferManagerImpl.cpp b/Swiften/FileTransfer/FileTransferManagerImpl.cpp
index 84b2061..d5d4aaf 100644
--- a/Swiften/FileTransfer/FileTransferManagerImpl.cpp
+++ b/Swiften/FileTransfer/FileTransferManagerImpl.cpp
@@ -7,9 +7,11 @@
#include <Swiften/FileTransfer/FileTransferManagerImpl.h>
#include <boost/bind.hpp>
+#include <boost/filesystem.hpp>
#include <boost/cstdint.hpp>
#include <Swiften/Base/foreach.h>
+#include <Swiften/Base/Log.h>
#include "Swiften/Disco/EntityCapsProvider.h"
#include <Swiften/JID/JID.h>
#include <Swiften/Elements/StreamInitiationFileInfo.h>
diff --git a/Swiften/FileTransfer/FileTransferManagerImpl.h b/Swiften/FileTransfer/FileTransferManagerImpl.h
index ecc692d..0bbbf31 100644
--- a/Swiften/FileTransfer/FileTransferManagerImpl.h
+++ b/Swiften/FileTransfer/FileTransferManagerImpl.h
@@ -9,7 +9,7 @@
#include <vector>
#include <string>
-#include <boost/filesystem.hpp>
+#include <boost/filesystem/path.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/optional.hpp>
diff --git a/Swiften/FileTransfer/FileWriteBytestream.cpp b/Swiften/FileTransfer/FileWriteBytestream.cpp
index 6a22c6a..5725e18 100644
--- a/Swiften/FileTransfer/FileWriteBytestream.cpp
+++ b/Swiften/FileTransfer/FileWriteBytestream.cpp
@@ -1,11 +1,12 @@
/*
- * 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.
*/
#include <boost/filesystem/fstream.hpp>
#include <cassert>
+#include <boost/numeric/conversion/cast.hpp>
#include <Swiften/FileTransfer/FileWriteBytestream.h>
@@ -26,7 +27,7 @@ void FileWriteBytestream::write(const std::vector<unsigned char>& data) {
stream = new boost::filesystem::ofstream(file, std::ios_base::out|std::ios_base::binary);
}
assert(stream->good());
- stream->write(reinterpret_cast<const char*>(&data[0]), data.size());
+ stream->write(reinterpret_cast<const char*>(&data[0]), boost::numeric_cast<std::streamsize>(data.size()));
onWrite(data);
}
diff --git a/Swiften/FileTransfer/IBBSendSession.cpp b/Swiften/FileTransfer/IBBSendSession.cpp
index c24cc0a..4d7477f 100644
--- a/Swiften/FileTransfer/IBBSendSession.cpp
+++ b/Swiften/FileTransfer/IBBSendSession.cpp
@@ -1,5 +1,5 @@
/*
- * 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.
*/
@@ -7,6 +7,7 @@
#include <Swiften/FileTransfer/IBBSendSession.h>
#include <boost/bind.hpp>
+#include <boost/numeric/conversion/cast.hpp>
#include <Swiften/Base/ByteArray.h>
#include <Swiften/Queries/IQRouter.h>
@@ -24,7 +25,7 @@ IBBSendSession::~IBBSendSession() {
}
void IBBSendSession::start() {
- IBBRequest::ref request = IBBRequest::create(from, to, IBB::createIBBOpen(id, blockSize), router);
+ IBBRequest::ref request = IBBRequest::create(from, to, IBB::createIBBOpen(id, boost::numeric_cast<int>(blockSize)), router);
request->onResponse.connect(boost::bind(&IBBSendSession::handleIBBResponse, this, _1, _2));
active = true;
request->send();
diff --git a/Swiften/FileTransfer/IBBSendSession.h b/Swiften/FileTransfer/IBBSendSession.h
index a535382..dcda11f 100644
--- a/Swiften/FileTransfer/IBBSendSession.h
+++ b/Swiften/FileTransfer/IBBSendSession.h
@@ -1,5 +1,5 @@
/*
- * 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.
*/
@@ -36,12 +36,12 @@ namespace Swift {
return to;
}
- void setBlockSize(int blockSize) {
+ void setBlockSize(unsigned int blockSize) {
this->blockSize = blockSize;
}
boost::signal<void (boost::optional<FileTransferError>)> onFinished;
- boost::signal<void (int)> onBytesSent;
+ boost::signal<void (unsigned long long)> onBytesSent;
private:
void handleIBBResponse(IBB::ref, ErrorPayload::ref);
@@ -55,7 +55,7 @@ namespace Swift {
JID to;
boost::shared_ptr<ReadBytestream> bytestream;
IQRouter* router;
- int blockSize;
+ unsigned int blockSize;
int sequenceNumber;
bool active;
bool waitingForData;
diff --git a/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp b/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp
index 808ff58..c462381 100644
--- a/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp
+++ b/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp
@@ -110,7 +110,7 @@ void IncomingJingleFileTransfer::accept(WriteBytestream::ref stream) {
s5bRegistry->addWriteBytestream(s5bDestination, stream);
fillCandidateMap(theirCandidates, s5bTransport);
candidateSelector->addRemoteTransportCandidates(s5bTransport);
- candidateSelector->setRequesterTargtet(session->getInitiator(), ourJID);
+ candidateSelector->setRequesterTarget(session->getInitiator(), ourJID);
s5bTransport->setSessionID(s5bSessionID);
candidateGenerator->generateLocalTransportCandidates(s5bTransport);
}
@@ -173,8 +173,9 @@ void IncomingJingleFileTransfer::handleRemoteTransportCandidateSelectFinished(Ji
}
}
+// TODO: Why was assert(false) there? Is this method no longer used perhaps? Delete it if not
void IncomingJingleFileTransfer::checkCandidateSelected() {
- assert(false);
+ //assert(false);
if (localTransportCandidateSelectFinished && remoteTransportCandidateSelectFinished) {
if (candidateGenerator->isActualCandidate(selectedLocalTransportCandidate) && candidateSelector->isActualCandidate(selectedRemoteTransportCandidate)) {
if (candidateGenerator->getPriority(selectedLocalTransportCandidate) > candidateSelector->getPriority(selectedRemoteTransportCandidate)) {
diff --git a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp
index e22260e..4da70ef 100644
--- a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp
+++ b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp
@@ -119,7 +119,7 @@ void OutgoingJingleFileTransfer::handleSessionAcceptReceived(const JingleContent
}
else if ((s5bPayload = boost::dynamic_pointer_cast<JingleS5BTransportPayload>(transportPayload))) {
fillCandidateMap(theirCandidates, s5bPayload);
- remoteCandidateSelector->setRequesterTargtet(toJID, session->getInitiator());
+ remoteCandidateSelector->setRequesterTarget(toJID, session->getInitiator());
remoteCandidateSelector->addRemoteTransportCandidates(s5bPayload);
remoteCandidateSelector->selectCandidate();
}
diff --git a/Swiften/FileTransfer/OutgoingSIFileTransfer.cpp b/Swiften/FileTransfer/OutgoingSIFileTransfer.cpp
index fc0a551..5e93343 100644
--- a/Swiften/FileTransfer/OutgoingSIFileTransfer.cpp
+++ b/Swiften/FileTransfer/OutgoingSIFileTransfer.cpp
@@ -1,5 +1,5 @@
/*
- * 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.
*/
@@ -16,7 +16,7 @@
namespace Swift {
-OutgoingSIFileTransfer::OutgoingSIFileTransfer(const std::string& id, const JID& from, const JID& to, const std::string& name, int size, const std::string& description, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* iqRouter, SOCKS5BytestreamServer* socksServer) : id(id), from(from), to(to), name(name), size(size), description(description), bytestream(bytestream), iqRouter(iqRouter), socksServer(socksServer) {
+OutgoingSIFileTransfer::OutgoingSIFileTransfer(const std::string& id, const JID& from, const JID& to, const std::string& name, unsigned long long size, const std::string& description, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* iqRouter, SOCKS5BytestreamServer* socksServer) : id(id), from(from), to(to), name(name), size(size), description(description), bytestream(bytestream), iqRouter(iqRouter), socksServer(socksServer) {
}
void OutgoingSIFileTransfer::start() {
diff --git a/Swiften/FileTransfer/OutgoingSIFileTransfer.h b/Swiften/FileTransfer/OutgoingSIFileTransfer.h
index 584eb60..79da339 100644
--- a/Swiften/FileTransfer/OutgoingSIFileTransfer.h
+++ b/Swiften/FileTransfer/OutgoingSIFileTransfer.h
@@ -1,5 +1,5 @@
/*
- * 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.
*/
@@ -25,7 +25,7 @@ namespace Swift {
class OutgoingSIFileTransfer : public OutgoingFileTransfer {
public:
- OutgoingSIFileTransfer(const std::string& id, const JID& from, const JID& to, const std::string& name, int size, const std::string& description, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* iqRouter, SOCKS5BytestreamServer* socksServer);
+ OutgoingSIFileTransfer(const std::string& id, const JID& from, const JID& to, const std::string& name, unsigned long long size, const std::string& description, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* iqRouter, SOCKS5BytestreamServer* socksServer);
virtual void start();
virtual void stop();
@@ -43,7 +43,7 @@ namespace Swift {
JID from;
JID to;
std::string name;
- int size;
+ unsigned long long size;
std::string description;
boost::shared_ptr<ReadBytestream> bytestream;
IQRouter* iqRouter;
diff --git a/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h b/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h
index 487747c..3d5612a 100644
--- a/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h
+++ b/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.h
@@ -22,7 +22,7 @@ namespace Swift {
virtual void addRemoteTransportCandidates(JingleTransportPayload::ref) = 0;
virtual void selectCandidate() = 0;
virtual void setMinimumPriority(int) = 0;
- virtual void setRequesterTargtet(const JID&, const JID&) {}
+ virtual void setRequesterTarget(const JID&, const JID&) {}
virtual SOCKS5BytestreamClientSession::ref getS5BSession() { return SOCKS5BytestreamClientSession::ref(); }
virtual bool isActualCandidate(JingleTransportPayload::ref) = 0;
diff --git a/Swiften/FileTransfer/SConscript b/Swiften/FileTransfer/SConscript
index 4e79992..8d98477 100644
--- a/Swiften/FileTransfer/SConscript
+++ b/Swiften/FileTransfer/SConscript
@@ -1,6 +1,7 @@
Import("swiften_env", "env")
sources = [
+ "ByteArrayReadBytestream.cpp",
"OutgoingFileTransfer.cpp",
"OutgoingSIFileTransfer.cpp",
"OutgoingJingleFileTransfer.cpp",
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp
index cd555e5..1b3399f 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp
+++ b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp
@@ -7,6 +7,7 @@
#include "SOCKS5BytestreamClientSession.h"
#include <boost/bind.hpp>
+#include <boost/numeric/conversion/cast.hpp>
#include <Swiften/Base/Algorithm.h>
#include <Swiften/Base/SafeByteArray.h>
@@ -127,7 +128,7 @@ void SOCKS5BytestreamClientSession::authenticate() {
SWIFT_LOG(debug) << std::endl;
SafeByteArray header = createSafeByteArray("\x05\x01\x00\x03", 4);
SafeByteArray message = header;
- append(message, createSafeByteArray(destination.size()));
+ append(message, createSafeByteArray(boost::numeric_cast<char>(destination.size())));
authenticateAddress = createByteArray(destination);
append(message, authenticateAddress);
append(message, createSafeByteArray("\x00\x00", 2)); // 2 byte for port
@@ -165,7 +166,7 @@ HostAddressPort SOCKS5BytestreamClientSession::getAddressPort() const {
void SOCKS5BytestreamClientSession::sendData() {
if (!readBytestream->isFinished()) {
try {
- boost::shared_ptr<ByteArray> dataToSend = readBytestream->read(chunkSize);
+ boost::shared_ptr<ByteArray> dataToSend = readBytestream->read(boost::numeric_cast<size_t>(chunkSize));
connection->write(createSafeByteArray(*dataToSend));
onBytesSent(dataToSend->size());
}
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h
index 0b9790d..a832796 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h
+++ b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h
@@ -58,8 +58,8 @@ public:
boost::signal<void (bool /*error*/)> onSessionReady;
boost::signal<void (boost::optional<FileTransferError>)> onFinished;
- boost::signal<void (int)> onBytesSent;
- boost::signal<void (int)> onBytesReceived;
+ boost::signal<void (size_t)> onBytesSent;
+ boost::signal<void (size_t)> onBytesReceived;
private:
void process();
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp
index 4412d0b..7521822 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp
+++ b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp
@@ -1,5 +1,5 @@
/*
- * 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.
*/
@@ -7,6 +7,7 @@
#include <Swiften/FileTransfer/SOCKS5BytestreamServerSession.h>
#include <boost/bind.hpp>
+#include <boost/numeric/conversion/cast.hpp>
#include <iostream>
#include <Swiften/Base/ByteArray.h>
@@ -133,7 +134,7 @@ void SOCKS5BytestreamServerSession::process() {
SafeByteArray result = createSafeByteArray("\x05", 1);
result.push_back((readBytestream || writeBytestream) ? 0x0 : 0x4);
append(result, createByteArray("\x00\x03", 2));
- result.push_back(static_cast<char>(requestID.size()));
+ result.push_back(boost::numeric_cast<unsigned char>(requestID.size()));
append(result, concat(requestID, createByteArray("\x00\x00", 2)));
if (!readBytestream && !writeBytestream) {
SWIFT_LOG(debug) << "Readstream or Wrtiestream with ID " << streamID << " not found!" << std::endl;
@@ -159,7 +160,7 @@ void SOCKS5BytestreamServerSession::process() {
void SOCKS5BytestreamServerSession::sendData() {
if (!readBytestream->isFinished()) {
try {
- SafeByteArray dataToSend = createSafeByteArray(*readBytestream->read(chunkSize));
+ SafeByteArray dataToSend = createSafeByteArray(*readBytestream->read(boost::numeric_cast<size_t>(chunkSize)));
if (!dataToSend.empty()) {
connection->write(dataToSend);
onBytesSent(dataToSend.size());
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.h b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.h
index 4cbda7c..60a404b 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.h
+++ b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.h
@@ -47,8 +47,8 @@ namespace Swift {
HostAddressPort getAddressPort() const;
boost::signal<void (boost::optional<FileTransferError>)> onFinished;
- boost::signal<void (int)> onBytesSent;
- boost::signal<void (int)> onBytesReceived;
+ boost::signal<void (unsigned long long)> onBytesSent;
+ boost::signal<void (unsigned long long)> onBytesReceived;
private:
void finish(bool error);
diff --git a/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h b/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h
index ae06cd3..9975a67 100644
--- a/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h
+++ b/Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h
@@ -7,7 +7,7 @@
#pragma once
#include <string>
-#include <boost/filesystem.hpp>
+#include <boost/filesystem/path.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <Swiften/FileTransfer/FileTransferManager.h>
diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
index 5fe096a..502cf2d 100644
--- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
@@ -33,7 +33,7 @@
using namespace Swift;
-boost::mt19937 randomGen;
+static boost::mt19937 randomGen;
class SOCKS5BytestreamClientSessionTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(SOCKS5BytestreamClientSessionTest);
@@ -52,7 +52,7 @@ public:
destination(SOCKS5BytestreamRegistry::getHostname("foo", JID("requester@example.com/test"), JID("target@example.com/test"))), eventLoop(NULL), timerFactory(NULL) { }
void setUp() {
- randomGen.seed(time(NULL));
+ randomGen.seed(static_cast<unsigned int>(time(NULL)));
eventLoop = new DummyEventLoop();
timerFactory = new DummyTimerFactory();
connection = boost::make_shared<MockeryConnection>(failingPorts, true, eventLoop);
@@ -82,7 +82,7 @@ public:
serverRespondHelloOK();
eventLoop->processEvents();
CPPUNIT_ASSERT_EQUAL(createByteArray("\x05\x01\x00\x03", 4), createByteArray(&helper.unprocessedInput[0], 4));
- CPPUNIT_ASSERT_EQUAL(createByteArray(destination.size()), createByteArray(helper.unprocessedInput[4]));
+ CPPUNIT_ASSERT_EQUAL(createByteArray(static_cast<char>(destination.size())), createByteArray(static_cast<char>(helper.unprocessedInput[4])));
CPPUNIT_ASSERT_EQUAL(createByteArray(destination), createByteArray(&helper.unprocessedInput[5], destination.size()));
CPPUNIT_ASSERT_EQUAL(createByteArray("\x00", 1), createByteArray(&helper.unprocessedInput[5 + destination.size()], 1));
@@ -128,7 +128,7 @@ public:
serverRespondHelloOK();
eventLoop->processEvents();
CPPUNIT_ASSERT_EQUAL(createByteArray("\x05\x01\x00\x03", 4), createByteArray(&helper.unprocessedInput[0], 4));
- CPPUNIT_ASSERT_EQUAL(createByteArray(destination.size()), createByteArray(helper.unprocessedInput[4]));
+ CPPUNIT_ASSERT_EQUAL(createByteArray(static_cast<char>(destination.size())), createByteArray(static_cast<char>(helper.unprocessedInput[4])));
CPPUNIT_ASSERT_EQUAL(createByteArray(destination), createByteArray(&helper.unprocessedInput[5], destination.size()));
CPPUNIT_ASSERT_EQUAL(createByteArray("\x00", 1), createByteArray(&helper.unprocessedInput[5 + destination.size()], 1));
@@ -205,7 +205,7 @@ private:
boost::variate_generator<boost::mt19937&, boost::uniform_int<> > randomByte(randomGen, dist);
ByteArray result(len);
for (size_t i=0; i < len; ++i ) {
- result[i] = randomByte();
+ result[i] = static_cast<unsigned char>(randomByte());
}
return result;
}
@@ -221,7 +221,7 @@ private:
void serverRespondRequestOK() {
boost::shared_ptr<SafeByteArray> dataToSend = createSafeByteArrayRef("\x05\x00\x00\x03", 4);
- append(*dataToSend, createSafeByteArray(destination.size()));
+ append(*dataToSend, createSafeByteArray(static_cast<char>(destination.size())));
append(*dataToSend, createSafeByteArray(destination));
append(*dataToSend, createSafeByteArray("\x00", 1));
connection->onDataRead(dataToSend);
@@ -229,7 +229,7 @@ private:
void serverRespondRequestFail() {
boost::shared_ptr<SafeByteArray> correctData = createSafeByteArrayRef("\x05\x00\x00\x03", 4);
- append(*correctData, createSafeByteArray(destination.size()));
+ append(*correctData, createSafeByteArray(static_cast<char>(destination.size())));
append(*correctData, createSafeByteArray(destination));
append(*correctData, createSafeByteArray("\x00", 1));
diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp
index 6dec37f..4e97399 100644
--- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp
@@ -76,7 +76,7 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture {
authenticate();
ByteArray hostname(createByteArray("abcdef"));
- receive(concat(createSafeByteArray("\x05\x01\x00\x03", 4), createSafeByteArray(hostname.size()), createSafeByteArray(hostname), createSafeByteArray("\x00\x00", 2)));
+ receive(concat(createSafeByteArray("\x05\x01\x00\x03", 4), createSafeByteArray(static_cast<char>(hostname.size())), createSafeByteArray(hostname), createSafeByteArray("\x00\x00", 2)));
CPPUNIT_ASSERT(createByteArray("\x05\x00\x00\x03\x06\x61\x62\x63\x64\x65\x66\x00\x00", 13) == createByteArray(&receivedData[0], 13));
}
@@ -86,7 +86,7 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture {
authenticate();
ByteArray hostname(createByteArray("abcdef"));
- receive(concat(createSafeByteArray("\x05\x01\x00\x03", 4), createSafeByteArray(hostname.size()), createSafeByteArray(hostname), createSafeByteArray("\x00\x00", 2)));
+ receive(concat(createSafeByteArray("\x05\x01\x00\x03", 4), createSafeByteArray(static_cast<char>(hostname.size())), createSafeByteArray(hostname), createSafeByteArray("\x00\x00", 2)));
CPPUNIT_ASSERT(createByteArray("\x05\x04\x00\x03\x06\x61\x62\x63\x64\x65\x66\x00\x00", 13) == receivedData);
}
@@ -173,11 +173,11 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture {
}
void request(const std::string& hostname) {
- receive(concat(createSafeByteArray("\x05\x01\x00\x03", 4), createSafeByteArray(hostname.size()), createSafeByteArray(hostname), createSafeByteArray("\x00\x00", 2)));
+ receive(concat(createSafeByteArray("\x05\x01\x00\x03", 4), createSafeByteArray(static_cast<char>(hostname.size())), createSafeByteArray(hostname), createSafeByteArray("\x00\x00", 2)));
}
void skipHeader(const std::string& hostname) {
- int headerSize = 7 + hostname.size();
+ size_t headerSize = 7 + hostname.size();
receivedData = createByteArray(&receivedData[headerSize], receivedData.size() - headerSize);
}