diff options
| author | Edwin Mons <edwin.mons@isode.com> | 2019-11-19 13:36:05 (GMT) |
|---|---|---|
| committer | Edwin Mons <edwin.mons@isode.com> | 2019-11-19 13:58:45 (GMT) |
| commit | 261ba8d8595ed8cb90f9c4feb1d6ef642942bcba (patch) | |
| tree | c7e60d473509db8c4dbff5aa83fbde963d8dd75e | |
| parent | 697ae6ae84512a744958b24118197ec7bfdbc1f0 (diff) | |
| download | swift-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
105 files changed, 575 insertions, 572 deletions
diff --git a/QA/Checker/checker.cpp b/QA/Checker/checker.cpp index f4ec6f1..4d6a90e 100644 --- a/QA/Checker/checker.cpp +++ b/QA/Checker/checker.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <cstdlib> #include <fstream> @@ -138,13 +138,13 @@ int main(int argc, char* argv[]) { delete listeners.Release(listeners.default_result_printer()); listeners.Append(new testing::CppUnitTestResultPrinter); } googleTestWasSuccessful = RUN_ALL_TESTS() == 0 ? true : false; } catch (const ::testing::internal::GoogleTestFailureException& e) { googleTestWasSuccessful = false; - SWIFT_LOG(error) << "GoogleTestFailureException was thrown: " << e.what() << std::endl; + SWIFT_LOG(error) << "GoogleTestFailureException was thrown: " << e.what(); } auto cppUnitWasSuccessful = result.wasSuccessful() ? true : false; return (googleTestWasSuccessful && cppUnitWasSuccessful) ? 0 : 1; } diff --git a/Slimber/Server.cpp b/Slimber/Server.cpp index bfa34f5..7bb2ed9 100644 --- a/Slimber/Server.cpp +++ b/Slimber/Server.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Slimber/Server.h> @@ -303,13 +303,13 @@ void Server::handleLinkLocalElementReceived(std::shared_ptr<ToplevelElement> ele serverFromClientSession->sendElement(stanza); } } void Server::handleConnectFinished(std::shared_ptr<LinkLocalConnector> connector, bool error) { if (error) { - SWIFT_LOG(warning) << "Error connecting" << std::endl; + SWIFT_LOG(warning) << "Error connecting"; // TODO: Send back queued stanzas } else { std::shared_ptr<OutgoingLinkLocalSession> outgoingSession( new OutgoingLinkLocalSession( selfJID, connector->getService().getJID(), connector->getConnection(), diff --git a/Sluift/ElementConvertors/DefaultElementConvertor.cpp b/Sluift/ElementConvertors/DefaultElementConvertor.cpp index 75e6706..d3d60ff 100644 --- a/Sluift/ElementConvertors/DefaultElementConvertor.cpp +++ b/Sluift/ElementConvertors/DefaultElementConvertor.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Sluift/ElementConvertors/DefaultElementConvertor.h> @@ -17,13 +17,13 @@ DefaultElementConvertor::DefaultElementConvertor() { } DefaultElementConvertor::~DefaultElementConvertor() { } std::shared_ptr<Element> DefaultElementConvertor::convertFromLua(lua_State*, int, const std::string& type) { - SWIFT_LOG(warning) << "Unable to convert type '" << type << "'" << std::endl; + SWIFT_LOG(warning) << "Unable to convert type '" << type << "'"; return std::shared_ptr<Element>(); } boost::optional<std::string> DefaultElementConvertor::convertToLua(lua_State*, std::shared_ptr<Element>) { // Should have been handled by the raw XML convertor assert(false); diff --git a/SwifTools/Application/ApplicationPathProvider.cpp b/SwifTools/Application/ApplicationPathProvider.cpp index 8b952bb..77457ef 100644 --- a/SwifTools/Application/ApplicationPathProvider.cpp +++ b/SwifTools/Application/ApplicationPathProvider.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <SwifTools/Application/ApplicationPathProvider.h> @@ -22,13 +22,13 @@ ApplicationPathProvider::~ApplicationPathProvider() { boost::filesystem::path ApplicationPathProvider::getProfileDir(const std::string& profile) const { boost::filesystem::path result(getHomeDir() / profile); try { boost::filesystem::create_directory(result); } catch (const boost::filesystem::filesystem_error& e) { - SWIFT_LOG(error) << e.what() << std::endl; + SWIFT_LOG(error) << e.what(); } return result; } boost::filesystem::path ApplicationPathProvider::getResourcePath(const std::string& resource) const { std::vector<boost::filesystem::path> resourcePaths = getResourceDirs(); diff --git a/SwifTools/Application/MacOSXApplicationPathProvider.cpp b/SwifTools/Application/MacOSXApplicationPathProvider.cpp index 684d8b2..d7b99b9 100644 --- a/SwifTools/Application/MacOSXApplicationPathProvider.cpp +++ b/SwifTools/Application/MacOSXApplicationPathProvider.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <SwifTools/Application/MacOSXApplicationPathProvider.h> @@ -20,13 +20,13 @@ MacOSXApplicationPathProvider::MacOSXApplicationPathProvider(const std::string& boost::filesystem::path MacOSXApplicationPathProvider::getDataDir() const { boost::filesystem::path result(getHomeDir() / "Library/Application Support" / getApplicationName()); try { boost::filesystem::create_directory(result); } catch (const boost::filesystem::filesystem_error& e) { - SWIFT_LOG(error) << e.what() << std::endl; + SWIFT_LOG(error) << e.what(); } return result; } boost::filesystem::path MacOSXApplicationPathProvider::getHomeDir() const { return boost::filesystem::path(getenv("HOME")); diff --git a/SwifTools/Application/UnixApplicationPathProvider.cpp b/SwifTools/Application/UnixApplicationPathProvider.cpp index e455d23..a345766 100644 --- a/SwifTools/Application/UnixApplicationPathProvider.cpp +++ b/SwifTools/Application/UnixApplicationPathProvider.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <SwifTools/Application/UnixApplicationPathProvider.h> @@ -51,12 +51,12 @@ boost::filesystem::path UnixApplicationPathProvider::getDataDir() const { : boost::filesystem::path(dataDir)) / boost::to_lower_copy(getApplicationName()); try { boost::filesystem::create_directories(dataPath); } catch (const boost::filesystem::filesystem_error& e) { - SWIFT_LOG(error) << "file system error: " << e.what() << std::endl; + SWIFT_LOG(error) << "file system error: " << e.what(); } return dataPath; } } diff --git a/SwifTools/AutoUpdater/SparkleAutoUpdater.mm b/SwifTools/AutoUpdater/SparkleAutoUpdater.mm index b4a4c05..274ab3c 100644 --- a/SwifTools/AutoUpdater/SparkleAutoUpdater.mm +++ b/SwifTools/AutoUpdater/SparkleAutoUpdater.mm @@ -1,8 +1,8 @@ /* - * Copyright (c) 2016-2017 Isode Limited. + * Copyright (c) 2016-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <SwifTools/AutoUpdater/SparkleAutoUpdater.h> @@ -43,13 +43,13 @@ SparkleAutoUpdater::SparkleAutoUpdater(const std::string& appcastFeed) : d(new P auto canDoSilentUpdates = applicationInstallationLocationWritable(); [d->updater setAutomaticallyDownloadsUpdates: canDoSilentUpdates]; SWIFT_LOG(debug) << (canDoSilentUpdates ? "The current running user has enough permissions to do a silent update." : - "The current running user has insufficient permissions to do a silent update.") << std::endl; + "The current running user has insufficient permissions to do a silent update."); setAppcastFeed(appcastFeed); } SparkleAutoUpdater::~SparkleAutoUpdater() { [d->updater release]; diff --git a/SwifTools/AutoUpdater/SparkleAutoUpdaterDelegate.mm b/SwifTools/AutoUpdater/SparkleAutoUpdaterDelegate.mm index be58355..b9294d9 100644 --- a/SwifTools/AutoUpdater/SparkleAutoUpdaterDelegate.mm +++ b/SwifTools/AutoUpdater/SparkleAutoUpdaterDelegate.mm @@ -1,8 +1,8 @@ /* - * Copyright (c) 2016-2017 Isode Limited. + * Copyright (c) 2016-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #import <SwifTools/AutoUpdater/SparkleAutoUpdaterDelegate.h> @@ -46,13 +46,13 @@ using namespace Swift; onNewUpdateState(AutoUpdater::State::DownloadingUpdate); } - (void)updater:(SUUpdater *)updater failedToDownloadUpdate:(SUAppcastItem *)item error:(NSError *)error { (void)updater; (void)item; - SWIFT_LOG(error) << ns2StdString([error localizedDescription]) << std::endl; + SWIFT_LOG(error) << ns2StdString([error localizedDescription]); onNewUpdateState(AutoUpdater::State::ErrorCheckingForUpdate); } - (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update { (void)updater; (void)update; @@ -68,12 +68,12 @@ using namespace Swift; - (void)updater:(SUUpdater *)updater didAbortWithError:(NSError *)error { (void)updater; if ([error code] == SUNoUpdateError) { onNewUpdateState(AutoUpdater::State::NoUpdateAvailable); } else { - SWIFT_LOG(error) << ns2StdString([error localizedDescription]) << std::endl; + SWIFT_LOG(error) << ns2StdString([error localizedDescription]); onNewUpdateState(AutoUpdater::State::ErrorCheckingForUpdate); } } @end diff --git a/SwifTools/CrashReporter.cpp b/SwifTools/CrashReporter.cpp index bf637c8..b02e73b 100644 --- a/SwifTools/CrashReporter.cpp +++ b/SwifTools/CrashReporter.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2012-2016 Isode Limited. + * Copyright (c) 2012-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Base/Log.h> #include <Swiften/Base/Platform.h> @@ -43,13 +43,13 @@ CrashReporter::CrashReporter(const boost::filesystem::path& path, const std::str // Create the path that will contain the crash dumps if (!boost::filesystem::exists(path)) { try { boost::filesystem::create_directories(path); } catch (const boost::filesystem::filesystem_error& e) { - SWIFT_LOG(error) << "ERROR: " << e.what() << std::endl; + SWIFT_LOG(error) << "ERROR: " << e.what(); } } p = std::make_shared<Private>(); #if defined(SWIFTEN_PLATFORM_WINDOWS) // FIXME: Need UTF8 conversion from string to wstring diff --git a/SwifTools/HunspellChecker.cpp b/SwifTools/HunspellChecker.cpp index 1de369b..019a4dc 100644 --- a/SwifTools/HunspellChecker.cpp +++ b/SwifTools/HunspellChecker.cpp @@ -81,18 +81,18 @@ bool HunspellChecker::isAutomaticallyDetectingLanguage() { return false; } void HunspellChecker::setActiveLanguage(const std::string& language) { auto dictionaries = detectedDictionaries(); if (dictionaries.find(language) != dictionaries.end()) { - SWIFT_LOG(debug) << "Initialized Hunspell with dic,aff files " << dictionaries[language].dicPath << " , " << dictionaries[language].affPath << std::endl; + SWIFT_LOG(debug) << "Initialized Hunspell with dic,aff files " << dictionaries[language].dicPath << " , " << dictionaries[language].affPath; speller_ = std::unique_ptr<Hunspell>(new Hunspell(dictionaries[language].affPath.c_str(), dictionaries[language].dicPath.c_str())); activeLangauge_ = language; } else { - SWIFT_LOG(warning) << "Unsupported language '" << language << "'" << std::endl; + SWIFT_LOG(warning) << "Unsupported language '" << language << "'"; } } std::string HunspellChecker::activeLanguage() const { return activeLangauge_.get_value_or(""); } diff --git a/SwifTools/Notifier/NotificationCenterNotifier.mm b/SwifTools/Notifier/NotificationCenterNotifier.mm index 1538186..e6fdfb6 100644 --- a/SwifTools/Notifier/NotificationCenterNotifier.mm +++ b/SwifTools/Notifier/NotificationCenterNotifier.mm @@ -1,8 +1,8 @@ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <SwifTools/Notifier/NotificationCenterNotifier.h> @@ -85,11 +85,11 @@ void NotificationCenterNotifier::handleUserNotificationActivated(const std::stri if (p->callbacksForNotifications.find(identifier) != p->callbacksForNotifications.end()) { if (!(*p->callbacksForNotifications[identifier]->callback).empty()) { (*p->callbacksForNotifications[identifier]->callback)(); } } else { - SWIFT_LOG(warning) << "Missing callback entry for activated notification. The activate notification may come from another instance." << std::endl; + SWIFT_LOG(warning) << "Missing callback entry for activated notification. The activate notification may come from another instance."; } } } diff --git a/Swift/Controllers/AccountController.cpp b/Swift/Controllers/AccountController.cpp index b877ce9..a257cc4 100644 --- a/Swift/Controllers/AccountController.cpp +++ b/Swift/Controllers/AccountController.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/Controllers/AccountController.h> @@ -778,16 +778,16 @@ void AccountController::handleServerDiscoInfoResponse(std::shared_ptr<DiscoInfo> } void AccountController::enableMessageCarbons() { auto enableCarbonsRequest = EnableCarbonsRequest::create(client_->getIQRouter()); enableCarbonsRequestHandlerConnection_ = enableCarbonsRequest->onResponse.connect([&](Payload::ref /*payload*/, ErrorPayload::ref error) { if (error) { - SWIFT_LOG(warning) << "Failed to enable carbons." << std::endl; + SWIFT_LOG(warning) << "Failed to enable carbons."; } else { - SWIFT_LOG(debug) << "Successfully enabled carbons." << std::endl; + SWIFT_LOG(debug) << "Successfully enabled carbons."; } enableCarbonsRequestHandlerConnection_.disconnect(); }); enableCarbonsRequest->send(); } diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index 5f441f8..debd83f 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/Controllers/Chat/ChatController.h> @@ -187,13 +187,13 @@ void ChatController::preHandleIncomingMessage(std::shared_ptr<MessageEvent> mess chatStateTracker_->handleMessageReceived(message); chatStateNotifier_->receivedMessageFromContact(!!message->getPayload<ChatState>()); // handle XEP-0184 Message Receipts // incomming receipts if (std::shared_ptr<DeliveryReceipt> receipt = message->getPayload<DeliveryReceipt>()) { - SWIFT_LOG(debug) << "received receipt for id: " << receipt->getReceivedID() << std::endl; + SWIFT_LOG(debug) << "received receipt for id: " << receipt->getReceivedID(); if (requestedReceipts_.find(receipt->getReceivedID()) != requestedReceipts_.end()) { chatWindow_->setMessageReceiptState(requestedReceipts_[receipt->getReceivedID()], ChatWindow::ReceiptReceived); requestedReceipts_.erase(receipt->getReceivedID()); } // incomming errors in response to send out receipts } else if (message->getPayload<DeliveryReceiptRequest>() && (message->getType() == Message::Error)) { @@ -404,40 +404,40 @@ void ChatController::handleWhiteboardSessionRequest(bool senderIsSelf) { void ChatController::handleWhiteboardStateChange(const ChatWindow::WhiteboardSessionState state) { chatWindow_->setWhiteboardSessionStatus(lastWbID_, state); } void ChatController::handleFileTransferCancel(std::string id) { - SWIFT_LOG(debug) << "handleFileTransferCancel(" << id << ")" << std::endl; + SWIFT_LOG(debug) << "handleFileTransferCancel(" << id << ")"; if (ftControllers.find(id) != ftControllers.end()) { ftControllers[id]->cancel(); } else { std::cerr << "unknown file transfer UI id" << std::endl; } } void ChatController::handleFileTransferStart(std::string id, std::string description) { - SWIFT_LOG(debug) << "handleFileTransferStart(" << id << ", " << description << ")" << std::endl; + SWIFT_LOG(debug) << "handleFileTransferStart(" << id << ", " << description << ")"; if (ftControllers.find(id) != ftControllers.end()) { ftControllers[id]->start(description); } else { std::cerr << "unknown file transfer UI id" << std::endl; } } void ChatController::handleFileTransferAccept(std::string id, std::string filename) { - SWIFT_LOG(debug) << "handleFileTransferAccept(" << id << ", " << filename << ")" << std::endl; + SWIFT_LOG(debug) << "handleFileTransferAccept(" << id << ", " << filename << ")"; if (ftControllers.find(id) != ftControllers.end()) { ftControllers[id]->accept(filename); } else { std::cerr << "unknown file transfer UI id" << std::endl; } } void ChatController::handleSendFileRequest(std::string filename) { - SWIFT_LOG(debug) << "ChatController::handleSendFileRequest(" << filename << ")" << std::endl; + SWIFT_LOG(debug) << "ChatController::handleSendFileRequest(" << filename << ")"; eventStream_->send(std::make_shared<SendFileUIEvent>(getToJID(), filename)); } void ChatController::handleWhiteboardSessionAccept() { eventStream_->send(std::make_shared<AcceptWhiteboardSessionUIEvent>(toJID_)); } diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index 6530a7e..193af7f 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/Controllers/Chat/ChatsManager.h> @@ -172,13 +172,13 @@ ChatsManager::~ChatsManager() { roster_->onJIDAdded.disconnect(boost::bind(&ChatsManager::handleJIDAddedToRoster, this, _1)); roster_->onJIDRemoved.disconnect(boost::bind(&ChatsManager::handleJIDRemovedFromRoster, this, _1)); roster_->onJIDUpdated.disconnect(boost::bind(&ChatsManager::handleJIDUpdatedInRoster, this, _1)); roster_->onRosterCleared.disconnect(boost::bind(&ChatsManager::handleRosterCleared, this)); ftOverview_->onNewFileTransferController.disconnect(boost::bind(&ChatsManager::handleNewFileTransferController, this, _1)); delete joinMUCWindow_; - SWIFT_LOG(debug) << "Destroying ChatsManager, containing " << chatControllers_.size() << " chats and " << mucControllers_.size() << " MUCs" << std::endl; + SWIFT_LOG(debug) << "Destroying ChatsManager, containing " << chatControllers_.size() << " chats and " << mucControllers_.size() << " MUCs"; for (JIDChatControllerPair controllerPair : chatControllers_) { delete controllerPair.second; } for (JIDMUCControllerPair controllerPair : mucControllers_) { delete controllerPair.second; } @@ -308,13 +308,13 @@ void ChatsManager::loadRecents() { std::vector<ChatListWindow::Chat> recentChats; std::stringstream deserializeStream(std::string(reinterpret_cast<const char*>(vecptr(debase64)), debase64.size())); try { boost::archive::text_iarchive ia(deserializeStream); ia >> recentChats; } catch (const boost::archive::archive_exception& e) { - SWIFT_LOG(debug) << "Failed to load recents: " << e.what() << std::endl; + SWIFT_LOG(debug) << "Failed to load recents: " << e.what(); return; } recentChats.erase(std::remove(recentChats.begin(), recentChats.end(), ChatListWindow::Chat()), recentChats.end()); for (auto chat : recentChats) { chat.statusType = StatusShow::None; chat = updateChatStatusAndAvatarHelper(chat); @@ -933,13 +933,13 @@ void ChatsManager::handleSearchMUCRequest() { } void ChatsManager::handleUserNicknameChanged(MUCController* mucController, const std::string& oldNickname, const std::string& newNickname) { JID oldMUCChatJID = mucController->getToJID().withResource(oldNickname); JID newMUCChatJID = mucController->getToJID().withResource(newNickname); - SWIFT_LOG(debug) << "nickname change in " << mucController->getToJID().toString() << " from " << oldNickname << " to " << newNickname << std::endl; + SWIFT_LOG(debug) << "nickname change in " << mucController->getToJID().toString() << " from " << oldNickname << " to " << newNickname; // get current chat controller ChatController *chatController = getChatControllerIfExists(oldMUCChatJID); if (chatController) { // adjust chat controller chatController->setToJID(newMUCChatJID); @@ -980,13 +980,13 @@ void ChatsManager::handleIncomingMessage(std::shared_ptr<Message> incomingMessag ChatController* controller = getChatControllerOrCreate(toJID); if (controller) { controller->handleIncomingOwnMessage(forwardedMessage); } else { - SWIFT_LOG(error) << "Carbons message ignored." << std::endl; + SWIFT_LOG(error) << "Carbons message ignored."; } return; } } JID fromJID = message->getFrom(); @@ -1138,13 +1138,13 @@ void ChatsManager::handleLocalServiceFound(const JID& service, std::shared_ptr<D if ((identity.getCategory() == "directory" && identity.getType() == "chatroom") || (identity.getCategory() == "conference" && identity.getType() == "text")) { localMUCServiceJID_ = service; localMUCServiceFinderWalker_->endWalk(); - SWIFT_LOG(debug) << "Use following MUC service for impromptu chats: " << localMUCServiceJID_ << std::endl; + SWIFT_LOG(debug) << "Use following MUC service for impromptu chats: " << localMUCServiceJID_; break; } } } void ChatsManager::handleLocalServiceWalkFinished() { diff --git a/Swift/Controllers/Chat/MUCSearchController.cpp b/Swift/Controllers/Chat/MUCSearchController.cpp index 5db917a..0b54d25 100644 --- a/Swift/Controllers/Chat/MUCSearchController.cpp +++ b/Swift/Controllers/Chat/MUCSearchController.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/Controllers/Chat/MUCSearchController.h> @@ -89,13 +89,13 @@ void MUCSearchController::handleSearchService(const JID& jid) { walker_->endWalk(); walker_->onServiceFound.disconnect(boost::bind(&MUCSearchController::handleDiscoServiceFound, this, _1, _2)); walker_->onWalkComplete.disconnect(boost::bind(&MUCSearchController::handleDiscoWalkFinished, this)); delete walker_; } - SWIFT_LOG(debug) << "Starting walking MUC services" << std::endl; + SWIFT_LOG(debug) << "Starting walking MUC services"; itemsInProgress_ = 0; walker_ = new DiscoServiceWalker(jid, iqRouter_); walker_->onServiceFound.connect(boost::bind(&MUCSearchController::handleDiscoServiceFound, this, _1, _2)); walker_->onWalkComplete.connect(boost::bind(&MUCSearchController::handleDiscoWalkFinished, this)); walker_->beginWalk(); } @@ -110,44 +110,44 @@ void MUCSearchController::handleDiscoServiceFound(const JID& jid, std::shared_pt && identity.getType() == "text")) { isMUC = true; name = identity.getName(); } } if (isMUC) { - SWIFT_LOG(debug) << "MUC Service found: " << jid << std::endl; + SWIFT_LOG(debug) << "MUC Service found: " << jid; services_.erase(std::remove(services_.begin(), services_.end(), jid), services_.end()); services_.push_back(jid); serviceDetails_[jid].setName(name); serviceDetails_[jid].setJID(jid); serviceDetails_[jid].setComplete(false); itemsInProgress_++; - SWIFT_LOG(debug) << "Requesting items of " << jid << " (" << itemsInProgress_ << " item requests in progress)" << std::endl; + SWIFT_LOG(debug) << "Requesting items of " << jid << " (" << itemsInProgress_ << " item requests in progress)"; GetDiscoItemsRequest::ref discoItemsRequest = GetDiscoItemsRequest::create(jid, iqRouter_); discoItemsRequest->onResponse.connect(boost::bind(&MUCSearchController::handleRoomsItemsResponse, this, _1, _2, jid)); discoItemsRequest->send(); } else { removeService(jid); } refreshView(); } void MUCSearchController::handleDiscoWalkFinished() { - SWIFT_LOG(debug) << "MUC Walk finished" << std::endl; + SWIFT_LOG(debug) << "MUC Walk finished"; updateInProgressness(); } void MUCSearchController::removeService(const JID& jid) { serviceDetails_.erase(jid); services_.erase(std::remove(services_.begin(), services_.end(), jid), services_.end()); refreshView(); } void MUCSearchController::handleRoomsItemsResponse(std::shared_ptr<DiscoItems> items, ErrorPayload::ref error, const JID& jid) { itemsInProgress_--; - SWIFT_LOG(debug) << "Items received for " << jid << " (" << itemsInProgress_ << " item requests in progress)" << std::endl; + SWIFT_LOG(debug) << "Items received for " << jid << " (" << itemsInProgress_ << " item requests in progress)"; updateInProgressness(); if (error) { handleDiscoError(jid, error); return; } serviceDetails_[jid].clearRooms(); diff --git a/Swift/Controllers/FileTransfer/FileTransferController.cpp b/Swift/Controllers/FileTransfer/FileTransferController.cpp index 27e9dbf..5b86a7b 100644 --- a/Swift/Controllers/FileTransfer/FileTransferController.cpp +++ b/Swift/Controllers/FileTransfer/FileTransferController.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) 2015-2017 Isode Limited. + * Copyright (c) 2015-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/Controllers/FileTransfer/FileTransferController.h> @@ -79,13 +79,13 @@ boost::uintmax_t FileTransferController::getSize() const { } else { return 0; } } void FileTransferController::start(std::string& description) { - SWIFT_LOG(debug) << "FileTransferController::start" << std::endl; + SWIFT_LOG(debug) << "FileTransferController::start"; fileReadStream = std::make_shared<FileReadBytestream>(boost::filesystem::path(filename)); OutgoingFileTransfer::ref outgoingTransfer = ftManager->createOutgoingFileTransfer(otherParty, boost::filesystem::path(filename), description, fileReadStream); if (outgoingTransfer) { ftProgressInfo = new FileTransferProgressInfo(outgoingTransfer->getFileSizeInBytes()); ftProgressInfo->onProgressPercentage.connect(boost::bind(&FileTransferController::handleProgressPercentageChange, this, _1)); outgoingTransfer->onStateChanged.connect(boost::bind(&FileTransferController::handleFileTransferStateChange, this, _1)); @@ -95,13 +95,13 @@ void FileTransferController::start(std::string& description) { } else { std::cerr << "File transfer not supported!" << std::endl; } } void FileTransferController::accept(std::string& file) { - SWIFT_LOG(debug) << "FileTransferController::accept" << std::endl; + SWIFT_LOG(debug) << "FileTransferController::accept"; IncomingFileTransfer::ref incomingTransfer = std::dynamic_pointer_cast<IncomingFileTransfer>(transfer); if (incomingTransfer) { fileWriteStream = std::make_shared<FileWriteBytestream>(boost::filesystem::path(file)); ftProgressInfo = new FileTransferProgressInfo(transfer->getFileSizeInBytes()); ftProgressInfo->onProgressPercentage.connect(boost::bind(&FileTransferController::handleProgressPercentageChange, this, _1)); diff --git a/Swift/Controllers/Highlighting/HighlightManager.cpp b/Swift/Controllers/Highlighting/HighlightManager.cpp index 2ca77e7..f09d94c 100644 --- a/Swift/Controllers/Highlighting/HighlightManager.cpp +++ b/Swift/Controllers/Highlighting/HighlightManager.cpp @@ -2,13 +2,13 @@ * Copyright (c) 2012 Maciej Niedzielski * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ /* - * Copyright (c) 2014-2017 Isode Limited. + * Copyright (c) 2014-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/Controllers/Highlighting/HighlightManager.h> @@ -82,13 +82,13 @@ HighlightConfiguration HighlightManager::highlightConfigurationFromString(const try { boost::archive::text_iarchive archive(stream); archive >> configuration; } catch (boost::archive::archive_exception&) { configuration = getDefaultConfig(); - SWIFT_LOG(warning) << "Failed to load highlight configuration. Will use default configuration instead." << std::endl; + SWIFT_LOG(warning) << "Failed to load highlight configuration. Will use default configuration instead."; } return configuration; } std::string HighlightManager::highlightConfigurationToString(const HighlightConfiguration& configuration) { std::stringstream stream; diff --git a/Swift/Controllers/Settings/XMLSettingsProvider.cpp b/Swift/Controllers/Settings/XMLSettingsProvider.cpp index f1049f1..a316cef 100644 --- a/Swift/Controllers/Settings/XMLSettingsProvider.cpp +++ b/Swift/Controllers/Settings/XMLSettingsProvider.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2012-2016 Isode Limited. + * Copyright (c) 2012-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/Controllers/Settings/XMLSettingsProvider.h> @@ -17,20 +17,20 @@ namespace Swift { XMLSettingsProvider::XMLSettingsProvider(const std::string& xmlConfig) : level_(0) { if (!xmlConfig.empty()) { PlatformXMLParserFactory factory; auto parser = factory.createXMLParser(this, true); if (parser->parse(xmlConfig)) { - SWIFT_LOG(debug) << "Found and parsed system config" << std::endl; + SWIFT_LOG(debug) << "Found and parsed system config"; } else { - SWIFT_LOG(debug) << "Found invalid system config" << std::endl; + SWIFT_LOG(debug) << "Found invalid system config"; } } else { - SWIFT_LOG(debug) << "No system config found" << std::endl; + SWIFT_LOG(debug) << "No system config found"; } } XMLSettingsProvider::~XMLSettingsProvider() { } @@ -107,13 +107,13 @@ void XMLSettingsProvider::handleStartElement(const std::string& element, const s } } void XMLSettingsProvider::handleEndElement(const std::string& /*element*/, const std::string& /*ns*/) { if (level_ == SettingLevel) { values_[currentElement_] = currentText_; - SWIFT_LOG(debug) << "Setting value of " << currentElement_ << " to " << currentText_ << std::endl; + SWIFT_LOG(debug) << "Setting value of " << currentElement_ << " to " << currentText_; } level_--; } void XMLSettingsProvider::handleCharacterData(const std::string& data) { if (level_ >= SettingLevel) { diff --git a/Swift/Controllers/StatusCache.cpp b/Swift/Controllers/StatusCache.cpp index 3c6baed..f9196f6 100644 --- a/Swift/Controllers/StatusCache.cpp +++ b/Swift/Controllers/StatusCache.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2012-2016 Isode Limited. + * Copyright (c) 2012-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/Controllers/StatusCache.h> @@ -73,19 +73,19 @@ void StatusCache::loadRecents() { StatusShow::Type type; try { type = static_cast<StatusShow::Type>(boost::lexical_cast<size_t>(bits[0])); previousStatuses_.push_back(PreviousStatus(boost::trim_copy(bits[1]), type)); } catch (const boost::bad_lexical_cast& e) { - SWIFT_LOG(error) << "Failed to load recent status cache entry: " << e.what() << std::endl; + SWIFT_LOG(error) << "Failed to load recent status cache entry: " << e.what(); } } } } catch (const boost::filesystem::filesystem_error& e) { - SWIFT_LOG(error) << "Failed to load recents: " << e.what() << std::endl; + SWIFT_LOG(error) << "Failed to load recents: " << e.what(); } } void StatusCache::saveRecents() { try { if (!boost::filesystem::exists(path_.parent_path())) { @@ -97,13 +97,13 @@ void StatusCache::saveRecents() { boost::replace_all(message, "\t", " "); file << recent.second << "\t" << message << std::endl; } file.close(); } catch (const boost::filesystem::filesystem_error& e) { - SWIFT_LOG(error) << "Failed to save recents: " << e.what() << std::endl; + SWIFT_LOG(error) << "Failed to save recents: " << e.what(); } } } diff --git a/Swift/Controllers/Storages/AvatarFileStorage.cpp b/Swift/Controllers/Storages/AvatarFileStorage.cpp index 9d9b9ea..808c432 100644 --- a/Swift/Controllers/Storages/AvatarFileStorage.cpp +++ b/Swift/Controllers/Storages/AvatarFileStorage.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/Controllers/Storages/AvatarFileStorage.h> @@ -27,19 +27,19 @@ AvatarFileStorage::AvatarFileStorage(const boost::filesystem::path& avatarsDir, std::pair<std::string, std::string> r = String::getSplittedAtFirst(line, ' '); JID jid(r.second); if (jid.isValid()) { jidAvatars.insert(std::make_pair(jid, r.first)); } else if (!r.first.empty() || !r.second.empty()) { - SWIFT_LOG(error) << "Invalid entry in avatars file: " << r.second << std::endl; + SWIFT_LOG(error) << "Invalid entry in avatars file: " << r.second; } } } } catch (...) { - SWIFT_LOG(error) << "Error reading avatars file" << std::endl; + SWIFT_LOG(error) << "Error reading avatars file"; } } } bool AvatarFileStorage::hasAvatar(const std::string& hash) const { return boost::filesystem::exists(getAvatarPath(hash)); @@ -51,22 +51,22 @@ void AvatarFileStorage::addAvatar(const std::string& hash, const ByteArray& avat boost::filesystem::path avatarPath = getAvatarPath(hash); if (!boost::filesystem::exists(avatarPath.parent_path())) { try { boost::filesystem::create_directories(avatarPath.parent_path()); } catch (const boost::filesystem::filesystem_error& e) { - SWIFT_LOG(error) << "filesystem error: " << e.what() << std::endl; + SWIFT_LOG(error) << "filesystem error: " << e.what(); } } try { boost::filesystem::ofstream file(avatarPath, boost::filesystem::ofstream::binary|boost::filesystem::ofstream::out); file.write(reinterpret_cast<const char*>(vecptr(avatar)), static_cast<std::streamsize>(avatar.size())); } catch (const boost::filesystem::filesystem_error& e) { - SWIFT_LOG(error) << "filesystem error: " << e.what() << std::endl; + SWIFT_LOG(error) << "filesystem error: " << e.what(); } } boost::filesystem::path AvatarFileStorage::getAvatarPath(const std::string& hash) const { return avatarsDir / hash; } @@ -74,13 +74,13 @@ boost::filesystem::path AvatarFileStorage::getAvatarPath(const std::string& hash ByteArray AvatarFileStorage::getAvatar(const std::string& hash) const { ByteArray data; try { readByteArrayFromFile(data, getAvatarPath(hash)); } catch (const boost::filesystem::filesystem_error& e) { - SWIFT_LOG(error) << "filesystem error: " << e.what() << std::endl; + SWIFT_LOG(error) << "filesystem error: " << e.what(); } return data; } void AvatarFileStorage::setAvatarForJID(const JID& jid, const std::string& hash) { std::pair<JIDAvatarMap::iterator, bool> r = jidAvatars.insert(std::make_pair(jid, hash)); @@ -104,11 +104,11 @@ void AvatarFileStorage::saveJIDAvatars() { for (JIDAvatarMap::const_iterator i = jidAvatars.begin(); i != jidAvatars.end(); ++i) { file << i->second << " " << i->first.toString() << std::endl; } file.close(); } catch (...) { - SWIFT_LOG(error) << "Error writing avatars file" << std::endl; + SWIFT_LOG(error) << "Error writing avatars file"; } } } diff --git a/Swift/Controllers/Storages/CertificateFileStorage.cpp b/Swift/Controllers/Storages/CertificateFileStorage.cpp index 2e1343f..a8661df 100644 --- a/Swift/Controllers/Storages/CertificateFileStorage.cpp +++ b/Swift/Controllers/Storages/CertificateFileStorage.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/Controllers/Storages/CertificateFileStorage.h> @@ -28,13 +28,13 @@ bool CertificateFileStorage::hasCertificate(Certificate::ref certificate) const readByteArrayFromFile(data, certificatePath); Certificate::ref storedCertificate(certificateFactory->createCertificateFromDER(data)); if (storedCertificate && storedCertificate->toDER() == certificate->toDER()) { return true; } else { - SWIFT_LOG(warning) << "Stored certificate does not match received certificate" << std::endl; + SWIFT_LOG(warning) << "Stored certificate does not match received certificate"; return false; } } else { return false; } @@ -54,13 +54,13 @@ void CertificateFileStorage::addCertificate(Certificate::ref certificate) { boost::filesystem::ofstream file(certificatePath, boost::filesystem::ofstream::binary|boost::filesystem::ofstream::out); ByteArray data = certificate->toDER(); file.write(reinterpret_cast<const char*>(vecptr(data)), boost::numeric_cast<std::streamsize>(data.size())); file.close(); } catch (...) { - SWIFT_LOG(warning) << "Failed to store certificate to " << certificatePath << std::endl; + SWIFT_LOG(warning) << "Failed to store certificate to " << certificatePath; } } boost::filesystem::path CertificateFileStorage::getCertificatePath(Certificate::ref certificate) const { return path / Hexify::hexify(crypto->getSHA1Hash(certificate->toDER())); } diff --git a/Swift/QtUI/CAPICertificateSelector.cpp b/Swift/QtUI/CAPICertificateSelector.cpp index e47121b..7e4bc0b 100644 --- a/Swift/QtUI/CAPICertificateSelector.cpp +++ b/Swift/QtUI/CAPICertificateSelector.cpp @@ -77,17 +77,17 @@ std::string selectCAPICertificate() { titleLength = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, certificateDialogTitle.c_str(), -1, titleChars, titleLength); promptLength = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, certificateDialogPrompt.c_str(), -1, promptChars, promptLength); if (titleLength == 0 || promptLength == 0) { int error = GetLastError(); switch (error) { - case ERROR_INSUFFICIENT_BUFFER: SWIFT_LOG(error) << "Insufficient buffer for rendering cert dialog" << std::endl;break; - case ERROR_INVALID_FLAGS: SWIFT_LOG(error) << "Invalid flags for rendering cert dialog" << std::endl;break; - case ERROR_INVALID_PARAMETER: SWIFT_LOG(error) << "Invalid parameter for rendering cert dialog" << std::endl;break; - case ERROR_NO_UNICODE_TRANSLATION: SWIFT_LOG(error) << "Invalid unicode for rendering cert dialog" << std::endl;break; - default: SWIFT_LOG(error) << "Unexpected multibyte conversion errorcode" << std::endl; + case ERROR_INSUFFICIENT_BUFFER: SWIFT_LOG(error) << "Insufficient buffer for rendering cert dialog"; break; + case ERROR_INVALID_FLAGS: SWIFT_LOG(error) << "Invalid flags for rendering cert dialog"; break; + case ERROR_INVALID_PARAMETER: SWIFT_LOG(error) << "Invalid parameter for rendering cert dialog"; break; + case ERROR_NO_UNICODE_TRANSLATION: SWIFT_LOG(error) << "Invalid unicode for rendering cert dialog"; break; + default: SWIFT_LOG(error) << "Unexpected multibyte conversion errorcode"; } } std::string result; /* Call Windows dialog to select a suitable certificate */ @@ -100,13 +100,13 @@ std::string selectCAPICertificate() { delete[] titleChars; delete[] promptChars; if (hstore) { if (CertCloseStore(hstore, 0) == FALSE) { - SWIFT_LOG(debug) << "Failed to close the certificate store handle." << std::endl; + SWIFT_LOG(debug) << "Failed to close the certificate store handle."; } } return result; } diff --git a/Swift/QtUI/QtAboutWidget.cpp b/Swift/QtUI/QtAboutWidget.cpp index 2db0c9d..0a4e0ba 100644 --- a/Swift/QtUI/QtAboutWidget.cpp +++ b/Swift/QtUI/QtAboutWidget.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/QtUI/QtAboutWidget.h> @@ -147,13 +147,13 @@ void QtAboutWidget::openPlainTextWindow(const QString& path) { file.close(); text->resize(500, 600); text->show(); text->activateWindow(); } else { - SWIFT_LOG(error) << "Failed to open " << Q2PSTRING(path) << "." << std::endl; + SWIFT_LOG(error) << "Failed to open " << Q2PSTRING(path) << "."; } } void QtAboutWidget::updateUpdateInfo() { updateChannelInfoLabel_->hide(); updateStateInfoLabel_->hide(); diff --git a/Swift/QtUI/QtScaledAvatarCache.cpp b/Swift/QtUI/QtScaledAvatarCache.cpp index 37ea6a9..e3a28d6 100644 --- a/Swift/QtUI/QtScaledAvatarCache.cpp +++ b/Swift/QtUI/QtScaledAvatarCache.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2011-2016 Isode Limited. + * Copyright (c) 2011-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/QtUI/QtScaledAvatarCache.h> @@ -50,14 +50,14 @@ static QPixmap cropToBiggestCenteredSquare(const QPixmap& input) { QString QtScaledAvatarCache::getScaledAvatarPath(const QString& path) { QFileInfo avatarFile(path); if (avatarFile.exists() && !avatarFile.absolutePath().startsWith(":/")) { QString cacheSubPath = QString("ScaledAvatarCacheV%1/%2").arg(QString::number(QT_SCALED_AVATAR_CACHE_VERSION), QString::number(size)); if (!avatarFile.dir().mkpath(cacheSubPath)) { - SWIFT_LOG(error) << "avatarFile.dir(): " << Q2PSTRING(avatarFile.dir().absolutePath()) << std::endl; - SWIFT_LOG(error) << "Failed creating cache folder: " << Q2PSTRING(cacheSubPath) << std::endl; + SWIFT_LOG(error) << "avatarFile.dir(): " << Q2PSTRING(avatarFile.dir().absolutePath()); + SWIFT_LOG(error) << "Failed creating cache folder: " << Q2PSTRING(cacheSubPath); return path; } QDir targetDir(avatarFile.dir().absoluteFilePath(cacheSubPath)); QString targetFile = targetDir.absoluteFilePath(avatarFile.baseName()); if (!QFileInfo(targetFile).exists()) { QPixmap avatarPixmap; @@ -72,13 +72,13 @@ QString QtScaledAvatarCache::getScaledAvatarPath(const QString& path) { maskPainter.drawPixmap(0, 0, squaredAvatarPixmap); maskPainter.end(); if (!maskedAvatar.scaled(size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation).save(targetFile, "PNG")) { return path; } } else { - SWIFT_LOG(warning) << "Failed to load " << Q2PSTRING(path) << std::endl; + SWIFT_LOG(warning) << "Failed to load " << Q2PSTRING(path); } } return targetFile; } else { return path; diff --git a/Swift/QtUI/QtSpellCheckerWindow.cpp b/Swift/QtUI/QtSpellCheckerWindow.cpp index a8178c4..23b0963 100644 --- a/Swift/QtUI/QtSpellCheckerWindow.cpp +++ b/Swift/QtUI/QtSpellCheckerWindow.cpp @@ -2,13 +2,13 @@ * Copyright (c) 2011 Vlad Voicu * Licensed under the Simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ /* - * Copyright (c) 2016 Isode Limited. + * Copyright (c) 2016-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/QtUI/QtSpellCheckerWindow.h> @@ -61,13 +61,13 @@ void QtSpellCheckerWindow::setSupportedLanguages(const std::vector<std::string>& languageItems_[shortLang] = item; ui_.languageView->addItem(item); } } void QtSpellCheckerWindow::setActiveLanguage(const std::string& language) { - SWIFT_LOG_ASSERT(languageItems_.find(language) != languageItems_.end(), warning) << "Language '" << language << "' is not available." << std::endl; + SWIFT_LOG_ASSERT(languageItems_.find(language) != languageItems_.end(), warning) << "Language '" << language << "' is not available."; if (languageItems_.find(language) != languageItems_.end()) { languageItems_[language]->setSelected(true); } } void QtSpellCheckerWindow::setAutomaticallyIdentifiesLanguage(bool isAutomaticallyIdentifying) { diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp index f1ad38e..73fd733 100644 --- a/Swift/QtUI/QtSwift.cpp +++ b/Swift/QtUI/QtSwift.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/QtUI/QtSwift.h> @@ -188,13 +188,13 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa if (options.count("logfile")) { try { std::string fileName = options["logfile"].as<std::string>(); Log::setLogFile(fileName); } catch (...) { - SWIFT_LOG(error) << "Error while retrieving the specified log file name from the command line" << std::endl; + SWIFT_LOG(error) << "Error while retrieving the specified log file name from the command line"; } } //TODO this old option can be purged useDelayForLatency_ = options.count("latency-debug") > 0; // Load fonts @@ -219,19 +219,19 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa "themes/Default/Lato2OFL/Lato-ThinItalic.ttf" }; for (auto&& fontName : fontNames) { std::string fontPath = std::string(":/") + fontName; int error = QFontDatabase::addApplicationFont(P2QSTRING(fontPath)); - SWIFT_LOG_ASSERT(error != -1, error) << "Failed to load font " << fontPath << std::endl; + SWIFT_LOG_ASSERT(error != -1, error) << "Failed to load font " << fontPath; } #ifdef SWIFTEN_PLATFORM_LINUX std::string fontPath = std::string(":/themes/Default/Noto/NotoColorEmoji.ttf"); int error = QFontDatabase::addApplicationFont(P2QSTRING(fontPath)); - SWIFT_LOG_ASSERT(error != -1, error) << "Failed to load font " << fontPath << std::endl; + SWIFT_LOG_ASSERT(error != -1, error) << "Failed to load font " << fontPath; QFont::insertSubstitution(QApplication::font().family(),"NotoColorEmoji"); #endif #ifdef SWIFTEN_PLATFORM_WINDOWS QFont::insertSubstitution(QApplication::font().family(), "Segoe UI Emoji"); #endif enableAdHocCommandOnJID_ = options.count("enable-jid-adhocs") > 0; diff --git a/Swift/QtUI/QtTextEdit.cpp b/Swift/QtUI/QtTextEdit.cpp index e63cd4f..b3c57a7 100644 --- a/Swift/QtUI/QtTextEdit.cpp +++ b/Swift/QtUI/QtTextEdit.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/QtUI/QtTextEdit.h> @@ -237,13 +237,13 @@ void QtTextEdit::setUpSpellChecker() { checker_->setActiveLanguage(settings_->getSetting(QtUISettingConstants::SPELL_CHECKER_LANGUAGE)); } highlighter_ = new QtSpellCheckHighlighter(document(), checker_); } else { // Spellchecking is not working, as we did not get a valid checker from the factory. Disable spellchecking. - SWIFT_LOG(warning) << "Spellchecking is currently misconfigured in Swift (e.g. missing dictionary or broken dictionary file). Disable spellchecking." << std::endl; + SWIFT_LOG(warning) << "Spellchecking is currently misconfigured in Swift (e.g. missing dictionary or broken dictionary file). Disable spellchecking."; settings_->storeSetting(QtUISettingConstants::SPELL_CHECKER, false); } } } #endif diff --git a/Swift/QtUI/QtUIFactory.cpp b/Swift/QtUI/QtUIFactory.cpp index 93fca5f..49f55dd 100644 --- a/Swift/QtUI/QtUIFactory.cpp +++ b/Swift/QtUI/QtUIFactory.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/QtUI/QtUIFactory.h> @@ -46,15 +46,15 @@ QtUIFactory::QtUIFactory(SettingsProviderHierachy* settings, QtSettingsProvider* chatWindowFactory_ = new QtChatWindowFactory(netbookSplitter_, settings, qtOnlySettings, tabs_, ":/themes/Default/", emoticons_); chatFontSize_ = settings_->getSetting(QtUISettingConstants::CHATWINDOW_FONT_SIZE); historyFontSize_ = settings_->getSetting(QtUISettingConstants::HISTORYWINDOW_FONT_SIZE); } QtUIFactory::~QtUIFactory() { - SWIFT_LOG(debug) << "Entering QtUIFactory destructor. chatWindows size:" << chatWindows_.size() << std::endl; + SWIFT_LOG(debug) << "Entering QtUIFactory destructor. chatWindows size:" << chatWindows_.size(); for (auto chat : chatWindows_) { - SWIFT_LOG_ASSERT(chat.isNull(), debug) << "QtUIFactory has active chat windows and has not been reset properly" << std::endl; + SWIFT_LOG_ASSERT(chat.isNull(), debug) << "QtUIFactory has active chat windows and has not been reset properly"; } delete chatWindowFactory_; } XMLConsoleWidget* QtUIFactory::createXMLConsoleWidget() { QtXMLConsoleWidget* widget = new QtXMLConsoleWidget(); diff --git a/Swift/QtUI/QtWebKitChatView.cpp b/Swift/QtUI/QtWebKitChatView.cpp index bca9e2e..75a23f8 100644 --- a/Swift/QtUI/QtWebKitChatView.cpp +++ b/Swift/QtUI/QtWebKitChatView.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/QtUI/QtWebKitChatView.h> @@ -138,13 +138,13 @@ void QtWebKitChatView::addMessageBottom(std::shared_ptr<ChatSnippet> snippet) { assert(false); } } void QtWebKitChatView::addMessageTop(std::shared_ptr<ChatSnippet> /* snippet */) { // TODO: Implement this in a sensible manner later. - SWIFT_LOG(error) << "Not yet implemented!" << std::endl; + SWIFT_LOG(error) << "Not yet implemented!"; } void QtWebKitChatView::addToDOM(std::shared_ptr<ChatSnippet> snippet) { //qDebug() << snippet->getContent(); rememberScrolledToBottom(); @@ -381,13 +381,13 @@ static QWebElement findElementWithID(QWebElement document, QString elementName, } void QtWebKitChatView::setFileTransferProgress(QString id, const int percentageDone) { rememberScrolledToBottom(); QWebElement ftElement = findElementWithID(document_, "div", id); if (ftElement.isNull()) { - SWIFT_LOG(debug) << "Tried to access FT UI via invalid id!" << std::endl; + SWIFT_LOG(debug) << "Tried to access FT UI via invalid id!"; return; } QWebElement progressBar = ftElement.findFirst("div.progressbar"); progressBar.setStyleProperty("width", QString::number(percentageDone) + "%"); QWebElement progressBarValue = ftElement.findFirst("div.progressbar-value"); @@ -395,13 +395,13 @@ void QtWebKitChatView::setFileTransferProgress(QString id, const int percentageD } void QtWebKitChatView::setFileTransferStatus(QString id, const ChatWindow::FileTransferState state, const QString& /* msg */) { rememberScrolledToBottom(); QWebElement ftElement = findElementWithID(document_, "div", id); if (ftElement.isNull()) { - SWIFT_LOG(debug) << "Tried to access FT UI via invalid id! id = " << Q2PSTRING(id) << std::endl; + SWIFT_LOG(debug) << "Tried to access FT UI via invalid id! id = " << Q2PSTRING(id); return; } QString newInnerHTML = ""; if (state == ChatWindow::Initialisation) { QWebElement filenameSizeDescriptionElement = ftElement.parent().firstChild(); @@ -480,13 +480,13 @@ int QtWebKitChatView::getSnippetPositionByDate(const QDate& date) { return message.geometry().top(); } void QtWebKitChatView::resetTopInsertPoint() { // TODO: Implement or refactor later. - SWIFT_LOG(error) << "Not yet implemented!" << std::endl; + SWIFT_LOG(error) << "Not yet implemented!"; } std::string QtWebKitChatView::addMessage( const ChatWindow::ChatMessage& message, const std::string& senderName, bool senderIsSelf, @@ -621,13 +621,13 @@ void QtWebKitChatView::resizeEvent(QResizeEvent* event) { scrollToBottom(); } QWidget::resizeEvent(event); } std::string QtWebKitChatView::addFileTransfer(const std::string& senderName, const std::string& avatarPath, bool senderIsSelf, const std::string& filename, const boost::uintmax_t sizeInBytes, const std::string& description) { - SWIFT_LOG(debug) << "addFileTransfer" << std::endl; + SWIFT_LOG(debug) << "addFileTransfer"; QString ft_id = QString("ft%1").arg(P2QSTRING(boost::lexical_cast<std::string>(idCounter_++))); QString actionText; QString htmlString; QString formattedFileSize = P2QSTRING(formatSize(sizeInBytes)); QString sanitizedFileName = QtUtilities::htmlEscape(P2QSTRING(filename)); @@ -723,24 +723,24 @@ static bool isFilePathWritable(const QString& path) { } } void QtWebKitChatView::setFileTransferWarning(QString id, QString warningText) { QWebElement ftElement = findElementWithID(document_, "div", id); if (ftElement.isNull()) { - SWIFT_LOG(debug) << "Tried to access FT UI via invalid id! id = " << Q2PSTRING(id) << std::endl; + SWIFT_LOG(debug) << "Tried to access FT UI via invalid id! id = " << Q2PSTRING(id); return; } removeFileTransferWarning(id); ftElement.appendInside(QString("<div class='ft_warning' style='color: red;'><br/>%1</div>").arg(QtUtilities::htmlEscape(warningText))); } void QtWebKitChatView::removeFileTransferWarning(QString id) { QWebElement ftElement = findElementWithID(document_, "div", id); if (ftElement.isNull()) { - SWIFT_LOG(debug) << "Tried to access FT UI via invalid id! id = " << Q2PSTRING(id) << std::endl; + SWIFT_LOG(debug) << "Tried to access FT UI via invalid id! id = " << Q2PSTRING(id); return; } QWebElement warningElement = ftElement.findFirst(".ft_warning"); if (!warningElement.isNull()) { warningElement.removeFromDocument(); @@ -826,13 +826,13 @@ void QtWebKitChatView::handleHTMLButtonClicked(QString id, QString encodedArgume } else if (id.startsWith(ButtonResendMessage)) { QString chatID = arg1; window_->resendMessage(Q2PSTRING(chatID)); } else { - SWIFT_LOG(debug) << "Unknown HTML button! ( " << Q2PSTRING(id) << " )" << std::endl; + SWIFT_LOG(debug) << "Unknown HTML button! ( " << Q2PSTRING(id) << " )"; } } void QtWebKitChatView::handleVerticalScrollBarPositionChanged(double position) { rememberScrolledToBottom(); if (position == 0) { diff --git a/Swift/QtUI/Trellis/QtDynamicGridLayout.cpp b/Swift/QtUI/Trellis/QtDynamicGridLayout.cpp index 2402529..53e2733 100644 --- a/Swift/QtUI/Trellis/QtDynamicGridLayout.cpp +++ b/Swift/QtUI/Trellis/QtDynamicGridLayout.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/QtUI/Trellis/QtDynamicGridLayout.h> @@ -511,25 +511,25 @@ void QtDynamicGridLayout::updateTabPositions() { } } } void QtDynamicGridLayout::moveTab(QtTabWidget* tabWidget, int oldIndex, int newIndex) { #if QT_VERSION >= 0x040500 - SWIFT_LOG_ASSERT(movingTab_ == nullptr, error) << std::endl; + SWIFT_LOG_ASSERT(movingTab_ == nullptr, error); movingTab_ = qobject_cast<QtTabbable*>(tabWidget->widget(oldIndex)); - SWIFT_LOG_ASSERT(movingTab_ != nullptr, error) << std::endl; + SWIFT_LOG_ASSERT(movingTab_ != nullptr, error); if (movingTab_) { // Install event filter that filters out events issued during the internal movement of the // tab but not targeted at the moving tab. qApp->installEventFilter(this); tabWidget->tabBar()->moveTab(oldIndex, newIndex); qApp->removeEventFilter(this); - SWIFT_LOG_ASSERT(movingTab_ == tabWidget->widget(newIndex), error) << std::endl; + SWIFT_LOG_ASSERT(movingTab_ == tabWidget->widget(newIndex), error); } movingTab_ = nullptr; tabWidget->widget(newIndex)->setFocus(); #else #warning Qt 4.5 or later is needed. Trying anyway, some things will be disabled. #endif diff --git a/Swiften/Avatars/CombinedAvatarProvider.cpp b/Swiften/Avatars/CombinedAvatarProvider.cpp index 465512f..ba6e6be 100644 --- a/Swiften/Avatars/CombinedAvatarProvider.cpp +++ b/Swiften/Avatars/CombinedAvatarProvider.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Avatars/CombinedAvatarProvider.h> @@ -36,23 +36,23 @@ void CombinedAvatarProvider::handleAvatarChanged(const JID& jid) { std::map<JID, std::string>::const_iterator i = avatars.find(jid); if (i != avatars.end()) { oldHash = i->second; } boost::optional<std::string> newHash = getCombinedAvatarAndCache(jid); if (newHash != oldHash) { - SWIFT_LOG(debug) << "Avatar changed: " << jid << ": " << oldHash << " -> " << (newHash ? newHash.get() : "NULL") << std::endl; + SWIFT_LOG(debug) << "Avatar changed: " << jid << ": " << oldHash << " -> " << (newHash ? newHash.get() : "NULL"); onAvatarChanged(jid); } } boost::optional<std::string> CombinedAvatarProvider::getCombinedAvatarAndCache(const JID& jid) const { - SWIFT_LOG(debug) << "JID: " << jid << std::endl; + SWIFT_LOG(debug) << "JID: " << jid; boost::optional<std::string> hash; for (size_t i = 0; i < providers.size() && !hash; ++i) { hash = providers[i]->getAvatarHash(jid); - SWIFT_LOG(debug) << "Provider " << providers[i] << ": " << (hash ? hash.get() : "NULL") << std::endl; + SWIFT_LOG(debug) << "Provider " << providers[i] << ": " << (hash ? hash.get() : "NULL"); } if (hash) { avatars[jid] = *hash; } else { avatars[jid] = ""; } diff --git a/Swiften/Avatars/VCardUpdateAvatarManager.cpp b/Swiften/Avatars/VCardUpdateAvatarManager.cpp index 349af2f..d04c13c 100644 --- a/Swiften/Avatars/VCardUpdateAvatarManager.cpp +++ b/Swiften/Avatars/VCardUpdateAvatarManager.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Avatars/VCardUpdateAvatarManager.h> @@ -30,30 +30,30 @@ void VCardUpdateAvatarManager::handlePresenceReceived(std::shared_ptr<Presence> std::shared_ptr<VCardUpdate> update = presence->getPayload<VCardUpdate>(); if (!update || presence->getPayload<ErrorPayload>()) { return; } JID from = getAvatarJID(presence->getFrom()); if (update->getPhotoHash().size() != 40) { - SWIFT_LOG(debug) << "Invalid vCard avatar photo hash length. Must be hex-encoded SHA-1, i.e. 40 characters." << std::endl; + SWIFT_LOG(debug) << "Invalid vCard avatar photo hash length. Must be hex-encoded SHA-1, i.e. 40 characters."; return; } if (getAvatarHash(from) == update->getPhotoHash()) { return; } - SWIFT_LOG(debug) << "Updated hash: " << from << " -> " << update->getPhotoHash() << std::endl; + SWIFT_LOG(debug) << "Updated hash: " << from << " -> " << update->getPhotoHash(); if (avatarStorage_->hasAvatar(update->getPhotoHash())) { setAvatarHash(from, update->getPhotoHash()); } else { vcardManager_->requestVCard(from); } } void VCardUpdateAvatarManager::handleVCardChanged(const JID& from, VCard::ref vCard) { if (!vCard) { - SWIFT_LOG(debug) << "Missing element: " << from << ": null vcard payload" << std::endl; + SWIFT_LOG(debug) << "Missing element: " << from << ": null vcard payload"; return; } if (vCard->getPhoto().empty()) { setAvatarHash(from, ""); } @@ -64,13 +64,13 @@ void VCardUpdateAvatarManager::handleVCardChanged(const JID& from, VCard::ref vC } setAvatarHash(from, hash); } } void VCardUpdateAvatarManager::setAvatarHash(const JID& from, const std::string& hash) { - SWIFT_LOG(debug) << "Updating hash: " << from << " -> " << hash << std::endl; + SWIFT_LOG(debug) << "Updating hash: " << from << " -> " << hash; avatarHashes_[from] = hash; onAvatarChanged(from); } /* void VCardUpdateAvatarManager::setAvatar(const JID& jid, const ByteArray& avatar) { diff --git a/Swiften/Base/DateTime.cpp b/Swiften/Base/DateTime.cpp index 4443566..23b3b84 100644 --- a/Swiften/Base/DateTime.cpp +++ b/Swiften/Base/DateTime.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2011-2016 Isode Limited. + * Copyright (c) 2011-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Base/DateTime.h> @@ -37,12 +37,12 @@ std::string dateTimeToString(const boost::posix_time::ptime& time) { std::string dateTimeToLocalString(const boost::posix_time::ptime& time) { std::string localString; try { localString = boost::posix_time::to_simple_string(boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local(time)); } catch(std::out_of_range& exception) { - SWIFT_LOG(debug) << exception.what() << std::endl; + SWIFT_LOG(debug) << exception.what(); } return localString; } } diff --git a/Swiften/Base/Log.cpp b/Swiften/Base/Log.cpp index abfd2bc..b6f1851 100644 --- a/Swiften/Base/Log.cpp +++ b/Swiften/Base/Log.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2015 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Base/Log.h> @@ -27,19 +27,22 @@ Log::~Log() { __android_log_print(ANDROID_LOG_VERBOSE, "Swift", stream.str().c_str(), 1); #else // Using stdio for thread safety (POSIX file i/o calls are guaranteed to be atomic) if (logCallback) { logCallback(severity_, std::move(file_), line_, std::move(function_), stream.str()); } - else if (logfile) { - fwrite(stream.str().c_str(), sizeof(char), stream.str().size(), logfile.get()); - fflush(logfile.get()); - } else { - fwrite(stream.str().c_str(), sizeof(char), stream.str().size(), stderr); - fflush(stderr); + stream << std::endl; + if (logfile) { + fwrite(stream.str().c_str(), sizeof(char), stream.str().size(), logfile.get()); + fflush(logfile.get()); + } + else { + fwrite(stream.str().c_str(), sizeof(char), stream.str().size(), stderr); + fflush(stderr); + } } #endif } std::ostringstream& Log::getStream( Severity severity, diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp index 4e34417..1114336 100644 --- a/Swiften/Client/ClientSession.cpp +++ b/Swiften/Client/ClientSession.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Client/ClientSession.h> @@ -85,13 +85,13 @@ ClientSession::ClientSession( authenticator(nullptr), certificateTrustChecker(nullptr), singleSignOn(false), authenticationPort(-1) { #ifdef SWIFTEN_PLATFORM_WIN32 if (WindowsRegistry::isFIPSEnabled()) { - SWIFT_LOG(info) << "Windows is running in FIPS-140 mode. Some authentication methods will be unavailable." << std::endl; + SWIFT_LOG(info) << "Windows is running in FIPS-140 mode. Some authentication methods will be unavailable."; } #endif } ClientSession::~ClientSession() { } @@ -528,26 +528,26 @@ void ClientSession::handleStreamShutdownTimeout() { void ClientSession::finish() { if (state != State::Finishing && state != State::Finished) { finishSession(std::shared_ptr<Error>()); } else { - SWIFT_LOG(warning) << "Session already finished or finishing." << std::endl; + SWIFT_LOG(warning) << "Session already finished or finishing."; } } void ClientSession::finishSession(Error::Type error) { finishSession(std::make_shared<Swift::ClientSession::Error>(error)); } void ClientSession::finishSession(std::shared_ptr<Swift::Error> error) { if (!error_) { error_ = error; } else { - SWIFT_LOG(warning) << "Session finished twice" << std::endl; + SWIFT_LOG(warning) << "Session finished twice"; } assert(stream->isOpen()); if (stanzaAckResponder_) { stanzaAckResponder_->handleAckRequestReceived(); } if (authenticator) { diff --git a/Swiften/Client/ClientSessionStanzaChannel.cpp b/Swiften/Client/ClientSessionStanzaChannel.cpp index f48b306..6a5d07d 100644 --- a/Swiften/Client/ClientSessionStanzaChannel.cpp +++ b/Swiften/Client/ClientSessionStanzaChannel.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Client/ClientSessionStanzaChannel.h> @@ -46,13 +46,13 @@ void ClientSessionStanzaChannel::sendPresence(std::shared_ptr<Presence> presence std::string ClientSessionStanzaChannel::getNewIQID() { return idGenerator.generateID(); } void ClientSessionStanzaChannel::send(std::shared_ptr<Stanza> stanza) { if (!isAvailable()) { - SWIFT_LOG(warning) << "Client: Trying to send a stanza while disconnected." << std::endl; + SWIFT_LOG(warning) << "Client: Trying to send a stanza while disconnected."; return; } session->sendStanza(stanza); } void ClientSessionStanzaChannel::handleSessionFinished(std::shared_ptr<Error>) { diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp index ccde0c2..7579bca 100644 --- a/Swiften/Client/CoreClient.cpp +++ b/Swiften/Client/CoreClient.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Client/CoreClient.h> @@ -66,59 +66,59 @@ void CoreClient::connect(const ClientOptions& o) { assert(proxyConnectionFactories.empty()); bool useDirectConnection = true; HostAddressPort systemSOCKS5Proxy = networkFactories->getProxyProvider()->getSOCKS5Proxy(); HostAddressPort systemHTTPConnectProxy = networkFactories->getProxyProvider()->getHTTPConnectProxy(); switch (o.proxyType) { case ClientOptions::NoProxy: - SWIFT_LOG(debug) << " without a proxy" << std::endl; + SWIFT_LOG(debug) << " without a proxy"; break; case ClientOptions::SystemConfiguredProxy: - SWIFT_LOG(debug) << " with a system configured proxy" << std::endl; + SWIFT_LOG(debug) << " with a system configured proxy"; if (systemSOCKS5Proxy.isValid()) { - SWIFT_LOG(debug) << "Found SOCK5 Proxy: " << systemSOCKS5Proxy.getAddress().toString() << ":" << systemSOCKS5Proxy.getPort() << std::endl; + SWIFT_LOG(debug) << "Found SOCK5 Proxy: " << systemSOCKS5Proxy.getAddress().toString() << ":" << systemSOCKS5Proxy.getPort(); proxyConnectionFactories.push_back(new SOCKS5ProxiedConnectionFactory(networkFactories->getDomainNameResolver(), networkFactories->getConnectionFactory(), networkFactories->getTimerFactory(), systemSOCKS5Proxy.getAddress().toString(), systemSOCKS5Proxy.getPort())); } if (systemHTTPConnectProxy.isValid()) { - SWIFT_LOG(debug) << "Found HTTPConnect Proxy: " << systemHTTPConnectProxy.getAddress().toString() << ":" << systemHTTPConnectProxy.getPort() << std::endl; + SWIFT_LOG(debug) << "Found HTTPConnect Proxy: " << systemHTTPConnectProxy.getAddress().toString() << ":" << systemHTTPConnectProxy.getPort(); proxyConnectionFactories.push_back(new HTTPConnectProxiedConnectionFactory(networkFactories->getDomainNameResolver(), networkFactories->getConnectionFactory(), networkFactories->getTimerFactory(), systemHTTPConnectProxy.getAddress().toString(), systemHTTPConnectProxy.getPort())); } break; case ClientOptions::SOCKS5Proxy: { - SWIFT_LOG(debug) << " with manual configured SOCKS5 proxy" << std::endl; + SWIFT_LOG(debug) << " with manual configured SOCKS5 proxy"; std::string proxyHostname = o.manualProxyHostname.empty() ? systemSOCKS5Proxy.getAddress().toString() : o.manualProxyHostname; auto proxyPort = systemSOCKS5Proxy.getPort(); if (o.manualProxyPort != -1) { try { proxyPort = boost::numeric_cast<unsigned short>(o.manualProxyPort); } catch (const boost::numeric::bad_numeric_cast& e) { - SWIFT_LOG(warning) << "Manual proxy port " << o.manualProxyPort << " is invalid: " << e.what() << std::endl; + SWIFT_LOG(warning) << "Manual proxy port " << o.manualProxyPort << " is invalid: " << e.what(); onDisconnected(boost::optional<ClientError>(ClientError::ConnectionError)); return; } } - SWIFT_LOG(debug) << "Proxy: " << proxyHostname << ":" << proxyPort << std::endl; + SWIFT_LOG(debug) << "Proxy: " << proxyHostname << ":" << proxyPort; proxyConnectionFactories.push_back(new SOCKS5ProxiedConnectionFactory(networkFactories->getDomainNameResolver(), networkFactories->getConnectionFactory(), networkFactories->getTimerFactory(), proxyHostname, proxyPort)); useDirectConnection = false; break; } case ClientOptions::HTTPConnectProxy: { - SWIFT_LOG(debug) << " with manual configured HTTPConnect proxy" << std::endl; + SWIFT_LOG(debug) << " with manual configured HTTPConnect proxy"; std::string proxyHostname = o.manualProxyHostname.empty() ? systemHTTPConnectProxy.getAddress().toString() : o.manualProxyHostname; unsigned short proxyPort = systemHTTPConnectProxy.getPort(); if (o.manualProxyPort != -1) { try { proxyPort = boost::numeric_cast<unsigned short>(o.manualProxyPort); } catch (const boost::numeric::bad_numeric_cast& e) { - SWIFT_LOG(warning) << "Manual proxy port " << o.manualProxyPort << " is invalid: " << e.what() << std::endl; + SWIFT_LOG(warning) << "Manual proxy port " << o.manualProxyPort << " is invalid: " << e.what(); onDisconnected(boost::optional<ClientError>(ClientError::ConnectionError)); return; } } - SWIFT_LOG(debug) << "Proxy: " << proxyHostname << ":" << proxyPort << std::endl; + SWIFT_LOG(debug) << "Proxy: " << proxyHostname << ":" << proxyPort; proxyConnectionFactories.push_back(new HTTPConnectProxiedConnectionFactory(networkFactories->getDomainNameResolver(), networkFactories->getConnectionFactory(), networkFactories->getTimerFactory(), proxyHostname, proxyPort, o.httpTrafficFilter)); useDirectConnection = false; break; } } std::vector<ConnectionFactory*> connectionFactories(proxyConnectionFactories); @@ -131,13 +131,13 @@ void CoreClient::connect(const ClientOptions& o) { unsigned short port = 0; if (o.manualPort != -1) { try { port = boost::numeric_cast<unsigned short>(o.manualPort); } catch (const boost::numeric::bad_numeric_cast& e) { - SWIFT_LOG(warning) << "Invalid manual port " << o.manualPort << ": " << e.what() << std::endl; + SWIFT_LOG(warning) << "Invalid manual port " << o.manualPort << ": " << e.what(); onDisconnected(boost::optional<ClientError>(ClientError::ConnectionError)); return; } } boost::optional<std::string> serviceLookupPrefix; if (o.manualHostname.empty()) { @@ -171,13 +171,13 @@ void CoreClient::connect(const ClientOptions& o) { options.tlsOptions, options.httpTrafficFilter)); sessionStream_ = boshSessionStream_; sessionStream_->onDataRead.connect(boost::bind(&CoreClient::handleDataRead, this, _1)); sessionStream_->onDataWritten.connect(boost::bind(&CoreClient::handleDataWritten, this, _1)); if (certificate_ && !certificate_->isNull()) { - SWIFT_LOG(debug) << "set certificate" << std::endl; + SWIFT_LOG(debug) << "set certificate"; sessionStream_->setTLSCertificate(certificate_); } boshSessionStream_->open(); bindSessionToStream(); } @@ -420,13 +420,13 @@ void CoreClient::sendMessage(std::shared_ptr<Message> message) { void CoreClient::sendPresence(std::shared_ptr<Presence> presence) { stanzaChannel_->sendPresence(presence); } void CoreClient::sendData(const std::string& data) { if (!sessionStream_) { - SWIFT_LOG(warning) << "Client: Trying to send data while disconnected." << std::endl; + SWIFT_LOG(warning) << "Client: Trying to send data while disconnected."; return; } sessionStream_->writeData(data); } bool CoreClient::isActive() const { @@ -504,16 +504,16 @@ void CoreClient::resetSession() { sessionStream_.reset(); connection_.reset(); } void CoreClient::forceReset() { if (connector_) { - SWIFT_LOG(warning) << "Client not disconnected properly: Connector still active" << std::endl; + SWIFT_LOG(warning) << "Client not disconnected properly: Connector still active"; resetConnector(); } if (sessionStream_ || connection_) { - SWIFT_LOG(warning) << "Client not disconnected properly: Session still active" << std::endl; + SWIFT_LOG(warning) << "Client not disconnected properly: Session still active"; resetSession(); } } } diff --git a/Swiften/Component/ComponentSessionStanzaChannel.cpp b/Swiften/Component/ComponentSessionStanzaChannel.cpp index e4bf231..deac8b2 100644 --- a/Swiften/Component/ComponentSessionStanzaChannel.cpp +++ b/Swiften/Component/ComponentSessionStanzaChannel.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Component/ComponentSessionStanzaChannel.h> @@ -44,13 +44,13 @@ void ComponentSessionStanzaChannel::sendPresence(std::shared_ptr<Presence> prese std::string ComponentSessionStanzaChannel::getNewIQID() { return idGenerator.generateID(); } void ComponentSessionStanzaChannel::send(std::shared_ptr<Stanza> stanza) { if (!isAvailable()) { - SWIFT_LOG(warning) << "Component: Trying to send a stanza while disconnected." << std::endl; + SWIFT_LOG(warning) << "Component: Trying to send a stanza while disconnected."; return; } session->sendStanza(stanza); } void ComponentSessionStanzaChannel::handleSessionFinished(std::shared_ptr<Error>) { diff --git a/Swiften/Component/CoreComponent.cpp b/Swiften/Component/CoreComponent.cpp index 2d91c9c..ef7d3a4 100644 --- a/Swiften/Component/CoreComponent.cpp +++ b/Swiften/Component/CoreComponent.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Component/CoreComponent.h> @@ -30,13 +30,13 @@ CoreComponent::CoreComponent(const JID& jid, const std::string& secret, NetworkF iqRouter_ = new IQRouter(stanzaChannel_); iqRouter_->setFrom(jid); } CoreComponent::~CoreComponent() { if (session_ || connection_) { - SWIFT_LOG(warning) << "Component not disconnected properly" << std::endl; + SWIFT_LOG(warning) << "Component not disconnected properly"; } delete iqRouter_; stanzaChannel_->onAvailableChanged.disconnect(boost::bind(&CoreComponent::handleStanzaChannelAvailableChanged, this, _1)); stanzaChannel_->onMessageReceived.disconnect(boost::ref(onMessageReceived)); stanzaChannel_->onPresenceReceived.disconnect(boost::ref(onPresenceReceived)); diff --git a/Swiften/Disco/CapsManager.cpp b/Swiften/Disco/CapsManager.cpp index 794cf74..2b8fb7d 100644 --- a/Swiften/Disco/CapsManager.cpp +++ b/Swiften/Disco/CapsManager.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Disco/CapsManager.h> @@ -50,13 +50,13 @@ void CapsManager::handleStanzaChannelAvailableChanged(bool available) { } void CapsManager::handleDiscoInfoReceived(const JID& from, const std::string& hash, DiscoInfo::ref discoInfo, ErrorPayload::ref error) { requestedDiscoInfos.erase(hash); if (error || !discoInfo || CapsInfoGenerator("", crypto).generateCapsInfo(*discoInfo.get()).getVersion() != hash) { if (warnOnInvalidHash && !error && discoInfo) { - SWIFT_LOG(warning) << "Caps from " << from.toString() << " do not verify" << std::endl; + SWIFT_LOG(warning) << "Caps from " << from.toString() << " do not verify"; } failingCaps.insert(std::make_pair(from, hash)); std::map<std::string, std::set< std::pair<JID, std::string> > >::iterator i = fallbacks.find(hash); if (i != fallbacks.end() && !i->second.empty()) { std::pair<JID,std::string> fallbackAndNode = *i->second.begin(); i->second.erase(i->second.begin()); diff --git a/Swiften/Disco/DiscoServiceWalker.cpp b/Swiften/Disco/DiscoServiceWalker.cpp index a3f95d2..7332e63 100644 --- a/Swiften/Disco/DiscoServiceWalker.cpp +++ b/Swiften/Disco/DiscoServiceWalker.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Disco/DiscoServiceWalker.h> @@ -14,35 +14,35 @@ namespace Swift { DiscoServiceWalker::DiscoServiceWalker(const JID& service, IQRouter* iqRouter, size_t maxSteps) : service_(service), iqRouter_(iqRouter), maxSteps_(maxSteps), active_(false) { } void DiscoServiceWalker::beginWalk() { - SWIFT_LOG(debug) << "Starting walk to " << service_ << std::endl; + SWIFT_LOG(debug) << "Starting walk to " << service_; assert(!active_); assert(servicesBeingSearched_.empty()); active_ = true; walkNode(service_); } void DiscoServiceWalker::endWalk() { if (active_) { - SWIFT_LOG(debug) << "Ending walk to " << service_ << std::endl; + SWIFT_LOG(debug) << "Ending walk to " << service_; for (auto&& request : pendingDiscoInfoRequests_) { request->onResponse.disconnect(boost::bind(&DiscoServiceWalker::handleDiscoInfoResponse, this, _1, _2, request)); } for (auto&& request : pendingDiscoItemsRequests_) { request->onResponse.disconnect(boost::bind(&DiscoServiceWalker::handleDiscoItemsResponse, this, _1, _2, request)); } active_ = false; onWalkAborted(); } } void DiscoServiceWalker::walkNode(const JID& jid) { - SWIFT_LOG(debug) << "Walking node " << jid << std::endl; + SWIFT_LOG(debug) << "Walking node " << jid; servicesBeingSearched_.insert(jid); searchedServices_.insert(jid); GetDiscoInfoRequest::ref discoInfoRequest = GetDiscoInfoRequest::create(jid, iqRouter_); discoInfoRequest->onResponse.connect(boost::bind(&DiscoServiceWalker::handleDiscoInfoResponse, this, _1, _2, discoInfoRequest)); pendingDiscoInfoRequests_.insert(discoInfoRequest); discoInfoRequest->send(); @@ -51,13 +51,13 @@ void DiscoServiceWalker::walkNode(const JID& jid) { void DiscoServiceWalker::handleDiscoInfoResponse(std::shared_ptr<DiscoInfo> info, ErrorPayload::ref error, GetDiscoInfoRequest::ref request) { /* If we got canceled, don't do anything */ if (!active_) { return; } - SWIFT_LOG(debug) << "Disco info response from " << request->getReceiver() << std::endl; + SWIFT_LOG(debug) << "Disco info response from " << request->getReceiver(); request->onResponse.disconnect(boost::bind(&DiscoServiceWalker::handleDiscoInfoResponse, this, _1, _2, request)); pendingDiscoInfoRequests_.erase(request); if (error) { handleDiscoError(request->getReceiver(), error); return; @@ -87,40 +87,40 @@ void DiscoServiceWalker::handleDiscoInfoResponse(std::shared_ptr<DiscoInfo> info void DiscoServiceWalker::handleDiscoItemsResponse(std::shared_ptr<DiscoItems> items, ErrorPayload::ref error, GetDiscoItemsRequest::ref request) { /* If we got canceled, don't do anything */ if (!active_) { return; } - SWIFT_LOG(debug) << "Received disco items from " << request->getReceiver() << std::endl; + SWIFT_LOG(debug) << "Received disco items from " << request->getReceiver(); request->onResponse.disconnect(boost::bind(&DiscoServiceWalker::handleDiscoItemsResponse, this, _1, _2, request)); pendingDiscoItemsRequests_.erase(request); if (error) { handleDiscoError(request->getReceiver(), error); return; } for (auto&& item : items->getItems()) { if (item.getNode().empty()) { /* Don't look at noded items. It's possible that this will exclude some services, * but I've never seen one in the wild, and it's an easy fix for not looping. */ if (std::find(searchedServices_.begin(), searchedServices_.end(), item.getJID()) == searchedServices_.end()) { /* Don't recurse infinitely */ - SWIFT_LOG(debug) << "Received disco item " << item.getJID() << std::endl; + SWIFT_LOG(debug) << "Received disco item " << item.getJID(); walkNode(item.getJID()); } } } markNodeCompleted(request->getReceiver()); } void DiscoServiceWalker::handleDiscoError(const JID& jid, ErrorPayload::ref /*error*/) { - SWIFT_LOG(debug) << "Disco error from " << jid << std::endl; + SWIFT_LOG(debug) << "Disco error from " << jid; markNodeCompleted(jid); } void DiscoServiceWalker::markNodeCompleted(const JID& jid) { - SWIFT_LOG(debug) << "Node completed " << jid << std::endl; + SWIFT_LOG(debug) << "Node completed " << jid; servicesBeingSearched_.erase(jid); /* All results are in */ if (servicesBeingSearched_.empty()) { active_ = false; onWalkComplete(); } diff --git a/Swiften/Entity/PayloadPersister.cpp b/Swiften/Entity/PayloadPersister.cpp index 3fd246c..fe51d86 100644 --- a/Swiften/Entity/PayloadPersister.cpp +++ b/Swiften/Entity/PayloadPersister.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2011-2016 Isode Limited. + * Copyright (c) 2011-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Entity/PayloadPersister.h> @@ -31,13 +31,13 @@ void PayloadPersister::savePayload(std::shared_ptr<Payload> payload, const boost } boost::filesystem::ofstream file(path); file << getSerializer()->serialize(payload); file.close(); } catch (const boost::filesystem::filesystem_error& e) { - SWIFT_LOG(error) << e.what() << std::endl; + SWIFT_LOG(error) << e.what(); } } std::shared_ptr<Payload> PayloadPersister::loadPayload(const boost::filesystem::path& path) { try { if (boost::filesystem::exists(path)) { @@ -47,10 +47,10 @@ std::shared_ptr<Payload> PayloadPersister::loadPayload(const boost::filesystem:: PayloadParserTester tester(parser.get()); tester.parse(byteArrayToString(data)); return parser->getPayload(); } } catch (const boost::filesystem::filesystem_error& e) { - SWIFT_LOG(error) << e.what() << std::endl; + SWIFT_LOG(error) << e.what(); } return std::shared_ptr<Payload>(); } diff --git a/Swiften/EventLoop/DummyEventLoop.cpp b/Swiften/EventLoop/DummyEventLoop.cpp index 4712fad..234ba7a 100644 --- a/Swiften/EventLoop/DummyEventLoop.cpp +++ b/Swiften/EventLoop/DummyEventLoop.cpp @@ -12,13 +12,13 @@ namespace Swift { DummyEventLoop::DummyEventLoop() { } DummyEventLoop::~DummyEventLoop() { if (hasEvents()) { - SWIFT_LOG(warning) << "DummyEventLoop: Unhandled events at destruction time" << std::endl; + SWIFT_LOG(warning) << "DummyEventLoop: Unhandled events at destruction time"; } } void DummyEventLoop::processEvents() { while(hasEvents()) { hasEvents_ = false; diff --git a/Swiften/EventLoop/EventLoop.cpp b/Swiften/EventLoop/EventLoop.cpp index 31c93e9..1852f3f 100644 --- a/Swiften/EventLoop/EventLoop.cpp +++ b/Swiften/EventLoop/EventLoop.cpp @@ -19,16 +19,16 @@ namespace Swift { inline void invokeCallback(const Event& event) { try { assert(!event.callback.empty()); event.callback(); } catch (const std::exception& e) { - SWIFT_LOG(error) << "Uncaught exception in event loop: " << e.what() << std::endl; + SWIFT_LOG(error) << "Uncaught exception in event loop: " << e.what(); } catch (...) { - SWIFT_LOG(error) << "Uncaught non-exception in event loop" << std::endl; + SWIFT_LOG(error) << "Uncaught non-exception in event loop"; } } EventLoop::EventLoop() : nextEventID_(0), handlingEvents_(false) { } diff --git a/Swiften/Examples/SendFile/ReceiveFile.cpp b/Swiften/Examples/SendFile/ReceiveFile.cpp index 193c1b7..d641662 100644 --- a/Swiften/Examples/SendFile/ReceiveFile.cpp +++ b/Swiften/Examples/SendFile/ReceiveFile.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <iostream> #include <memory> @@ -77,13 +77,13 @@ class FileReceiver { client->getDiscoManager()->setCapsNode(CLIENT_NODE); client->getDiscoManager()->setDiscoInfo(discoInfo); client->getPresenceSender()->sendPresence(Presence::create()); } void handleIncomingFileTransfer(IncomingFileTransfer::ref transfer) { - SWIFT_LOG(debug) << "foo" << std::endl; + SWIFT_LOG(debug) << "foo"; incomingFileTransfers.push_back(transfer); std::shared_ptr<FileWriteBytestream> out = std::make_shared<FileWriteBytestream>("out"); transfer->onFinished.connect(boost::bind(&FileReceiver::handleFileTransferFinished, this, _1, out)); transfer->accept(out); } diff --git a/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp b/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp index c6987c0..ae3d7e0 100644 --- a/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp +++ b/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp @@ -1,8 +1,8 @@ /* - * 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/DefaultFileTransferTransporter.h> @@ -130,13 +130,13 @@ void DefaultFileTransferTransporter::stopTryingRemoteCandidates() { void DefaultFileTransferTransporter::handleActivateProxySessionResult(const std::string& sessionID, ErrorPayload::ref error) { onProxyActivated(sessionID, error); } void DefaultFileTransferTransporter::startActivatingProxy(const JID& proxyServiceJID) { // activate proxy - SWIFT_LOG(debug) << "Start activating proxy " << proxyServiceJID.toString() << " with sid = " << s5bSessionID << "." << std::endl; + SWIFT_LOG(debug) << "Start activating proxy " << proxyServiceJID.toString() << " with sid = " << s5bSessionID << "."; S5BProxyRequest::ref proxyRequest = std::make_shared<S5BProxyRequest>(); proxyRequest->setSID(s5bSessionID); proxyRequest->setActivate(role == Initiator ? responder : initiator); std::shared_ptr<GenericRequest<S5BProxyRequest> > request = std::make_shared<GenericRequest<S5BProxyRequest> >(IQ::Set, proxyServiceJID, proxyRequest, router); request->onResponse.connect(boost::bind(&DefaultFileTransferTransporter::handleActivateProxySessionResult, this, s5bSessionID, _2)); @@ -204,13 +204,13 @@ std::shared_ptr<TransportSession> DefaultFileTransferTransporter::createLocalCan if (candidate.type == JingleS5BTransportPayload::Candidate::ProxyType) { SOCKS5BytestreamClientSession::ref proxySession = s5bProxy->getProxySessionAndCloseOthers(candidate.jid, getLocalCandidateSOCKS5DstAddr()); if (proxySession) { transportSession = std::make_shared<S5BTransportSession<SOCKS5BytestreamClientSession> >(proxySession, stream); } else { - SWIFT_LOG(error) << "Failed obtaining proxy session with candidate JID " << candidate.jid << " and dstAddr " << getLocalCandidateSOCKS5DstAddr() << "." << std::endl; + SWIFT_LOG(error) << "Failed obtaining proxy session with candidate JID " << candidate.jid << " and dstAddr " << getLocalCandidateSOCKS5DstAddr() << "."; } } if (!transportSession) { std::shared_ptr<SOCKS5BytestreamServerSession> serverSession = getServerSession(); if (serverSession) { @@ -231,13 +231,13 @@ std::shared_ptr<TransportSession> DefaultFileTransferTransporter::createLocalCan if (candidate.type == JingleS5BTransportPayload::Candidate::ProxyType) { SOCKS5BytestreamClientSession::ref proxySession = s5bProxy->getProxySessionAndCloseOthers(candidate.jid, getLocalCandidateSOCKS5DstAddr()); if (proxySession) { transportSession = std::make_shared<S5BTransportSession<SOCKS5BytestreamClientSession> >(proxySession, stream); } else { - SWIFT_LOG(error) << "Failed obtaining proxy session with candidate JID " << candidate.jid << " and dstAddr " << getLocalCandidateSOCKS5DstAddr() << "." << std::endl; + SWIFT_LOG(error) << "Failed obtaining proxy session with candidate JID " << candidate.jid << " and dstAddr " << getLocalCandidateSOCKS5DstAddr() << "."; } } if (!transportSession) { std::shared_ptr<SOCKS5BytestreamServerSession> serverSession = getServerSession(); if (serverSession) { @@ -252,17 +252,17 @@ std::shared_ptr<TransportSession> DefaultFileTransferTransporter::createLocalCan } std::string DefaultFileTransferTransporter::getSOCKS5DstAddr() const { std::string result; if (role == Initiator) { result = getInitiatorCandidateSOCKS5DstAddr(); - SWIFT_LOG(debug) << "Initiator S5B DST.ADDR = " << s5bSessionID << " + " << initiator.toString() << " + " << responder.toString() << " : " << result << std::endl; + SWIFT_LOG(debug) << "Initiator S5B DST.ADDR = " << s5bSessionID << " + " << initiator.toString() << " + " << responder.toString() << " : " << result; } else { result = getResponderCandidateSOCKS5DstAddr(); - SWIFT_LOG(debug) << "Responder S5B DST.ADDR = " << s5bSessionID << " + " << responder.toString() << " + " << initiator.toString() << " : " << result << std::endl; + SWIFT_LOG(debug) << "Responder S5B DST.ADDR = " << s5bSessionID << " + " << responder.toString() << " + " << initiator.toString() << " : " << result; } return result; } std::string DefaultFileTransferTransporter::getInitiatorCandidateSOCKS5DstAddr() const { return Hexify::hexify(crypto->getSHA1Hash(createSafeByteArray(s5bSessionID + initiator.toString() + responder.toString()))); diff --git a/Swiften/FileTransfer/FailingTransportSession.cpp b/Swiften/FileTransfer/FailingTransportSession.cpp index d1eb6a6..b9c79a0 100644 --- a/Swiften/FileTransfer/FailingTransportSession.cpp +++ b/Swiften/FileTransfer/FailingTransportSession.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2016 Isode Limited. + * Copyright (c) 2016-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/FileTransfer/FailingTransportSession.h> @@ -11,13 +11,13 @@ namespace Swift { FailingTransportSession::~FailingTransportSession() { } void FailingTransportSession::start() { - SWIFT_LOG(error) << "Trying to start failing transport." << std::endl; + SWIFT_LOG(error) << "Trying to start failing transport."; onFinished(FileTransferError(FileTransferError::PeerError)); } void FailingTransportSession::stop() { } diff --git a/Swiften/FileTransfer/FileTransferManagerImpl.cpp b/Swiften/FileTransfer/FileTransferManagerImpl.cpp index 05dd3bb..98eb50e 100644 --- a/Swiften/FileTransfer/FileTransferManagerImpl.cpp +++ b/Swiften/FileTransfer/FileTransferManagerImpl.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/FileTransferManagerImpl.h> @@ -153,13 +153,13 @@ OutgoingFileTransfer::ref FileTransferManagerImpl::createOutgoingFileTransfer( } if (!capabilities->hasFeature(DiscoInfo::JingleTransportsIBBFeature)) { options = options.withInBandAllowed(false); } } else { - SWIFT_LOG(warning) << "No entity capabilities information for " << receipient.toString() << std::endl; + SWIFT_LOG(warning) << "No entity capabilities information for " << receipient.toString(); } return outgoingFTManager->createOutgoingFileTransfer(iqRouter->getJID(), receipient, bytestream, fileInfo, options); } } diff --git a/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp b/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp index d5de5e4..7c46c60 100644 --- a/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp +++ b/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2011-2016 Isode Limited. + * Copyright (c) 2011-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/FileTransfer/IncomingJingleFileTransfer.h> @@ -64,14 +64,14 @@ IncomingJingleFileTransfer::~IncomingJingleFileTransfer() { hashCalculator = nullptr; } void IncomingJingleFileTransfer::accept( std::shared_ptr<WriteBytestream> stream, const FileTransferOptions& options) { - SWIFT_LOG(debug) << std::endl; - if (state != Initial) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } + SWIFT_LOG(debug); + if (state != Initial) { SWIFT_LOG(warning) << "Incorrect state"; return; } assert(!this->stream); this->stream = stream; this->options = options; assert(!hashCalculator); @@ -82,21 +82,21 @@ void IncomingJingleFileTransfer::accept( writeStreamDataReceivedConnection = stream->onWrite.connect( boost::bind(&IncomingJingleFileTransfer::handleWriteStreamDataReceived, this, _1)); JingleS5BTransportPayload::ref s5bTransport = initialContent->getTransport<JingleS5BTransportPayload>(); JingleIBBTransportPayload::ref ibbTransport = initialContent->getTransport<JingleIBBTransportPayload>(); if (s5bTransport) { - SWIFT_LOG(debug) << "Got S5B transport as initial payload." << std::endl; + SWIFT_LOG(debug) << "Got S5B transport as initial payload."; setTransporter(transporterFactory->createResponderTransporter( getInitiator(), getResponder(), s5bTransport->getSessionID(), options)); transporter->addRemoteCandidates(s5bTransport->getCandidates(), s5bTransport->getDstAddr()); setState(GeneratingInitialLocalCandidates); transporter->startGeneratingLocalCandidates(); } else if (ibbTransport && options.isInBandAllowed()) { - SWIFT_LOG(debug) << "Got IBB transport as initial payload." << std::endl; + SWIFT_LOG(debug) << "Got IBB transport as initial payload."; setTransporter(transporterFactory->createResponderTransporter( getInitiator(), getResponder(), ibbTransport->getSessionID(), options)); startTransferring(transporter->createIBBReceiveSession( ibbTransport->getSessionID(), description->getFileInfo().getSize(), @@ -109,22 +109,22 @@ void IncomingJingleFileTransfer::accept( session->sendTerminate(JinglePayload::Reason::UnsupportedTransports); setFinishedState(FileTransfer::State::Failed, FileTransferError(FileTransferError::PeerError)); } } void IncomingJingleFileTransfer::cancel() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); terminate(state == Initial ? JinglePayload::Reason::Decline : JinglePayload::Reason::Cancel); } void IncomingJingleFileTransfer::handleLocalTransportCandidatesGenerated( const std::string& s5bSessionID, const std::vector<JingleS5BTransportPayload::Candidate>& candidates, const std::string& dstAddr) { - SWIFT_LOG(debug) << std::endl; - if (state != GeneratingInitialLocalCandidates) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } + SWIFT_LOG(debug); + if (state != GeneratingInitialLocalCandidates) { SWIFT_LOG(warning) << "Incorrect state"; return; } fillCandidateMap(localCandidates, candidates); JingleS5BTransportPayload::ref transport = std::make_shared<JingleS5BTransportPayload>(); transport->setSessionID(s5bSessionID); transport->setMode(JingleS5BTransportPayload::TCPMode); @@ -137,39 +137,39 @@ void IncomingJingleFileTransfer::handleLocalTransportCandidatesGenerated( setState(TryingCandidates); transporter->startTryingRemoteCandidates(); } void IncomingJingleFileTransfer::handleSessionInfoReceived(JinglePayload::ref jinglePayload) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); JingleFileTransferHash::ref transferHash = jinglePayload->getPayload<JingleFileTransferHash>(); if (transferHash) { - SWIFT_LOG(debug) << "Received hash information." << std::endl; + SWIFT_LOG(debug) << "Received hash information."; waitOnHashTimer->stop(); if (transferHash->getFileInfo().getHashes().find("sha-1") != transferHash->getFileInfo().getHashes().end()) { hashes["sha-1"] = transferHash->getFileInfo().getHash("sha-1").get(); } if (transferHash->getFileInfo().getHashes().find("md5") != transferHash->getFileInfo().getHashes().end()) { hashes["md5"] = transferHash->getFileInfo().getHash("md5").get(); } if (state == WaitingForHash) { checkHashAndTerminate(); } } else { - SWIFT_LOG(debug) << "Ignoring unknown session info" << std::endl; + SWIFT_LOG(debug) << "Ignoring unknown session info"; } } void IncomingJingleFileTransfer::handleSessionTerminateReceived(boost::optional<JinglePayload::Reason> reason) { - SWIFT_LOG(debug) << std::endl; - if (state == Finished) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } + SWIFT_LOG(debug); + if (state == Finished) { SWIFT_LOG(warning) << "Incorrect state"; return; } if (state == Finished) { - SWIFT_LOG(debug) << "Already terminated" << std::endl; + SWIFT_LOG(debug) << "Already terminated"; return; } stopAll(); if (reason && reason->type == JinglePayload::Reason::Cancel) { setFinishedState(FileTransfer::State::Canceled, FileTransferError(FileTransferError::PeerError)); @@ -184,36 +184,36 @@ void IncomingJingleFileTransfer::handleSessionTerminateReceived(boost::optional< void IncomingJingleFileTransfer::checkHashAndTerminate() { if (verifyData()) { terminate(JinglePayload::Reason::Success); } else { - SWIFT_LOG(warning) << "Hash verification failed" << std::endl; + SWIFT_LOG(warning) << "Hash verification failed"; terminate(JinglePayload::Reason::MediaError); } } void IncomingJingleFileTransfer::checkIfAllDataReceived() { if (receivedBytes == getFileSizeInBytes()) { - SWIFT_LOG(debug) << "All data received." << std::endl; + SWIFT_LOG(debug) << "All data received."; bool hashInfoAvailable = false; for (const auto& hashElement : hashes) { hashInfoAvailable |= !hashElement.second.empty(); } if (!hashInfoAvailable) { - SWIFT_LOG(debug) << "No hash information yet. Waiting a while on hash info." << std::endl; + SWIFT_LOG(debug) << "No hash information yet. Waiting a while on hash info."; setState(WaitingForHash); waitOnHashTimer->start(); } else { checkHashAndTerminate(); } } else if (receivedBytes > getFileSizeInBytes()) { - SWIFT_LOG(debug) << "We got more than we could handle!" << std::endl; + SWIFT_LOG(debug) << "We got more than we could handle!"; terminate(JinglePayload::Reason::MediaError); } } void IncomingJingleFileTransfer::handleWriteStreamDataReceived( const std::vector<unsigned char>& data) { @@ -222,59 +222,59 @@ void IncomingJingleFileTransfer::handleWriteStreamDataReceived( onProcessedBytes(data.size()); checkIfAllDataReceived(); } void IncomingJingleFileTransfer::handleTransportReplaceReceived( const JingleContentID& content, JingleTransportPayload::ref transport) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); if (state != WaitingForFallbackOrTerminate) { - SWIFT_LOG(warning) << "Incorrect state" << std::endl; + SWIFT_LOG(warning) << "Incorrect state"; return; } JingleIBBTransportPayload::ref ibbTransport; if (options.isInBandAllowed() && (ibbTransport = std::dynamic_pointer_cast<JingleIBBTransportPayload>(transport))) { - SWIFT_LOG(debug) << "transport replaced with IBB" << std::endl; + SWIFT_LOG(debug) << "transport replaced with IBB"; startTransferring(transporter->createIBBReceiveSession( ibbTransport->getSessionID(), description->getFileInfo().getSize(), stream)); session->sendTransportAccept(content, ibbTransport); } else { - SWIFT_LOG(debug) << "Unknown replace transport" << std::endl; + SWIFT_LOG(debug) << "Unknown replace transport"; session->sendTransportReject(content, transport); } } JingleContentID IncomingJingleFileTransfer::getContentID() const { return JingleContentID(initialContent->getName(), initialContent->getCreator()); } bool IncomingJingleFileTransfer::verifyData() { if (hashes.empty()) { - SWIFT_LOG(debug) << "no verification possible, skipping" << std::endl; + SWIFT_LOG(debug) << "no verification possible, skipping"; return true; } if (hashes.find("sha-1") != hashes.end()) { - SWIFT_LOG(debug) << "Verify SHA-1 hash: " << (hashes["sha-1"] == hashCalculator->getSHA1Hash()) << std::endl; + SWIFT_LOG(debug) << "Verify SHA-1 hash: " << (hashes["sha-1"] == hashCalculator->getSHA1Hash()); return hashes["sha-1"] == hashCalculator->getSHA1Hash(); } else if (hashes.find("md5") != hashes.end()) { - SWIFT_LOG(debug) << "Verify MD5 hash: " << (hashes["md5"] == hashCalculator->getMD5Hash()) << std::endl; + SWIFT_LOG(debug) << "Verify MD5 hash: " << (hashes["md5"] == hashCalculator->getMD5Hash()); return hashes["md5"] == hashCalculator->getMD5Hash(); } else { - SWIFT_LOG(debug) << "Unknown hash, skipping" << std::endl; + SWIFT_LOG(debug) << "Unknown hash, skipping"; return true; } } void IncomingJingleFileTransfer::handleWaitOnHashTimerTicked() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); waitOnHashTimer->stop(); terminate(JinglePayload::Reason::Success); } const JID& IncomingJingleFileTransfer::getSender() const { return getInitiator(); @@ -282,20 +282,20 @@ const JID& IncomingJingleFileTransfer::getSender() const { const JID& IncomingJingleFileTransfer::getRecipient() const { return getResponder(); } void IncomingJingleFileTransfer::setState(State state) { - SWIFT_LOG(debug) << state << std::endl; + SWIFT_LOG(debug) << state; this->state = state; onStateChanged(FileTransfer::State(getExternalState(state))); } void IncomingJingleFileTransfer::setFinishedState( FileTransfer::State::Type type, const boost::optional<FileTransferError>& error) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); this->state = Finished; onStateChanged(type); onFinished(error); } void IncomingJingleFileTransfer::handleTransferFinished(boost::optional<FileTransferError> error) { @@ -337,13 +337,13 @@ void IncomingJingleFileTransfer::stopAll() { case Transferring: assert(transportSession); transferFinishedConnection.disconnect(); transportSession->stop(); transportSession.reset(); break; - case Finished: SWIFT_LOG(warning) << "Already finished" << std::endl; break; + case Finished: SWIFT_LOG(warning) << "Already finished"; break; } if (state != Initial) { removeTransporter(); } } @@ -353,36 +353,36 @@ bool IncomingJingleFileTransfer::hasPriorityOnCandidateTie() const { void IncomingJingleFileTransfer::fallback() { setState(WaitingForFallbackOrTerminate); } void IncomingJingleFileTransfer::startTransferViaRemoteCandidate() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); if (ourCandidateChoice->type == JingleS5BTransportPayload::Candidate::ProxyType) { setState(WaitingForPeerProxyActivate); } else { startTransferring(createRemoteCandidateSession()); } } void IncomingJingleFileTransfer::startTransferViaLocalCandidate() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); if (theirCandidateChoice->type == JingleS5BTransportPayload::Candidate::ProxyType) { setState(WaitingForLocalProxyActivate); transporter->startActivatingProxy(theirCandidateChoice->jid); } else { startTransferring(createLocalCandidateSession()); } } void IncomingJingleFileTransfer::startTransferring(std::shared_ptr<TransportSession> transportSession) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); this->transportSession = transportSession; transferFinishedConnection = transportSession->onFinished.connect( boost::bind(&IncomingJingleFileTransfer::handleTransferFinished, this, _1)); setState(Transferring); transportSession->start(); @@ -406,13 +406,13 @@ std::shared_ptr<TransportSession> IncomingJingleFileTransfer::createLocalCandida std::shared_ptr<TransportSession> IncomingJingleFileTransfer::createRemoteCandidateSession() { return transporter->createRemoteCandidateSession(stream, ourCandidateChoice.get()); } void IncomingJingleFileTransfer::terminate(JinglePayload::Reason::Type reason) { - SWIFT_LOG(debug) << reason << std::endl; + SWIFT_LOG(debug) << reason; if (state != Finished) { session->sendTerminate(reason); } stopAll(); setFinishedState(getExternalFinishedState(reason), getFileTransferError(reason)); diff --git a/Swiften/FileTransfer/JingleFileTransfer.cpp b/Swiften/FileTransfer/JingleFileTransfer.cpp index cc1cd1c..3d05db9 100644 --- a/Swiften/FileTransfer/JingleFileTransfer.cpp +++ b/Swiften/FileTransfer/JingleFileTransfer.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2013-2018 Isode Limited. + * Copyright (c) 2013-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/FileTransfer/JingleFileTransfer.h> @@ -75,13 +75,13 @@ boost::optional<FileTransferError> JingleFileTransfer::getFileTransferError(Jing return boost::optional<FileTransferError>(FileTransferError::UnknownError); } } void JingleFileTransfer::handleRemoteTransportCandidateSelectFinished( const std::string& s5bSessionID, const boost::optional<JingleS5BTransportPayload::Candidate>& candidate) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); ourCandidateChoice = candidate; ourCandidateSelectFinished = true; JingleS5BTransportPayload::ref s5bPayload = std::make_shared<JingleS5BTransportPayload>(); s5bPayload->setSessionID(s5bSessionID); @@ -95,61 +95,61 @@ void JingleFileTransfer::handleRemoteTransportCandidateSelectFinished( decideOnCandidates(); } // decide on candidates according to http://xmpp.org/extensions/xep-0260.html#complete void JingleFileTransfer::decideOnCandidates() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); if (!ourCandidateSelectFinished || !theirCandidateSelectFinished) { - SWIFT_LOG(debug) << "Can't make a decision yet!" << std::endl; + SWIFT_LOG(debug) << "Can't make a decision yet!"; return; } if (!ourCandidateChoice && !theirCandidateChoice) { - SWIFT_LOG(debug) << "No candidates succeeded." << std::endl; + SWIFT_LOG(debug) << "No candidates succeeded."; fallback(); } else if (ourCandidateChoice && !theirCandidateChoice) { - SWIFT_LOG(debug) << "Start transfer using remote candidate: " << ourCandidateChoice.get().cid << "." << std::endl; + SWIFT_LOG(debug) << "Start transfer using remote candidate: " << ourCandidateChoice.get().cid << "."; startTransferViaRemoteCandidate(); } else if (theirCandidateChoice && !ourCandidateChoice) { - SWIFT_LOG(debug) << "Start transfer using local candidate: " << theirCandidateChoice.get().cid << "." << std::endl; + SWIFT_LOG(debug) << "Start transfer using local candidate: " << theirCandidateChoice.get().cid << "."; startTransferViaLocalCandidate(); } else { SWIFT_LOG(debug) << "Choosing between candidates " << ourCandidateChoice->cid << "(" << ourCandidateChoice->priority << ")" << " and " - << theirCandidateChoice->cid << "(" << theirCandidateChoice->priority << ")" << std::endl; + << theirCandidateChoice->cid << "(" << theirCandidateChoice->priority << ")"; if (ourCandidateChoice->priority > theirCandidateChoice->priority) { - SWIFT_LOG(debug) << "Start transfer using remote candidate: " << ourCandidateChoice.get().cid << "." << std::endl; + SWIFT_LOG(debug) << "Start transfer using remote candidate: " << ourCandidateChoice.get().cid << "."; startTransferViaRemoteCandidate(); } else if (ourCandidateChoice->priority < theirCandidateChoice->priority) { - SWIFT_LOG(debug) << "Start transfer using local candidate:" << theirCandidateChoice.get().cid << "." << std::endl; + SWIFT_LOG(debug) << "Start transfer using local candidate:" << theirCandidateChoice.get().cid << "."; startTransferViaLocalCandidate(); } else { if (hasPriorityOnCandidateTie()) { - SWIFT_LOG(debug) << "Start transfer using remote candidate: " << ourCandidateChoice.get().cid << std::endl; + SWIFT_LOG(debug) << "Start transfer using remote candidate: " << ourCandidateChoice.get().cid; startTransferViaRemoteCandidate(); } else { - SWIFT_LOG(debug) << "Start transfer using local candidate: " << theirCandidateChoice.get().cid << std::endl; + SWIFT_LOG(debug) << "Start transfer using local candidate: " << theirCandidateChoice.get().cid; startTransferViaLocalCandidate(); } } } } void JingleFileTransfer::handleProxyActivateFinished( const std::string& s5bSessionID, ErrorPayload::ref error) { - SWIFT_LOG(debug) << std::endl; - if (!isWaitingForLocalProxyActivate()) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } + SWIFT_LOG(debug); + if (!isWaitingForLocalProxyActivate()) { SWIFT_LOG(warning) << "Incorrect state"; return; } if (error) { - SWIFT_LOG(debug) << "Error activating proxy" << std::endl; + SWIFT_LOG(debug) << "Error activating proxy"; JingleS5BTransportPayload::ref proxyError = std::make_shared<JingleS5BTransportPayload>(); proxyError->setSessionID(s5bSessionID); proxyError->setProxyError(true); session->sendTransportInfo(getContentID(), proxyError); fallback(); } @@ -161,53 +161,53 @@ void JingleFileTransfer::handleProxyActivateFinished( startTransferring(createLocalCandidateSession()); } } void JingleFileTransfer::handleTransportInfoReceived( const JingleContentID& /* contentID */, JingleTransportPayload::ref transport) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); if (JingleS5BTransportPayload::ref s5bPayload = std::dynamic_pointer_cast<JingleS5BTransportPayload>(transport)) { if (s5bPayload->hasCandidateError() || !s5bPayload->getCandidateUsed().empty()) { - SWIFT_LOG(debug) << "Received candidate decision from peer" << std::endl; - if (!isTryingCandidates()) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } + SWIFT_LOG(debug) << "Received candidate decision from peer"; + if (!isTryingCandidates()) { SWIFT_LOG(warning) << "Incorrect state"; return; } theirCandidateSelectFinished = true; if (!s5bPayload->hasCandidateError()) { auto theirCandidate = localCandidates.find(s5bPayload->getCandidateUsed()); if (theirCandidate == localCandidates.end()) { - SWIFT_LOG(warning) << "Got invalid candidate" << std::endl; + SWIFT_LOG(warning) << "Got invalid candidate"; terminate(JinglePayload::Reason::GeneralError); return; } theirCandidateChoice = theirCandidate->second; } decideOnCandidates(); } else if (!s5bPayload->getActivated().empty()) { - SWIFT_LOG(debug) << "Received peer activate from peer" << std::endl; - if (!isWaitingForPeerProxyActivate()) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } + SWIFT_LOG(debug) << "Received peer activate from peer"; + if (!isWaitingForPeerProxyActivate()) { SWIFT_LOG(warning) << "Incorrect state"; return; } if (ourCandidateChoice->cid == s5bPayload->getActivated()) { startTransferring(createRemoteCandidateSession()); } else { - SWIFT_LOG(warning) << "ourCandidateChoice doesn't match activated proxy candidate!" << std::endl; + SWIFT_LOG(warning) << "ourCandidateChoice doesn't match activated proxy candidate!"; terminate(JinglePayload::Reason::GeneralError); } } else if (s5bPayload->hasProxyError()) { - SWIFT_LOG(debug) << "Received proxy error. Trying to fall back to IBB." << std::endl; + SWIFT_LOG(debug) << "Received proxy error. Trying to fall back to IBB."; fallback(); } else { - SWIFT_LOG(debug) << "Ignoring unknown info" << std::endl; + SWIFT_LOG(debug) << "Ignoring unknown info"; } } else { - SWIFT_LOG(debug) << "Ignoring unknown info" << std::endl; + SWIFT_LOG(debug) << "Ignoring unknown info"; } } void JingleFileTransfer::setTransporter(FileTransferTransporter* transporter) { SWIFT_LOG_ASSERT(!this->transporter, error); this->transporter = transporter; diff --git a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp index 834a401..7cb4cbb 100644 --- a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp +++ b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.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/LocalJingleTransportCandidateGenerator.h> @@ -42,13 +42,13 @@ LocalJingleTransportCandidateGenerator::LocalJingleTransportCandidateGenerator( triedForwarding_(false), triedProxyDiscovery_(false), options_(options) { } LocalJingleTransportCandidateGenerator::~LocalJingleTransportCandidateGenerator() { - SWIFT_LOG_ASSERT(!s5bServerInitializeRequest, warning) << std::endl; + SWIFT_LOG_ASSERT(!s5bServerInitializeRequest, warning); } void LocalJingleTransportCandidateGenerator::start() { assert(!s5bServerInitializeRequest); if (options_.isDirectAllowed() || options_.isAssistedAllowed()) { s5bServerResourceUser_ = s5bServerManager->aquireResourceUser(); @@ -95,13 +95,13 @@ void LocalJingleTransportCandidateGenerator::handleS5BServerInitialized(bool suc if (s5bServerPortForwardingUser_->isForwardingSetup()) { handlePortForwardingSetup(true); } } } else { - SWIFT_LOG(warning) << "Unable to start SOCKS5 server" << std::endl; + SWIFT_LOG(warning) << "Unable to start SOCKS5 server"; if (s5bServerResourceUser_) { s5bServerResourceUser_->onSuccessfulInitialized.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handleS5BServerInitialized, this, _1)); } s5bServerResourceUser_.reset(); handlePortForwardingSetup(false); } diff --git a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp index 367fc97..57a18a8 100644 --- a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp +++ b/Swiften/FileTransfer/OutgoingJingleFileTransfer.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. */ // TODO: // - We should handle incoming terminates after we have terminated, so the other @@ -84,15 +84,15 @@ OutgoingJingleFileTransfer::~OutgoingJingleFileTransfer() { delete hashCalculator; hashCalculator = nullptr; removeTransporter(); } void OutgoingJingleFileTransfer::start() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); if (state != Initial) { - SWIFT_LOG(warning) << "Incorrect state" << std::endl; + SWIFT_LOG(warning) << "Incorrect state"; return; } if (!options.isInBandAllowed() && !options.isDirectAllowed() && !options.isAssistedAllowed() && !options.isProxiedAllowed()) { // Started outgoing file transfer while not supporting transport methods. setFinishedState(FileTransfer::State::Failed, FileTransferError(FileTransferError::UnknownError)); @@ -106,45 +106,45 @@ void OutgoingJingleFileTransfer::start() { void OutgoingJingleFileTransfer::cancel() { terminate(JinglePayload::Reason::Cancel); } void OutgoingJingleFileTransfer::terminate(JinglePayload::Reason::Type reason) { - SWIFT_LOG(debug) << reason << std::endl; + SWIFT_LOG(debug) << reason; if (state != Initial && state != GeneratingInitialLocalCandidates && state != Finished) { session->sendTerminate(reason); } stopAll(); setFinishedState(getExternalFinishedState(reason), getFileTransferError(reason)); } void OutgoingJingleFileTransfer::handleSessionAcceptReceived( const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref transportPayload) { - SWIFT_LOG(debug) << std::endl; - if (state != WaitingForAccept) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } + SWIFT_LOG(debug); + if (state != WaitingForAccept) { SWIFT_LOG(warning) << "Incorrect state"; return; } if (JingleS5BTransportPayload::ref s5bPayload = std::dynamic_pointer_cast<JingleS5BTransportPayload>(transportPayload)) { transporter->addRemoteCandidates(s5bPayload->getCandidates(), s5bPayload->getDstAddr()); setInternalState(TryingCandidates); transporter->startTryingRemoteCandidates(); } else if (JingleIBBTransportPayload::ref ibbPayload = std::dynamic_pointer_cast<JingleIBBTransportPayload>(transportPayload)) { startTransferring(transporter->createIBBSendSession(ibbPayload->getSessionID(), ibbPayload->getBlockSize().get_value_or(DEFAULT_BLOCK_SIZE), stream)); } else { - SWIFT_LOG(debug) << "Unknown transport payload. Falling back." << std::endl; + SWIFT_LOG(debug) << "Unknown transport payload. Falling back."; fallback(); } } void OutgoingJingleFileTransfer::handleSessionTerminateReceived(boost::optional<JinglePayload::Reason> reason) { - SWIFT_LOG(debug) << std::endl; - if (state == Finished) { SWIFT_LOG(warning) << "Incorrect state: " << state << std::endl; return; } + SWIFT_LOG(debug); + if (state == Finished) { SWIFT_LOG(warning) << "Incorrect state: " << state; return; } stopAll(); if (state == WaitForTermination) { waitForRemoteTermination->stop(); } if (reason && reason->type == JinglePayload::Reason::Cancel) { @@ -159,92 +159,92 @@ void OutgoingJingleFileTransfer::handleSessionTerminateReceived(boost::optional< else { setFinishedState(FileTransfer::State::Failed, FileTransferError(FileTransferError::PeerError)); } } void OutgoingJingleFileTransfer::handleTransportAcceptReceived(const JingleContentID&, JingleTransportPayload::ref transport) { - SWIFT_LOG(debug) << std::endl; - if (state != FallbackRequested) { SWIFT_LOG(warning) << "Incorrect state" << std::endl; return; } + SWIFT_LOG(debug); + if (state != FallbackRequested) { SWIFT_LOG(warning) << "Incorrect state"; return; } if (JingleIBBTransportPayload::ref ibbPayload = std::dynamic_pointer_cast<JingleIBBTransportPayload>(transport)) { startTransferring(transporter->createIBBSendSession(ibbPayload->getSessionID(), ibbPayload->getBlockSize().get_value_or(DEFAULT_BLOCK_SIZE), stream)); } else { - SWIFT_LOG(debug) << "Unknown transport replacement" << std::endl; + SWIFT_LOG(debug) << "Unknown transport replacement"; terminate(JinglePayload::Reason::FailedTransport); } } void OutgoingJingleFileTransfer::handleTransportRejectReceived(const JingleContentID &, std::shared_ptr<JingleTransportPayload>) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); terminate(JinglePayload::Reason::UnsupportedTransports); } void OutgoingJingleFileTransfer::sendSessionInfoHash() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); JingleFileTransferHash::ref hashElement = std::make_shared<JingleFileTransferHash>(); hashElement->getFileInfo().addHash(HashElement("sha-1", hashCalculator->getSHA1Hash())); hashElement->getFileInfo().addHash(HashElement("md5", hashCalculator->getMD5Hash())); session->sendInfo(hashElement); } void OutgoingJingleFileTransfer::handleLocalTransportCandidatesGenerated( const std::string& s5bSessionID, const std::vector<JingleS5BTransportPayload::Candidate>& candidates, const std::string& dstAddr) { - SWIFT_LOG(debug) << std::endl; - if (state != GeneratingInitialLocalCandidates) { SWIFT_LOG(warning) << "Incorrect state: " << state << std::endl; return; } + SWIFT_LOG(debug); + if (state != GeneratingInitialLocalCandidates) { SWIFT_LOG(warning) << "Incorrect state: " << state; return; } fillCandidateMap(localCandidates, candidates); JingleFileTransferDescription::ref description = std::make_shared<JingleFileTransferDescription>(); fileInfo.addHash(HashElement("sha-1", ByteArray())); fileInfo.addHash(HashElement("md5", ByteArray())); description->setFileInfo(fileInfo); JingleTransportPayload::ref transport; if (candidates.empty()) { - SWIFT_LOG(debug) << "no S5B candidates generated. Send IBB transport candidate." << std::endl; + SWIFT_LOG(debug) << "no S5B candidates generated. Send IBB transport candidate."; JingleIBBTransportPayload::ref ibbTransport = std::make_shared<JingleIBBTransportPayload>(); ibbTransport->setBlockSize(DEFAULT_BLOCK_SIZE); ibbTransport->setSessionID(idGenerator->generateID()); transport = ibbTransport; } else { JingleS5BTransportPayload::ref s5bTransport = std::make_shared<JingleS5BTransportPayload>(); s5bTransport->setSessionID(s5bSessionID); s5bTransport->setMode(JingleS5BTransportPayload::TCPMode); s5bTransport->setDstAddr(dstAddr); for (auto&& candidate : candidates) { s5bTransport->addCandidate(candidate); - SWIFT_LOG(debug) << "\t" << "S5B candidate: " << candidate.hostPort.toString() << std::endl; + SWIFT_LOG(debug) << "\t" << "S5B candidate: " << candidate.hostPort.toString(); } transport = s5bTransport; } setInternalState(WaitingForAccept); session->sendInitiate(contentID, description, transport); } void OutgoingJingleFileTransfer::fallback() { if (options.isInBandAllowed()) { - SWIFT_LOG(debug) << "Trying to fallback to IBB transport." << std::endl; + SWIFT_LOG(debug) << "Trying to fallback to IBB transport."; JingleIBBTransportPayload::ref ibbTransport = std::make_shared<JingleIBBTransportPayload>(); ibbTransport->setBlockSize(DEFAULT_BLOCK_SIZE); ibbTransport->setSessionID(idGenerator->generateID()); setInternalState(FallbackRequested); session->sendTransportReplace(contentID, ibbTransport); } else { - SWIFT_LOG(debug) << "Fallback to IBB transport not allowed." << std::endl; + SWIFT_LOG(debug) << "Fallback to IBB transport not allowed."; terminate(JinglePayload::Reason::ConnectivityError); } } void OutgoingJingleFileTransfer::handleTransferFinished(boost::optional<FileTransferError> error) { - SWIFT_LOG(debug) << std::endl; - if (state != Transferring) { SWIFT_LOG(warning) << "Incorrect state: " << state << std::endl; return; } + SWIFT_LOG(debug); + if (state != Transferring) { SWIFT_LOG(warning) << "Incorrect state: " << state; return; } if (error) { terminate(JinglePayload::Reason::ConnectivityError); } else { sendSessionInfoHash(); @@ -253,33 +253,33 @@ void OutgoingJingleFileTransfer::handleTransferFinished(boost::optional<FileTran setInternalState(WaitForTermination); waitForRemoteTermination->start(); } } void OutgoingJingleFileTransfer::startTransferring(std::shared_ptr<TransportSession> transportSession) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); this->transportSession = transportSession; processedBytesConnection = transportSession->onBytesSent.connect( boost::bind(boost::ref(onProcessedBytes), _1)); transferFinishedConnection = transportSession->onFinished.connect( boost::bind(&OutgoingJingleFileTransfer::handleTransferFinished, this, _1)); setInternalState(Transferring); transportSession->start(); } void OutgoingJingleFileTransfer::setInternalState(State state) { - SWIFT_LOG(debug) << state << std::endl; + SWIFT_LOG(debug) << state; this->state = state; setState(FileTransfer::State(getExternalState(state))); } void OutgoingJingleFileTransfer::setFinishedState( FileTransfer::State::Type type, const boost::optional<FileTransferError>& error) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); this->state = Finished; onStateChanged(type); onFinished(error); } FileTransfer::State::Type OutgoingJingleFileTransfer::getExternalState(State state) { @@ -298,15 +298,15 @@ FileTransfer::State::Type OutgoingJingleFileTransfer::getExternalState(State sta } assert(false); return FileTransfer::State::Initial; } void OutgoingJingleFileTransfer::stopAll() { - SWIFT_LOG(debug) << state << std::endl; + SWIFT_LOG(debug) << state; switch (state) { - case Initial: SWIFT_LOG(warning) << "Not yet started" << std::endl; break; + case Initial: SWIFT_LOG(warning) << "Not yet started"; break; case GeneratingInitialLocalCandidates: transporter->stopGeneratingLocalCandidates(); break; case WaitingForAccept: break; case TryingCandidates: transporter->stopTryingRemoteCandidates(); break; case FallbackRequested: break; case WaitingForPeerProxyActivate: break; case WaitingForLocalProxyActivate: transporter->stopActivatingProxy(); break; @@ -317,33 +317,33 @@ void OutgoingJingleFileTransfer::stopAll() { transferFinishedConnection.disconnect(); transportSession->stop(); transportSession.reset(); break; case WaitForTermination: break; - case Finished: SWIFT_LOG(warning) << "Already finished" << std::endl; break; + case Finished: SWIFT_LOG(warning) << "Already finished"; break; } if (state != Initial) { removeTransporter(); } } void OutgoingJingleFileTransfer::startTransferViaRemoteCandidate() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); if (ourCandidateChoice->type == JingleS5BTransportPayload::Candidate::ProxyType) { setInternalState(WaitingForPeerProxyActivate); } else { transportSession = createRemoteCandidateSession(); startTransferringIfCandidateAcknowledged(); } } void OutgoingJingleFileTransfer::startTransferViaLocalCandidate() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); if (theirCandidateChoice->type == JingleS5BTransportPayload::Candidate::ProxyType) { setInternalState(WaitingForLocalProxyActivate); transporter->startActivatingProxy(theirCandidateChoice->jid); } else { @@ -397,11 +397,11 @@ std::shared_ptr<TransportSession> OutgoingJingleFileTransfer::createLocalCandida std::shared_ptr<TransportSession> OutgoingJingleFileTransfer::createRemoteCandidateSession() { return transporter->createRemoteCandidateSession(stream, ourCandidateChoice.get()); } void OutgoingJingleFileTransfer::handleWaitForRemoteTerminationTimeout() { assert(state == WaitForTermination); - SWIFT_LOG(warning) << "Other party did not terminate session. Terminate it now." << std::endl; + SWIFT_LOG(warning) << "Other party did not terminate session. Terminate it now."; waitForRemoteTermination->stop(); terminate(JinglePayload::Reason::MediaError); } diff --git a/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.cpp b/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.cpp index 56013ca..4023be3 100644 --- a/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.cpp +++ b/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.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/RemoteJingleTransportCandidateSelector.h> @@ -53,32 +53,32 @@ void RemoteJingleTransportCandidateSelector::stopSelectingCandidate() { s5bSession->stop(); } } void RemoteJingleTransportCandidateSelector::tryNextCandidate() { if (candidates.empty()) { - SWIFT_LOG(debug) << "No more candidates" << std::endl; + SWIFT_LOG(debug) << "No more candidates"; onCandidateSelectFinished( boost::optional<JingleS5BTransportPayload::Candidate>(), std::shared_ptr<SOCKS5BytestreamClientSession>()); } else { lastCandidate = candidates.top(); candidates.pop(); - SWIFT_LOG(debug) << "Trying candidate " << lastCandidate.cid << std::endl; + SWIFT_LOG(debug) << "Trying candidate " << lastCandidate.cid; if ((lastCandidate.type == JingleS5BTransportPayload::Candidate::DirectType && options.isDirectAllowed()) || (lastCandidate.type == JingleS5BTransportPayload::Candidate::AssistedType && options.isAssistedAllowed()) || (lastCandidate.type == JingleS5BTransportPayload::Candidate::ProxyType && options.isProxiedAllowed())) { std::shared_ptr<Connection> connection = connectionFactory->createConnection(); s5bSession = std::make_shared<SOCKS5BytestreamClientSession>( connection, lastCandidate.hostPort, socks5DstAddr, timerFactory); sessionReadyConnection = s5bSession->onSessionReady.connect( boost::bind(&RemoteJingleTransportCandidateSelector::handleSessionReady, this, _1)); s5bSession->start(); } else { - SWIFT_LOG(debug) << "Can't handle this type of candidate" << std::endl; + SWIFT_LOG(debug) << "Can't handle this type of candidate"; tryNextCandidate(); } } } void RemoteJingleTransportCandidateSelector::handleSessionReady(bool error) { 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(); diff --git a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp index cd4cfaa..72c4d41 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.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) 2015-2016 Isode Limited. + * Copyright (c) 2015-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h> @@ -43,13 +43,13 @@ SOCKS5BytestreamProxiesManager::~SOCKS5BytestreamProxiesManager() { } } } void SOCKS5BytestreamProxiesManager::addS5BProxy(S5BProxyRequest::ref proxy) { if (proxy) { - SWIFT_LOG_ASSERT(HostAddress::fromString(proxy->getStreamHost().get().host), warning) << std::endl; + SWIFT_LOG_ASSERT(HostAddress::fromString(proxy->getStreamHost().get().host), warning); if (!localS5BProxies_) { localS5BProxies_ = std::vector<S5BProxyRequest::ref>(); } localS5BProxies_->push_back(proxy); } } @@ -59,22 +59,22 @@ const boost::optional<std::vector<S5BProxyRequest::ref> >& SOCKS5BytestreamProxi queryForProxies(); } return localS5BProxies_; } void SOCKS5BytestreamProxiesManager::connectToProxies(const std::string& sessionID) { - SWIFT_LOG(debug) << "session ID: " << sessionID << std::endl; + SWIFT_LOG(debug) << "session ID: " << sessionID; ProxyJIDClientSessionVector clientSessions; if (localS5BProxies_) { for (auto&& proxy : localS5BProxies_.get()) { auto proxyHostAddress = HostAddress::fromString(proxy->getStreamHost().get().host); if (proxyHostAddress) { std::shared_ptr<Connection> conn = connectionFactory_->createConnection(); HostAddressPort addressPort = HostAddressPort(proxyHostAddress.get(), proxy->getStreamHost().get().port); - SWIFT_LOG_ASSERT(addressPort.isValid(), warning) << std::endl; + SWIFT_LOG_ASSERT(addressPort.isValid(), warning); std::shared_ptr<SOCKS5BytestreamClientSession> session = std::make_shared<SOCKS5BytestreamClientSession>(conn, addressPort, sessionID, timerFactory_); JID proxyJid = proxy->getStreamHost().get().jid; clientSessions.push_back(std::pair<JID, std::shared_ptr<SOCKS5BytestreamClientSession> >(proxyJid, session)); session->onSessionReady.connect(boost::bind(&SOCKS5BytestreamProxiesManager::handleProxySessionReady, this,sessionID, proxyJid, session, _1)); session->onFinished.connect(boost::bind(&SOCKS5BytestreamProxiesManager::handleProxySessionFinished, this, sessionID, proxyJid, session, _1)); session->start(); @@ -100,13 +100,13 @@ std::shared_ptr<SOCKS5BytestreamClientSession> SOCKS5BytestreamProxiesManager::g activeSession = i->second; } else { i->second->stop(); } } - SWIFT_LOG_ASSERT(activeSession, warning) << "No active session with matching ID found." << std::endl; + SWIFT_LOG_ASSERT(activeSession, warning) << "No active session with matching ID found."; proxySessions_.erase(sessionID); return activeSession; } @@ -141,13 +141,13 @@ void SOCKS5BytestreamProxiesManager::handleProxiesFound(std::vector<S5BProxyRequ void SOCKS5BytestreamProxiesManager::handleNameLookupResult(const std::vector<HostAddress>& addresses, boost::optional<DomainNameResolveError> error, S5BProxyRequest::ref proxy) { if (error) { onDiscoveredProxiesChanged(); } else { if (addresses.empty()) { - SWIFT_LOG(warning) << "S5B proxy hostname does not resolve." << std::endl; + SWIFT_LOG(warning) << "S5B proxy hostname does not resolve."; } else { // generate proxy per returned address for (const auto& address : addresses) { S5BProxyRequest::StreamHost streamHost = proxy->getStreamHost().get(); S5BProxyRequest::ref proxyForAddress = std::make_shared<S5BProxyRequest>(*proxy); diff --git a/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.cpp b/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.cpp index 90c42dd..1efc54a 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.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) 2015-2016 Isode Limited. + * Copyright (c) 2015-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.h> @@ -68,16 +68,16 @@ void SOCKS5BytestreamProxyFinder::handleWalkEnded() { } void SOCKS5BytestreamProxyFinder::handleProxyResponse(std::shared_ptr<GenericRequest<S5BProxyRequest> > requester, std::shared_ptr<S5BProxyRequest> request, ErrorPayload::ref error) { requester->onResponse.disconnect(boost::bind(&SOCKS5BytestreamProxyFinder::handleProxyResponse, this, requester, _1, _2)); pendingRequests.erase(requester); if (error) { - SWIFT_LOG(debug) << "ERROR" << std::endl; + SWIFT_LOG(debug) << "ERROR"; } else { if (request) { - SWIFT_LOG(debug) << "add request" << std::endl; + SWIFT_LOG(debug) << "add request"; proxyHosts.push_back(request); } } if (pendingRequests.empty() && !serviceWalker->isActive()) { onProxiesFound(proxyHosts); } diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp index a6b75da..7fc1388 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2012-2018 Isode Limited. + * Copyright (c) 2012-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ /* * Copyright (c) 2011 Tobias Markmann @@ -45,18 +45,18 @@ SOCKS5BytestreamServerManager::SOCKS5BytestreamServerManager( state(Start), server(nullptr), attemptedPortMapping_(false) { } SOCKS5BytestreamServerManager::~SOCKS5BytestreamServerManager() { - SWIFT_LOG_ASSERT(!connectionServer, warning) << std::endl; - SWIFT_LOG_ASSERT(!getPublicIPRequest, warning) << std::endl; - SWIFT_LOG_ASSERT(!forwardPortRequest, warning) << std::endl; - SWIFT_LOG_ASSERT(state == Start, warning) << std::endl; + SWIFT_LOG_ASSERT(!connectionServer, warning); + SWIFT_LOG_ASSERT(!getPublicIPRequest, warning); + SWIFT_LOG_ASSERT(!forwardPortRequest, warning); + SWIFT_LOG_ASSERT(state == Start, warning); if (portMapping && !unforwardPortRequest) { - SWIFT_LOG(warning) << "Port forwarding still alive. Trying to remove it now." << std::endl; + SWIFT_LOG(warning) << "Port forwarding still alive. Trying to remove it now."; unforwardPortRequest = natTraverser->createRemovePortForwardingRequest(portMapping.get().getLocalPort(), portMapping.get().getPublicPort()); unforwardPortRequest->start(); } } std::shared_ptr<SOCKS5BytestreamServerResourceUser> SOCKS5BytestreamServerManager::aquireResourceUser() { @@ -113,31 +113,31 @@ void SOCKS5BytestreamServerManager::initialize() { state = Initializing; // Find a port to listen on assert(!connectionServer); unsigned short port; for (port = LISTEN_PORTS_BEGIN; port < LISTEN_PORTS_END; ++port) { - SWIFT_LOG(debug) << "Trying to start server on port " << port << std::endl; + SWIFT_LOG(debug) << "Trying to start server on port " << port; connectionServer = connectionServerFactory->createConnectionServer(HostAddress::fromString("::").get(), port); boost::optional<ConnectionServer::Error> error = connectionServer->tryStart(); if (!error) { break; } else if (*error != ConnectionServer::Conflict) { - SWIFT_LOG(debug) << "Error starting server" << std::endl; + SWIFT_LOG(debug) << "Error starting server"; onInitialized(false); return; } connectionServer.reset(); } if (!connectionServer) { - SWIFT_LOG(debug) << "Unable to find an open port" << std::endl; + SWIFT_LOG(debug) << "Unable to find an open port"; onInitialized(false); return; } - SWIFT_LOG(debug) << "Server started succesfully" << std::endl; + SWIFT_LOG(debug) << "Server started succesfully"; connectionServerPort = port; // Start bytestream server. Should actually happen before the connectionserver is started // but that doesn't really matter here. assert(!server); server = new SOCKS5BytestreamServer(connectionServer, bytestreamRegistry); @@ -208,30 +208,30 @@ void SOCKS5BytestreamServerManager::stop() { state = Start; } void SOCKS5BytestreamServerManager::handleGetPublicIPResult(boost::optional<HostAddress> address) { if (address) { - SWIFT_LOG(debug) << "Public IP discovered as " << address.get().toString() << "." << std::endl; + SWIFT_LOG(debug) << "Public IP discovered as " << address.get().toString() << "."; } else { - SWIFT_LOG(debug) << "No public IP discoverable." << std::endl; + SWIFT_LOG(debug) << "No public IP discoverable."; } publicAddress = address; getPublicIPRequest->stop(); getPublicIPRequest.reset(); } void SOCKS5BytestreamServerManager::handleForwardPortResult(boost::optional<NATPortMapping> mapping) { if (mapping) { - SWIFT_LOG(debug) << "Mapping port was successful." << std::endl; + SWIFT_LOG(debug) << "Mapping port was successful."; } else { - SWIFT_LOG(debug) << "Mapping port has failed." << std::endl; + SWIFT_LOG(debug) << "Mapping port has failed."; } portMapping = mapping; onPortForwardingSetup(mapping.is_initialized()); forwardPortRequest->stop(); @@ -240,13 +240,13 @@ void SOCKS5BytestreamServerManager::handleForwardPortResult(boost::optional<NATP void SOCKS5BytestreamServerManager::handleUnforwardPortResult(boost::optional<bool> result) { if (result.is_initialized() && result.get()) { portMapping.reset(); } else { - SWIFT_LOG(warning) << "Failed to remove port forwarding." << std::endl; + SWIFT_LOG(warning) << "Failed to remove port forwarding."; } attemptedPortMapping_ = false; unforwardPortRequest.reset(); } void SOCKS5BytestreamServerManager::checkInitializeFinished() { diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp index 0fd40bf..a4ab751 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/FileTransfer/SOCKS5BytestreamServerSession.h> @@ -30,42 +30,42 @@ SOCKS5BytestreamServerSession::SOCKS5BytestreamServerSession( waitingForData(false) { disconnectedConnection = connection->onDisconnected.connect(boost::bind(&SOCKS5BytestreamServerSession::handleDisconnected, this, _1)); } SOCKS5BytestreamServerSession::~SOCKS5BytestreamServerSession() { if (state != Finished && state != Initial) { - SWIFT_LOG(warning) << "SOCKS5BytestreamServerSession unfinished" << std::endl; + SWIFT_LOG(warning) << "SOCKS5BytestreamServerSession unfinished"; finish(); } } void SOCKS5BytestreamServerSession::start() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); dataReadConnection = connection->onDataRead.connect( boost::bind(&SOCKS5BytestreamServerSession::handleDataRead, this, _1)); state = WaitingForAuthentication; } void SOCKS5BytestreamServerSession::stop() { finish(); } void SOCKS5BytestreamServerSession::startSending(std::shared_ptr<ReadBytestream> stream) { - if (state != ReadyForTransfer) { SWIFT_LOG(debug) << "Not ready for transfer!" << std::endl; return; } + if (state != ReadyForTransfer) { SWIFT_LOG(debug) << "Not ready for transfer!"; return; } readBytestream = stream; state = WritingData; dataAvailableConnection = readBytestream->onDataAvailable.connect( boost::bind(&SOCKS5BytestreamServerSession::handleDataAvailable, this)); dataWrittenConnection = connection->onDataWritten.connect( boost::bind(&SOCKS5BytestreamServerSession::sendData, this)); sendData(); } void SOCKS5BytestreamServerSession::startReceiving(std::shared_ptr<WriteBytestream> stream) { - if (state != ReadyForTransfer) { SWIFT_LOG(debug) << "Not ready for transfer!" << std::endl; return; } + if (state != ReadyForTransfer) { SWIFT_LOG(debug) << "Not ready for transfer!"; return; } writeBytestream = stream; state = ReadingData; writeBytestream->write(unprocessedData); // onBytesReceived(unprocessedData.size()); unprocessedData.clear(); @@ -90,13 +90,13 @@ void SOCKS5BytestreamServerSession::handleDataAvailable() { if (waitingForData) { sendData(); } } void SOCKS5BytestreamServerSession::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"); finish(error ? boost::optional<FileTransferError>(FileTransferError::PeerError) : boost::optional<FileTransferError>()); } void SOCKS5BytestreamServerSession::process() { if (state == WaitingForAuthentication) { if (unprocessedData.size() >= 2) { @@ -106,13 +106,13 @@ void SOCKS5BytestreamServerSession::process() { // Skip authentication mechanism ++i; } if (i == 2 + authCount) { // Authentication message is complete if (i != unprocessedData.size()) { - SWIFT_LOG(debug) << "Junk after authentication mechanism" << std::endl; + SWIFT_LOG(debug) << "Junk after authentication mechanism"; } unprocessedData.clear(); connection->write(createSafeByteArray("\x05\x00", 2)); state = WaitingForRequest; } } @@ -127,36 +127,36 @@ void SOCKS5BytestreamServerSession::process() { ++i; } // Skip the port: 2 byte large, one already skipped. Add one for comparison with size i += 2; if (i <= unprocessedData.size()) { if (i != unprocessedData.size()) { - SWIFT_LOG(debug) << "Junk after authentication mechanism" << std::endl; + SWIFT_LOG(debug) << "Junk after authentication mechanism"; } unprocessedData.clear(); streamID = byteArrayToString(requestID); bool hasBytestream = bytestreams->hasBytestream(streamID); SafeByteArray result = createSafeByteArray("\x05", 1); result.push_back(hasBytestream ? 0x0 : 0x4); append(result, createByteArray("\x00\x03", 2)); try { result.push_back(boost::numeric_cast<unsigned char>(requestID.size())); } catch (const boost::numeric::bad_numeric_cast& e) { - SWIFT_LOG(warning) << "SOCKS5 request ID is too long (" << requestID.size() << "): " << e.what() << std::endl; + SWIFT_LOG(warning) << "SOCKS5 request ID is too long (" << requestID.size() << "): " << e.what(); finish(); return; } append(result, concat(requestID, createByteArray("\x00\x00", 2))); if (!hasBytestream) { - SWIFT_LOG(debug) << "Readstream or Wrtiestream with ID " << streamID << " not found!" << std::endl; + SWIFT_LOG(debug) << "Readstream or Wrtiestream with ID " << streamID << " not found!"; connection->write(result); finish(boost::optional<FileTransferError>(FileTransferError::PeerError)); } else { - SWIFT_LOG(debug) << "Found stream. Sent OK." << std::endl; + SWIFT_LOG(debug) << "Found stream. Sent OK."; connection->write(result); state = ReadyForTransfer; } } } } @@ -182,13 +182,13 @@ void SOCKS5BytestreamServerSession::sendData() { else { finish(); } } void SOCKS5BytestreamServerSession::finish(const boost::optional<FileTransferError>& error) { - SWIFT_LOG(debug) << "state: " << state << std::endl; + SWIFT_LOG(debug) << "state: " << state; if (state == Finished) { return; } disconnectedConnection.disconnect(); dataReadConnection.disconnect(); diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp index 80667b6..fad02da 100644 --- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp +++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.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) 2015-2016 Isode Limited. + * Copyright (c) 2015-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <memory> @@ -235,13 +235,13 @@ private: append(*correctData, createSafeByteArray(destination)); append(*correctData, createSafeByteArray("\x00", 1)); std::shared_ptr<SafeByteArray> dataToSend; //ByteArray failingData = Hexify::unhexify("8417947d1d305c72c11520ea7d2c6e787396705e72c312c6ccc3f66613d7cae1b91b7ab48e8b59a17d559c15fb51"); //append(dataToSend, failingData); - //SWIFT_LOG(debug) << "hexed: " << Hexify::hexify(failingData) << std::endl; + //SWIFT_LOG(debug) << "hexed: " << Hexify::hexify(failingData); do { ByteArray rndArray = generateRandomByteArray(correctData->size()); dataToSend = createSafeByteArrayRef(vecptr(rndArray), rndArray.size()); } while (*dataToSend == *correctData); connection->onDataRead(dataToSend); } @@ -252,13 +252,13 @@ private: ByteArray unprocessedInput; bool sessionReadyCalled; bool sessionReadyError; void handleConnectionDataWritten(const SafeByteArray& data) { append(unprocessedInput, data); - //SWIFT_LOG(debug) << "unprocessedInput (" << unprocessedInput.size() << "): " << Hexify::hexify(unprocessedInput) << std::endl; + //SWIFT_LOG(debug) << "unprocessedInput (" << unprocessedInput.size() << "): " << Hexify::hexify(unprocessedInput); } void handleSessionReady(bool error) { sessionReadyCalled = true; sessionReadyError = error; } diff --git a/Swiften/Jingle/AbstractJingleSessionListener.cpp b/Swiften/Jingle/AbstractJingleSessionListener.cpp index 20edf15..56d2e92 100644 --- a/Swiften/Jingle/AbstractJingleSessionListener.cpp +++ b/Swiften/Jingle/AbstractJingleSessionListener.cpp @@ -1,42 +1,42 @@ /* - * Copyright (c) 2013-2016 Isode Limited. + * Copyright (c) 2013-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Jingle/AbstractJingleSessionListener.h> #include <Swiften/Base/Log.h> using namespace Swift; void AbstractJingleSessionListener::handleSessionAcceptReceived(const JingleContentID&, std::shared_ptr<JingleDescription>, std::shared_ptr<JingleTransportPayload>) { - SWIFT_LOG(warning) << "Unimplemented" << std::endl; + SWIFT_LOG(warning) << "Unimplemented"; } void AbstractJingleSessionListener::handleSessionInfoReceived(std::shared_ptr<JinglePayload>) { - SWIFT_LOG(warning) << "Unimplemented" << std::endl; + SWIFT_LOG(warning) << "Unimplemented"; } void AbstractJingleSessionListener::handleSessionTerminateReceived(boost::optional<JinglePayload::Reason>) { - SWIFT_LOG(warning) << "Unimplemented" << std::endl; + SWIFT_LOG(warning) << "Unimplemented"; } void AbstractJingleSessionListener::handleTransportAcceptReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) { - SWIFT_LOG(warning) << "Unimplemented" << std::endl; + SWIFT_LOG(warning) << "Unimplemented"; } void AbstractJingleSessionListener::handleTransportInfoReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) { - SWIFT_LOG(warning) << "Unimplemented" << std::endl; + SWIFT_LOG(warning) << "Unimplemented"; } void AbstractJingleSessionListener::handleTransportRejectReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) { - SWIFT_LOG(warning) << "Unimplemented" << std::endl; + SWIFT_LOG(warning) << "Unimplemented"; } void AbstractJingleSessionListener::handleTransportReplaceReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) { - SWIFT_LOG(warning) << "Unimplemented" << std::endl; + SWIFT_LOG(warning) << "Unimplemented"; } void AbstractJingleSessionListener::handleTransportInfoAcknowledged(const std::string&) { } diff --git a/Swiften/Jingle/JingleResponder.cpp b/Swiften/Jingle/JingleResponder.cpp index 09bb234..af9808e 100644 --- a/Swiften/Jingle/JingleResponder.cpp +++ b/Swiften/Jingle/JingleResponder.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2011-2016 Isode Limited. + * Copyright (c) 2011-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Jingle/JingleResponder.h> @@ -29,23 +29,23 @@ bool JingleResponder::handleSetRequest(const JID& from, const JID& to, const std else { sendResponse(from, id, std::shared_ptr<JinglePayload>()); if (!payload->getInitiator().isBare()) { JingleSessionImpl::ref session = std::make_shared<JingleSessionImpl>(payload->getInitiator(), from, payload->getSessionID(), router); sessionManager->handleIncomingSession(from, to, session, payload->getContents()); } else { - SWIFT_LOG(debug) << "Unable to create Jingle session due to initiator not being a full JID." << std::endl; + SWIFT_LOG(debug) << "Unable to create Jingle session due to initiator not being a full JID."; } } } else { JingleSessionImpl::ref session; if (payload->getInitiator().isValid()) { - SWIFT_LOG(debug) << "Lookup session by initiator." << std::endl; + SWIFT_LOG(debug) << "Lookup session by initiator."; session = sessionManager->getSession(payload->getInitiator(), payload->getSessionID()); } else { - SWIFT_LOG(debug) << "Lookup session by from attribute." << std::endl; + SWIFT_LOG(debug) << "Lookup session by from attribute."; session = sessionManager->getSession(from, payload->getSessionID()); } if (session) { session->handleIncomingAction(payload); sendResponse(from, id, std::shared_ptr<JinglePayload>()); } diff --git a/Swiften/Jingle/JingleSessionImpl.cpp b/Swiften/Jingle/JingleSessionImpl.cpp index 06aa039..b4c5d03 100644 --- a/Swiften/Jingle/JingleSessionImpl.cpp +++ b/Swiften/Jingle/JingleSessionImpl.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Jingle/JingleSessionImpl.h> @@ -20,13 +20,13 @@ #include <Swiften/Queries/Request.h> #include <Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.h> namespace Swift { JingleSessionImpl::JingleSessionImpl(const JID& initiator, const JID& peerJID, const std::string& id, IQRouter* router) : JingleSession(initiator, id), iqRouter(router), peerJID(peerJID) { - SWIFT_LOG(debug) << "initiator: " << initiator << ", peerJID: " << peerJID << std::endl; + SWIFT_LOG(debug) << "initiator: " << initiator << ", peerJID: " << peerJID; } void JingleSessionImpl::handleIncomingAction(JinglePayload::ref action) { if (action->getAction() == JinglePayload::SessionTerminate) { notifyListeners(&JingleSessionListener::handleSessionTerminateReceived, action->getReason()); return; @@ -35,13 +35,13 @@ void JingleSessionImpl::handleIncomingAction(JinglePayload::ref action) { notifyListeners(&JingleSessionListener::handleSessionInfoReceived, action); return; } JingleContentPayload::ref content = action->getPayload<JingleContentPayload>(); if (!content) { - SWIFT_LOG(debug) << "no content payload!" << std::endl; + SWIFT_LOG(debug) << "no content payload!"; return; } JingleContentID contentID(content->getName(), content->getCreator()); JingleDescription::ref description = content->getDescriptions().empty() ? JingleDescription::ref() : content->getDescriptions()[0]; JingleTransportPayload::ref transport = content->getTransports().empty() ? JingleTransportPayload::ref() : content->getTransports()[0]; switch(action->getAction()) { diff --git a/Swiften/Jingle/JingleSessionManager.cpp b/Swiften/Jingle/JingleSessionManager.cpp index f7ed58e..083554a 100644 --- a/Swiften/Jingle/JingleSessionManager.cpp +++ b/Swiften/Jingle/JingleSessionManager.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2011-2016 Isode Limited. + * Copyright (c) 2011-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Jingle/JingleSessionManager.h> @@ -35,13 +35,13 @@ void JingleSessionManager::addIncomingSessionHandler(IncomingJingleSessionHandle void JingleSessionManager::removeIncomingSessionHandler(IncomingJingleSessionHandler* handler) { erase(incomingSessionHandlers, handler); } void JingleSessionManager::registerOutgoingSession(const JID& initiator, JingleSessionImpl::ref session) { sessions.insert(std::make_pair(JIDSession(initiator, session->getID()), session)); - SWIFT_LOG(debug) << "Added session " << session->getID() << " for initiator " << initiator.toString() << std::endl; + SWIFT_LOG(debug) << "Added session " << session->getID() << " for initiator " << initiator.toString(); } void JingleSessionManager::handleIncomingSession(const JID& initiator, const JID& recipient, JingleSessionImpl::ref session, const std::vector<JingleContentPayload::ref>& contents) { sessions.insert(std::make_pair(JIDSession(initiator, session->getID()), session)); for (auto handler : incomingSessionHandlers) { if (handler->handleIncomingJingleSession(session, contents, recipient)) { diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveHostnameQuery.cpp b/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveHostnameQuery.cpp index 08de722..262add3 100644 --- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveHostnameQuery.cpp +++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveHostnameQuery.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveHostnameQuery.h> @@ -12,13 +12,13 @@ #include <Swiften/Base/Log.h> namespace Swift { AvahiResolveHostnameQuery::AvahiResolveHostnameQuery(const std::string& hostname, int, std::shared_ptr<AvahiQuerier> querier, EventLoop* eventLoop) : AvahiQuery(querier, eventLoop), hostname(hostname) { - SWIFT_LOG(debug) << "Resolving hostname " << hostname << std::endl; + SWIFT_LOG(debug) << "Resolving hostname " << hostname; } void AvahiResolveHostnameQuery::run() { eventLoop->postEvent(boost::bind(boost::ref(onHostnameResolved), HostAddress::fromString(hostname)), shared_from_this()); } diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h index 9eb8cd9..cc95d64 100644 --- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h +++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once @@ -23,21 +23,21 @@ namespace Swift { BonjourRegisterQuery(const std::string& name, unsigned short port, const ByteArray& txtRecord, std::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) { unsigned short recordSize = 0; try { recordSize = boost::numeric_cast<unsigned short>(txtRecord.size()); } catch (const boost::numeric::bad_numeric_cast&) { - SWIFT_LOG(warning) << "Bonjour TXT record is too long (" << txtRecord.size() << " bytes), not registring service" << std::endl; + SWIFT_LOG(warning) << "Bonjour TXT record is too long (" << txtRecord.size() << " bytes), not registring service"; return; } DNSServiceErrorType result = DNSServiceRegister( &sdRef, 0, 0, name.c_str(), "_presence._tcp", nullptr, nullptr, port, recordSize, vecptr(txtRecord), &BonjourRegisterQuery::handleServiceRegisteredStatic, this); if (result != kDNSServiceErr_NoError) { - SWIFT_LOG(warning) << "Failed to register Bonjour service" << std::endl; + SWIFT_LOG(warning) << "Failed to register Bonjour service"; sdRef = nullptr; } } void registerService() { if (sdRef) { @@ -55,13 +55,13 @@ namespace Swift { void updateServiceInfo(const ByteArray& txtRecord) { std::lock_guard<std::mutex> lock(sdRefMutex); try { DNSServiceUpdateRecord(sdRef, nullptr, 0, boost::numeric_cast<unsigned short>(txtRecord.size()), vecptr(txtRecord), 0); } catch (const boost::numeric::bad_numeric_cast&) { - SWIFT_LOG(warning) << "Bonjour TXT record is too long (" << txtRecord.size() << " bytes), not updating service record" << std::endl; + SWIFT_LOG(warning) << "Bonjour TXT record is too long (" << txtRecord.size() << " bytes), not updating service record"; } } private: static void handleServiceRegisteredStatic(DNSServiceRef, DNSServiceFlags, DNSServiceErrorType errorCode, const char *name, const char *regtype, const char *domain, void *context) { static_cast<BonjourRegisterQuery*>(context)->handleServiceRegistered(errorCode, name, regtype, domain); diff --git a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp index 914fab4..5e529fd 100644 --- a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp +++ b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/LinkLocal/LinkLocalServiceInfo.h> @@ -46,13 +46,13 @@ boost::optional<ByteArray> LinkLocalServiceInfo::toTXTRecord() const { case DND: append(result, getEncoded("status=dnd")); break; } return result; } catch (const std::exception& e) { - SWIFT_LOG(warning) << "Failed to create TXT record for link local service info: " << e.what() << std::endl; + SWIFT_LOG(warning) << "Failed to create TXT record for link local service info: " << e.what(); return boost::none; } } ByteArray LinkLocalServiceInfo::getEncoded(const std::string& s) { ByteArray sizeByte; diff --git a/Swiften/Network/BOSHConnection.cpp b/Swiften/Network/BOSHConnection.cpp index aaec9f2..1312a3e 100644 --- a/Swiften/Network/BOSHConnection.cpp +++ b/Swiften/Network/BOSHConnection.cpp @@ -71,33 +71,33 @@ void BOSHConnection::cancelConnector() { connector_->stop(); connector_.reset(); } } void BOSHConnection::handleTLSConnected() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); onConnectFinished(false); } void BOSHConnection::handleTLSApplicationDataRead(const SafeByteArray& data) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); handleDataRead(std::make_shared<SafeByteArray>(data)); } void BOSHConnection::handleTLSNetowrkDataWriteRequest(const SafeByteArray& data) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); connection_->write(data); } void BOSHConnection::handleRawDataRead(std::shared_ptr<SafeByteArray> data) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); tlsLayer_->handleDataRead(*data.get()); } void BOSHConnection::handleTLSError(std::shared_ptr<TLSError> error) { - SWIFT_LOG(debug) << (error ? error->getMessage() : "Unknown TLS error") << std::endl; + SWIFT_LOG(debug) << (error ? error->getMessage() : "Unknown TLS error"); } void BOSHConnection::writeData(const SafeByteArray& data) { if (tlsLayer_) { tlsLayer_->writeData(data); } @@ -120,13 +120,13 @@ void BOSHConnection::disconnect() { void BOSHConnection::restartStream() { write(createSafeByteArray(""), true, false); } bool BOSHConnection::setClientCertificate(CertificateWithKey::ref cert) { if (tlsLayer_) { - SWIFT_LOG(debug) << "set client certificate" << std::endl; + SWIFT_LOG(debug) << "set client certificate"; return tlsLayer_->setClientCertificate(cert); } else { return false; } } @@ -208,13 +208,13 @@ void BOSHConnection::write(const SafeByteArray& data, bool streamRestart, bool t SafeByteArray safeHeader = createHTTPRequest(data, streamRestart, terminate, rid_, sid_, boshURL_).first; onBOSHDataWritten(safeHeader); writeData(safeHeader); pending_ = true; - SWIFT_LOG(debug) << "write data: " << safeByteArrayToString(safeHeader) << std::endl; + SWIFT_LOG(debug) << "write data: " << safeByteArrayToString(safeHeader); } void BOSHConnection::handleConnectFinished(Connection::ref connection) { cancelConnector(); connectionReady_ = !!connection; if (connectionReady_) { @@ -272,13 +272,13 @@ void BOSHConnection::startStream(const std::string& to, unsigned long long rid) << contentString; waitingForStartResponse_ = true; SafeByteArray safeHeader = createSafeByteArray(header.str()); onBOSHDataWritten(safeHeader); writeData(safeHeader); - SWIFT_LOG(debug) << "write stream header: " << safeByteArrayToString(safeHeader) << std::endl; + SWIFT_LOG(debug) << "write stream header: " << safeByteArrayToString(safeHeader); } void BOSHConnection::handleDataRead(std::shared_ptr<SafeByteArray> data) { onBOSHDataRead(*data); buffer_ = concat(buffer_, *data); std::string response = safeByteArrayToString(buffer_); diff --git a/Swiften/Network/BOSHConnectionPool.cpp b/Swiften/Network/BOSHConnectionPool.cpp index 8a75e81..3a79a16 100644 --- a/Swiften/Network/BOSHConnectionPool.cpp +++ b/Swiften/Network/BOSHConnectionPool.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2011-2016 Isode Limited. + * Copyright (c) 2011-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Network/BOSHConnectionPool.h> #include <climits> @@ -263,13 +263,13 @@ std::shared_ptr<BOSHConnection> BOSHConnectionPool::createConnection() { connection->onConnectFinished.connect(boost::bind(&BOSHConnectionPool::handleConnectFinished, this, _1, connection)); connection->onSessionTerminated.connect(boost::bind(&BOSHConnectionPool::handleSessionTerminated, this, _1)); connection->onHTTPError.connect(boost::bind(&BOSHConnectionPool::handleHTTPError, this, _1)); if (boshURL.getScheme() == "https") { bool success = connection->setClientCertificate(clientCertificate); - SWIFT_LOG(debug) << "setClientCertificate, success: " << success << std::endl; + SWIFT_LOG(debug) << "setClientCertificate, success: " << success; } connection->connect(); connections.push_back(connection); return connection; } diff --git a/Swiften/Network/BoostConnection.cpp b/Swiften/Network/BoostConnection.cpp index 551363d..6ae6bf6 100644 --- a/Swiften/Network/BoostConnection.cpp +++ b/Swiften/Network/BoostConnection.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Network/BoostConnection.h> @@ -104,13 +104,13 @@ void BoostConnection::write(const SafeByteArray& data) { void BoostConnection::doWrite(const SafeByteArray& data) { boost::asio::async_write(socket_, SharedBuffer(data), boost::bind(&BoostConnection::handleDataWritten, shared_from_this(), boost::asio::placeholders::error)); } void BoostConnection::handleConnectFinished(const boost::system::error_code& error) { - SWIFT_LOG(debug) << "Connect finished: " << error << std::endl; + SWIFT_LOG(debug) << "Connect finished: " << error; if (!error) { eventLoop->postEvent(boost::bind(boost::ref(onConnectFinished), false), shared_from_this()); doRead(); } else if (error != boost::asio::error::operation_aborted) { eventLoop->postEvent(boost::bind(boost::ref(onConnectFinished), true), shared_from_this()); @@ -123,13 +123,13 @@ void BoostConnection::doRead() { socket_.async_read_some( boost::asio::buffer(*readBuffer_), boost::bind(&BoostConnection::handleSocketRead, shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); } void BoostConnection::handleSocketRead(const boost::system::error_code& error, size_t bytesTransferred) { - SWIFT_LOG(debug) << "Socket read " << error << std::endl; + SWIFT_LOG(debug) << "Socket read " << error; if (!error) { readBuffer_->resize(bytesTransferred); eventLoop->postEvent(boost::bind(boost::ref(onDataRead), readBuffer_), shared_from_this()); doRead(); } else if (/*error == boost::asio::error::eof ||*/ error == boost::asio::error::operation_aborted) { @@ -138,13 +138,13 @@ void BoostConnection::handleSocketRead(const boost::system::error_code& error, s else { eventLoop->postEvent(boost::bind(boost::ref(onDisconnected), ReadError), shared_from_this()); } } void BoostConnection::handleDataWritten(const boost::system::error_code& error) { - SWIFT_LOG(debug) << "Data written " << error << std::endl; + SWIFT_LOG(debug) << "Data written " << error; if (!error) { eventLoop->postEvent(boost::ref(onDataWritten), shared_from_this()); } else if (/*error == boost::asio::error::eof || */error == boost::asio::error::operation_aborted) { eventLoop->postEvent(boost::bind(boost::ref(onDisconnected), boost::optional<Error>()), shared_from_this()); } diff --git a/Swiften/Network/BoostConnectionServer.cpp b/Swiften/Network/BoostConnectionServer.cpp index 8db9656..dc05172 100644 --- a/Swiften/Network/BoostConnectionServer.cpp +++ b/Swiften/Network/BoostConnectionServer.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Network/BoostConnectionServer.h> @@ -43,13 +43,13 @@ boost::optional<BoostConnectionServer::Error> BoostConnectionServer::tryStart() endpoint = boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v6(), port_); } acceptor_ = new boost::asio::ip::tcp::acceptor(*ioService_, endpoint); if (endpoint.protocol() == boost::asio::ip::tcp::v6()) { boost::system::error_code ec; acceptor_->set_option(boost::asio::ip::v6_only(false), ec); - SWIFT_LOG_ASSERT(ec, warning) << "IPv4/IPv6 dual-stack support is not supported on this platform." << std::endl; + SWIFT_LOG_ASSERT(ec, warning) << "IPv4/IPv6 dual-stack support is not supported on this platform."; } acceptNextConnection(); } catch (const boost::system::system_error& e) { if (e.code() == boost::asio::error::address_in_use) { return Conflict; diff --git a/Swiften/Network/ChainedConnector.cpp b/Swiften/Network/ChainedConnector.cpp index 94899ad..a9210ba 100644 --- a/Swiften/Network/ChainedConnector.cpp +++ b/Swiften/Network/ChainedConnector.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2011-2018 Isode Limited. + * Copyright (c) 2011-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Network/ChainedConnector.h> @@ -42,13 +42,13 @@ ChainedConnector::~ChainedConnector() { void ChainedConnector::setTimeoutMilliseconds(int milliseconds) { timeoutMilliseconds = milliseconds; } void ChainedConnector::start() { - SWIFT_LOG(debug) << "Starting queued connector for " << hostname << std::endl; + SWIFT_LOG(debug) << "Starting queued connector for " << hostname; connectionFactoryQueue = std::deque<ConnectionFactory*>(connectionFactories.begin(), connectionFactories.end()); tryNextConnectionFactory(); } void ChainedConnector::stop() { @@ -60,28 +60,28 @@ void ChainedConnector::stop() { finish(std::shared_ptr<Connection>(), std::shared_ptr<Error>()); } void ChainedConnector::tryNextConnectionFactory() { assert(!currentConnector); if (connectionFactoryQueue.empty()) { - SWIFT_LOG(debug) << "No more connection factories" << std::endl; + SWIFT_LOG(debug) << "No more connection factories"; finish(std::shared_ptr<Connection>(), lastError); } else { ConnectionFactory* connectionFactory = connectionFactoryQueue.front(); - SWIFT_LOG(debug) << "Trying next connection factory: " << typeid(*connectionFactory).name() << std::endl; + SWIFT_LOG(debug) << "Trying next connection factory: " << typeid(*connectionFactory).name(); connectionFactoryQueue.pop_front(); currentConnector = Connector::create(hostname, port, serviceLookupPrefix, resolver, connectionFactory, timerFactory); currentConnector->setTimeoutMilliseconds(timeoutMilliseconds); currentConnector->onConnectFinished.connect(boost::bind(&ChainedConnector::handleConnectorFinished, this, _1, _2)); currentConnector->start(); } } void ChainedConnector::handleConnectorFinished(std::shared_ptr<Connection> connection, std::shared_ptr<Error> error) { - SWIFT_LOG(debug) << "Connector finished" << std::endl; + SWIFT_LOG(debug) << "Connector finished"; currentConnector->onConnectFinished.disconnect(boost::bind(&ChainedConnector::handleConnectorFinished, this, _1, _2)); lastError = error; currentConnector.reset(); if (connection) { finish(connection, error); } diff --git a/Swiften/Network/Connector.cpp b/Swiften/Network/Connector.cpp index a0e6b23..e27b95d 100644 --- a/Swiften/Network/Connector.cpp +++ b/Swiften/Network/Connector.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Network/Connector.h> @@ -22,13 +22,13 @@ Connector::Connector(const std::string& hostname, unsigned short port, const boo void Connector::setTimeoutMilliseconds(int milliseconds) { timeoutMilliseconds = milliseconds; } void Connector::start() { - SWIFT_LOG(debug) << "Starting connector for " << hostname << std::endl; + SWIFT_LOG(debug) << "Starting connector for " << hostname; assert(!currentConnection); assert(!serviceQuery); assert(!timer); auto hostAddress = HostAddress::fromString(hostname); if (timeoutMilliseconds > 0) { timer = timerFactory->createTimer(timeoutMilliseconds); @@ -63,40 +63,40 @@ void Connector::queryAddress(const std::string& hostname) { addressQuery = resolver->createAddressQuery(hostname); addressQuery->onResult.connect(boost::bind(&Connector::handleAddressQueryResult, shared_from_this(), _1, _2)); addressQuery->run(); } void Connector::handleServiceQueryResult(const std::vector<DomainNameServiceQuery::Result>& result) { - SWIFT_LOG(debug) << result.size() << " SRV result(s)" << std::endl; + SWIFT_LOG(debug) << result.size() << " SRV result(s)"; serviceQueryResults = std::deque<DomainNameServiceQuery::Result>(result.begin(), result.end()); serviceQuery.reset(); if (!serviceQueryResults.empty()) { foundSomeDNS = true; } tryNextServiceOrFallback(); } void Connector::tryNextServiceOrFallback() { if (queriedAllServices) { - SWIFT_LOG(debug) << "Queried all services" << std::endl; + SWIFT_LOG(debug) << "Queried all services"; finish(std::shared_ptr<Connection>()); } else if (serviceQueryResults.empty()) { - SWIFT_LOG(debug) << "Falling back on A resolution" << std::endl; + SWIFT_LOG(debug) << "Falling back on A resolution"; // Fall back on simple address resolving queriedAllServices = true; queryAddress(hostname); } else { - SWIFT_LOG(debug) << "Querying next address" << std::endl; + SWIFT_LOG(debug) << "Querying next address"; queryAddress(serviceQueryResults.front().hostname); } } void Connector::handleAddressQueryResult(const std::vector<HostAddress>& addresses, boost::optional<DomainNameResolveError> error) { - SWIFT_LOG(debug) << addresses.size() << " addresses" << std::endl; + SWIFT_LOG(debug) << addresses.size() << " addresses"; addressQuery.reset(); if (error || addresses.empty()) { if (!serviceQueryResults.empty()) { serviceQueryResults.pop_front(); } tryNextServiceOrFallback(); @@ -107,21 +107,21 @@ void Connector::handleAddressQueryResult(const std::vector<HostAddress>& address tryNextAddress(); } } void Connector::tryNextAddress() { if (addressQueryResults.empty()) { - SWIFT_LOG(debug) << "Done trying addresses. Moving on." << std::endl; + SWIFT_LOG(debug) << "Done trying addresses. Moving on."; // Done trying all addresses. Move on to the next host. if (!serviceQueryResults.empty()) { serviceQueryResults.pop_front(); } tryNextServiceOrFallback(); } else { - SWIFT_LOG(debug) << "Trying next address" << std::endl; + SWIFT_LOG(debug) << "Trying next address"; HostAddress address = addressQueryResults.front(); addressQueryResults.pop_front(); unsigned short connectPort = (port == 0 ? 5222 : port); if (!serviceQueryResults.empty()) { connectPort = serviceQueryResults.front().port; @@ -130,23 +130,23 @@ void Connector::tryNextAddress() { tryConnect(HostAddressPort(address, connectPort)); } } void Connector::tryConnect(const HostAddressPort& target) { assert(!currentConnection); - SWIFT_LOG(debug) << "Trying to connect to " << target.getAddress().toString() << ":" << target.getPort() << std::endl; + SWIFT_LOG(debug) << "Trying to connect to " << target.getAddress().toString() << ":" << target.getPort(); currentConnection = connectionFactory->createConnection(); currentConnection->onConnectFinished.connect(boost::bind(&Connector::handleConnectionConnectFinished, shared_from_this(), _1)); currentConnection->connect(target); if (timer) { timer->start(); } } void Connector::handleConnectionConnectFinished(bool error) { - SWIFT_LOG(debug) << "ConnectFinished: " << (error ? "error" : "success") << std::endl; + SWIFT_LOG(debug) << "ConnectFinished: " << (error ? "error" : "success"); if (timer) { timer->stop(); timer.reset(); } if (!currentConnection) { // We've hit a race condition where multiple finisheds were on the eventloop queue at once. @@ -192,12 +192,12 @@ void Connector::finish(std::shared_ptr<Connection> connection) { currentConnection.reset(); } onConnectFinished(connection, (connection || foundSomeDNS) ? std::shared_ptr<Error>() : std::make_shared<DomainNameResolveError>()); } void Connector::handleTimeout() { - SWIFT_LOG(debug) << "Timeout" << std::endl; - SWIFT_LOG_ASSERT(currentConnection, error) << "Connection not valid but triggered a timeout" <<std::endl; + SWIFT_LOG(debug) << "Timeout"; + SWIFT_LOG_ASSERT(currentConnection, error) << "Connection not valid but triggered a timeout"; handleConnectionConnectFinished(true); } } diff --git a/Swiften/Network/EnvironmentProxyProvider.cpp b/Swiften/Network/EnvironmentProxyProvider.cpp index 65cf4ff..6fbf373 100644 --- a/Swiften/Network/EnvironmentProxyProvider.cpp +++ b/Swiften/Network/EnvironmentProxyProvider.cpp @@ -2,13 +2,13 @@ * Copyright (c) 2010-2011 Thilo Cestonaro * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ /* - * Copyright (c) 2016 Isode Limited. + * Copyright (c) 2016-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Network/EnvironmentProxyProvider.h> @@ -23,13 +23,13 @@ namespace Swift { EnvironmentProxyProvider::EnvironmentProxyProvider() { socksProxy = getFromEnv("all_proxy", "socks"); httpProxy = getFromEnv("http_proxy", "http"); - SWIFT_LOG(debug) << "Environment: SOCKS5 => " << socksProxy.toString() << "; HTTP Connect => " << httpProxy.toString() << std::endl; + SWIFT_LOG(debug) << "Environment: SOCKS5 => " << socksProxy.toString() << "; HTTP Connect => " << httpProxy.toString(); } HostAddressPort EnvironmentProxyProvider::getHTTPConnectProxy() const { return httpProxy; } diff --git a/Swiften/Network/GConfProxyProvider.cpp b/Swiften/Network/GConfProxyProvider.cpp index 7c31868..a2f8adc 100644 --- a/Swiften/Network/GConfProxyProvider.cpp +++ b/Swiften/Network/GConfProxyProvider.cpp @@ -2,13 +2,13 @@ * Copyright (c) 2010-2011 Thilo Cestonaro * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ /* - * Copyright (c) 2016-2018 Isode Limited. + * Copyright (c) 2016-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Network/GConfProxyProvider.h> @@ -36,13 +36,13 @@ GConfProxyProvider::GConfProxyProvider() { glibInitialized = true; } #endif socksProxy = getFromGConf("/system/proxy/socks_host", "/system/proxy/socks_port"); httpProxy = getFromGConf("/system/http_proxy/host", "/system/http_proxy/port"); - SWIFT_LOG(debug) << "GConf: SOCKS5 => " << socksProxy.toString() << "; HTTP Connect => " << httpProxy.toString() << std::endl; + SWIFT_LOG(debug) << "GConf: SOCKS5 => " << socksProxy.toString() << "; HTTP Connect => " << httpProxy.toString(); } HostAddressPort GConfProxyProvider::getHTTPConnectProxy() const { return httpProxy; } diff --git a/Swiften/Network/HTTPConnectProxiedConnection.cpp b/Swiften/Network/HTTPConnectProxiedConnection.cpp index 8eba49e..e63b8e2 100644 --- a/Swiften/Network/HTTPConnectProxiedConnection.cpp +++ b/Swiften/Network/HTTPConnectProxiedConnection.cpp @@ -2,13 +2,13 @@ * Copyright (c) 2010-2011 Thilo Cestonaro * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ /* - * Copyright (c) 2011-2018 Isode Limited. + * Copyright (c) 2011-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Network/HTTPConnectProxiedConnection.h> @@ -74,13 +74,13 @@ void HTTPConnectProxiedConnection::initializeProxy() { append(data, createSafeByteArray("\r\n")); } nextHTTPRequestHeaders_.clear(); } append(data, createSafeByteArray("\r\n")); - SWIFT_LOG(debug) << "HTTP Proxy send headers: " << byteArrayToString(ByteArray(data.begin(), data.end())) << std::endl; + SWIFT_LOG(debug) << "HTTP Proxy send headers: " << byteArrayToString(ByteArray(data.begin(), data.end())); write(data); } void HTTPConnectProxiedConnection::parseHTTPHeader(const std::string& data, std::string& statusLine, std::vector<std::pair<std::string, std::string> >& headerFields) { std::istringstream dataStream(data); @@ -108,13 +108,13 @@ void HTTPConnectProxiedConnection::sendHTTPRequest(const std::string& statusLine request << "\r\n"; write(createSafeByteArray(request.str())); } void HTTPConnectProxiedConnection::handleProxyInitializeData(std::shared_ptr<SafeByteArray> data) { std::string dataString = byteArrayToString(ByteArray(data->begin(), data->end())); - SWIFT_LOG(debug) << data << std::endl; + SWIFT_LOG(debug) << data; httpResponseBuffer_.append(dataString); std::string statusLine; std::vector<std::pair<std::string, std::string> > headerFields; std::string::size_type headerEnd = httpResponseBuffer_.find("\r\n\r\n", 0); @@ -138,23 +138,23 @@ void HTTPConnectProxiedConnection::handleProxyInitializeData(std::shared_ptr<Saf } std::vector<std::string> tmp = String::split(statusLine, ' '); if (tmp.size() > 1) { try { int status = boost::lexical_cast<int>(tmp[1]); - SWIFT_LOG(debug) << "Proxy Status: " << status << std::endl; + SWIFT_LOG(debug) << "Proxy Status: " << status; if (status / 100 == 2) { // all 2XX states are OK setProxyInitializeFinished(true); } else { - SWIFT_LOG(debug) << "HTTP Proxy returned an error: " << httpResponseBuffer_ << std::endl; + SWIFT_LOG(debug) << "HTTP Proxy returned an error: " << httpResponseBuffer_; setProxyInitializeFinished(false); } } catch (boost::bad_lexical_cast&) { - SWIFT_LOG(warning) << "Unexpected response: " << tmp[1] << std::endl; + SWIFT_LOG(warning) << "Unexpected response: " << tmp[1]; setProxyInitializeFinished(false); } } else { setProxyInitializeFinished(false); } diff --git a/Swiften/Network/HostAddress.cpp b/Swiften/Network/HostAddress.cpp index 6eca80b..e82f433 100644 --- a/Swiften/Network/HostAddress.cpp +++ b/Swiften/Network/HostAddress.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Network/HostAddress.h> @@ -40,13 +40,13 @@ HostAddress::HostAddress(const boost::asio::ip::address& address) : address_(add std::string HostAddress::toString() const { std::string addressString; boost::system::error_code errorCode; addressString = address_.to_string(errorCode); if (errorCode) { - SWIFT_LOG(debug) << "error: " << errorCode.message() << std::endl; + SWIFT_LOG(debug) << "error: " << errorCode.message(); } return addressString; } bool HostAddress::isValid() const { diff --git a/Swiften/Network/NATPMPInterface.cpp b/Swiften/Network/NATPMPInterface.cpp index 0c33c1f..e20fecd 100644 --- a/Swiften/Network/NATPMPInterface.cpp +++ b/Swiften/Network/NATPMPInterface.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) 2014-2018 Isode Limited. + * Copyright (c) 2014-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Network/NATPMPInterface.h> @@ -39,13 +39,13 @@ NATPMPInterface::~NATPMPInterface() { bool NATPMPInterface::isAvailable() { return getPublicIP() ? true : false; } boost::optional<HostAddress> NATPMPInterface::getPublicIP() { if (sendpublicaddressrequest(&p->natpmp) < 0) { - SWIFT_LOG(debug) << "Failed to send NAT-PMP public address request!" << std::endl; + SWIFT_LOG(debug) << "Failed to send NAT-PMP public address request!"; return boost::optional<HostAddress>(); } int r = 0; natpmpresp_t response; do { @@ -64,26 +64,26 @@ boost::optional<HostAddress> NATPMPInterface::getPublicIP() { } while (false /*r == NATPMP_TRYAGAIN*/); if (r == 0) { return boost::optional<HostAddress>(HostAddress(reinterpret_cast<const unsigned char*>(&(response.pnu.publicaddress.addr)), 4)); } else { - SWIFT_LOG(debug) << "Inavlid NAT-PMP response." << std::endl; + SWIFT_LOG(debug) << "Inavlid NAT-PMP response."; return boost::optional<HostAddress>(); } } boost::optional<NATPortMapping> NATPMPInterface::addPortForward(unsigned short localPort, unsigned short publicPort) { NATPortMapping mapping(localPort, publicPort, NATPortMapping::TCP); if (sendnewportmappingrequest( &p->natpmp, mapping.getProtocol() == NATPortMapping::TCP ? NATPMP_PROTOCOL_TCP : NATPMP_PROTOCOL_UDP, mapping.getLocalPort(), mapping.getPublicPort(), mapping.getLeaseInSeconds()) < 0) { - SWIFT_LOG(debug) << "Failed to send NAT-PMP port forwarding request!" << std::endl; + SWIFT_LOG(debug) << "Failed to send NAT-PMP port forwarding request!"; return boost::optional<NATPortMapping>(); } int r = 0; natpmpresp_t response; do { @@ -103,20 +103,20 @@ boost::optional<NATPortMapping> NATPMPInterface::addPortForward(unsigned short l if (r == 0) { NATPortMapping result(response.pnu.newportmapping.privateport, response.pnu.newportmapping.mappedpublicport, NATPortMapping::TCP, response.pnu.newportmapping.lifetime); return result; } else { - SWIFT_LOG(debug) << "Invalid NAT-PMP response." << std::endl; + SWIFT_LOG(debug) << "Invalid NAT-PMP response."; return boost::optional<NATPortMapping>(); } } bool NATPMPInterface::removePortForward(const NATPortMapping& mapping) { if (sendnewportmappingrequest(&p->natpmp, mapping.getProtocol() == NATPortMapping::TCP ? NATPMP_PROTOCOL_TCP : NATPMP_PROTOCOL_UDP, mapping.getLocalPort(), 0, 0) < 0) { - SWIFT_LOG(debug) << "Failed to send NAT-PMP remove forwarding request!" << std::endl; + SWIFT_LOG(debug) << "Failed to send NAT-PMP remove forwarding request!"; return false; } int r = 0; natpmpresp_t response; do { @@ -130,13 +130,13 @@ bool NATPMPInterface::removePortForward(const NATPortMapping& mapping) { } while(r == NATPMP_TRYAGAIN); if (r == 0) { return true; } else { - SWIFT_LOG(debug) << "Invalid NAT-PMP response." << std::endl; + SWIFT_LOG(debug) << "Invalid NAT-PMP response."; return false; } } } diff --git a/Swiften/Network/PlatformDomainNameServiceQuery.cpp b/Swiften/Network/PlatformDomainNameServiceQuery.cpp index f884500..2ff14e1 100644 --- a/Swiften/Network/PlatformDomainNameServiceQuery.cpp +++ b/Swiften/Network/PlatformDomainNameServiceQuery.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <boost/asio.hpp> @@ -55,13 +55,13 @@ void PlatformDomainNameServiceQuery::run() { void PlatformDomainNameServiceQuery::runBlocking() { if (!serviceValid) { emitError(); return; } - SWIFT_LOG(debug) << "Querying " << service << std::endl; + SWIFT_LOG(debug) << "Querying " << service; std::vector<DomainNameServiceQuery::Result> records; #if defined(SWIFTEN_PLATFORM_WINDOWS) DNS_RECORD* responses; // FIXME: This conversion doesn't work if unicode is deffed above @@ -94,13 +94,13 @@ void PlatformDomainNameServiceQuery::runBlocking() { res_init(); ByteArray response; response.resize(NS_PACKETSZ); int responseLength = res_query(const_cast<char*>(service.c_str()), ns_c_in, ns_t_srv, reinterpret_cast<u_char*>(vecptr(response)), response.size()); if (responseLength == -1) { - SWIFT_LOG(debug) << "Error" << std::endl; + SWIFT_LOG(debug) << "Error"; emitError(); return; } // Parse header HEADER* header = reinterpret_cast<HEADER*>(vecptr(response)); diff --git a/Swiften/Network/PlatformNATTraversalWorker.cpp b/Swiften/Network/PlatformNATTraversalWorker.cpp index 041ad2d..5431379 100644 --- a/Swiften/Network/PlatformNATTraversalWorker.cpp +++ b/Swiften/Network/PlatformNATTraversalWorker.cpp @@ -154,24 +154,24 @@ PlatformNATTraversalWorker::~PlatformNATTraversalWorker() { NATTraversalInterface* PlatformNATTraversalWorker::getNATTraversalInterface() const { #ifdef HAVE_LIBMINIUPNPC if (boost::logic::indeterminate(miniUPnPSupported)) { miniUPnPInterface = new MiniUPnPInterface(); miniUPnPSupported = miniUPnPInterface->isAvailable(); } - SWIFT_LOG(debug) << "UPnP NAT traversal supported: " << static_cast<bool>(miniUPnPSupported) << std::endl; + SWIFT_LOG(debug) << "UPnP NAT traversal supported: " << static_cast<bool>(miniUPnPSupported); if (miniUPnPSupported) { return miniUPnPInterface; } #endif #ifdef HAVE_LIBNATPMP if (boost::logic::indeterminate(natPMPSupported)) { natPMPInterface = new NATPMPInterface(); natPMPSupported = natPMPInterface->isAvailable(); } - SWIFT_LOG(debug) << "NAT-PMP NAT traversal supported: " << static_cast<bool>(natPMPSupported) << std::endl; + SWIFT_LOG(debug) << "NAT-PMP NAT traversal supported: " << static_cast<bool>(natPMPSupported); if (natPMPSupported) { return natPMPInterface; } #endif return nullNATTraversalInterface; diff --git a/Swiften/Network/ProxiedConnection.cpp b/Swiften/Network/ProxiedConnection.cpp index 4c97e31..0c5cda6 100644 --- a/Swiften/Network/ProxiedConnection.cpp +++ b/Swiften/Network/ProxiedConnection.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2012-2018 Isode Limited. + * Copyright (c) 2012-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Network/ProxiedConnection.h> @@ -34,13 +34,13 @@ ProxiedConnection::~ProxiedConnection() { cancelConnector(); if (connection_) { connection_->onDataRead.disconnect(boost::bind(&ProxiedConnection::handleDataRead, shared_from_this(), _1)); connection_->onDisconnected.disconnect(boost::bind(&ProxiedConnection::handleDisconnected, shared_from_this(), _1)); } if (connected_) { - SWIFT_LOG(warning) << "Connection was still established." << std::endl; + SWIFT_LOG(warning) << "Connection was still established."; } } void ProxiedConnection::cancelConnector() { if (connector_) { connector_->onConnectFinished.disconnect(boost::bind(&ProxiedConnection::handleConnectFinished, shared_from_this(), _1)); diff --git a/Swiften/Network/SOCKS5ProxiedConnection.cpp b/Swiften/Network/SOCKS5ProxiedConnection.cpp index d7036f2..c76b6e6 100644 --- a/Swiften/Network/SOCKS5ProxiedConnection.cpp +++ b/Swiften/Network/SOCKS5ProxiedConnection.cpp @@ -2,13 +2,13 @@ * Copyright (c) 2010-2011 Thilo Cestonaro * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ /* - * Copyright (c) 2014-2018 Isode Limited. + * Copyright (c) 2014-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Network/SOCKS5ProxiedConnection.h> @@ -47,13 +47,13 @@ void SOCKS5ProxiedConnection::initializeProxy() { void SOCKS5ProxiedConnection::handleProxyInitializeData(std::shared_ptr<SafeByteArray> data) { SafeByteArray socksConnect; boost::asio::ip::address rawAddress = getServer().getAddress().getRawAddress(); assert(rawAddress.is_v4() || rawAddress.is_v6()); if (proxyState_ == ProxyAuthenticating) { - SWIFT_LOG(debug) << "ProxyAuthenticating response received, reply with the connect BYTEs" << std::endl; + SWIFT_LOG(debug) << "ProxyAuthenticating response received, reply with the connect BYTEs"; unsigned char choosenMethod = static_cast<unsigned char> ((*data)[1]); if ((*data)[0] == 0x05 && choosenMethod != 0xFF) { switch(choosenMethod) { // use the correct Method case 0x00: try { proxyState_ = ProxyConnecting; @@ -76,27 +76,27 @@ void SOCKS5ProxiedConnection::handleProxyInitializeData(std::shared_ptr<SafeByte socksConnect.push_back(static_cast<unsigned char> ((getServer().getPort() >> 8) & 0xFF)); // highbyte of the port. socksConnect.push_back(static_cast<unsigned char> (getServer().getPort() & 0xFF)); // lowbyte of the port. write(socksConnect); return; } catch(...) { - SWIFT_LOG(error) << "exception caught" << std::endl; + SWIFT_LOG(error) << "exception caught"; } write(socksConnect); break; default: setProxyInitializeFinished(true); break; } return; } setProxyInitializeFinished(false); } else if (proxyState_ == ProxyConnecting) { - SWIFT_LOG(debug) << "Connect response received, check if successfully." << std::endl; - SWIFT_LOG(debug) << "Errorbyte: 0x" << std::hex << static_cast<int> ((*data)[1]) << std::dec << std::endl; + SWIFT_LOG(debug) << "Connect response received, check if successfully."; + SWIFT_LOG(debug) << "Errorbyte: 0x" << std::hex << static_cast<int> ((*data)[1]) << std::dec; /* data.at(1) can be one of the following: 0x00 succeeded 0x01 general SOCKS server failure 0x02 connection not allowed by ruleset @@ -106,15 +106,15 @@ void SOCKS5ProxiedConnection::handleProxyInitializeData(std::shared_ptr<SafeByte 0x06 TTL expired 0x07 Command not supported (CMD) 0x08 Address type not supported (ATYP) 0x09 bis 0xFF unassigned */ if ((*data)[0] == 0x05 && (*data)[1] == 0x0) { - SWIFT_LOG(debug) << "Successfully connected the server via the proxy." << std::endl; + SWIFT_LOG(debug) << "Successfully connected the server via the proxy."; setProxyInitializeFinished(true); } else { - SWIFT_LOG(error) << "SOCKS Proxy returned an error: " << std::hex << (*data)[1] << std::endl; + SWIFT_LOG(error) << "SOCKS Proxy returned an error: " << std::hex << (*data)[1]; setProxyInitializeFinished(false); } } } diff --git a/Swiften/Network/UnboundDomainNameResolver.cpp b/Swiften/Network/UnboundDomainNameResolver.cpp index 1df6b8f..21bc697 100644 --- a/Swiften/Network/UnboundDomainNameResolver.cpp +++ b/Swiften/Network/UnboundDomainNameResolver.cpp @@ -61,22 +61,22 @@ class UnboundDomainNameServiceQuery : public DomainNameServiceQuery, public Unbo UnboundWrapperHelper* helper = new UnboundWrapperHelper(resolver, shared_from_this()); retval = ub_resolve_async(ubContext, const_cast<char*>(name.c_str()), LDNS_RR_TYPE_SRV, 1 /* CLASS IN (internet) */, helper, UnboundDomainNameResolver::unbound_callback_wrapper, NULL); if(retval != 0) { - SWIFT_LOG(debug) << "resolve error: " << ub_strerror(retval) << std::endl; + SWIFT_LOG(debug) << "resolve error: " << ub_strerror(retval); delete helper; } } void handleResult(int err, struct ub_result* result) { std::vector<DomainNameServiceQuery::Result> serviceRecords; if(err != 0) { - SWIFT_LOG(debug) << "resolve error: " << ub_strerror(err) << std::endl; + SWIFT_LOG(debug) << "resolve error: " << ub_strerror(err); } else { if(result->havedata) { ldns_pkt* replyPacket = 0; ldns_buffer* buffer = ldns_buffer_new(1024); if (buffer && ldns_wire2pkt(&replyPacket, static_cast<const uint8_t*>(result->answer_packet), result->answer_len) == LDNS_STATUS_OK) { ldns_rr_list* rrList = ldns_pkt_answer(replyPacket); @@ -102,13 +102,13 @@ class UnboundDomainNameServiceQuery : public DomainNameServiceQuery, public Unbo } char terminator = 0; ldns_buffer_write(buffer, &terminator, sizeof(terminator)); serviceRecord.hostname = std::string(reinterpret_cast<char*>(ldns_buffer_at(buffer, 0))); serviceRecords.push_back(serviceRecord); - SWIFT_LOG(debug) << "hostname " << serviceRecord.hostname << " added" << std::endl; + SWIFT_LOG(debug) << "hostname " << serviceRecord.hostname << " added"; } } if (replyPacket) ldns_pkt_free(replyPacket); if (buffer) ldns_buffer_free(buffer); } } @@ -134,38 +134,38 @@ class UnboundDomainNameAddressQuery : public DomainNameAddressQuery, public Unbo //FIXME: support AAAA queries in some way retval = ub_resolve_async(ubContext, const_cast<char*>(name.c_str()), LDNS_RR_TYPE_A, 1 /* CLASS IN (internet) */, helper, UnboundDomainNameResolver::unbound_callback_wrapper, NULL); if(retval != 0) { - SWIFT_LOG(debug) << "resolve error: " << ub_strerror(retval) << std::endl; + SWIFT_LOG(debug) << "resolve error: " << ub_strerror(retval); delete helper; } } void handleResult(int err, struct ub_result* result) { std::vector<HostAddress> addresses; boost::optional<DomainNameResolveError> error; - SWIFT_LOG(debug) << "Result for: " << name << std::endl; + SWIFT_LOG(debug) << "Result for: " << name; if(err != 0) { - SWIFT_LOG(debug) << "resolve error: " << ub_strerror(err) << std::endl; + SWIFT_LOG(debug) << "resolve error: " << ub_strerror(err); error = DomainNameResolveError(); } else { if(result->havedata) { for(int i=0; result->data[i]; i++) { char address[100]; const char* addressStr = 0; if ((addressStr = inet_ntop(AF_INET, result->data[i], address, 100))) { - SWIFT_LOG(debug) << "IPv4 address: " << addressStr << std::endl; + SWIFT_LOG(debug) << "IPv4 address: " << addressStr; addresses.push_back(HostAddress(std::string(addressStr))); } else if ((addressStr = inet_ntop(AF_INET6, result->data[i], address, 100))) { - SWIFT_LOG(debug) << "IPv6 address: " << addressStr << std::endl; + SWIFT_LOG(debug) << "IPv6 address: " << addressStr; addresses.push_back(HostAddress(std::string(addressStr))); } else { - SWIFT_LOG(debug) << "inet_ntop() failed" << std::endl; + SWIFT_LOG(debug) << "inet_ntop() failed"; error = DomainNameResolveError(); } } } else { error = DomainNameResolveError(); } @@ -179,27 +179,27 @@ class UnboundDomainNameAddressQuery : public DomainNameAddressQuery, public Unbo std::string name; }; UnboundDomainNameResolver::UnboundDomainNameResolver(IDNConverter* idnConverter, std::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop) : idnConverter(idnConverter), ioService(ioService), ubDescriptior(*ioService), eventLoop(eventLoop) { ubContext = ub_ctx_create(); if(!ubContext) { - SWIFT_LOG(debug) << "could not create unbound context" << std::endl; + SWIFT_LOG(debug) << "could not create unbound context"; } eventOwner = std::make_shared<EventOwner>(); ub_ctx_async(ubContext, true); int ret; /* read /etc/resolv.conf for DNS proxy settings (from DHCP) */ if( (ret=ub_ctx_resolvconf(ubContext, const_cast<char*>("/etc/resolv.conf"))) != 0) { - SWIFT_LOG(error) << "error reading resolv.conf: " << ub_strerror(ret) << ". errno says: " << strerror(errno) << std::endl; + SWIFT_LOG(error) << "error reading resolv.conf: " << ub_strerror(ret) << ". errno says: " << strerror(errno); } /* read /etc/hosts for locally supplied host addresses */ if( (ret=ub_ctx_hosts(ubContext, const_cast<char*>("/etc/hosts"))) != 0) { - SWIFT_LOG(error) << "error reading hosts: " << ub_strerror(ret) << ". errno says: " << strerror(errno) << std::endl; + SWIFT_LOG(error) << "error reading hosts: " << ub_strerror(ret) << ". errno says: " << strerror(errno); } ubDescriptior.assign(ub_fd(ubContext)); ubDescriptior.async_read_some(boost::asio::null_buffers(), boost::bind(&UnboundDomainNameResolver::handleUBSocketReadable, this, boost::asio::placeholders::error)); } @@ -228,13 +228,13 @@ void UnboundDomainNameResolver::handleUBSocketReadable(boost::system::error_code } void UnboundDomainNameResolver::processData() { if (ub_poll(ubContext)) { int ret = ub_process(ubContext); if(ret != 0) { - SWIFT_LOG(debug) << "resolve error: " << ub_strerror(ret) << std::endl; + SWIFT_LOG(debug) << "resolve error: " << ub_strerror(ret); } } } std::shared_ptr<DomainNameServiceQuery> UnboundDomainNameResolver::createServiceQuery(const std::string& serviceLookupPrefix, const std::string& domain) { boost::optional<std::string> encodedDomain = idnConverter->getIDNAEncoded(domain); diff --git a/Swiften/Network/UnitTest/HTTPConnectProxiedConnectionTest.cpp b/Swiften/Network/UnitTest/HTTPConnectProxiedConnectionTest.cpp index 065d015..e9268b0 100644 --- a/Swiften/Network/UnitTest/HTTPConnectProxiedConnectionTest.cpp +++ b/Swiften/Network/UnitTest/HTTPConnectProxiedConnectionTest.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <memory> @@ -34,13 +34,13 @@ namespace { public: ExampleHTTPTrafficFilter() {} virtual ~ExampleHTTPTrafficFilter() {} virtual std::vector<std::pair<std::string, std::string> > filterHTTPResponseHeader(const std::string& /* statusLine */, const std::vector<std::pair<std::string, std::string> >& response) { filterResponses.push_back(response); - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); return filterResponseReturn; } std::vector<std::vector<std::pair<std::string, std::string> > > filterResponses; std::vector<std::pair<std::string, std::string> > filterResponseReturn; @@ -406,13 +406,13 @@ class HTTPConnectProxiedConnectionTest : public CppUnit::TestFixture { MockConnectionFactory(EventLoop* eventLoop) : eventLoop(eventLoop) { } std::shared_ptr<Connection> createConnection() { std::shared_ptr<MockConnection> connection = std::make_shared<MockConnection>(failingPorts, eventLoop); connections.push_back(connection); - SWIFT_LOG(debug) << "new connection created" << std::endl; + SWIFT_LOG(debug) << "new connection created"; return connection; } EventLoop* eventLoop; std::vector< std::shared_ptr<MockConnection> > connections; std::vector<HostAddressPort> failingPorts; diff --git a/Swiften/Network/WindowsProxyProvider.cpp b/Swiften/Network/WindowsProxyProvider.cpp index 9a60bb4..13fdb25 100644 --- a/Swiften/Network/WindowsProxyProvider.cpp +++ b/Swiften/Network/WindowsProxyProvider.cpp @@ -49,13 +49,13 @@ WindowsProxyProvider::WindowsProxyProvider() if(result == ERROR_SUCCESS) { std::vector<std::string> proxies = String::split(byteArrayToString(dataBuffer), ';'); std::pair<std::string, std::string> protocolAndProxy; for(auto&& proxy : proxies) { if(proxy.find('=') != std::string::npos) { protocolAndProxy = String::getSplittedAtFirst(proxy, '='); - SWIFT_LOG(debug) << "Found proxy: " << protocolAndProxy.first << " => " << protocolAndProxy.second << std::endl; + SWIFT_LOG(debug) << "Found proxy: " << protocolAndProxy.first << " => " << protocolAndProxy.second; if(protocolAndProxy.first.compare("socks") == 0) { socksProxy = getAsHostAddressPort(protocolAndProxy.second); } else if (protocolAndProxy.first.compare("http") == 0) { httpProxy = getAsHostAddressPort(protocolAndProxy.second); } @@ -83,13 +83,13 @@ HostAddressPort WindowsProxyProvider::getAsHostAddressPort(std::string proxy) { // .c_str() is needed as tmp.second can include a \0 char which will end in an exception of the lexical cast. // with .c_str() the \0 will not be part of the string which is to be casted port = boost::numeric_cast<unsigned short>(boost::lexical_cast<int> (tmp.second.c_str())); ret = HostAddressPort(HostAddress::fromString(tmp.first).get(), port); } catch(...) { - SWIFT_LOG(error) << "Exception occured while parsing windows proxy \"getHostAddressPort\"." << std::endl; + SWIFT_LOG(error) << "Exception occured while parsing windows proxy \"getHostAddressPort\"."; } return ret; } diff --git a/Swiften/Parser/IQParser.cpp b/Swiften/Parser/IQParser.cpp index 5cfae34..363f7ec 100644 --- a/Swiften/Parser/IQParser.cpp +++ b/Swiften/Parser/IQParser.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Parser/IQParser.h> @@ -29,13 +29,13 @@ void IQParser::handleStanzaAttributes(const AttributeMap& attributes) { getStanzaGeneric()->setType(IQ::Result); } else if (*type == "error") { getStanzaGeneric()->setType(IQ::Error); } else { - SWIFT_LOG(warning) << "Unknown IQ type: " << *type << std::endl; + SWIFT_LOG(warning) << "Unknown IQ type: " << *type; getStanzaGeneric()->setType(IQ::Get); } } } } diff --git a/Swiften/Parser/LibXMLParser.cpp b/Swiften/Parser/LibXMLParser.cpp index 158958b..32b91a1 100644 --- a/Swiften/Parser/LibXMLParser.cpp +++ b/Swiften/Parser/LibXMLParser.cpp @@ -31,13 +31,13 @@ struct LibXMLParser::Private { }; static void handleStartElement(void* parser, const xmlChar* name, const xmlChar* prefix, const xmlChar* xmlns, int nbNamespaces, const xmlChar** namespaces, int nbAttributes, int nbDefaulted, const xmlChar ** attributes) { AttributeMap attributeValues; if (nbDefaulted != 0) { // Just because i don't understand what this means yet :-) - SWIFT_LOG(error) << "Unexpected nbDefaulted on XML element" << std::endl; + SWIFT_LOG(error) << "Unexpected nbDefaulted on XML element"; } for (int i = 0; i < nbAttributes*5; i += 5) { std::string attributeName = asString(attributes[i]); std::string attributePrefix = asString(attributes[i+1]); std::string attributeNS = asString(attributes[i+2]); assert(attributes[i+4] >= attributes[i+3]); diff --git a/Swiften/Parser/PresenceParser.cpp b/Swiften/Parser/PresenceParser.cpp index 0235a12..f73e9d8 100644 --- a/Swiften/Parser/PresenceParser.cpp +++ b/Swiften/Parser/PresenceParser.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Parser/PresenceParser.h> @@ -38,13 +38,13 @@ void PresenceParser::handleStanzaAttributes(const AttributeMap& attributes) { getStanzaGeneric()->setType(Presence::Unsubscribed); } else if (*type == "error") { getStanzaGeneric()->setType(Presence::Error); } else { - SWIFT_LOG(error) << "Unknown Presence type: " << *type << std::endl; + SWIFT_LOG(error) << "Unknown Presence type: " << *type; getStanzaGeneric()->setType(Presence::Available); } } else { getStanzaGeneric()->setType(Presence::Available); } diff --git a/Swiften/Roster/XMPPRosterController.cpp b/Swiften/Roster/XMPPRosterController.cpp index 8ee9755..2b98b53 100644 --- a/Swiften/Roster/XMPPRosterController.cpp +++ b/Swiften/Roster/XMPPRosterController.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Roster/XMPPRosterController.h> @@ -63,13 +63,13 @@ void XMPPRosterController::handleRosterReceived(std::shared_ptr<RosterPayload> r // The cached version hasn't changed; emit all items for (const auto& item : previousRoster->getItems()) { if (item.getSubscription() != RosterItemPayload::Remove) { xmppRoster_->addContact(item.getJID(), item.getName(), item.getGroups(), item.getSubscription()); } else { - SWIFT_LOG(error) << "Stored invalid roster item" << std::endl; + SWIFT_LOG(error) << "Stored invalid roster item"; } } } if (initial) { xmppRoster_->onInitialRosterPopulated(); } diff --git a/Swiften/SASL/WindowsAuthentication.cpp b/Swiften/SASL/WindowsAuthentication.cpp index b86381b..f951fac 100644 --- a/Swiften/SASL/WindowsAuthentication.cpp +++ b/Swiften/SASL/WindowsAuthentication.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/SASL/WindowsAuthentication.h> @@ -13,20 +13,20 @@ #include <Swiften/Base/Log.h> #include <Swiften/Base/String.h> #define ASSIGN_ERROR(status, errorCode) \ { \ errorCode = std::make_shared<boost::system::error_code>(status, boost::system::system_category()); \ - SWIFT_LOG(debug) << std::hex << "status: 0x" << status << ": " << errorCode->message() << std::endl; \ + SWIFT_LOG(debug) << std::hex << "status: 0x" << status << ": " << errorCode->message(); \ } #define ASSIGN_SEC_ERROR(status, errorCode) \ { \ if (status == SEC_E_OK) \ { \ - SWIFT_LOG(debug) << "success" << std::endl; \ + SWIFT_LOG(debug) << "success"; \ } \ else { \ ASSIGN_ERROR(status, errorCode); \ } \ } @@ -43,20 +43,20 @@ std::shared_ptr<boost::system::error_code> getUserNameEx(std::string& userName, /* length after this call will contain the required length if current length is not enough - so the next call should succeed */ if (GetUserNameExW(NameSamCompatible, vecptr(value), &length)) { std::size_t position; userName = convertWStringToString(std::wstring(vecptr(value), length)); - SWIFT_LOG(debug) << "User Name: " << userName << std::endl; + SWIFT_LOG(debug) << "User Name: " << userName; position = userName.find("\\"); clientName = userName.substr(position + 1); - SWIFT_LOG(debug) << "Client name: " << clientName << std::endl; + SWIFT_LOG(debug) << "Client name: " << clientName; serverName = userName.substr(0, position); - SWIFT_LOG(debug) << "Server name: " << serverName << std::endl; + SWIFT_LOG(debug) << "Server name: " << serverName; break; } status = GetLastError(); if ((firstCall == false) || (status != ERROR_MORE_DATA)) { @@ -158,13 +158,13 @@ std::shared_ptr<boost::system::error_code> initializeSecurityContext(const boost } if ((status == SEC_E_OK) || (status == SEC_I_COMPLETE_NEEDED)) { *haveCompleteContext = true; } if ((status == SEC_E_OK) || (status == SEC_I_COMPLETE_AND_CONTINUE) || (status == SEC_I_COMPLETE_NEEDED) || (status == SEC_I_CONTINUE_NEEDED)) { outputToken = createSafeByteArray (static_cast<unsigned char *>(outputTokenBuffer.pvBuffer), outputTokenBuffer.cbBuffer); - SWIFT_LOG(debug) << "outputToken.size(): " << outputToken.size() << std::endl; + SWIFT_LOG(debug) << "outputToken.size(): " << outputToken.size(); freeContextBuffer(outputTokenBuffer.pvBuffer); return std::shared_ptr<boost::system::error_code>(); /* success */ } return errorCode; @@ -226,29 +226,29 @@ std::shared_ptr<boost::system::error_code> decryptMessage(const PCtxtHandle cont messageBuffer[0].pvBuffer = static_cast<void *>(vecptr(inputMessage)); messageBuffer[1].BufferType = SECBUFFER_DATA; messageBuffer[1].cbBuffer = 0; messageBuffer[1].pvBuffer = NULL; - SWIFT_LOG(debug) << "inputMessage.size(): " << inputMessage.size() << std::endl; + SWIFT_LOG(debug) << "inputMessage.size(): " << inputMessage.size(); status = DecryptMessage( contextHandle, &inOut, 0, /* Don't maintain sequence numbers */ &qualityOfProtection); ASSIGN_SEC_ERROR(status, errorCode); if (status == SEC_E_OK) { if (qualityOfProtection == SECQOP_WRAP_NO_ENCRYPT) { - SWIFT_LOG(debug) << "Message was signed only" << std::endl; + SWIFT_LOG(debug) << "Message was signed only"; } else { - SWIFT_LOG(debug) << "Message was encrypted" << std::endl; + SWIFT_LOG(debug) << "Message was encrypted"; } - SWIFT_LOG(debug) << "messageBuffer[1].cbBuffer: " << messageBuffer[1].cbBuffer << std::endl; + SWIFT_LOG(debug) << "messageBuffer[1].cbBuffer: " << messageBuffer[1].cbBuffer; decrypted = createSafeByteArray (static_cast<unsigned char *>(messageBuffer[1].pvBuffer), messageBuffer[1].cbBuffer); } return errorCode; } @@ -278,28 +278,28 @@ std::shared_ptr<boost::system::error_code> encryptMessage(const PCtxtHandle cont messageBuffer[1].pvBuffer = (void *) vecptr(inputMessage); messageBuffer[2].BufferType = SECBUFFER_PADDING; messageBuffer[2].cbBuffer = sizes.cbBlockSize; messageBuffer[2].pvBuffer = vecptr(blockSize); - SWIFT_LOG(debug) << "sizes.cbSecurityTrailer: " << sizes.cbSecurityTrailer << std::endl; - SWIFT_LOG(debug) << "inputMessage.size(): " << inputMessage.size() << std::endl; - SWIFT_LOG(debug) << "sizes.cbBlockSize: " << sizes.cbBlockSize << std::endl; + SWIFT_LOG(debug) << "sizes.cbSecurityTrailer: " << sizes.cbSecurityTrailer; + SWIFT_LOG(debug) << "inputMessage.size(): " << inputMessage.size(); + SWIFT_LOG(debug) << "sizes.cbBlockSize: " << sizes.cbBlockSize; status = EncryptMessage( contextHandle, SECQOP_WRAP_NO_ENCRYPT, &inOut, 0); /* Don't maintain sequence numbers */ ASSIGN_SEC_ERROR(status, errorCode); if (status == SEC_E_OK) { unsigned char* pointer; - SWIFT_LOG(debug) << "messageBuffer[0].cbBuffer: " << messageBuffer[0].cbBuffer << std::endl; - SWIFT_LOG(debug) << "messageBuffer[1].cbBuffer: " << messageBuffer[1].cbBuffer << std::endl; - SWIFT_LOG(debug) << "messageBuffer[2].cbBuffer: " << messageBuffer[2].cbBuffer << std::endl; + SWIFT_LOG(debug) << "messageBuffer[0].cbBuffer: " << messageBuffer[0].cbBuffer; + SWIFT_LOG(debug) << "messageBuffer[1].cbBuffer: " << messageBuffer[1].cbBuffer; + SWIFT_LOG(debug) << "messageBuffer[2].cbBuffer: " << messageBuffer[2].cbBuffer; output.resize(messageBuffer[0].cbBuffer + messageBuffer[1].cbBuffer + messageBuffer[2].cbBuffer); pointer = vecptr(output); for (size_t i = 0; i < inOut.cBuffers; i++) { if (messageBuffer[i].cbBuffer) { memcpy(pointer, messageBuffer[i].pvBuffer, messageBuffer[i].cbBuffer); diff --git a/Swiften/SASL/WindowsGSSAPIClientAuthenticator.cpp b/Swiften/SASL/WindowsGSSAPIClientAuthenticator.cpp index aae437f..10e8c89 100644 --- a/Swiften/SASL/WindowsGSSAPIClientAuthenticator.cpp +++ b/Swiften/SASL/WindowsGSSAPIClientAuthenticator.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/SASL/WindowsGSSAPIClientAuthenticator.h> @@ -41,61 +41,61 @@ WindowsGSSAPIClientAuthenticator::~WindowsGSSAPIClientAuthenticator() { if (haveCredentialsHandle_) { freeCredentialsHandle(&credentialsHandle_); } } boost::optional<SafeByteArray> WindowsGSSAPIClientAuthenticator::getResponse() const { - SWIFT_LOG(debug) << "response_.size(): " << response_.size() << std::endl; + SWIFT_LOG(debug) << "response_.size(): " << response_.size(); return response_; } bool WindowsGSSAPIClientAuthenticator::setChallenge(const boost::optional<ByteArray>& challengeData) { /* Following http://tools.ietf.org/html/rfc4752, https://msdn.microsoft.com/en-us/library/windows/desktop/aa380496%28v=vs.85%29.aspx */ if (step_ == BuildingSecurityContext) { buildSecurityContext(challengeData); } else if (step_ == SecurityLayerNegotiation) { if (!challengeData) { - SWIFT_LOG(debug) << "Empty message received from the server" << std::endl; + SWIFT_LOG(debug) << "Empty message received from the server"; error_ = true; return false; } SafeByteArray challenge; errorCode_ = decryptMessage(&contextHandle_, challengeData.get(), challenge); if (isError()) { return false; } if (challenge.size() != 4) { - SWIFT_LOG(debug) << "Token received from the server of incorrect length: " << challenge.size() << std::endl; + SWIFT_LOG(debug) << "Token received from the server of incorrect length: " << challenge.size(); error_ = true; return false; } unsigned char* challengePointer = vecptr(challenge); unsigned char serverSecurityLayer = challengePointer[0]; if (serverSecurityLayer == 0) { - SWIFT_LOG(debug) << "Server supports unknown security layer, assuming no security layer" << std::endl; + SWIFT_LOG(debug) << "Server supports unknown security layer, assuming no security layer"; serverSecurityLayer = SECURITY_LAYER_NONE; } else if (serverSecurityLayer == SECURITY_LAYER_NONE) { - SWIFT_LOG(debug) << "Server supports no security layer" << std::endl; + SWIFT_LOG(debug) << "Server supports no security layer"; } else { - SWIFT_LOG(debug) << "Server supports security layer" << std::endl; + SWIFT_LOG(debug) << "Server supports security layer"; } unsigned int serverMaximumBuffer = (challengePointer[1] << 16) | (challengePointer[2] << 8) | (challengePointer[3] << 0); if ((serverSecurityLayer == SECURITY_LAYER_NONE) && (serverMaximumBuffer != 0)) { - SWIFT_LOG(debug) << "Server supports no security layer but has maximum buffer size" << serverMaximumBuffer << std::endl; + SWIFT_LOG(debug) << "Server supports no security layer but has maximum buffer size" << serverMaximumBuffer; error_ = true; return false; } SafeByteArray message(4); @@ -155,13 +155,13 @@ void WindowsGSSAPIClientAuthenticator::buildSecurityContext(const boost::optiona if (!haveCompleteContext_) { return; } if (contextSupported & ISC_REQ_MUTUAL_AUTH == 0) { - SWIFT_LOG(debug) << "Mutual authentication not supported" << std::endl; + SWIFT_LOG(debug) << "Mutual authentication not supported"; error_ = true; return; } errorCode_ = queryContextAttributes(&contextHandle_, SECPKG_ATTR_SIZES, &sizes_); if (isError()) { @@ -178,20 +178,20 @@ void WindowsGSSAPIClientAuthenticator::buildSecurityContext(const boost::optiona errorCode_ = queryContextAttributes(&contextHandle_, SECPKG_ATTR_NAMES, &names); if (isError()) { return; } userName_ = names.sUserName; - SWIFT_LOG(debug) << "User name: " << userName_ << std::endl; + SWIFT_LOG(debug) << "User name: " << userName_; std::size_t position = userName_.find("\\"); clientName_ = userName_.substr(position + 1); - SWIFT_LOG(debug) << "Client name: " << clientName_ << std::endl; + SWIFT_LOG(debug) << "Client name: " << clientName_; serverName_ = userName_.substr(0, position); - SWIFT_LOG(debug) << "Server name: " << serverName_ << std::endl; + SWIFT_LOG(debug) << "Server name: " << serverName_; freeContextBuffer(names.sUserName); step_ = SecurityLayerNegotiation; } } diff --git a/Swiften/SASL/WindowsServicePrincipalName.cpp b/Swiften/SASL/WindowsServicePrincipalName.cpp index 419395c..6c87925 100644 --- a/Swiften/SASL/WindowsServicePrincipalName.cpp +++ b/Swiften/SASL/WindowsServicePrincipalName.cpp @@ -61,31 +61,31 @@ std::string WindowsServicePrincipalName::toString() { throw std::runtime_error(errorString.str()); } firstCall = false; } - SWIFT_LOG(debug) << "SPN: " << str << std::endl; + SWIFT_LOG(debug) << "SPN: " << str; return str; } DWORD WindowsServicePrincipalName::dsMakeSpn(DWORD* length, wchar_t* value) { DWORD status; #ifdef UNICODE - SWIFT_LOG(debug) << "UNICODE is defined" << std::endl; + SWIFT_LOG(debug) << "UNICODE is defined"; #else - SWIFT_LOG(debug) << "UNICODE is not defined" << std::endl; + SWIFT_LOG(debug) << "UNICODE is not defined"; #endif - SWIFT_LOG(debug) << "serviceClass_: " << convertWStringToString(serviceClass_.c_str()) << std::endl; - SWIFT_LOG(debug) << "serviceName_: " << convertWStringToString(serviceName_.c_str()) << std::endl; - SWIFT_LOG(debug) << "instanceName_: " << convertWStringToString(instanceName_.c_str()) << std::endl; - SWIFT_LOG(debug) << "referrer_: " << convertWStringToString(referrer_.c_str()) << std::endl; - SWIFT_LOG(debug) << "instancePort_: " << instancePort_ << std::endl; - SWIFT_LOG(debug) << "length: " << *length << std::endl; + SWIFT_LOG(debug) << "serviceClass_: " << convertWStringToString(serviceClass_.c_str()); + SWIFT_LOG(debug) << "serviceName_: " << convertWStringToString(serviceName_.c_str()); + SWIFT_LOG(debug) << "instanceName_: " << convertWStringToString(instanceName_.c_str()); + SWIFT_LOG(debug) << "referrer_: " << convertWStringToString(referrer_.c_str()); + SWIFT_LOG(debug) << "instancePort_: " << instancePort_; + SWIFT_LOG(debug) << "length: " << *length; /* Call the Unicode function because that is recommended: https://msdn.microsoft.com/en-us/library/windows/desktop/ff381407%28v=vs.85%29.aspx */ status = DsMakeSpnW( serviceClass_.c_str(), serviceName_.c_str(), @@ -94,13 +94,13 @@ https://msdn.microsoft.com/en-us/library/windows/desktop/ff381407%28v=vs.85%29.a referrer_.empty() ? NULL : referrer_.c_str(), length, value); if (status != ERROR_SUCCESS) { boost::system::error_code errorCode(status, boost::system::system_category()); - SWIFT_LOG(debug) << std::hex << "status: 0x" << status << ": " << errorCode.message() << std::endl; + SWIFT_LOG(debug) << std::hex << "status: 0x" << status << ": " << errorCode.message(); } return status; } } diff --git a/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.cpp index aaac757..566d556 100644 --- a/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.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) 2015-2016 Isode Limited. + * Copyright (c) 2015-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.h> @@ -90,23 +90,23 @@ std::string JinglePayloadSerializer::actionToString(JinglePayload::Action action return "transport-info"; case JinglePayload::TransportReject: return "transport-reject"; case JinglePayload::TransportReplace: return "transport-replace"; case JinglePayload::UnknownAction: - SWIFT_LOG(warning) << "Serializing unknown action value." << std::endl; + SWIFT_LOG(warning) << "Serializing unknown action value."; return ""; } assert(false); return ""; } std::string JinglePayloadSerializer::reasonTypeToString(JinglePayload::Reason::Type type) const { switch(type) { case JinglePayload::Reason::UnknownType: - SWIFT_LOG(warning) << "Unknown jingle reason type!" << std::endl; + SWIFT_LOG(warning) << "Unknown jingle reason type!"; return ""; case JinglePayload::Reason::AlternativeSession: return "alternative-session"; case JinglePayload::Reason::Busy: return "busy"; case JinglePayload::Reason::Cancel: diff --git a/Swiften/Serializer/PayloadSerializers/ReferencePayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/ReferencePayloadSerializer.cpp index 6e78a8d..128aac7 100644 --- a/Swiften/Serializer/PayloadSerializers/ReferencePayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/ReferencePayloadSerializer.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2018 Isode Limited. + * Copyright (c) 2018-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Serializer/PayloadSerializers/ReferencePayloadSerializer.h> @@ -41,13 +41,13 @@ std::string ReferencePayloadSerializer::serializePayload(ReferencePayload::ref r std::string serializedPayloads; for (const auto& payload : reference->getPayloads()) { if (auto serializer = payloadSerializers_->getPayloadSerializer(payload)) { element.addNode(std::make_shared<XMLRawTextNode>(serializer->serialize(payload))); } else { - SWIFT_LOG(warning) << "Could not find serializer for " << typeid(*(payload.get())).name() << std::endl; + SWIFT_LOG(warning) << "Could not find serializer for " << typeid(*(payload.get())).name(); } } } return element.serialize(); } diff --git a/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp b/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp index 8c05c6f..f38f5b7 100644 --- a/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp @@ -2,13 +2,13 @@ * Copyright (c) 2012 Mateusz Piękos * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ /* - * Copyright (c) 2016 Isode Limited. + * Copyright (c) 2016-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.h> @@ -196,13 +196,13 @@ namespace Swift { return "session-request"; case WhiteboardPayload::SessionAccept: return "session-accept"; case WhiteboardPayload::SessionTerminate: return "session-terminate"; case WhiteboardPayload::UnknownType: - SWIFT_LOG(warning) << "Serializing unknown action value." << std::endl; + SWIFT_LOG(warning) << "Serializing unknown action value."; return ""; } assert(false); return ""; } } diff --git a/Swiften/Serializer/StanzaSerializer.cpp b/Swiften/Serializer/StanzaSerializer.cpp index 3de706d..d4231c5 100644 --- a/Swiften/Serializer/StanzaSerializer.cpp +++ b/Swiften/Serializer/StanzaSerializer.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Serializer/StanzaSerializer.h> @@ -50,13 +50,13 @@ SafeByteArray StanzaSerializer::serialize(std::shared_ptr<ToplevelElement> eleme for (const auto& payload : stanza->getPayloads()) { PayloadSerializer* serializer = payloadSerializers_->getPayloadSerializer(payload); if (serializer) { serializedPayloads += serializer->serialize(payload); } else { - SWIFT_LOG(warning) << "Could not find serializer for " << typeid(*(payload.get())).name() << std::endl; + SWIFT_LOG(warning) << "Could not find serializer for " << typeid(*(payload.get())).name(); } } serializedPayloads = String::sanitizeXMPPString(serializedPayloads); if (!serializedPayloads.empty()) { stanzaElement.addNode(std::make_shared<XMLRawTextNode>(serializedPayloads)); } diff --git a/Swiften/Serializer/XMPPSerializer.cpp b/Swiften/Serializer/XMPPSerializer.cpp index 9cde777..7a003fb 100644 --- a/Swiften/Serializer/XMPPSerializer.cpp +++ b/Swiften/Serializer/XMPPSerializer.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Serializer/XMPPSerializer.h> @@ -86,13 +86,13 @@ std::string XMPPSerializer::serializeHeader(const ProtocolHeader& header) const SafeByteArray XMPPSerializer::serializeElement(std::shared_ptr<ToplevelElement> element) const { std::vector< std::shared_ptr<ElementSerializer> >::const_iterator i = std::find_if(serializers_.begin(), serializers_.end(), boost::bind(&ElementSerializer::canSerialize, _1, element)); if (i != serializers_.end()) { return (*i)->serialize(element); } else { - SWIFT_LOG(warning) << "Could not find serializer for " << typeid(*(element.get())).name() << std::endl; + SWIFT_LOG(warning) << "Could not find serializer for " << typeid(*(element.get())).name(); return createSafeByteArray(""); } } std::string XMPPSerializer::serializeFooter() const { return "</stream:stream>"; diff --git a/Swiften/StreamManagement/StanzaAckRequester.cpp b/Swiften/StreamManagement/StanzaAckRequester.cpp index a0f5b70..c71803a 100644 --- a/Swiften/StreamManagement/StanzaAckRequester.cpp +++ b/Swiften/StreamManagement/StanzaAckRequester.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2018 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/StreamManagement/StanzaAckRequester.h> @@ -25,13 +25,13 @@ void StanzaAckRequester::handleStanzaSent(std::shared_ptr<Stanza> stanza) { } void StanzaAckRequester::handleAckReceived(unsigned int handledStanzasCount) { unsigned int i = lastHandledStanzasCount; while (i != handledStanzasCount) { if (unackedStanzas.empty()) { - SWIFT_LOG(warning) << "Server acked more stanzas than we sent" << std::endl; + SWIFT_LOG(warning) << "Server acked more stanzas than we sent"; break; } std::shared_ptr<Stanza> ackedStanza = unackedStanzas.front(); unackedStanzas.pop_front(); onStanzaAcked(ackedStanza); i = (i == MAX_HANDLED_STANZA_COUNT ? 0 : i + 1); diff --git a/Swiften/StreamStack/WhitespacePingLayer.cpp b/Swiften/StreamStack/WhitespacePingLayer.cpp index 9a473f3..7c8301e 100644 --- a/Swiften/StreamStack/WhitespacePingLayer.cpp +++ b/Swiften/StreamStack/WhitespacePingLayer.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/StreamStack/WhitespacePingLayer.h> @@ -19,13 +19,13 @@ static const int TIMEOUT_MILLISECONDS = 60000; WhitespacePingLayer::WhitespacePingLayer(TimerFactory* timerFactory) : isActive(false) { timer = timerFactory->createTimer(TIMEOUT_MILLISECONDS); timer->onTick.connect(boost::bind(&WhitespacePingLayer::handleTimerTick, this)); } WhitespacePingLayer::~WhitespacePingLayer() { - SWIFT_LOG_ASSERT(!isActive, debug) << "WhitespacePingLayer still active at destruction." << std::endl; + SWIFT_LOG_ASSERT(!isActive, debug) << "WhitespacePingLayer still active at destruction."; if (isActive) { timer->stop(); } timer->onTick.disconnect(boost::bind(&WhitespacePingLayer::handleTimerTick, this)); } diff --git a/Swiften/TLS/CAPICertificate.cpp b/Swiften/TLS/CAPICertificate.cpp index f10ad47..526b535 100644 --- a/Swiften/TLS/CAPICertificate.cpp +++ b/Swiften/TLS/CAPICertificate.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2012-2016 Isode Limited. + * Copyright (c) 2012-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once @@ -19,13 +19,13 @@ // Size of the SHA1 hash #define SHA1_HASH_LEN 20 #define DEBUG_SCARD_STATUS(function, status) \ { \ std::shared_ptr<boost::system::error_code> errorCode = std::make_shared<boost::system::error_code>(status, boost::system::system_category()); \ - SWIFT_LOG(debug) << std::hex << function << ": status: 0x" << status << ": " << errorCode->message() << std::endl; \ + SWIFT_LOG(debug) << std::hex << function << ": status: 0x" << status << ": " << errorCode->message(); \ } namespace Swift { CAPICertificate::CAPICertificate(const std::string& capiUri, TimerFactory* timerFactory) : valid_(false), @@ -41,22 +41,22 @@ CAPICertificate::CAPICertificate(const std::string& capiUri, TimerFactory* timer assert(timerFactory_); setUri(capiUri); } CAPICertificate::~CAPICertificate() { - SWIFT_LOG(debug) << "Destroying the CAPICertificate" << std::endl; + SWIFT_LOG(debug) << "Destroying the CAPICertificate"; if (smartCardTimer_) { smartCardTimer_->stop(); smartCardTimer_->onTick.disconnect(boost::bind(&CAPICertificate::handleSmartCardTimerTick, this)); smartCardTimer_.reset(); } if (certStoreHandle_) { if (CertCloseStore(certStoreHandle_, 0) == FALSE) { - SWIFT_LOG(debug) << "Failed to close the certificate store handle" << std::endl; + SWIFT_LOG(debug) << "Failed to close the certificate store handle"; } } if (cardHandle_) { LONG result = SCardDisconnect(cardHandle_, SCARD_LEAVE_CARD); DEBUG_SCARD_STATUS("SCardDisconnect", result); @@ -158,13 +158,13 @@ void CAPICertificate::setUri(const std::string& capiUri) { DWORD len; if (!CertGetCertificateContextProperty(certContext, CERT_KEY_PROV_INFO_PROP_ID, NULL, &len)) { - SWIFT_LOG(error) << "Error while retrieving context properties" << std::endl; + SWIFT_LOG(error) << "Error while retrieving context properties"; return; } std::shared_ptr<CRYPT_KEY_PROV_INFO> pinfo(static_cast<CRYPT_KEY_PROV_INFO *>(malloc(len)), free); if (!pinfo) { return; @@ -284,31 +284,31 @@ bool CAPICertificate::checkIfSmartCardPresent() { if (!smartCardReaderName_.empty()) { DWORD dwState; smartcard_check_status(scardContext_, smartCardReaderName_.c_str(), cardHandle_, &cardHandle_, &dwState); switch (dwState) { case SCARD_ABSENT: - SWIFT_LOG(debug) << "Card absent." << std::endl; + SWIFT_LOG(debug) << "Card absent."; break; case SCARD_PRESENT: - SWIFT_LOG(debug) << "Card present." << std::endl; + SWIFT_LOG(debug) << "Card present."; break; case SCARD_SWALLOWED: - SWIFT_LOG(debug) << "Card swallowed." << std::endl; + SWIFT_LOG(debug) << "Card swallowed."; break; case SCARD_POWERED: - SWIFT_LOG(debug) << "Card has power." << std::endl; + SWIFT_LOG(debug) << "Card has power."; break; case SCARD_NEGOTIABLE: - SWIFT_LOG(debug) << "Card reset and waiting PTS negotiation." << std::endl; + SWIFT_LOG(debug) << "Card reset and waiting PTS negotiation."; break; case SCARD_SPECIFIC: - SWIFT_LOG(debug) << "Card has specific communication protocols set." << std::endl; + SWIFT_LOG(debug) << "Card has specific communication protocols set."; break; default: - SWIFT_LOG(debug) << "Unknown or unexpected card state." << std::endl; + SWIFT_LOG(debug) << "Unknown or unexpected card state."; break; } switch (dwState) { case SCARD_ABSENT: return false; @@ -329,13 +329,13 @@ bool CAPICertificate::checkIfSmartCardPresent() { } } void CAPICertificate::handleSmartCardTimerTick() { bool poll = checkIfSmartCardPresent(); if (lastPollingResult_ && !poll) { - SWIFT_LOG(debug) << "CAPI Certificate detected that the certificate card was removed" << std::endl; + SWIFT_LOG(debug) << "CAPI Certificate detected that the certificate card was removed"; onCertificateCardRemoved(); } lastPollingResult_ = poll; smartCardTimer_->start(); } diff --git a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp index 16b0b2b..66b650d 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp +++ b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/TLS/OpenSSL/OpenSSLCertificate.h> @@ -29,13 +29,13 @@ OpenSSLCertificate::OpenSSLCertificate(const ByteArray& der) { unsigned char* p = const_cast<unsigned char*>(vecptr(der)); #else const unsigned char* p = vecptr(der); #endif cert = std::shared_ptr<X509>(d2i_X509(nullptr, &p, der.size()), X509_free); if (!cert) { -// SWIFT_LOG(warning) << "Error creating certificate from DER data" << std::endl; +// SWIFT_LOG(warning) << "Error creating certificate from DER data"; } parse(); } void OpenSSLCertificate::incrementReferenceCount() const { #if OPENSSL_VERSION_NUMBER >= 0x10100000L diff --git a/Swiften/TLS/OpenSSL/OpenSSLContext.cpp b/Swiften/TLS/OpenSSL/OpenSSLContext.cpp index a183a75..86b0504 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLContext.cpp +++ b/Swiften/TLS/OpenSSL/OpenSSLContext.cpp @@ -204,13 +204,13 @@ static int certVerifyCallback(X509_STORE_CTX* store_ctx, void* arg) // This callback shouldn't have been set up if the context doesn't // have a verifyCertCallback set, but it doesn't hurt to double check std::function<int (const TLSContext *)> cb = context->getVerifyCertCallback(); if (cb != nullptr) { ret = cb(static_cast<const OpenSSLContext*>(context)); } else { - SWIFT_LOG(debug) << "certVerifyCallback called but context.verifyCertCallback is unset" << std::endl; + SWIFT_LOG(debug) << "certVerifyCallback called but context.verifyCertCallback is unset"; ret = 0; } context->setX509StoreContext(nullptr); return ret; } @@ -247,18 +247,18 @@ static int verifyCallback(int preverifyOk, X509_STORE_CTX* ctx) int err = X509_STORE_CTX_get_error(ctx); int depth = X509_STORE_CTX_get_error_depth(ctx); SSL* ssl = static_cast<SSL*>(X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx())); SSL_CTX* sslctx = ssl ? SSL_get_SSL_CTX(ssl) : nullptr; if (!sslctx) { - SWIFT_LOG(debug) << "verifyCallback: internal error" << std::endl; + SWIFT_LOG(debug) << "verifyCallback: internal error"; return preverifyOk; } if (SSL_CTX_get_verify_mode(sslctx) == SSL_VERIFY_NONE) { - SWIFT_LOG(debug) << "verifyCallback: no verification required" << std::endl; + SWIFT_LOG(debug) << "verifyCallback: no verification required"; // No verification requested return 1; } X509* errCert = X509_STORE_CTX_get_current_cert(ctx); std::string subjectString; @@ -285,16 +285,16 @@ static int verifyCallback(int preverifyOk, X509_STORE_CTX* ctx) if (errCert) { X509_NAME* issuerName = X509_get_issuer_name(errCert); issuerString = X509_NAME_to_text(issuerName); } SWIFT_LOG(debug) << "verifyCallback: verification error " << X509_verify_cert_error_string(err) << " depth: " << - depth << " issuer: " << ((issuerString.length() > 0) ? issuerString : "<unknown>") << std::endl; + depth << " issuer: " << ((issuerString.length() > 0) ? issuerString : "<unknown>"); } else { SWIFT_LOG(debug) << "verifyCallback: SSL depth: " << depth << " Subject: " << - ((subjectString.length() > 0) ? subjectString : "<>") << std::endl; + ((subjectString.length() > 0) ? subjectString : "<>"); } // Always return "OK", as check on verification status // will be performed once TLS handshake has completed, // by calling OpenSSLContext::getVerificationErrorTypeForResult() to // get the value set via X509_STORE_CTX_set_error() above. return 1; @@ -302,37 +302,37 @@ static int verifyCallback(int preverifyOk, X509_STORE_CTX* ctx) bool OpenSSLContext::configure(const TLSOptions &options) { if (options.cipherSuites) { std::string cipherSuites = *(options.cipherSuites); if (SSL_CTX_set_cipher_list(context_.get(), cipherSuites.c_str()) != 1 ) { - SWIFT_LOG(debug) << "Failed to set cipher-suites" << std::endl; + SWIFT_LOG(debug) << "Failed to set cipher-suites"; return false; } } if (options.context) { const auto& contextId = *options.context; if (SSL_CTX_set_session_id_context(context_.get(), reinterpret_cast<const unsigned char *>(contextId.c_str()), contextId.length()) != 1) { - SWIFT_LOG(debug) << "Failed to set context-id" << std::endl; + SWIFT_LOG(debug) << "Failed to set context-id"; return false; } } if (options.sessionCacheTimeout) { int scto = *options.sessionCacheTimeout; if (scto <= 0) { - SWIFT_LOG(debug) << "Invalid value for session-cache-timeout" << std::endl; + SWIFT_LOG(debug) << "Invalid value for session-cache-timeout"; return false; } (void)SSL_CTX_set_timeout(context_.get(), scto); if (SSL_CTX_get_timeout(context_.get()) != scto) { - SWIFT_LOG(debug) << "Failed to set session-cache-timeout" << std::endl; + SWIFT_LOG(debug) << "Failed to set session-cache-timeout"; return false; } } if (options.verifyCertificateCallback) { verifyCertCallback = *options.verifyCertificateCallback; @@ -368,13 +368,13 @@ bool OpenSSLContext::configure(const TLSOptions &options) } } if (options.verifyDepth) { int depth = *options.verifyDepth; if (depth <= 0) { - SWIFT_LOG(debug) << "Invalid value for verify-depth" << std::endl; + SWIFT_LOG(debug) << "Invalid value for verify-depth"; return false; } // Increase depth limit by one, so that verifyCallback() will log it SSL_CTX_set_verify_depth(context_.get(), depth + 1); } @@ -590,13 +590,13 @@ void OpenSSLContext::sendPendingDataToApplication() { onError(std::make_shared<TLSError>(TLSError::UnknownError, openSSLInternalErrorToString())); } } bool OpenSSLContext::setCertificateChain(const std::vector<std::shared_ptr<Certificate>>& certificateChain) { if (certificateChain.size() == 0) { - SWIFT_LOG(debug) << "Trying to load empty certificate chain." << std::endl; + SWIFT_LOG(debug) << "Trying to load empty certificate chain."; return false; } // load endpoint certificate auto openSSLCert = dynamic_cast<OpenSSLCertificate*>(certificateChain[0].get()); if (!openSSLCert) { @@ -613,13 +613,13 @@ bool OpenSSLContext::setCertificateChain(const std::vector<std::shared_ptr<Certi auto openSSLCert = dynamic_cast<OpenSSLCertificate*>(certificate->get()); if (!openSSLCert) { return false; } if (SSL_CTX_add_extra_chain_cert(context_.get(), openSSLCert->getInternalX509().get()) != 1) { - SWIFT_LOG(debug) << "Trying to load empty certificate chain." << std::endl; + SWIFT_LOG(debug) << "Trying to load empty certificate chain."; return false; } // Have to manually increment reference count as SSL_CTX_add_extra_chain_cert does not do so openSSLCert->incrementReferenceCount(); } } diff --git a/Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp b/Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp index 12445fd..e332ca8 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp +++ b/Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp @@ -44,20 +44,20 @@ ByteArray OpenSSLContextFactory::convertDHParametersFromPEMToDER(const std::stri } return dhParametersInDER; } void OpenSSLContextFactory::setCheckCertificateRevocation(bool check) { if (check) { - SWIFT_LOG(warning) << "CRL Checking not supported for OpenSSL" << std::endl; + SWIFT_LOG(warning) << "CRL Checking not supported for OpenSSL"; assert(false); } } void OpenSSLContextFactory::setDisconnectOnCardRemoval(bool check) { if (check) { - SWIFT_LOG(warning) << "Smart cards not supported for OpenSSL" << std::endl; + SWIFT_LOG(warning) << "Smart cards not supported for OpenSSL"; } } } diff --git a/Swiften/TLS/Schannel/SchannelContext.cpp b/Swiften/TLS/Schannel/SchannelContext.cpp index c07d009..722fb4a 100644 --- a/Swiften/TLS/Schannel/SchannelContext.cpp +++ b/Swiften/TLS/Schannel/SchannelContext.cpp @@ -2,13 +2,13 @@ * Copyright (c) 2011 Soren Dreijer * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ /* - * Copyright (c) 2012-2016 Isode Limited. + * Copyright (c) 2012-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/TLS/Schannel/SchannelContext.h> @@ -37,25 +37,25 @@ SchannelContext::SchannelContext(bool tls1_0Workaround) : state_(Start), secCont ZeroMemory(&streamSizes_, sizeof(streamSizes_)); } //------------------------------------------------------------------------ SchannelContext::~SchannelContext() { - SWIFT_LOG(debug) << "Destroying SchannelContext" << std::endl; + SWIFT_LOG(debug) << "Destroying SchannelContext"; if (myCertStore_) { if (CertCloseStore(myCertStore_, 0) == FALSE) { - SWIFT_LOG(debug) << "Failed to close the certificate store" << std::endl; + SWIFT_LOG(debug) << "Failed to close the certificate store"; } } } //------------------------------------------------------------------------ void SchannelContext::determineStreamSizes() { if (QueryContextAttributes(contextHandle_, SECPKG_ATTR_STREAM_SIZES, &streamSizes_) != SEC_E_OK) { - SWIFT_LOG(debug) << "QueryContextAttributes failed to determinate the stream size" << std::endl; + SWIFT_LOG(debug) << "QueryContextAttributes failed to determinate the stream size"; } } //------------------------------------------------------------------------ void SchannelContext::connect() { @@ -650,13 +650,13 @@ std::vector<Certificate::ref> SchannelContext::getPeerCertificateChain() const { ScopedCertContext pServerCert; ScopedCertContext pIssuerCert; ScopedCertContext pCurrentCert; SECURITY_STATUS status = QueryContextAttributes(contextHandle_, SECPKG_ATTR_REMOTE_CERT_CONTEXT, pServerCert.Reset()); if (status != SEC_E_OK) { - SWIFT_LOG(debug) << "Error while Querying the Certificate Chain" << std::endl; + SWIFT_LOG(debug) << "Error while Querying the Certificate Chain"; return certificateChain; } certificateChain.push_back(std::make_shared<SchannelCertificate>(pServerCert)); pCurrentCert = pServerCert; while(pCurrentCert.GetPointer()) { @@ -685,13 +685,13 @@ ByteArray SchannelContext::getFinishMessage() const { SecPkgContext_Bindings bindings; int ret = QueryContextAttributes(contextHandle_, SECPKG_ATTR_UNIQUE_BINDINGS, &bindings); if (ret == SEC_E_OK) { return createByteArray(((unsigned char*) bindings.Bindings) + bindings.Bindings->dwApplicationDataOffset + 11 /* tls-unique:*/, bindings.Bindings->cbApplicationDataLength - 11); } else { - SWIFT_LOG(debug) << "Error while retrieving Finish Message" << std::endl; + SWIFT_LOG(debug) << "Error while retrieving Finish Message"; } return ByteArray(); } //------------------------------------------------------------------------ diff --git a/Swiften/TLS/SecureTransport/SecureTransportContext.mm b/Swiften/TLS/SecureTransport/SecureTransportContext.mm index 25f476f..b4f7842 100644 --- a/Swiften/TLS/SecureTransport/SecureTransportContext.mm +++ b/Swiften/TLS/SecureTransport/SecureTransportContext.mm @@ -1,8 +1,8 @@ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/TLS/SecureTransport/SecureTransportContext.h> @@ -69,20 +69,20 @@ CFArrayRef CreateClientCertificateChainAsCFArrayRef(CertificateWithKey::ref key) switch(securityError) { case errSecSuccess: break; case errSecAuthFailed: // Password did not work for decoding the certificate. - SWIFT_LOG(warning) << "Invalid password." << std::endl; + SWIFT_LOG(warning) << "Invalid password."; break; case errSecDecode: // Other decoding error. - SWIFT_LOG(warning) << "PKCS12 decoding error." << std::endl; + SWIFT_LOG(warning) << "PKCS12 decoding error."; break; default: - SWIFT_LOG(warning) << "Unknown error." << std::endl; + SWIFT_LOG(warning) << "Unknown error."; } if (securityError != errSecSuccess) { if (items) { CFRelease(items); items = nullptr; @@ -107,26 +107,26 @@ SecureTransportContext::SecureTransportContext(bool checkCertificateRevocation) sslContext_ = std::shared_ptr<SSLContext>(SSLCreateContext(nullptr, kSSLClientSide, kSSLStreamType), CFRelease); OSStatus error = noErr; // set IO callbacks error = SSLSetIOFuncs(sslContext_.get(), &SecureTransportContext::SSLSocketReadCallback, &SecureTransportContext::SSLSocketWriteCallback); if (error != noErr) { - SWIFT_LOG(error) << "Unable to set IO functions to SSL context." << std::endl; + SWIFT_LOG(error) << "Unable to set IO functions to SSL context."; sslContext_.reset(); } error = SSLSetConnection(sslContext_.get(), this); if (error != noErr) { - SWIFT_LOG(error) << "Unable to set connection to SSL context." << std::endl; + SWIFT_LOG(error) << "Unable to set connection to SSL context."; sslContext_.reset(); } error = SSLSetSessionOption(sslContext_.get(), kSSLSessionOptionBreakOnServerAuth, true); if (error != noErr) { - SWIFT_LOG(error) << "Unable to set kSSLSessionOptionBreakOnServerAuth on session." << std::endl; + SWIFT_LOG(error) << "Unable to set kSSLSessionOptionBreakOnServerAuth on session."; sslContext_.reset(); } } SecureTransportContext::~SecureTransportContext() { if (sslContext_) { @@ -151,49 +151,49 @@ std::string SecureTransportContext::stateToString(State state) { break; } return returnValue; } void SecureTransportContext::setState(State newState) { - SWIFT_LOG(debug) << "Switch state from " << stateToString(state_) << " to " << stateToString(newState) << "." << std::endl; + SWIFT_LOG(debug) << "Switch state from " << stateToString(state_) << " to " << stateToString(newState) << "."; state_ = newState; } void SecureTransportContext::connect() { - SWIFT_LOG_ASSERT(state_ == None, error) << "current state '" << stateToString(state_) << " invalid." << std::endl; + SWIFT_LOG_ASSERT(state_ == None, error) << "current state '" << stateToString(state_) << " invalid."; if (clientCertificate_) { CFArrayRef certs = CreateClientCertificateChainAsCFArrayRef(clientCertificate_); if (certs) { std::shared_ptr<CFArray> certRefs(certs, CFRelease); OSStatus result = SSLSetCertificate(sslContext_.get(), certRefs.get()); if (result != noErr) { - SWIFT_LOG(error) << "SSLSetCertificate failed with error " << result << "." << std::endl; + SWIFT_LOG(error) << "SSLSetCertificate failed with error " << result << "."; } } } processHandshake(); } void SecureTransportContext::processHandshake() { - SWIFT_LOG_ASSERT(state_ == None || state_ == Handshake, error) << "current state '" << stateToString(state_) << " invalid." << std::endl; + SWIFT_LOG_ASSERT(state_ == None || state_ == Handshake, error) << "current state '" << stateToString(state_) << " invalid."; OSStatus error = SSLHandshake(sslContext_.get()); if (error == errSSLWouldBlock) { setState(Handshake); } else if (error == noErr) { - SWIFT_LOG(debug) << "TLS handshake successful." << std::endl; + SWIFT_LOG(debug) << "TLS handshake successful."; setState(HandshakeDone); onConnected(); } else if (error == errSSLPeerAuthCompleted) { - SWIFT_LOG(debug) << "Received server certificate. Start verification." << std::endl; + SWIFT_LOG(debug) << "Received server certificate. Start verification."; setState(Handshake); verifyServerCertificate(); } else { - SWIFT_LOG(debug) << "Error returned from SSLHandshake call is " << error << "." << std::endl; + SWIFT_LOG(debug) << "Error returned from SSLHandshake call is " << error << "."; fatalError(nativeToTLSError(error), std::make_shared<CertificateVerificationError>()); } } #pragma clang diagnostic push @@ -223,19 +223,19 @@ void SecureTransportContext::verifyServerCertificate() { return; } OSStatus cssmResult = 0; switch(trustResult) { case kSecTrustResultUnspecified: - SWIFT_LOG(warning) << "Successful implicit validation. Result unspecified." << std::endl; + SWIFT_LOG(warning) << "Successful implicit validation. Result unspecified."; break; case kSecTrustResultProceed: - SWIFT_LOG(warning) << "Validation resulted in explicitly trusted." << std::endl; + SWIFT_LOG(warning) << "Validation resulted in explicitly trusted."; break; case kSecTrustResultRecoverableTrustFailure: - SWIFT_LOG(warning) << "recoverable trust failure" << std::endl; + SWIFT_LOG(warning) << "recoverable trust failure"; error = SecTrustGetCssmResultCode(trust, &cssmResult); if (error == errSecSuccess) { verificationError_ = CSSMErrorToVerificationError(cssmResult); if (cssmResult == CSSMERR_TP_VERIFY_ACTION_FAILED || cssmResult == CSSMERR_APPLETP_INCOMPLETE_REVOCATION_CHECK ) { // Find out the reason why the verification failed. CFArrayRef certChain; @@ -301,14 +301,14 @@ bool SecureTransportContext::setClientCertificate(CertificateWithKey::ref cert) else { return false; } } void SecureTransportContext::handleDataFromNetwork(const SafeByteArray& data) { - SWIFT_LOG(debug) << std::endl; - SWIFT_LOG_ASSERT(state_ == HandshakeDone || state_ == Handshake, error) << "current state '" << stateToString(state_) << " invalid." << std::endl; + SWIFT_LOG(debug); + SWIFT_LOG_ASSERT(state_ == HandshakeDone || state_ == Handshake, error) << "current state '" << stateToString(state_) << " invalid."; append(readingBuffer_, data); size_t bytesRead = 0; OSStatus error = noErr; SafeByteArray applicationData; @@ -329,13 +329,13 @@ void SecureTransportContext::handleDataFromNetwork(const SafeByteArray& data) { } else if (error == errSSLWouldBlock) { // Secure Transport does not want more data. break; } else { - SWIFT_LOG(error) << "SSLRead failed with error " << error << ", read bytes: " << bytesRead << "." << std::endl; + SWIFT_LOG(error) << "SSLRead failed with error " << error << ", read bytes: " << bytesRead << "."; fatalError(std::make_shared<TLSError>(), std::make_shared<CertificateVerificationError>()); return; } if (bytesRead > 0) { applicationData.resize(bytesRead); @@ -344,30 +344,30 @@ void SecureTransportContext::handleDataFromNetwork(const SafeByteArray& data) { else { break; } } break; case Error: - SWIFT_LOG(debug) << "Igoring received data in error state." << std::endl; + SWIFT_LOG(debug) << "Igoring received data in error state."; break; } } void SecureTransportContext::handleDataFromApplication(const SafeByteArray& data) { size_t processedBytes = 0; OSStatus error = SSLWrite(sslContext_.get(), data.data(), data.size(), &processedBytes); switch(error) { case errSSLWouldBlock: - SWIFT_LOG(warning) << "Unexpected because the write callback does not block." << std::endl; + SWIFT_LOG(warning) << "Unexpected because the write callback does not block."; return; case errSSLClosedGraceful: case noErr: return; default: - SWIFT_LOG(warning) << "SSLWrite returned error code: " << error << ", processed bytes: " << processedBytes << std::endl; + SWIFT_LOG(warning) << "SSLWrite returned error code: " << error << ", processed bytes: " << processedBytes; fatalError(std::make_shared<TLSError>(), std::shared_ptr<CertificateVerificationError>()); } } std::vector<Certificate::ref> SecureTransportContext::getPeerCertificateChain() const { std::vector<Certificate::ref> peerCertificateChain; @@ -387,25 +387,25 @@ std::vector<Certificate::ref> SecureTransportContext::getPeerCertificateChain() if (certificate) { peerCertificateChain.push_back(std::make_shared<SecureTransportCertificate>(certificate)); } } } else { - SWIFT_LOG(warning) << "Failed to obtain peer trust structure; error = " << error << "." << std::endl; + SWIFT_LOG(warning) << "Failed to obtain peer trust structure; error = " << error << "."; } } return peerCertificateChain; } CertificateVerificationError::ref SecureTransportContext::getPeerCertificateVerificationError() const { return verificationError_; } ByteArray SecureTransportContext::getFinishMessage() const { - SWIFT_LOG(warning) << "Access to TLS handshake finish message is not part of OS X Secure Transport APIs." << std::endl; + SWIFT_LOG(warning) << "Access to TLS handshake finish message is not part of OS X Secure Transport APIs."; return ByteArray(); } /** * This I/O callback simulates an asynchronous read to the read buffer of the context. If it is empty, it returns errSSLWouldBlock; else * the data within the buffer is returned. @@ -450,48 +450,48 @@ std::shared_ptr<TLSError> SecureTransportContext::nativeToTLSError(OSStatus /* e } std::shared_ptr<CertificateVerificationError> SecureTransportContext::CSSMErrorToVerificationError(OSStatus resultCode) { std::shared_ptr<CertificateVerificationError> error; switch(resultCode) { case CSSMERR_TP_NOT_TRUSTED: - SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_NOT_TRUSTED" << std::endl; + SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_NOT_TRUSTED"; error = std::make_shared<CertificateVerificationError>(CertificateVerificationError::Untrusted); break; case CSSMERR_TP_CERT_NOT_VALID_YET: - SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_CERT_NOT_VALID_YET" << std::endl; + SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_CERT_NOT_VALID_YET"; error = std::make_shared<CertificateVerificationError>(CertificateVerificationError::NotYetValid); break; case CSSMERR_TP_CERT_EXPIRED: - SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_CERT_EXPIRED" << std::endl; + SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_CERT_EXPIRED"; error = std::make_shared<CertificateVerificationError>(CertificateVerificationError::Expired); break; case CSSMERR_TP_CERT_REVOKED: - SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_CERT_REVOKED" << std::endl; + SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_CERT_REVOKED"; error = std::make_shared<CertificateVerificationError>(CertificateVerificationError::Revoked); break; case CSSMERR_TP_VERIFY_ACTION_FAILED: - SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_VERIFY_ACTION_FAILED" << std::endl; + SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_VERIFY_ACTION_FAILED"; break; case CSSMERR_APPLETP_INCOMPLETE_REVOCATION_CHECK: - SWIFT_LOG(debug) << "CSSM result code: CSSMERR_APPLETP_INCOMPLETE_REVOCATION_CHECK" << std::endl; + SWIFT_LOG(debug) << "CSSM result code: CSSMERR_APPLETP_INCOMPLETE_REVOCATION_CHECK"; if (checkCertificateRevocation_) { error = std::make_shared<CertificateVerificationError>(CertificateVerificationError::RevocationCheckFailed); } break; case CSSMERR_APPLETP_OCSP_UNAVAILABLE: - SWIFT_LOG(debug) << "CSSM result code: CSSMERR_APPLETP_OCSP_UNAVAILABLE" << std::endl; + SWIFT_LOG(debug) << "CSSM result code: CSSMERR_APPLETP_OCSP_UNAVAILABLE"; if (checkCertificateRevocation_) { error = std::make_shared<CertificateVerificationError>(CertificateVerificationError::RevocationCheckFailed); } break; case CSSMERR_APPLETP_SSL_BAD_EXT_KEY_USE: - SWIFT_LOG(debug) << "CSSM result code: CSSMERR_APPLETP_SSL_BAD_EXT_KEY_USE" << std::endl; + SWIFT_LOG(debug) << "CSSM result code: CSSMERR_APPLETP_SSL_BAD_EXT_KEY_USE"; error = std::make_shared<CertificateVerificationError>(CertificateVerificationError::InvalidPurpose); break; default: - SWIFT_LOG(warning) << "unhandled CSSM error: " << resultCode << ", CSSM_TP_BASE_TP_ERROR: " << CSSM_TP_BASE_TP_ERROR << std::endl; + SWIFT_LOG(warning) << "unhandled CSSM error: " << resultCode << ", CSSM_TP_BASE_TP_ERROR: " << CSSM_TP_BASE_TP_ERROR; error = std::make_shared<CertificateVerificationError>(CertificateVerificationError::UnknownError); break; } return error; } diff --git a/Swiften/TLS/SecureTransport/SecureTransportContextFactory.cpp b/Swiften/TLS/SecureTransport/SecureTransportContextFactory.cpp index cc10987..ac399e1 100644 --- a/Swiften/TLS/SecureTransport/SecureTransportContextFactory.cpp +++ b/Swiften/TLS/SecureTransport/SecureTransportContextFactory.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2015-2018 Isode Limited. + * Copyright (c) 2015-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/TLS/SecureTransport/SecureTransportContextFactory.h> @@ -36,11 +36,11 @@ void SecureTransportContextFactory::setCheckCertificateRevocation(bool b) { checkCertificateRevocation_ = b; } void SecureTransportContextFactory::setDisconnectOnCardRemoval(bool b) { disconnectOnCardRemoval_ = b; if (disconnectOnCardRemoval_) { - SWIFT_LOG(warning) << "Smart cards have not been tested yet" << std::endl; + SWIFT_LOG(warning) << "Smart cards have not been tested yet"; } } } |
Swift