diff options
Diffstat (limited to 'src/components/application_manager/src/commands/command_request_impl.cc')
-rw-r--r-- | src/components/application_manager/src/commands/command_request_impl.cc | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index 5f8757754..5d70e1572 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2013, Ford Motor Company All rights reserved. @@ -53,12 +53,12 @@ struct DisallowedParamsInserter { application_manager::MessageHelper::vehicle_data(); VehicleData::const_iterator it = vehicle_data.find(param); if (vehicle_data.end() != it) { - smart_objects::SmartObject* disallowed_param = + smart_objects::SmartObjectSPtr disallowed_param = new smart_objects::SmartObject(smart_objects::SmartType_Map); (*disallowed_param)[strings::data_type] = (*it).second; (*disallowed_param)[strings::result_code] = code_; - response_[strings::msg_params][param.c_str()] = *disallowed_param; - return true; + response_[strings::msg_params][param.c_str()] = *disallowed_param; + return true; } return false; } @@ -75,7 +75,7 @@ CommandRequestImpl::CommandRequestImpl(const MessageSharedPtr& message) CommandRequestImpl::~CommandRequestImpl() { } -bool CommandRequestImpl::Init() { +bool CommandRequestImpl::Init() { return true; } @@ -91,12 +91,14 @@ void CommandRequestImpl::Run() { } void CommandRequestImpl::onTimeOut() { - LOG4CXX_INFO(logger_, "CommandRequestImpl::onTimeOut"); + LOG4CXX_AUTO_TRACE(logger_); unsubscribe_from_all_events(); { + // FIXME (dchmerev@luxoft.com): atomic_xchg fits better sync_primitives::AutoLock auto_lock(state_lock_); if (kCompleted == current_state_) { + LOG4CXX_DEBUG(logger_, "current_state_ = kCompleted"); // don't send timeout if request completed return; } @@ -104,7 +106,7 @@ void CommandRequestImpl::onTimeOut() { current_state_ = kTimedOut; } - smart_objects::SmartObject* response = + smart_objects::SmartObjectSPtr response = MessageHelper::CreateNegativeResponse(connection_key(), function_id(), correlation_id(), mobile_api::Result::GENERIC_ERROR); @@ -116,7 +118,7 @@ void CommandRequestImpl::on_event(const event_engine::Event& event) { void CommandRequestImpl::SendResponse( const bool success, const mobile_apis::Result::eType& result_code, - const char* info, const NsSmart::SmartObject* response_params) { + const char* info, const smart_objects::SmartObject* response_params) { { sync_primitives::AutoLock auto_lock(state_lock_); @@ -128,13 +130,12 @@ void CommandRequestImpl::SendResponse( current_state_ = kCompleted; } - NsSmartDeviceLink::NsSmartObjects::SmartObject* result = - new NsSmartDeviceLink::NsSmartObjects::SmartObject; + smart_objects::SmartObjectSPtr result = new smart_objects::SmartObject; if (!result) { LOG4CXX_ERROR(logger_, "Memory allocation failed."); return; } - NsSmartDeviceLink::NsSmartObjects::SmartObject& response = *result; + smart_objects::SmartObject& response = *result; response[strings::params][strings::message_type] = MessageType::kResponse; response[strings::params][strings::correlation_id] = correlation_id(); @@ -193,10 +194,9 @@ bool CommandRequestImpl::CheckSyntax(std::string str, bool allow_empty_line) { void CommandRequestImpl::SendHMIRequest( const hmi_apis::FunctionID::eType& function_id, - const NsSmart::SmartObject* msg_params, bool use_events) { + const smart_objects::SmartObject* msg_params, bool use_events) { - NsSmartDeviceLink::NsSmartObjects::SmartObject* result = - new NsSmartDeviceLink::NsSmartObjects::SmartObject; + smart_objects::SmartObjectSPtr result = new smart_objects::SmartObject; if (!result) { LOG4CXX_ERROR(logger_, "Memory allocation failed."); return; @@ -205,11 +205,11 @@ void CommandRequestImpl::SendHMIRequest( const uint32_t hmi_correlation_id = ApplicationManagerImpl::instance()->GetNextHMICorrelationID(); if (use_events) { - LOG4CXX_WARN(logger_, "subscribe_on_event " << function_id << " " << hmi_correlation_id); + LOG4CXX_DEBUG(logger_, "subscribe_on_event " << function_id << " " << hmi_correlation_id); subscribe_on_event(function_id, hmi_correlation_id); } - NsSmartDeviceLink::NsSmartObjects::SmartObject& request = *result; + smart_objects::SmartObject& request = *result; request[strings::params][strings::message_type] = MessageType::kRequest; request[strings::params][strings::function_id] = function_id; request[strings::params][strings::correlation_id] = hmi_correlation_id; @@ -232,13 +232,12 @@ void CommandRequestImpl::CreateHMINotification( const hmi_apis::FunctionID::eType& function_id, const NsSmart::SmartObject& msg_params) const { - NsSmartDeviceLink::NsSmartObjects::SmartObject* result = - new NsSmartDeviceLink::NsSmartObjects::SmartObject; + smart_objects::SmartObjectSPtr result = new smart_objects::SmartObject; if (!result) { LOG4CXX_ERROR(logger_, "Memory allocation failed."); return; } - NsSmartDeviceLink::NsSmartObjects::SmartObject& notify = *result; + smart_objects::SmartObject& notify = *result; notify[strings::params][strings::message_type] = static_cast<int32_t>(application_manager::MessageType::kNotification); @@ -369,11 +368,11 @@ bool CommandRequestImpl::CheckAllowedParameters() { return true; } - typedef std::set<application_manager::ApplicationSharedPtr> ApplicationList; ApplicationManagerImpl::ApplicationListAccessor accessor; - ApplicationList app_list = accessor.applications(); - ApplicationList::const_iterator it_app_list = app_list.begin(); - ApplicationList::const_iterator it_app_list_end = app_list.end(); + ApplicationManagerImpl::ApplictionSetConstIt it_app_list = + accessor.begin(); + ApplicationManagerImpl::ApplictionSetConstIt it_app_list_end = + accessor.end(); for (; it_app_list != it_app_list_end; ++it_app_list) { if (connection_key() == (*it_app_list).get()->app_id()) { @@ -385,7 +384,10 @@ bool CommandRequestImpl::CheckAllowedParameters() { smart_objects::SmartMap::iterator iter_end = s_map.map_end(); for (; iter != iter_end; ++iter) { - params.push_back(iter->first); + if (true == iter->second.asBool()) { + LOG4CXX_INFO(logger_, "Request's param: " << iter->first); + params.push_back(iter->first); + } } } @@ -393,7 +395,7 @@ bool CommandRequestImpl::CheckAllowedParameters() { mobile_apis::Result::eType check_result = application_manager::ApplicationManagerImpl::instance()-> CheckPolicyPermissions( - (*it_app_list).get()->mobile_app_id()->asString(), + (*it_app_list).get()->mobile_app_id(), (*it_app_list).get()->hmi_level(), static_cast<mobile_api::FunctionID::eType>(function_id()), params, @@ -401,7 +403,7 @@ bool CommandRequestImpl::CheckAllowedParameters() { // Check, if RPC is allowed by policy if (mobile_apis::Result::SUCCESS != check_result) { - smart_objects::SmartObject* response = + smart_objects::SmartObjectSPtr response = MessageHelper::CreateBlockedByPoliciesResponse( static_cast<mobile_api::FunctionID::eType>(function_id()), check_result, correlation_id(), (*it_app_list)->app_id()); |