summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdwin Mons <edwin.mons@isode.com>2019-11-19 13:36:05 (GMT)
committerEdwin Mons <edwin.mons@isode.com>2019-11-19 13:58:45 (GMT)
commit261ba8d8595ed8cb90f9c4feb1d6ef642942bcba (patch)
treec7e60d473509db8c4dbff5aa83fbde963d8dd75e /Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp
parent697ae6ae84512a744958b24118197ec7bfdbc1f0 (diff)
downloadswift-261ba8d8595ed8cb90f9c4feb1d6ef642942bcba.zip
swift-261ba8d8595ed8cb90f9c4feb1d6ef642942bcba.tar.bz2
Remove std::endl from SWIFT_LOG calls
The std::endl is now added by ~Log, but only for output to stderr or a log file. Calls to the Android logging system or manually set callbacks will not include the newline in the logging output. JIRA: SWIFT-430 Test-Information: Unit tests pass on Debian 9 Checked that running Swift with logging to stderr still had a newline. Change-Id: I096fdba78a3b8f87db2097951c28c528592183e8
Diffstat (limited to 'Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp')
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp
index 5ddd32b..a3f0dab 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp
+++ b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp
@@ -2,13 +2,13 @@
* Copyright (c) 2011 Tobias Markmann
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
/*
- * Copyright (c) 2013-2016 Isode Limited.
+ * Copyright (c) 2013-2019 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/FileTransfer/SOCKS5BytestreamClientSession.h>
@@ -46,34 +46,34 @@ SOCKS5BytestreamClientSession::~SOCKS5BytestreamClientSession() {
boost::bind(&SOCKS5BytestreamClientSession::handleWeFailedTimeout, this));
weFailedTimeout->stop();
}
void SOCKS5BytestreamClientSession::start() {
assert(state == Initial);
- SWIFT_LOG(debug) << "Trying to connect via TCP to " << addressPort.toString() << "." << std::endl;
+ SWIFT_LOG(debug) << "Trying to connect via TCP to " << addressPort.toString() << ".";
weFailedTimeout->start();
connectFinishedConnection = connection->onConnectFinished.connect(
boost::bind(&SOCKS5BytestreamClientSession::handleConnectFinished, this, _1));
connection->connect(addressPort);
}
void SOCKS5BytestreamClientSession::stop() {
- SWIFT_LOG(debug) << std::endl;
+ SWIFT_LOG(debug);
if (state < Ready) {
weFailedTimeout->stop();
}
if (state == Finished) {
return;
}
closeConnection();
readBytestream.reset();
state = Finished;
}
void SOCKS5BytestreamClientSession::process() {
- SWIFT_LOG(debug) << "unprocessedData.size(): " << unprocessedData.size() << std::endl;
+ SWIFT_LOG(debug) << "unprocessedData.size(): " << unprocessedData.size();
ByteArray bndAddress;
switch(state) {
case Initial:
hello();
break;
case Hello:
@@ -121,25 +121,25 @@ void SOCKS5BytestreamClientSession::process() {
// we expect a 0 as port
// disconnect and fail
finish(true);
}
unprocessedData.clear();
state = Ready;
- SWIFT_LOG(debug) << "session ready" << std::endl;
+ SWIFT_LOG(debug) << "session ready";
// issue ready signal so the bytestream can be used for reading or writing
weFailedTimeout->stop();
onSessionReady(false);
break;
case Ready:
- SWIFT_LOG(debug) << "Received further data in Ready state." << std::endl;
+ SWIFT_LOG(debug) << "Received further data in Ready state.";
break;
case Reading:
case Writing:
case Finished:
- SWIFT_LOG(debug) << "Unexpected receive of data. Current state: " << state << std::endl;
- SWIFT_LOG(debug) << "Data: " << Hexify::hexify(unprocessedData) << std::endl;
+ SWIFT_LOG(debug) << "Unexpected receive of data. Current state: " << state;
+ SWIFT_LOG(debug) << "Data: " << Hexify::hexify(unprocessedData);
unprocessedData.clear();
//assert(false);
}
}
void SOCKS5BytestreamClientSession::hello() {
@@ -147,13 +147,13 @@ void SOCKS5BytestreamClientSession::hello() {
const SafeByteArray hello = createSafeByteArray("\x05\x01\x00", 3);
connection->write(hello);
state = Hello;
}
void SOCKS5BytestreamClientSession::authenticate() {
- SWIFT_LOG(debug) << std::endl;
+ SWIFT_LOG(debug);
SafeByteArray header = createSafeByteArray("\x05\x01\x00\x03", 4);
SafeByteArray message = header;
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,25 +165,25 @@ void SOCKS5BytestreamClientSession::startReceiving(std::shared_ptr<WriteBytestre
if (state == Ready) {
state = Reading;
writeBytestream = writeStream;
writeBytestream->write(unprocessedData);
unprocessedData.clear();
} else {
- SWIFT_LOG(debug) << "Session isn't ready for transfer yet!" << std::endl;
+ SWIFT_LOG(debug) << "Session isn't ready for transfer yet!";
}
}
void SOCKS5BytestreamClientSession::startSending(std::shared_ptr<ReadBytestream> readStream) {
if (state == Ready) {
state = Writing;
readBytestream = readStream;
dataWrittenConnection = connection->onDataWritten.connect(
boost::bind(&SOCKS5BytestreamClientSession::sendData, this));
sendData();
} else {
- SWIFT_LOG(debug) << "Session isn't ready for transfer yet!" << std::endl;
+ SWIFT_LOG(debug) << "Session isn't ready for transfer yet!";
}
}
HostAddressPort SOCKS5BytestreamClientSession::getAddressPort() const {
return addressPort;
}
@@ -202,13 +202,13 @@ void SOCKS5BytestreamClientSession::sendData() {
else {
finish(false);
}
}
void SOCKS5BytestreamClientSession::finish(bool error) {
- SWIFT_LOG(debug) << std::endl;
+ SWIFT_LOG(debug);
if (state < Ready) {
weFailedTimeout->stop();
}
closeConnection();
readBytestream.reset();
if (state == Initial || state == Hello || state == Authenticating) {
@@ -224,47 +224,47 @@ void SOCKS5BytestreamClientSession::finish(bool error) {
}
}
void SOCKS5BytestreamClientSession::handleConnectFinished(bool error) {
connectFinishedConnection.disconnect();
if (error) {
- SWIFT_LOG(debug) << "Failed to connect via TCP to " << addressPort.toString() << "." << std::endl;
+ SWIFT_LOG(debug) << "Failed to connect via TCP to " << addressPort.toString() << ".";
finish(true);
} else {
- SWIFT_LOG(debug) << "Successfully connected via TCP" << addressPort.toString() << "." << std::endl;
+ SWIFT_LOG(debug) << "Successfully connected via TCP" << addressPort.toString() << ".";
disconnectedConnection = connection->onDisconnected.connect(
boost::bind(&SOCKS5BytestreamClientSession::handleDisconnected, this, _1));
dataReadConnection = connection->onDataRead.connect(
boost::bind(&SOCKS5BytestreamClientSession::handleDataRead, this, _1));
weFailedTimeout->stop();
weFailedTimeout->start();
process();
}
}
void SOCKS5BytestreamClientSession::handleDataRead(std::shared_ptr<SafeByteArray> data) {
- SWIFT_LOG(debug) << "state: " << state << " data.size() = " << data->size() << std::endl;
+ SWIFT_LOG(debug) << "state: " << state << " data.size() = " << data->size();
if (state != Reading) {
append(unprocessedData, *data);
process();
}
else {
writeBytestream->write(createByteArray(vecptr(*data), data->size()));
//onBytesReceived(data->size());
}
}
void SOCKS5BytestreamClientSession::handleDisconnected(const boost::optional<Connection::Error>& error) {
- SWIFT_LOG(debug) << (error ? (error == Connection::ReadError ? "Read Error" : "Write Error") : "No Error") << std::endl;
+ SWIFT_LOG(debug) << (error ? (error == Connection::ReadError ? "Read Error" : "Write Error") : "No Error");
if (error) {
finish(true);
}
}
void SOCKS5BytestreamClientSession::handleWeFailedTimeout() {
- SWIFT_LOG(debug) << "Failed due to timeout!" << std::endl;
+ SWIFT_LOG(debug) << "Failed due to timeout!";
finish(true);
}
void SOCKS5BytestreamClientSession::closeConnection() {
connectFinishedConnection.disconnect();
dataWrittenConnection.disconnect();