diff options
author | Remko Tronçon <git@el-tramo.be> | 2013-01-06 14:56:17 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2013-01-13 10:06:37 (GMT) |
commit | 188fc285c6555eadd3c9d50ab8a94adcade78d89 (patch) | |
tree | f02f5e249f8b511300d55a826d3b727f9d8d844f /Swiften/FileTransfer | |
parent | d5cab0388f6a40db6156a993e5f00acf9e63b577 (diff) | |
download | swift-188fc285c6555eadd3c9d50ab8a94adcade78d89.zip swift-188fc285c6555eadd3c9d50ab8a94adcade78d89.tar.bz2 |
Fix more warnings.
Fix sign conversion warnings.
Removing heavy unnecessary includes.
Change-Id: I992f43065498823098a875badb020c7c84fc4797
Diffstat (limited to 'Swiften/FileTransfer')
-rw-r--r-- | Swiften/FileTransfer/ByteArrayReadBytestream.cpp | 33 | ||||
-rw-r--r-- | Swiften/FileTransfer/ByteArrayReadBytestream.h | 21 | ||||
-rw-r--r-- | Swiften/FileTransfer/FileReadBytestream.cpp | 7 | ||||
-rw-r--r-- | Swiften/FileTransfer/FileTransferManager.h | 2 | ||||
-rw-r--r-- | Swiften/FileTransfer/FileTransferManagerImpl.cpp | 2 | ||||
-rw-r--r-- | Swiften/FileTransfer/FileTransferManagerImpl.h | 2 | ||||
-rw-r--r-- | Swiften/FileTransfer/FileWriteBytestream.cpp | 5 | ||||
-rw-r--r-- | Swiften/FileTransfer/IBBSendSession.cpp | 5 | ||||
-rw-r--r-- | Swiften/FileTransfer/IBBSendSession.h | 6 | ||||
-rw-r--r-- | Swiften/FileTransfer/OutgoingSIFileTransfer.cpp | 4 | ||||
-rw-r--r-- | Swiften/FileTransfer/OutgoingSIFileTransfer.h | 6 | ||||
-rw-r--r-- | Swiften/FileTransfer/SConscript | 1 | ||||
-rw-r--r-- | Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp | 2 | ||||
-rw-r--r-- | Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp | 6 | ||||
-rw-r--r-- | Swiften/FileTransfer/UnitTest/DummyFileTransferManager.h | 2 | ||||
-rw-r--r-- | Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp | 2 |
16 files changed, 65 insertions, 41 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/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/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 8584d38..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,7 +36,7 @@ namespace Swift { return to; } - void setBlockSize(int blockSize) { + void setBlockSize(unsigned int blockSize) { this->blockSize = blockSize; } @@ -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/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/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 b167663..1b3399f 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp @@ -166,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/SOCKS5BytestreamServerSession.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp index e0e6044..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. */ @@ -134,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; @@ -160,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/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 6781de8..502cf2d 100644 --- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp +++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp @@ -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] = static_cast<char>(randomByte()); + result[i] = static_cast<unsigned char>(randomByte()); } return result; } |