summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src/commands/command_request_impl.cc
diff options
context:
space:
mode:
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.cc95
1 files changed, 47 insertions, 48 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 36627be735..86e3547676 100644
--- a/src/components/application_manager/src/commands/command_request_impl.cc
+++ b/src/components/application_manager/src/commands/command_request_impl.cc
@@ -44,9 +44,7 @@ namespace commands {
struct DisallowedParamsInserter {
DisallowedParamsInserter(smart_objects::SmartObject& response,
mobile_apis::VehicleDataResultCode::eType code)
- : response_(response),
- code_(code) {
- }
+ : response_(response), code_(code) {}
bool operator()(const std::string& param) {
const VehicleData& vehicle_data =
@@ -62,7 +60,8 @@ struct DisallowedParamsInserter {
}
return false;
}
-private:
+
+ private:
smart_objects::SmartObject& response_;
mobile_apis::VehicleDataResultCode::eType code_;
};
@@ -73,8 +72,7 @@ CommandRequestImpl::CommandRequestImpl(const MessageSharedPtr& message,
, EventObserver(application_manager.event_dispatcher())
, current_state_(kAwaitingHMIResponse) {}
-CommandRequestImpl::~CommandRequestImpl() {
-}
+CommandRequestImpl::~CommandRequestImpl() {}
bool CommandRequestImpl::Init() {
return true;
@@ -88,8 +86,7 @@ bool CommandRequestImpl::CleanUp() {
return true;
}
-void CommandRequestImpl::Run() {
-}
+void CommandRequestImpl::Run() {}
void CommandRequestImpl::onTimeOut() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -108,14 +105,15 @@ void CommandRequestImpl::onTimeOut() {
}
smart_objects::SmartObjectSPtr response =
- MessageHelper::CreateNegativeResponse(connection_key(), function_id(),
- correlation_id(), mobile_api::Result::GENERIC_ERROR);
+ MessageHelper::CreateNegativeResponse(connection_key(),
+ function_id(),
+ correlation_id(),
+ mobile_api::Result::GENERIC_ERROR);
application_manager_.ManageMobileCommand(response, ORIGIN_SDL);
}
-void CommandRequestImpl::on_event(const event_engine::Event& event) {
-}
+void CommandRequestImpl::on_event(const event_engine::Event& event) {}
void CommandRequestImpl::SendResponse(
const bool success,
@@ -156,12 +154,13 @@ void CommandRequestImpl::SendResponse(
response[strings::msg_params][strings::info] = std::string(info);
}
- // Add disallowed parameters and info from request back to response with appropriate
+ // Add disallowed parameters and info from request back to response with
+ // appropriate
// reasons (VehicleData result codes)
if (result_code != mobile_apis::Result::APPLICATION_NOT_REGISTERED) {
const mobile_apis::FunctionID::eType& id =
static_cast<mobile_apis::FunctionID::eType>(function_id());
- if ((id == mobile_apis::FunctionID::SubscribeVehicleDataID) ||
+ if ((id == mobile_apis::FunctionID::SubscribeVehicleDataID) ||
(id == mobile_apis::FunctionID::UnsubscribeVehicleDataID)) {
AddDisallowedParameters(response);
AddDisallowedParametersToInfo(response);
@@ -176,7 +175,8 @@ void CommandRequestImpl::SendResponse(
application_manager_.ManageMobileCommand(result, ORIGIN_SDL);
}
-bool CommandRequestImpl::CheckSyntax(const std::string& str, bool allow_empty_line) {
+bool CommandRequestImpl::CheckSyntax(const std::string& str,
+ bool allow_empty_line) {
if (std::string::npos != str.find_first_of("\t\n")) {
LOG4CXX_ERROR(logger_, "CheckSyntax failed! :" << str);
return false;
@@ -196,14 +196,16 @@ bool CommandRequestImpl::CheckSyntax(const std::string& str, bool allow_empty_li
uint32_t CommandRequestImpl::SendHMIRequest(
const hmi_apis::FunctionID::eType& function_id,
- const smart_objects::SmartObject* msg_params, bool use_events) {
-
+ const smart_objects::SmartObject* msg_params,
+ bool use_events) {
smart_objects::SmartObjectSPtr result = new smart_objects::SmartObject;
const uint32_t hmi_correlation_id =
- application_manager_.GetNextHMICorrelationID();
+ application_manager_.GetNextHMICorrelationID();
if (use_events) {
- LOG4CXX_DEBUG(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);
}
@@ -381,7 +383,8 @@ bool CommandRequestImpl::CheckAllowedParameters() {
if (connection_key() == (*it_app_list).get()->app_id()) {
RPCParams params;
- const smart_objects::SmartObject& s_map = (*message_)[strings::msg_params];
+ const smart_objects::SmartObject& s_map =
+ (*message_)[strings::msg_params];
if (smart_objects::SmartType_Map == s_map.getType()) {
smart_objects::SmartMap::iterator iter = s_map.map_begin();
smart_objects::SmartMap::iterator iter_end = s_map.map_end();
@@ -396,13 +399,12 @@ bool CommandRequestImpl::CheckAllowedParameters() {
CommandParametersPermissions params_permissions;
mobile_apis::Result::eType check_result =
- application_manager_.
- CheckPolicyPermissions(
- (*it_app_list).get()->policy_app_id(),
- (*it_app_list).get()->hmi_level(),
- static_cast<mobile_api::FunctionID::eType>(function_id()),
- params,
- &params_permissions);
+ application_manager_.CheckPolicyPermissions(
+ (*it_app_list).get()->policy_app_id(),
+ (*it_app_list).get()->hmi_level(),
+ static_cast<mobile_api::FunctionID::eType>(function_id()),
+ params,
+ &params_permissions);
// Check, if RPC is allowed by policy
if (mobile_apis::Result::SUCCESS != check_result) {
@@ -442,13 +444,13 @@ void CommandRequestImpl::RemoveDisallowedParameters(
params_permissions.disallowed_params.begin();
std::vector<std::string>::const_iterator it_disallowed_end =
params_permissions.disallowed_params.end();
- for (;it_disallowed != it_disallowed_end; ++it_disallowed) {
+ for (; it_disallowed != it_disallowed_end; ++it_disallowed) {
if (params.keyExists(*it_disallowed)) {
params.erase(*it_disallowed);
- parameters_permissions_.disallowed_params.push_back(
- *it_disallowed);
- LOG4CXX_INFO(logger_, "Following parameter is disallowed by user: "
- << *it_disallowed);
+ parameters_permissions_.disallowed_params.push_back(*it_disallowed);
+ LOG4CXX_INFO(
+ logger_,
+ "Following parameter is disallowed by user: " << *it_disallowed);
}
}
@@ -457,13 +459,13 @@ void CommandRequestImpl::RemoveDisallowedParameters(
params_permissions.undefined_params.begin();
std::vector<std::string>::const_iterator it_undefined_end =
params_permissions.undefined_params.end();
- for (;it_undefined != it_undefined_end; ++it_undefined) {
+ for (; it_undefined != it_undefined_end; ++it_undefined) {
if (params.keyExists(*it_undefined)) {
params.erase(*it_undefined);
- parameters_permissions_.undefined_params.push_back(
- *it_undefined);
- LOG4CXX_INFO(logger_, "Following parameter is disallowed by policy: "
- << *it_undefined);
+ parameters_permissions_.undefined_params.push_back(*it_undefined);
+ LOG4CXX_INFO(
+ logger_,
+ "Following parameter is disallowed by policy: " << *it_undefined);
}
}
@@ -473,19 +475,18 @@ void CommandRequestImpl::RemoveDisallowedParameters(
VehicleData::const_iterator it_vehicle_data = vehicle_data.begin();
VehicleData::const_iterator it_vehicle_data_end = vehicle_data.end();
- for (;it_vehicle_data != it_vehicle_data_end; ++it_vehicle_data) {
+ for (; it_vehicle_data != it_vehicle_data_end; ++it_vehicle_data) {
const std::string key = it_vehicle_data->first;
if (params.keyExists(key) &&
params_permissions.allowed_params.end() ==
- std::find(params_permissions.allowed_params.begin(),
- params_permissions.allowed_params.end(),
- key)) {
+ std::find(params_permissions.allowed_params.begin(),
+ params_permissions.allowed_params.end(),
+ key)) {
params.erase(key);
parameters_permissions_.undefined_params.push_back(key);
LOG4CXX_INFO(logger_,
"Following parameter is not found among allowed parameters '"
- << key
- << "' and will be treated as disallowed.");
+ << key << "' and will be treated as disallowed.");
}
}
}
@@ -531,15 +532,13 @@ void CommandRequestImpl::AddDisallowedParametersToInfo(
void CommandRequestImpl::AddDisallowedParameters(
smart_objects::SmartObject& response) {
DisallowedParamsInserter disallowed_inserter(
- response,
- mobile_apis::VehicleDataResultCode::VDRC_USER_DISALLOWED);
+ response, mobile_apis::VehicleDataResultCode::VDRC_USER_DISALLOWED);
std::for_each(parameters_permissions_.disallowed_params.begin(),
parameters_permissions_.disallowed_params.end(),
disallowed_inserter);
DisallowedParamsInserter undefined_inserter(
- response,
- mobile_apis::VehicleDataResultCode::VDRC_DISALLOWED);
+ response, mobile_apis::VehicleDataResultCode::VDRC_DISALLOWED);
std::for_each(parameters_permissions_.undefined_params.begin(),
parameters_permissions_.undefined_params.end(),
undefined_inserter);
@@ -547,7 +546,7 @@ void CommandRequestImpl::AddDisallowedParameters(
bool CommandRequestImpl::HasDisallowedParams() const {
return ((!parameters_permissions_.disallowed_params.empty()) ||
- (!parameters_permissions_.undefined_params.empty()));
+ (!parameters_permissions_.undefined_params.empty()));
}
} // namespace commands