diff options
Diffstat (limited to 'Swiften/FileTransfer')
5 files changed, 26 insertions, 26 deletions
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp index a18b998..db3d83f 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp @@ -209,15 +209,15 @@ void SOCKS5BytestreamClientSession::handleConnectFinished(bool error) { } } -void SOCKS5BytestreamClientSession::handleDataRead(const SafeByteArray& data) { - SWIFT_LOG(debug) << "state: " << state << " data.size() = " << data.size() << std::endl; +void SOCKS5BytestreamClientSession::handleDataRead(boost::shared_ptr<SafeByteArray> data) { + SWIFT_LOG(debug) << "state: " << state << " data.size() = " << data->size() << std::endl; if (state != Reading) { - append(unprocessedData, data); + append(unprocessedData, *data); process(); } else { - writeBytestream->write(createByteArray(vecptr(data), data.size())); - onBytesReceived(data.size()); + writeBytestream->write(createByteArray(vecptr(*data), data->size())); + onBytesReceived(data->size()); } } diff --git a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h index 894e977..ea45955 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h +++ b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.h @@ -66,7 +66,7 @@ private: void authenticate(); void handleConnectFinished(bool error); - void handleDataRead(const SafeByteArray&); + void handleDataRead(boost::shared_ptr<SafeByteArray>); void handleDisconnected(const boost::optional<Connection::Error>&); void handleWeFailedTimeout(); diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp index fa7e054..def9e33 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp @@ -65,13 +65,13 @@ HostAddressPort SOCKS5BytestreamServerSession::getAddressPort() const { return connection->getLocalAddress(); } -void SOCKS5BytestreamServerSession::handleDataRead(const SafeByteArray& data) { +void SOCKS5BytestreamServerSession::handleDataRead(boost::shared_ptr<SafeByteArray> data) { if (state != ReadingData) { - append(unprocessedData, data); + append(unprocessedData, *data); process(); } else { - writeBytestream->write(createByteArray(vecptr(data), data.size())); - onBytesReceived(data.size()); + writeBytestream->write(createByteArray(vecptr(*data), data->size())); + onBytesReceived(data->size()); } } diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.h b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.h index 3e1018f..4557a36 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.h +++ b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.h @@ -52,7 +52,7 @@ namespace Swift { private: void finish(bool error); void process(); - void handleDataRead(const SafeByteArray&); + void handleDataRead(boost::shared_ptr<SafeByteArray>); void handleDisconnected(const boost::optional<Connection::Error>&); void sendData(); diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp index 75b9faf..527e0ca 100644 --- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp +++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp @@ -164,7 +164,7 @@ public: clientSession->startReceiving(output); ByteArray transferData = generateRandomByteArray(1024); - connection->onDataRead(createSafeByteArray(transferData.data(), transferData.size())); + connection->onDataRead(createSafeByteArrayRef(transferData.data(), transferData.size())); CPPUNIT_ASSERT_EQUAL(transferData, output->getData()); } @@ -212,35 +212,35 @@ private: // Server responses void serverRespondHelloOK() { - connection->onDataRead(createSafeByteArray("\x05\00", 2)); + connection->onDataRead(createSafeByteArrayRef("\x05\00", 2)); } void serverRespondHelloAuthFail() { - connection->onDataRead(createSafeByteArray("\x05\xFF", 2)); + connection->onDataRead(createSafeByteArrayRef("\x05\xFF", 2)); } void serverRespondRequestOK() { - SafeByteArray dataToSend = createSafeByteArray("\x05\x00\x00\x03", 4); - append(dataToSend, createSafeByteArray(destination.size())); - append(dataToSend, createSafeByteArray(destination)); - append(dataToSend, createSafeByteArray("\x00", 1)); + boost::shared_ptr<SafeByteArray> dataToSend = createSafeByteArrayRef("\x05\x00\x00\x03", 4); + append(*dataToSend, createSafeByteArray(destination.size())); + append(*dataToSend, createSafeByteArray(destination)); + append(*dataToSend, createSafeByteArray("\x00", 1)); connection->onDataRead(dataToSend); } void serverRespondRequestFail() { - SafeByteArray correctData = createSafeByteArray("\x05\x00\x00\x03", 4); - append(correctData, createSafeByteArray(destination.size())); - append(correctData, createSafeByteArray(destination)); - append(correctData, createSafeByteArray("\x00", 1)); + boost::shared_ptr<SafeByteArray> correctData = createSafeByteArrayRef("\x05\x00\x00\x03", 4); + append(*correctData, createSafeByteArray(destination.size())); + append(*correctData, createSafeByteArray(destination)); + append(*correctData, createSafeByteArray("\x00", 1)); - SafeByteArray dataToSend; + boost::shared_ptr<SafeByteArray> dataToSend; //ByteArray failingData = Hexify::unhexify("8417947d1d305c72c11520ea7d2c6e787396705e72c312c6ccc3f66613d7cae1b91b7ab48e8b59a17d559c15fb51"); //append(dataToSend, failingData); //SWIFT_LOG(debug) << "hexed: " << Hexify::hexify(failingData) << std::endl; do { - ByteArray rndArray = generateRandomByteArray(correctData.size()); - dataToSend = createSafeByteArray(rndArray.data(), rndArray.size()); - } while (dataToSend == correctData); + ByteArray rndArray = generateRandomByteArray(correctData->size()); + dataToSend = createSafeByteArrayRef(rndArray.data(), rndArray.size()); + } while (*dataToSend == *correctData); connection->onDataRead(dataToSend); } |