summaryrefslogtreecommitdiff
path: root/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc')
-rw-r--r--src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc369
1 files changed, 171 insertions, 198 deletions
diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc
index 8301c50a4e..7d0eda9773 100644
--- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc
+++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc
@@ -51,7 +51,7 @@ const char* tc_enabled = "enabled";
const char* tc_tcp_port = "tcp_port";
const char* tc_tcp_ip_address = "tcp_ip_address";
-CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager")
+SDL_CREATE_LOG_VARIABLE("TransportManager")
namespace {
DeviceTypes devicesType = {
std::make_pair(DeviceType::AOA, std::string("USB_AOA")),
@@ -99,42 +99,39 @@ TransportAdapterImpl::~TransportAdapterImpl() {
Terminate();
if (device_scanner_) {
- LOG4CXX_DEBUG(logger_, "Deleting device_scanner_ " << device_scanner_);
+ SDL_LOG_DEBUG("Deleting device_scanner_ " << device_scanner_);
delete device_scanner_;
- LOG4CXX_DEBUG(logger_, "device_scanner_ deleted.");
+ SDL_LOG_DEBUG("device_scanner_ deleted.");
}
if (server_connection_factory_) {
- LOG4CXX_DEBUG(
- logger_,
+ SDL_LOG_DEBUG(
+
"Deleting server_connection_factory " << server_connection_factory_);
delete server_connection_factory_;
- LOG4CXX_DEBUG(logger_, "server_connection_factory deleted.");
+ SDL_LOG_DEBUG("server_connection_factory deleted.");
}
if (client_connection_listener_) {
- LOG4CXX_DEBUG(
- logger_,
+ SDL_LOG_DEBUG(
+
"Deleting client_connection_listener_ " << client_connection_listener_);
delete client_connection_listener_;
- LOG4CXX_DEBUG(logger_, "client_connection_listener_ deleted.");
+ SDL_LOG_DEBUG("client_connection_listener_ deleted.");
}
}
void TransportAdapterImpl::Terminate() {
if (device_scanner_) {
device_scanner_->Terminate();
- LOG4CXX_DEBUG(logger_,
- "device_scanner_ " << device_scanner_ << " terminated.");
+ SDL_LOG_DEBUG("device_scanner_ " << device_scanner_ << " terminated.");
}
if (server_connection_factory_) {
server_connection_factory_->Terminate();
- LOG4CXX_DEBUG(logger_,
- "server_connection_factory " << server_connection_factory_
+ SDL_LOG_DEBUG("server_connection_factory " << server_connection_factory_
<< " terminated.");
}
if (client_connection_listener_) {
client_connection_listener_->Terminate();
- LOG4CXX_DEBUG(logger_,
- "client_connection_listener_ " << client_connection_listener_
+ SDL_LOG_DEBUG("client_connection_listener_ " << client_connection_listener_
<< " terminated.");
}
@@ -150,7 +147,7 @@ void TransportAdapterImpl::Terminate() {
}
connections.clear();
- LOG4CXX_DEBUG(logger_, "Connections deleted");
+ SDL_LOG_DEBUG("Connections deleted");
DeviceMap devices;
devices_mutex_.Acquire();
@@ -158,11 +155,11 @@ void TransportAdapterImpl::Terminate() {
devices_mutex_.Release();
devices.clear();
- LOG4CXX_DEBUG(logger_, "Devices deleted");
+ SDL_LOG_DEBUG("Devices deleted");
}
TransportAdapter::Error TransportAdapterImpl::Init() {
- LOG4CXX_TRACE(logger_, "enter");
+ SDL_LOG_TRACE("enter");
Error error = OK;
@@ -180,42 +177,42 @@ TransportAdapter::Error TransportAdapterImpl::Init() {
if (get_settings().use_last_state() && initialised_) {
if (!Restore()) {
- LOG4CXX_WARN(logger_, "could not restore transport adapter state");
+ SDL_LOG_WARN("could not restore transport adapter state");
}
}
- LOG4CXX_TRACE(logger_, "exit with error: " << error);
+ SDL_LOG_TRACE("exit with error: " << error);
return error;
}
TransportAdapter::Error TransportAdapterImpl::SearchDevices() {
- LOG4CXX_TRACE(logger_, "enter");
+ SDL_LOG_TRACE("enter");
if (device_scanner_ == NULL) {
- LOG4CXX_TRACE(logger_, "exit with NOT_SUPPORTED");
+ SDL_LOG_TRACE("exit with NOT_SUPPORTED");
return NOT_SUPPORTED;
} else if (!device_scanner_->IsInitialised()) {
- LOG4CXX_TRACE(logger_, "exit with BAD_STATE");
+ SDL_LOG_TRACE("exit with BAD_STATE");
return BAD_STATE;
}
TransportAdapter::Error er = device_scanner_->Scan();
- LOG4CXX_TRACE(logger_, "exit with error: " << er);
+ SDL_LOG_TRACE("exit with error: " << er);
return er;
}
TransportAdapter::Error TransportAdapterImpl::Connect(
const DeviceUID& device_id, const ApplicationHandle& app_handle) {
- LOG4CXX_TRACE(
- logger_,
+ SDL_LOG_TRACE(
+
"enter. DeviceUID " << device_id << " ApplicationHandle " << app_handle);
if (server_connection_factory_ == 0) {
- LOG4CXX_TRACE(logger_, "exit with NOT_SUPPORTED");
+ SDL_LOG_TRACE("exit with NOT_SUPPORTED");
return NOT_SUPPORTED;
}
if (!server_connection_factory_->IsInitialised()) {
- LOG4CXX_TRACE(logger_, "exit with BAD_STATE");
+ SDL_LOG_TRACE("exit with BAD_STATE");
return BAD_STATE;
}
if (!initialised_) {
- LOG4CXX_TRACE(logger_, "exit with BAD_STATE");
+ SDL_LOG_TRACE("exit with BAD_STATE");
return BAD_STATE;
}
@@ -235,7 +232,7 @@ TransportAdapter::Error TransportAdapterImpl::Connect(
connections_lock_.Release();
if (already_exists && !pending_app) {
- LOG4CXX_TRACE(logger_, "exit with ALREADY_EXISTS");
+ SDL_LOG_TRACE("exit with ALREADY_EXISTS");
return ALREADY_EXISTS;
}
@@ -246,19 +243,18 @@ TransportAdapter::Error TransportAdapterImpl::Connect(
RemoveConnection(device_id, app_handle);
}
}
- LOG4CXX_TRACE(logger_, "exit with error: " << err);
+ SDL_LOG_TRACE("exit with error: " << err);
return err;
}
TransportAdapter::Error TransportAdapterImpl::ConnectDevice(
const DeviceUID& device_handle) {
- LOG4CXX_TRACE(logger_, "enter with device_handle: " << &device_handle);
+ SDL_LOG_TRACE("enter with device_handle: " << &device_handle);
DeviceSptr device = FindDevice(device_handle);
if (device) {
TransportAdapter::Error err = ConnectDevice(device);
if (FAIL == err && GetDeviceType() == DeviceType::CLOUD_WEBSOCKET) {
- LOG4CXX_TRACE(logger_,
- "Error occurred while connecting cloud app: " << err);
+ SDL_LOG_TRACE("Error occurred while connecting cloud app: " << err);
// Update retry count
if (device->retry_count() >=
get_settings().cloud_app_max_retry_attempts()) {
@@ -283,10 +279,10 @@ TransportAdapter::Error TransportAdapterImpl::ConnectDevice(
} else if (OK == err) {
ConnectionStatusUpdated(device, ConnectionStatus::CONNECTED);
}
- LOG4CXX_TRACE(logger_, "exit with error: " << err);
+ SDL_LOG_TRACE("exit with error: " << err);
return err;
} else {
- LOG4CXX_TRACE(logger_, "exit with BAD_PARAM");
+ SDL_LOG_TRACE("exit with BAD_PARAM");
return BAD_PARAM;
}
}
@@ -295,8 +291,7 @@ void TransportAdapterImpl::RetryConnection() {
ClearCompletedTimers();
const DeviceUID device_id = GetNextRetryDevice();
if (device_id.empty()) {
- LOG4CXX_ERROR(logger_,
- "Unable to find timer, ignoring RetryConnection request");
+ SDL_LOG_ERROR("Unable to find timer, ignoring RetryConnection request");
return;
}
ConnectDevice(device_id);
@@ -347,36 +342,36 @@ void TransportAdapterImpl::ConnectionStatusUpdated(DeviceSptr device,
TransportAdapter::Error TransportAdapterImpl::Disconnect(
const DeviceUID& device_id, const ApplicationHandle& app_handle) {
- LOG4CXX_TRACE(
- logger_,
+ SDL_LOG_TRACE(
+
"enter. device_id: " << &device_id << ", device_id: " << &device_id);
if (!initialised_) {
- LOG4CXX_TRACE(logger_, "exit with BAD_STATE");
+ SDL_LOG_TRACE("exit with BAD_STATE");
return BAD_STATE;
}
ConnectionSPtr connection = FindEstablishedConnection(device_id, app_handle);
if (connection) {
TransportAdapter::Error err = connection->Disconnect();
- LOG4CXX_TRACE(logger_, "exit with error: " << err);
+ SDL_LOG_TRACE("exit with error: " << err);
return err;
} else {
- LOG4CXX_TRACE(logger_, "exit with BAD_PARAM");
+ SDL_LOG_TRACE("exit with BAD_PARAM");
return BAD_PARAM;
}
}
TransportAdapter::Error TransportAdapterImpl::DisconnectDevice(
const DeviceUID& device_id) {
- LOG4CXX_TRACE(logger_, "enter. device_id: " << &device_id);
+ SDL_LOG_TRACE("enter. device_id: " << &device_id);
if (!initialised_) {
- LOG4CXX_TRACE(logger_, "exit with BAD_STATE");
+ SDL_LOG_TRACE("exit with BAD_STATE");
return BAD_STATE;
}
Error error = OK;
DeviceSptr device = FindDevice(device_id);
if (!device) {
- LOG4CXX_WARN(logger_, "Device with id: " << device_id << " Not found");
+ SDL_LOG_WARN("Device with id: " << device_id << " Not found");
return BAD_PARAM;
}
ConnectionStatusUpdated(device, ConnectionStatus::CLOSING);
@@ -400,7 +395,7 @@ TransportAdapter::Error TransportAdapterImpl::DisconnectDevice(
ConnectionInfo info = *j;
if (OK != info.connection->Disconnect()) {
error = FAIL;
- LOG4CXX_ERROR(logger_, "Error on disconnect " << error);
+ SDL_LOG_ERROR("Error on disconnect " << error);
}
}
@@ -411,34 +406,33 @@ TransportAdapter::Error TransportAdapterImpl::SendData(
const DeviceUID& device_id,
const ApplicationHandle& app_handle,
const ::protocol_handler::RawMessagePtr data) {
- LOG4CXX_TRACE(logger_,
- "enter. device_id: " << &device_id << ", app_handle: "
+ SDL_LOG_TRACE("enter. device_id: " << &device_id << ", app_handle: "
<< &app_handle << ", data: " << data);
if (!initialised_) {
- LOG4CXX_TRACE(logger_, "exit with BAD_STATE");
+ SDL_LOG_TRACE("exit with BAD_STATE");
return BAD_STATE;
}
ConnectionSPtr connection = FindEstablishedConnection(device_id, app_handle);
if (connection) {
TransportAdapter::Error err = connection->SendData(data);
- LOG4CXX_TRACE(logger_, "exit with error: " << err);
+ SDL_LOG_TRACE("exit with error: " << err);
return err;
} else {
- LOG4CXX_TRACE(logger_, "exit with BAD_PARAM");
+ SDL_LOG_TRACE("exit with BAD_PARAM");
return BAD_PARAM;
}
}
TransportAdapter::Error TransportAdapterImpl::ChangeClientListening(
TransportAction required_change) {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
if (client_connection_listener_ == 0) {
- LOG4CXX_TRACE(logger_, "exit with NOT_SUPPORTED");
+ SDL_LOG_TRACE("exit with NOT_SUPPORTED");
return NOT_SUPPORTED;
}
if (!client_connection_listener_->IsInitialised()) {
- LOG4CXX_TRACE(logger_, "exit with BAD_STATE");
+ SDL_LOG_TRACE("exit with BAD_STATE");
return BAD_STATE;
}
@@ -477,30 +471,28 @@ TransportAdapter::Error TransportAdapterImpl::ChangeClientListening(
default:
NOTREACHED();
}
- LOG4CXX_TRACE(logger_, "Exit with error: " << err);
+ SDL_LOG_TRACE("Exit with error: " << err);
return err;
}
DeviceList TransportAdapterImpl::GetDeviceList() const {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
DeviceList devices;
sync_primitives::AutoLock locker(devices_mutex_);
for (DeviceMap::const_iterator it = devices_.begin(); it != devices_.end();
++it) {
devices.push_back(it->first);
}
- LOG4CXX_TRACE(logger_,
- "exit with DeviceList. It's' size = " << devices.size());
+ SDL_LOG_TRACE("exit with DeviceList. It's' size = " << devices.size());
return devices;
}
DeviceSptr TransportAdapterImpl::GetWebEngineDevice() const {
#ifndef WEBSOCKET_SERVER_TRANSPORT_SUPPORT
- LOG4CXX_TRACE(logger_,
- "Web engine support is disabled. Device does not exist");
+ SDL_LOG_TRACE("Web engine support is disabled. Device does not exist");
return DeviceSptr();
#else
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
sync_primitives::AutoLock locker(devices_mutex_);
auto web_engine_device =
@@ -515,14 +507,14 @@ DeviceSptr TransportAdapterImpl::GetWebEngineDevice() const {
return web_engine_device->second;
}
- LOG4CXX_ERROR(logger_, "WebEngine device not found!");
+ SDL_LOG_ERROR("WebEngine device not found!");
return std::make_shared<transport_adapter::WebSocketDevice>("", "");
#endif
}
DeviceSptr TransportAdapterImpl::AddDevice(DeviceSptr device) {
- LOG4CXX_AUTO_TRACE(logger_);
- LOG4CXX_TRACE(logger_, "enter. device: " << device);
+ SDL_LOG_AUTO_TRACE();
+ SDL_LOG_TRACE("enter. device: " << device);
DeviceSptr existing_device;
bool same_device_found = false;
devices_mutex_.Acquire();
@@ -531,7 +523,7 @@ DeviceSptr TransportAdapterImpl::AddDevice(DeviceSptr device) {
existing_device = i->second;
if (device->IsSameAs(existing_device.get())) {
same_device_found = true;
- LOG4CXX_DEBUG(logger_, "Device " << device << " already exists");
+ SDL_LOG_DEBUG("Device " << device << " already exists");
break;
}
}
@@ -540,7 +532,7 @@ DeviceSptr TransportAdapterImpl::AddDevice(DeviceSptr device) {
}
devices_mutex_.Release();
if (same_device_found) {
- LOG4CXX_TRACE(logger_, "Exit with TRUE. Condition: same_device_found");
+ SDL_LOG_TRACE("Exit with TRUE. Condition: same_device_found");
return existing_device;
} else {
device->set_connection_status(ConnectionStatus::PENDING);
@@ -552,13 +544,13 @@ DeviceSptr TransportAdapterImpl::AddDevice(DeviceSptr device) {
if (ToBeAutoConnected(device)) {
ConnectDevice(device);
}
- LOG4CXX_TRACE(logger_, "exit with DeviceSptr " << device);
+ SDL_LOG_TRACE("exit with DeviceSptr " << device);
return device;
}
}
void TransportAdapterImpl::SearchDeviceDone(const DeviceVector& devices) {
- LOG4CXX_TRACE(logger_, "enter. devices: " << &devices);
+ SDL_LOG_TRACE("enter. devices: " << &devices);
DeviceMap new_devices;
for (DeviceVector::const_iterator it = devices.begin(); it != devices.end();
++it) {
@@ -572,15 +564,14 @@ void TransportAdapterImpl::SearchDeviceDone(const DeviceVector& devices) {
if (device->IsSameAs(existing_device.get())) {
existing_device->set_keep_on_disconnect(true);
device_found = true;
- LOG4CXX_DEBUG(logger_, "device found. DeviceSptr" << it->second);
+ SDL_LOG_DEBUG("device found. DeviceSptr" << it->second);
break;
}
}
devices_mutex_.Release();
if (!device_found) {
- LOG4CXX_INFO(logger_,
- "Adding new device " << device->unique_device_id() << " (\""
+ SDL_LOG_INFO("Adding new device " << device->unique_device_id() << " (\""
<< device->name() << "\")");
}
@@ -629,7 +620,7 @@ void TransportAdapterImpl::SearchDeviceDone(const DeviceVector& devices) {
ConnectDevice(device);
}
}
- LOG4CXX_TRACE(logger_, "exit");
+ SDL_LOG_TRACE("exit");
}
void TransportAdapterImpl::ApplicationListUpdated(
@@ -639,38 +630,38 @@ void TransportAdapterImpl::ApplicationListUpdated(
}
void TransportAdapterImpl::FindNewApplicationsRequest() {
- LOG4CXX_TRACE(logger_, "enter");
+ SDL_LOG_TRACE("enter");
for (TransportAdapterListenerList::iterator i = listeners_.begin();
i != listeners_.end();
++i) {
TransportAdapterListener* listener = *i;
listener->OnFindNewApplicationsRequest(this);
}
- LOG4CXX_TRACE(logger_, "exit");
+ SDL_LOG_TRACE("exit");
}
void TransportAdapterImpl::SearchDeviceFailed(const SearchDeviceError& error) {
- LOG4CXX_TRACE(logger_, "enter");
+ SDL_LOG_TRACE("enter");
for (TransportAdapterListenerList::iterator it = listeners_.begin();
it != listeners_.end();
++it) {
(*it)->OnSearchDeviceFailed(this, error);
}
- LOG4CXX_TRACE(logger_, "exit");
+ SDL_LOG_TRACE("exit");
}
bool TransportAdapterImpl::IsSearchDevicesSupported() const {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
return device_scanner_ != 0;
}
bool TransportAdapterImpl::IsServerOriginatedConnectSupported() const {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
return server_connection_factory_ != 0;
}
bool TransportAdapterImpl::IsClientOriginatedConnectSupported() const {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
return client_connection_listener_ != 0;
}
@@ -678,9 +669,8 @@ void TransportAdapterImpl::ConnectionCreated(
ConnectionSPtr connection,
const DeviceUID& device_id,
const ApplicationHandle& app_handle) {
- LOG4CXX_AUTO_TRACE(logger_);
- LOG4CXX_TRACE(logger_,
- "enter connection:" << connection
+ SDL_LOG_AUTO_TRACE();
+ SDL_LOG_TRACE("enter connection:" << connection
<< ", device_id: " << &device_id
<< ", app_handle: " << &app_handle);
connections_lock_.AcquireForReading();
@@ -694,11 +684,10 @@ void TransportAdapterImpl::ConnectionCreated(
void TransportAdapterImpl::DeviceDisconnected(
const DeviceUID& device_handle, const DisconnectDeviceError& error) {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
const DeviceUID device_uid = device_handle;
- LOG4CXX_TRACE(
- logger_,
- "enter. device_handle: " << &device_uid << ", error: " << &error);
+ SDL_LOG_TRACE("enter. device_handle: " << &device_uid
+ << ", error: " << &error);
ApplicationList app_list = GetApplicationList(device_uid);
for (ApplicationList::const_iterator i = app_list.begin();
i != app_list.end();
@@ -728,12 +717,12 @@ void TransportAdapterImpl::DeviceDisconnected(
}
RemoveDevice(device_uid);
- LOG4CXX_TRACE(logger_, "exit");
+ SDL_LOG_TRACE("exit");
}
bool TransportAdapterImpl::IsSingleApplication(
const DeviceUID& device_uid, const ApplicationHandle& app_uid) {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
sync_primitives::AutoReadLock locker(connections_lock_);
for (ConnectionMap::const_iterator it = connections_.begin();
it != connections_.end();
@@ -741,9 +730,9 @@ bool TransportAdapterImpl::IsSingleApplication(
const DeviceUID& current_device_id = it->first.first;
const ApplicationHandle& current_app_handle = it->first.second;
if (current_device_id == device_uid && current_app_handle != app_uid) {
- LOG4CXX_DEBUG(logger_,
- "break. Condition: current_device_id == device_id && "
- "current_app_handle != app_handle");
+ SDL_LOG_DEBUG(
+ "break. Condition: current_device_id == device_id && "
+ "current_app_handle != app_handle");
return false;
}
@@ -753,15 +742,15 @@ bool TransportAdapterImpl::IsSingleApplication(
void TransportAdapterImpl::DisconnectDone(const DeviceUID& device_handle,
const ApplicationHandle& app_handle) {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
const DeviceUID device_uid = device_handle;
const ApplicationHandle app_uid = app_handle;
- LOG4CXX_TRACE(
- logger_,
+ SDL_LOG_TRACE(
+
"enter. device_id: " << &device_uid << ", app_handle: " << &app_uid);
DeviceSptr device = FindDevice(device_handle);
if (!device) {
- LOG4CXX_WARN(logger_, "Device: uid " << &device_uid << " not found");
+ SDL_LOG_WARN("Device: uid " << &device_uid << " not found");
return;
}
@@ -780,20 +769,19 @@ void TransportAdapterImpl::DisconnectDone(const DeviceUID& device_handle,
RemoveConnection(device_uid, app_uid);
if (device_disconnected) {
- LOG4CXX_DEBUG(logger_, "Removing device...");
+ SDL_LOG_DEBUG("Removing device...");
RemoveDevice(device_uid);
}
Store();
- LOG4CXX_TRACE(logger_, "exit");
+ SDL_LOG_TRACE("exit");
}
void TransportAdapterImpl::DataReceiveDone(
const DeviceUID& device_id,
const ApplicationHandle& app_handle,
::protocol_handler::RawMessagePtr message) {
- LOG4CXX_TRACE(logger_,
- "enter. device_id: " << &device_id
+ SDL_LOG_TRACE("enter. device_id: " << &device_id
<< ", app_handle: " << &app_handle
<< ", message: " << message);
@@ -808,33 +796,33 @@ void TransportAdapterImpl::DataReceiveDone(
++it) {
(*it)->OnDataReceiveDone(this, device_id, app_handle, message);
}
- LOG4CXX_TRACE(logger_, "exit");
+ SDL_LOG_TRACE("exit");
}
void TransportAdapterImpl::DataReceiveFailed(
const DeviceUID& device_id,
const ApplicationHandle& app_handle,
const DataReceiveError& error) {
- LOG4CXX_TRACE(logger_, "enter");
+ SDL_LOG_TRACE("enter");
for (TransportAdapterListenerList::iterator it = listeners_.begin();
it != listeners_.end();
++it) {
(*it)->OnDataReceiveFailed(this, device_id, app_handle, error);
}
- LOG4CXX_TRACE(logger_, "exit");
+ SDL_LOG_TRACE("exit");
}
void TransportAdapterImpl::DataSendDone(
const DeviceUID& device_id,
const ApplicationHandle& app_handle,
::protocol_handler::RawMessagePtr message) {
- LOG4CXX_TRACE(logger_, "enter");
+ SDL_LOG_TRACE("enter");
for (TransportAdapterListenerList::iterator it = listeners_.begin();
it != listeners_.end();
++it) {
(*it)->OnDataSendDone(this, device_id, app_handle, message);
}
- LOG4CXX_TRACE(logger_, "exit");
+ SDL_LOG_TRACE("exit");
}
void TransportAdapterImpl::DataSendFailed(
@@ -842,18 +830,18 @@ void TransportAdapterImpl::DataSendFailed(
const ApplicationHandle& app_handle,
::protocol_handler::RawMessagePtr message,
const DataSendError& error) {
- LOG4CXX_TRACE(logger_, "enter");
+ SDL_LOG_TRACE("enter");
for (TransportAdapterListenerList::iterator it = listeners_.begin();
it != listeners_.end();
++it) {
(*it)->OnDataSendFailed(this, device_id, app_handle, message, error);
}
- LOG4CXX_TRACE(logger_, "exit");
+ SDL_LOG_TRACE("exit");
}
void TransportAdapterImpl::TransportConfigUpdated(
const TransportConfig& new_config) {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
for (TransportAdapterListenerList::iterator it = listeners_.begin();
it != listeners_.end();
++it) {
@@ -862,7 +850,7 @@ void TransportAdapterImpl::TransportConfigUpdated(
}
void TransportAdapterImpl::DoTransportSwitch() const {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
std::for_each(
listeners_.begin(),
listeners_.end(),
@@ -872,16 +860,15 @@ void TransportAdapterImpl::DoTransportSwitch() const {
}
void TransportAdapterImpl::DeviceSwitched(const DeviceUID& device_handle) {
- LOG4CXX_DEBUG(logger_,
- "Switching is not implemented for that adapter type "
- << GetConnectionType().c_str());
+ SDL_LOG_DEBUG("Switching is not implemented for that adapter type "
+ << GetConnectionType().c_str());
UNUSED(device_handle);
}
ConnectionSPtr TransportAdapterImpl::FindPendingConnection(
const DeviceUID& device_id, const ApplicationHandle& app_handle) const {
- LOG4CXX_TRACE(
- logger_,
+ SDL_LOG_TRACE(
+
"enter. device_id: " << &device_id << ", app_handle: " << &app_handle);
ConnectionSPtr connection;
connections_lock_.AcquireForReading();
@@ -894,28 +881,28 @@ ConnectionSPtr TransportAdapterImpl::FindPendingConnection(
}
}
connections_lock_.Release();
- LOG4CXX_TRACE(logger_, "exit with Connection: " << connection);
+ SDL_LOG_TRACE("exit with Connection: " << connection);
return connection;
}
DeviceSptr TransportAdapterImpl::FindDevice(const DeviceUID& device_id) const {
- LOG4CXX_TRACE(logger_, "enter. device_id: " << &device_id);
+ SDL_LOG_TRACE("enter. device_id: " << &device_id);
DeviceSptr ret;
sync_primitives::AutoLock locker(devices_mutex_);
- LOG4CXX_DEBUG(logger_, "devices_.size() = " << devices_.size());
+ SDL_LOG_DEBUG("devices_.size() = " << devices_.size());
DeviceMap::const_iterator it = devices_.find(device_id);
if (it != devices_.end()) {
ret = it->second;
} else {
- LOG4CXX_WARN(logger_, "Device " << device_id << " not found.");
+ SDL_LOG_WARN("Device " << device_id << " not found.");
}
- LOG4CXX_TRACE(logger_, "exit with DeviceSptr: " << ret);
+ SDL_LOG_TRACE("exit with DeviceSptr: " << ret);
return ret;
}
void TransportAdapterImpl::ConnectPending(const DeviceUID& device_id,
const ApplicationHandle& app_handle) {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
connections_lock_.AcquireForWriting();
ConnectionMap::iterator it_conn =
connections_.find(std::make_pair(device_id, app_handle));
@@ -927,8 +914,8 @@ void TransportAdapterImpl::ConnectPending(const DeviceUID& device_id,
DeviceSptr device = FindDevice(device_id);
if (device.use_count() == 0) {
- LOG4CXX_ERROR(
- logger_, "Unable to find device, cannot set connection pending status");
+ SDL_LOG_ERROR(
+ "Unable to find device, cannot set connection pending status");
return;
} else {
device->set_connection_status(ConnectionStatus::PENDING);
@@ -943,8 +930,8 @@ void TransportAdapterImpl::ConnectPending(const DeviceUID& device_id,
void TransportAdapterImpl::ConnectDone(const DeviceUID& device_id,
const ApplicationHandle& app_handle) {
- LOG4CXX_TRACE(
- logger_,
+ SDL_LOG_TRACE(
+
"enter. device_id: " << &device_id << ", app_handle: " << &app_handle);
connections_lock_.AcquireForReading();
ConnectionMap::iterator it_conn =
@@ -962,7 +949,7 @@ void TransportAdapterImpl::ConnectDone(const DeviceUID& device_id,
}
Store();
- LOG4CXX_TRACE(logger_, "exit");
+ SDL_LOG_TRACE("exit");
}
void TransportAdapterImpl::ConnectFailed(const DeviceUID& device_handle,
@@ -970,8 +957,7 @@ void TransportAdapterImpl::ConnectFailed(const DeviceUID& device_handle,
const ConnectError& error) {
const DeviceUID device_uid = device_handle;
const ApplicationHandle app_uid = app_handle;
- LOG4CXX_TRACE(logger_,
- "enter. device_id: " << &device_uid << ", app_handle: "
+ SDL_LOG_TRACE("enter. device_id: " << &device_uid << ", app_handle: "
<< &app_uid << ", error: " << &error);
RemoveConnection(device_uid, app_uid);
for (TransportAdapterListenerList::iterator it = listeners_.begin();
@@ -979,27 +965,25 @@ void TransportAdapterImpl::ConnectFailed(const DeviceUID& device_handle,
++it) {
(*it)->OnConnectFailed(this, device_uid, app_uid, error);
}
- LOG4CXX_TRACE(logger_, "exit");
+ SDL_LOG_TRACE("exit");
}
void TransportAdapterImpl::RemoveFinalizedConnection(
const DeviceUID& device_handle, const ApplicationHandle& app_handle) {
const DeviceUID device_uid = device_handle;
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
{
connections_lock_.AcquireForWriting();
auto it_conn = connections_.find(std::make_pair(device_uid, app_handle));
if (connections_.end() == it_conn) {
- LOG4CXX_WARN(logger_,
- "Device_id: " << &device_uid << ", app_handle: "
+ SDL_LOG_WARN("Device_id: " << &device_uid << ", app_handle: "
<< &app_handle << " connection not found");
connections_lock_.Release();
return;
}
const ConnectionInfo& info = it_conn->second;
if (ConnectionInfo::FINALISING != info.state) {
- LOG4CXX_WARN(logger_,
- "Device_id: " << &device_uid << ", app_handle: "
+ SDL_LOG_WARN("Device_id: " << &device_uid << ", app_handle: "
<< &app_handle << " connection not finalized");
connections_lock_.Release();
return;
@@ -1007,20 +991,18 @@ void TransportAdapterImpl::RemoveFinalizedConnection(
// By copying the info.connection shared pointer into this local variable,
// we can delay the connection's destructor until after
// connections_lock_.Release.
- LOG4CXX_DEBUG(
- logger_,
+ SDL_LOG_DEBUG(
"RemoveFinalizedConnection copying connection with Device_id: "
- << &device_uid << ", app_handle: " << &app_handle);
+ << &device_uid << ", app_handle: " << &app_handle);
ConnectionSPtr connection = info.connection;
connections_.erase(it_conn);
connections_lock_.Release();
- LOG4CXX_DEBUG(logger_,
- "RemoveFinalizedConnection Connections Lock Released");
+ SDL_LOG_DEBUG("RemoveFinalizedConnection Connections Lock Released");
}
DeviceSptr device = FindDevice(device_handle);
if (!device) {
- LOG4CXX_WARN(logger_, "Device: uid " << &device_uid << " not found");
+ SDL_LOG_WARN("Device: uid " << &device_uid << " not found");
return;
}
@@ -1032,7 +1014,7 @@ void TransportAdapterImpl::RemoveFinalizedConnection(
void TransportAdapterImpl::RemoveConnection(
const DeviceUID& device_id, const ApplicationHandle& app_handle) {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
ConnectionSPtr connection;
connections_lock_.AcquireForWriting();
ConnectionMap::const_iterator it =
@@ -1040,48 +1022,45 @@ void TransportAdapterImpl::RemoveConnection(
if (it != connections_.end()) {
// By copying the connection from the map to this shared pointer,
// we can erase the object from the map without triggering the destructor
- LOG4CXX_DEBUG(logger_,
- "Copying connection with Device_id: "
- << &device_id << ", app_handle: " << &app_handle);
+ SDL_LOG_DEBUG("Copying connection with Device_id: "
+ << &device_id << ", app_handle: " << &app_handle);
connection = it->second.connection;
connections_.erase(it);
}
connections_lock_.Release();
- LOG4CXX_DEBUG(logger_, "Connections Lock Released");
+ SDL_LOG_DEBUG("Connections Lock Released");
// And now, "connection" goes out of scope, triggering the destructor outside
// of the "connections_lock_"
}
void TransportAdapterImpl::AddListener(TransportAdapterListener* listener) {
- LOG4CXX_TRACE(logger_, "enter");
+ SDL_LOG_TRACE("enter");
listeners_.push_back(listener);
- LOG4CXX_TRACE(logger_, "exit");
+ SDL_LOG_TRACE("exit");
}
ApplicationList TransportAdapterImpl::GetApplicationList(
const DeviceUID& device_id) const {
- LOG4CXX_TRACE(logger_, "enter. device_id: " << &device_id);
+ SDL_LOG_TRACE("enter. device_id: " << &device_id);
DeviceSptr device = FindDevice(device_id);
if (device.use_count() != 0) {
ApplicationList lst = device->GetApplicationList();
- LOG4CXX_TRACE(logger_,
- "exit with ApplicationList. It's size = "
- << lst.size() << " Condition: device.use_count() != 0");
+ SDL_LOG_TRACE("exit with ApplicationList. It's size = "
+ << lst.size() << " Condition: device.use_count() != 0");
return lst;
}
- LOG4CXX_TRACE(logger_,
- "exit with empty ApplicationList. Condition: NOT "
- "device.use_count() != 0");
+ SDL_LOG_TRACE(
+ "exit with empty ApplicationList. Condition: NOT "
+ "device.use_count() != 0");
return ApplicationList();
}
void TransportAdapterImpl::ConnectionFinished(
const DeviceUID& device_id, const ApplicationHandle& app_handle) {
- LOG4CXX_AUTO_TRACE(logger_);
- LOG4CXX_TRACE(
- logger_,
- "enter. device_id: " << &device_id << ", app_handle: " << &app_handle);
+ SDL_LOG_AUTO_TRACE();
+ SDL_LOG_TRACE("enter. device_id: " << &device_id
+ << ", app_handle: " << &app_handle);
connections_lock_.AcquireForReading();
ConnectionMap::iterator it =
connections_.find(std::make_pair(device_id, app_handle));
@@ -1096,7 +1075,7 @@ void TransportAdapterImpl::ConnectionAborted(
const DeviceUID& device_id,
const ApplicationHandle& app_handle,
const CommunicationError& error) {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
ConnectionFinished(device_id, app_handle);
for (TransportAdapterListenerList::iterator it = listeners_.begin();
it != listeners_.end();
@@ -1106,32 +1085,32 @@ void TransportAdapterImpl::ConnectionAborted(
}
bool TransportAdapterImpl::IsInitialised() const {
- LOG4CXX_TRACE(logger_, "enter");
+ SDL_LOG_TRACE("enter");
if (!initialised_) {
- LOG4CXX_TRACE(logger_, "exit with FALSE. Condition: !initialised_");
+ SDL_LOG_TRACE("exit with FALSE. Condition: !initialised_");
return false;
}
if (device_scanner_ && !device_scanner_->IsInitialised()) {
- LOG4CXX_TRACE(logger_,
- "exit with FALSE. Condition: device_scanner_ && "
- "!device_scanner_->IsInitialised()");
+ SDL_LOG_TRACE(
+ "exit with FALSE. Condition: device_scanner_ && "
+ "!device_scanner_->IsInitialised()");
return false;
}
if (server_connection_factory_ &&
!server_connection_factory_->IsInitialised()) {
- LOG4CXX_TRACE(logger_,
- "exit with FALSE. Condition: server_connection_factory_ && "
- "!server_connection_factory_->IsInitialised()");
+ SDL_LOG_TRACE(
+ "exit with FALSE. Condition: server_connection_factory_ && "
+ "!server_connection_factory_->IsInitialised()");
return false;
}
if (client_connection_listener_ &&
!client_connection_listener_->IsInitialised()) {
- LOG4CXX_TRACE(logger_,
- "exit with FALSE. Condition: client_connection_listener_ && "
- "!client_connection_listener_->IsInitialised()");
+ SDL_LOG_TRACE(
+ "exit with FALSE. Condition: client_connection_listener_ && "
+ "!client_connection_listener_->IsInitialised()");
return false;
}
- LOG4CXX_TRACE(logger_, "exit with TRUE");
+ SDL_LOG_TRACE("exit with TRUE");
return true;
}
@@ -1145,7 +1124,7 @@ std::string TransportAdapterImpl::DeviceName(const DeviceUID& device_id) const {
}
void TransportAdapterImpl::StopDevice(const DeviceUID& device_id) const {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
DeviceSptr device = FindDevice(device_id);
if (device) {
device->Stop();
@@ -1157,7 +1136,7 @@ std::string TransportAdapterImpl::GetConnectionType() const {
}
SwitchableDevices TransportAdapterImpl::GetSwitchableDevices() const {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
SwitchableDevices devices;
sync_primitives::AutoLock locker(devices_mutex_);
for (DeviceMap::const_iterator it = devices_.begin(); it != devices_.end();
@@ -1166,15 +1145,13 @@ SwitchableDevices TransportAdapterImpl::GetSwitchableDevices() const {
const auto device = it->second;
const auto transport_switch_id = device->transport_switch_id();
if (transport_switch_id.empty()) {
- LOG4CXX_DEBUG(logger_,
- "Device is not suitable for switching: " << device_uid);
+ SDL_LOG_DEBUG("Device is not suitable for switching: " << device_uid);
continue;
}
- LOG4CXX_DEBUG(logger_, "Device is suitable for switching: " << device_uid);
+ SDL_LOG_DEBUG("Device is suitable for switching: " << device_uid);
devices.insert(std::make_pair(device_uid, transport_switch_id));
}
- LOG4CXX_INFO(logger_,
- "Found number of switchable devices: " << devices.size());
+ SDL_LOG_INFO("Found number of switchable devices: " << devices.size());
return devices;
}
@@ -1201,14 +1178,14 @@ bool TransportAdapterImpl::ToBeAutoConnected(DeviceSptr device) const {
}
bool TransportAdapterImpl::ToBeAutoDisconnected(DeviceSptr device) const {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
return true;
}
ConnectionSPtr TransportAdapterImpl::FindEstablishedConnection(
const DeviceUID& device_id, const ApplicationHandle& app_handle) const {
- LOG4CXX_TRACE(
- logger_,
+ SDL_LOG_TRACE(
+
"enter. device_id: " << &device_id << ", app_handle: " << &app_handle);
ConnectionSPtr connection;
connections_lock_.AcquireForReading();
@@ -1221,59 +1198,55 @@ ConnectionSPtr TransportAdapterImpl::FindEstablishedConnection(
}
}
connections_lock_.Release();
- LOG4CXX_TRACE(logger_, "exit with Connection: " << connection);
+ SDL_LOG_TRACE("exit with Connection: " << connection);
return connection;
}
TransportAdapter::Error TransportAdapterImpl::ConnectDevice(DeviceSptr device) {
- LOG4CXX_TRACE(logger_, "enter. device: " << device);
+ SDL_LOG_TRACE("enter. device: " << device);
DeviceUID device_id = device->unique_device_id();
ApplicationList app_list = device->GetApplicationList();
- LOG4CXX_INFO(logger_,
- "Device " << device->name() << " has " << app_list.size()
+ SDL_LOG_INFO("Device " << device->name() << " has " << app_list.size()
<< " applications.");
bool errors_occurred = false;
for (ApplicationList::iterator it = app_list.begin(); it != app_list.end();
++it) {
const ApplicationHandle app_handle = *it;
- LOG4CXX_DEBUG(logger_,
- "Attempt to connect device " << device_id << ", channel "
+ SDL_LOG_DEBUG("Attempt to connect device " << device_id << ", channel "
<< app_handle);
const Error error = Connect(device_id, app_handle);
switch (error) {
case OK:
- LOG4CXX_DEBUG(logger_, "error = OK");
+ SDL_LOG_DEBUG("error = OK");
break;
case ALREADY_EXISTS:
- LOG4CXX_DEBUG(logger_, "error = ALREADY_EXISTS");
+ SDL_LOG_DEBUG("error = ALREADY_EXISTS");
break;
default:
- LOG4CXX_ERROR(logger_,
- "Connect to device " << device_id << ", channel "
+ SDL_LOG_ERROR("Connect to device " << device_id << ", channel "
<< app_handle
<< " failed with error " << error);
errors_occurred = true;
- LOG4CXX_DEBUG(logger_, "switch (error), default case");
+ SDL_LOG_DEBUG("switch (error), default case");
break;
}
}
if (errors_occurred) {
- LOG4CXX_TRACE(logger_, "exit with error:FAIL");
+ SDL_LOG_TRACE("exit with error:FAIL");
return FAIL;
} else {
- LOG4CXX_TRACE(logger_, "exit with error:OK");
+ SDL_LOG_TRACE("exit with error:OK");
return OK;
}
}
void TransportAdapterImpl::RunAppOnDevice(const DeviceUID& device_uid,
const std::string& bundle_id) {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
DeviceSptr device = FindDevice(device_uid);
if (!device) {
- LOG4CXX_WARN(logger_,
- "Device with id: " << device_uid << " Not found"
+ SDL_LOG_WARN("Device with id: " << device_uid << " Not found"
<< "withing list of connected deviced");
return;
}
@@ -1282,8 +1255,8 @@ void TransportAdapterImpl::RunAppOnDevice(const DeviceUID& device_uid,
}
void TransportAdapterImpl::RemoveDevice(const DeviceUID& device_handle) {
- LOG4CXX_AUTO_TRACE(logger_);
- LOG4CXX_DEBUG(logger_, "Remove Device_handle: " << &device_handle);
+ SDL_LOG_AUTO_TRACE();
+ SDL_LOG_DEBUG("Remove Device_handle: " << &device_handle);
sync_primitives::AutoLock locker(devices_mutex_);
DeviceMap::iterator i = devices_.find(device_handle);
if (i != devices_.end()) {