From 7cba1c57a9966cd8b6215439ff83ba5036a633ca Mon Sep 17 00:00:00 2001 From: Andrey Oleynik Date: Tue, 4 Aug 2015 15:43:59 +0300 Subject: Implements new handling of WARNING code from HMI. Part 1. In case of HMI sends WARNING as result code SDL must transfer it to mobile side with 'success:true' Implements: APPLINK-15040 Conflicts: src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc src/components/application_manager/src/commands/mobile/register_app_interface_request.cc --- .../create_interaction_choice_set_request.cc | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc') diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc index 9908756cfc..6406f833b6 100644 --- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc @@ -371,7 +371,7 @@ void CreateInteractionChoiceSetRequest::on_event( } Common_Result::eType vr_result_ = static_cast( - message[strings::params][hmi_response::code].asInt()); + message[strings::params][hmi_response::code].asInt()); if (Common_Result::SUCCESS == vr_result_) { VRCommandInfo& vr_command = it->second; vr_command.succesful_response_received_ = true; @@ -393,10 +393,24 @@ void CreateInteractionChoiceSetRequest::on_event( sync_primitives::AutoLock timeout_lock_(is_timed_out_lock_); if (!is_timed_out_) { ApplicationManagerImpl::instance()->updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); + connection_key(), correlation_id(), default_timeout()); + Common_Result::eType vr_result = static_cast( + message[strings::params][hmi_response::code].asInt()); + if (Common_Result::SUCCESS == vr_result || + Common_Result::WARNINGS == vr_result) { + VRCommandInfo& vr_command = it->second; + vr_command.succesful_response_received_ = true; + } else { + LOG4CXX_DEBUG(logger_, "Hmi response is not Success: " << vr_result + << ". Stop sending VRAddCommand requests"); + if (!error_from_hmi_) { + error_from_hmi_ = true; + SendResponse(false, GetMobileResultCode(vr_result)); + } + } + } else { + OnAllHMIResponsesReceived(); } - } else { - OnAllHMIResponsesReceived(); } } } -- cgit v1.2.1 From 95573b9098fde9c7084e00ba270cd60c10ffb562 Mon Sep 17 00:00:00 2001 From: Andrey Oleynik Date: Sun, 9 Aug 2015 13:22:43 +0300 Subject: Implements new handling of WARNINGS code from HMI. Part 2. In case of HMI sends WARNING as result code SDL must transfer it to mobile side with 'success:true' Implements: APPLINK-15040 Conflicts: src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc src/components/application_manager/src/commands/mobile/set_app_icon_request.cc src/components/application_manager/src/commands/mobile/system_request.cc --- .../create_interaction_choice_set_request.cc | 84 ++++++++++------------ 1 file changed, 39 insertions(+), 45 deletions(-) (limited to 'src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc') diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc index 6406f833b6..b551a4be00 100644 --- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc @@ -39,6 +39,8 @@ #include "application_manager/application_manager_impl.h" #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" +#include "utils/gen_hash.h" +#include "utils/helpers.h" namespace application_manager { @@ -60,7 +62,7 @@ void CreateInteractionChoiceSetRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); using namespace mobile_apis; ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( - (*message_)[strings::params][strings::connection_key].asUInt()); + connection_key()); if (!app) { LOG4CXX_ERROR(logger_, "NULL pointer"); @@ -86,7 +88,7 @@ void CreateInteractionChoiceSetRequest::Run() { } if (verification_result_image == Result::INVALID_DATA || verification_result_secondary_image == Result::INVALID_DATA) { - LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + LOG4CXX_ERROR(logger_, "Image verification failed."); SendResponse(false, Result::INVALID_DATA); return; } @@ -96,7 +98,8 @@ void CreateInteractionChoiceSetRequest::Run() { [strings::interaction_choice_set_id].asInt(); if (app->FindChoiceSet(choice_set_id_)) { - LOG4CXX_ERROR(logger_, "Invalid ID"); + LOG4CXX_ERROR(logger_, "Choice set with id " << choice_set_id_ << + " is not found."); SendResponse(false, Result::INVALID_ID); return; } @@ -353,6 +356,7 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests( void CreateInteractionChoiceSetRequest::on_event( const event_engine::Event& event) { using namespace hmi_apis; + using namespace helpers; LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); @@ -364,54 +368,44 @@ void CreateInteractionChoiceSetRequest::on_event( uint32_t corr_id = static_cast(message[strings::params] [strings::correlation_id].asUInt()); - SentCommandsMap::iterator it = sent_commands_map_.find(corr_id); - if (sent_commands_map_.end() == it) { - LOG4CXX_WARN(logger_, "HMI response for unknown VR command received"); - return; - } + { + sync_primitives::AutoLock commands_lock(vr_commands_lock_); + SentCommandsMap::iterator it = sent_commands_map_.find(corr_id); + if (sent_commands_map_.end() == it) { + LOG4CXX_WARN(logger_, "HMI response for unknown VR command received"); + return; + } - Common_Result::eType vr_result_ = static_cast( - message[strings::params][hmi_response::code].asInt()); - if (Common_Result::SUCCESS == vr_result_) { - VRCommandInfo& vr_command = it->second; - vr_command.succesful_response_received_ = true; - } else { - LOG4CXX_DEBUG(logger_, "Hmi response is not Success: " << vr_result_ - << ". Stop sending VRAddCommand requests"); - sync_primitives::AutoLock error_lock(error_from_hmi_lock_); - if (!error_from_hmi_) { - error_from_hmi_ = true; - SendResponse(false, GetMobileResultCode(vr_result_)); + + Common_Result::eType vr_result = static_cast( + message[strings::params][hmi_response::code].asInt()); + + const bool is_vr_no_error = + Compare( + vr_result, + Common_Result::SUCCESS, + Common_Result::WARNINGS); + + if (is_vr_no_error) { + VRCommandInfo& vr_command = it->second; + vr_command.succesful_response_received_ = true; + } else { + LOG4CXX_DEBUG(logger_, "Hmi response is not Success: " << vr_result + << ". Stop sending VRAddCommand requests"); + if (!error_from_hmi_) { + error_from_hmi_ = true; + SendResponse(false, GetMobileResultCode(vr_result)); + } } } - // update request timeout for case we send many VR add command requests - // and HMI has no time to send responses for all of them - LOG4CXX_DEBUG(logger_, "expected_chs_count_ = " << expected_chs_count_ - << "received_chs_count_ = " << received_chs_count_); if (received_chs_count_ < expected_chs_count_) { - sync_primitives::AutoLock timeout_lock_(is_timed_out_lock_); - if (!is_timed_out_) { - ApplicationManagerImpl::instance()->updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); - Common_Result::eType vr_result = static_cast( - message[strings::params][hmi_response::code].asInt()); - if (Common_Result::SUCCESS == vr_result || - Common_Result::WARNINGS == vr_result) { - VRCommandInfo& vr_command = it->second; - vr_command.succesful_response_received_ = true; - } else { - LOG4CXX_DEBUG(logger_, "Hmi response is not Success: " << vr_result - << ". Stop sending VRAddCommand requests"); - if (!error_from_hmi_) { - error_from_hmi_ = true; - SendResponse(false, GetMobileResultCode(vr_result)); - } - } - } else { - OnAllHMIResponsesReceived(); - } + ApplicationManagerImpl::instance()->updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + LOG4CXX_DEBUG(logger_, "Timeout for request was updated"); + return; } + OnAllHMIResponsesReceived(); } } -- cgit v1.2.1 From e68527034f7c1a6cf1247672bb4a178e118e8c6d Mon Sep 17 00:00:00 2001 From: dtrunov Date: Tue, 22 Dec 2015 17:55:38 +0200 Subject: Change checking choice id for CreateInteraction request, and PerformInteraction request. Mobile sends createInteractionChoiceSet with ChoiceSetID = 1 and choiceId = 1 SDL answers SUCCESS, mobile sends createInteractionChoiceSet with ChoiceSetID = 2 and choiceId = 1 SDL answers SUCCESS. If mobile sends performInteractionChoiceSest with ChoiceSetID = 1 and ChoiceSetID = 2, SDL answer INVALID_ID, because these ChoiceSets contain same choiceIds. Conflicts: src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc --- .../create_interaction_choice_set_request.cc | 73 +++++----------------- 1 file changed, 15 insertions(+), 58 deletions(-) (limited to 'src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc') diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc index c770532138..65c24f9a07 100644 --- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc @@ -117,75 +117,32 @@ void CreateInteractionChoiceSetRequest::Run() { mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( ApplicationConstSharedPtr app) { + using namespace smart_objects; LOG4CXX_AUTO_TRACE(logger_); + std::set choice_id_set; + const smart_objects::SmartArray* new_choice_set_array = - (*message_)[strings::msg_params][strings::choice_set].asArray(); + (*message_)[strings::msg_params][strings::choice_set].asArray(); smart_objects::SmartArray::const_iterator it_array = - new_choice_set_array->begin(); + new_choice_set_array->begin(); - smart_objects::SmartArray::const_iterator it_array_end = - new_choice_set_array->end(); + const SmartArray* choice_set = + (*message_)[strings::msg_params][strings::choice_set].asArray(); - // Self check of new choice set for params coincidence - for (; it_array != it_array_end; ++it_array) { - const smart_objects::SmartArray* vr_array = - (*it_array)[strings::vr_commands].asArray(); + SmartArray::const_iterator choice_set_it = choice_set->begin(); - CoincidencePredicateChoiceID c((*it_array)[strings::choice_id].asInt()); - if (1 != std::count_if( - new_choice_set_array->begin(), - new_choice_set_array->end(), c)) { - LOG4CXX_ERROR(logger_, "Incoming choice set has duplicate IDs."); + for (; choice_set->end() != choice_set_it; ++choice_set_it) { + std::pair::iterator, bool> ins_res = + choice_id_set.insert((*choice_set_it)[strings::choice_id].asInt()); + if (!ins_res.second) { + LOG4CXX_ERROR(logger_, "Choise with ID " + << (*choice_set_it)[strings::choice_id].asInt() + << " already exists"); return mobile_apis::Result::INVALID_ID; } - // Check new choice set params along with already registered choice sets - const DataAccessor accessor = app->choice_set_map(); - const ChoiceSetMap& app_choice_set_map = accessor.GetData(); - ChoiceSetMap::const_iterator it = app_choice_set_map.begin(); - ChoiceSetMap::const_iterator itEnd = app_choice_set_map.end(); - for (; it != itEnd; ++it) { - const smart_objects::SmartObject* app_choice_set = it->second; - if (NULL != app_choice_set) { - const smart_objects::SmartArray* curr_choice_set = - (*app_choice_set)[strings::choice_set].asArray(); - - if (0 != std::count_if( - curr_choice_set->begin(), - curr_choice_set->end(), - c)) { - LOG4CXX_ERROR(logger_, "Incoming choice ID already exists."); - return mobile_apis::Result::INVALID_ID; - } - } - } - - CoincidencePredicateMenuName m((*it_array)[strings::menu_name].asString()); - if (1 != std::count_if( - new_choice_set_array->begin(), - new_choice_set_array->end(), - m)) { - LOG4CXX_ERROR(logger_, "Incoming choice set has duplicate menu names."); - return mobile_apis::Result::DUPLICATE_NAME; - } - - // Check coincidence inside the current choice - - smart_objects::SmartArray::const_iterator it_vr = vr_array->begin(); - smart_objects::SmartArray::const_iterator it_vr_end = vr_array->end(); - - for (; it_vr != it_vr_end; ++it_vr) { - CoincidencePredicateVRCommands v((*it_vr)); - if (1 != std::count_if(vr_array->begin(), vr_array->end(), v)) { - LOG4CXX_ERROR(logger_, - "Incoming choice set has duplicate VR command(s)"); - - return mobile_apis::Result::DUPLICATE_NAME; - } - } - // Check along with VR commands in other choices in the new set smart_objects::SmartArray::const_iterator it_same_array = new_choice_set_array->begin(); -- cgit v1.2.1 From 058523534deb78c99b3bea70dc720c4f55cf3193 Mon Sep 17 00:00:00 2001 From: Herasym Oleh Date: Wed, 3 Feb 2016 14:25:20 +0200 Subject: Delete namespace in variable declaration Rename bool variable Related: APPLINK-17490 --- .../src/commands/mobile/create_interaction_choice_set_request.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc') diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc index 65c24f9a07..ecfac3aad4 100644 --- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc @@ -122,10 +122,10 @@ mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( std::set choice_id_set; - const smart_objects::SmartArray* new_choice_set_array = + const SmartArray* new_choice_set_array = (*message_)[strings::msg_params][strings::choice_set].asArray(); - smart_objects::SmartArray::const_iterator it_array = + SmartArray::const_iterator it_array = new_choice_set_array->begin(); const SmartArray* choice_set = @@ -144,10 +144,10 @@ mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( } // Check along with VR commands in other choices in the new set - smart_objects::SmartArray::const_iterator it_same_array = + SmartArray::const_iterator it_same_array = new_choice_set_array->begin(); - smart_objects::SmartArray::const_iterator it_same_array_end = + SmartArray::const_iterator it_same_array_end = new_choice_set_array->end(); for (; it_same_array != it_same_array_end; ++it_same_array) { -- cgit v1.2.1 From 498d708ae04429a128e9aa7c79f34ee31ff2d51f Mon Sep 17 00:00:00 2001 From: dtrunov Date: Tue, 22 Dec 2015 17:55:38 +0200 Subject: Change checking choice id for CreateInteraction request, and PerformInteraction request. Mobile sends createInteractionChoiceSet with ChoiceSetID = 1 and choiceId = 1 SDL answers SUCCESS, mobile sends createInteractionChoiceSet with ChoiceSetID = 2 and choiceId = 1 SDL answers SUCCESS. If mobile sends performInteractionChoiceSest with ChoiceSetID = 1 and ChoiceSetID = 2, SDL answer INVALID_ID, because these ChoiceSets contain same choiceIds. --- .../create_interaction_choice_set_request.cc | 31 +--------------------- 1 file changed, 1 insertion(+), 30 deletions(-) (limited to 'src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc') diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc index 29ffaa5695..9f2f0ba3a1 100644 --- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc @@ -122,12 +122,6 @@ mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( std::set choice_id_set; - const SmartArray* new_choice_set_array = - (*message_)[strings::msg_params][strings::choice_set].asArray(); - - SmartArray::const_iterator it_array = - new_choice_set_array->begin(); - const SmartArray* choice_set = (*message_)[strings::msg_params][strings::choice_set].asArray(); @@ -143,35 +137,12 @@ mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( return mobile_apis::Result::INVALID_ID; } - // Check along with VR commands in other choices in the new set - SmartArray::const_iterator it_same_array = - new_choice_set_array->begin(); - - SmartArray::const_iterator it_same_array_end = - new_choice_set_array->end(); - - for (; it_same_array != it_same_array_end; ++it_same_array) { - // Skip check for itself - if ((*it_array)[strings::choice_id] == - (*it_same_array)[strings::choice_id]) { - continue; - } - - if (compareSynonyms((*it_array), (*it_same_array))) { - LOG4CXX_ERROR(logger_, - "Incoming choice set has duplicate VR command(s)."); - - return mobile_apis::Result::DUPLICATE_NAME; - } - } - - if (IsWhiteSpaceExist((*it_array))) { + if (IsWhiteSpaceExist(*choice_set_it)) { LOG4CXX_ERROR(logger_, "Incoming choice set has contains \t\n \\t \\n"); return mobile_apis::Result::INVALID_DATA; } } - return mobile_apis::Result::SUCCESS; } -- cgit v1.2.1 From 2c7dc612ce41461bebc3416917d2607f24002285 Mon Sep 17 00:00:00 2001 From: Kozoriz Date: Mon, 11 Apr 2016 16:21:12 +0300 Subject: Mobile commands update after removing all singletones --- .../create_interaction_choice_set_request.cc | 35 ++++++++++------------ 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc') diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc index 9f2f0ba3a1..8f2d531032 100644 --- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc @@ -1,6 +1,6 @@ /* - Copyright (c) 2013, Ford Motor Company + Copyright (c) 2016, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without @@ -31,12 +31,11 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include #include "application_manager/commands/mobile/create_interaction_choice_set_request.h" -#include "application_manager/application_manager_impl.h" + #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" #include "utils/gen_hash.h" @@ -47,8 +46,8 @@ namespace application_manager { namespace commands { CreateInteractionChoiceSetRequest::CreateInteractionChoiceSetRequest( - const MessageSharedPtr& message) - : CommandRequestImpl(message), + const MessageSharedPtr& message, ApplicationManager& application_manager) + : CommandRequestImpl(message, application_manager), expected_chs_count_(0), received_chs_count_(0), error_from_hmi_(false) { @@ -61,7 +60,7 @@ CreateInteractionChoiceSetRequest::~CreateInteractionChoiceSetRequest() { void CreateInteractionChoiceSetRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); using namespace mobile_apis; - ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + ApplicationSharedPtr app = application_manager_.application( connection_key()); if (!app) { @@ -78,13 +77,13 @@ void CreateInteractionChoiceSetRequest::Run() { [strings::choice_set][i].keyExists(strings::image)) { verification_result_image = MessageHelper::VerifyImage( (*message_)[strings::msg_params][strings::choice_set] - [i][strings::image], app); + [i][strings::image], app, application_manager_); } if ((*message_)[strings::msg_params] [strings::choice_set][i].keyExists(strings::secondary_image)) { verification_result_secondary_image = MessageHelper::VerifyImage( (*message_)[strings::msg_params][strings::choice_set] - [i][strings::secondary_image], app); + [i][strings::secondary_image], app, application_manager_); } if (verification_result_image == Result::INVALID_DATA || verification_result_secondary_image == Result::INVALID_DATA) { @@ -109,7 +108,7 @@ void CreateInteractionChoiceSetRequest::Run() { SendResponse(false, result); return; } - uint32_t grammar_id = ApplicationManagerImpl::instance()->GenerateGrammarID(); + uint32_t grammar_id = application_manager_.GenerateGrammarID(); (*message_)[strings::msg_params][strings::grammar_id] = grammar_id; app->AddChoiceSet(choice_set_id_, (*message_)[strings::msg_params]); SendVRAddCommandRequests(app); @@ -304,7 +303,6 @@ void CreateInteractionChoiceSetRequest::on_event( return; } - Common_Result::eType vr_result = static_cast( message[strings::params][hmi_response::code].asInt()); @@ -326,10 +324,9 @@ void CreateInteractionChoiceSetRequest::on_event( } } } - if (received_chs_count_ < expected_chs_count_) { - ApplicationManagerImpl::instance()->updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); + application_manager_.updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); LOG4CXX_DEBUG(logger_, "Timeout for request was updated"); return; } @@ -340,7 +337,6 @@ void CreateInteractionChoiceSetRequest::on_event( void CreateInteractionChoiceSetRequest::onTimeOut() { LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock error_lock(error_from_hmi_lock_); if (!error_from_hmi_) { SendResponse(false, mobile_apis::Result::GENERIC_ERROR); } @@ -350,7 +346,7 @@ void CreateInteractionChoiceSetRequest::onTimeOut() { // according to SDLAQ-CRS-2976 sync_primitives::AutoLock timeout_lock_(is_timed_out_lock_); is_timed_out_ = true; - ApplicationManagerImpl::instance()->TerminateRequest( + application_manager_.TerminateRequest( connection_key(), correlation_id()); } @@ -358,7 +354,7 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() { LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr application = - ApplicationManagerImpl::instance()->application(connection_key()); + application_manager_.application(connection_key()); if (!application) { LOG4CXX_ERROR(logger_, "NULL pointer"); return; @@ -391,7 +387,7 @@ void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() { SendResponse(true, mobile_apis::Result::SUCCESS); ApplicationSharedPtr application = - ApplicationManagerImpl::instance()->application(connection_key()); + application_manager_.application(connection_key()); if (!application) { LOG4CXX_ERROR(logger_, "NULL pointer"); return; @@ -400,8 +396,9 @@ void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() { } else { DeleteChoices(); } - ApplicationManagerImpl::instance()->TerminateRequest(connection_key(), - correlation_id()); + + application_manager_.TerminateRequest( + connection_key(), correlation_id()); } } // namespace commands -- cgit v1.2.1 From 990bee92cc9d67f9845629bf86e0a700ccc700ce Mon Sep 17 00:00:00 2001 From: Kozoriz Date: Mon, 25 Apr 2016 16:39:26 +0300 Subject: Code style format with clang-format --- .../create_interaction_choice_set_request.cc | 157 +++++++++++---------- 1 file changed, 81 insertions(+), 76 deletions(-) (limited to 'src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc') diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc index 8f2d531032..b602601f26 100644 --- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc @@ -46,12 +46,11 @@ namespace application_manager { namespace commands { CreateInteractionChoiceSetRequest::CreateInteractionChoiceSetRequest( - const MessageSharedPtr& message, ApplicationManager& application_manager) - : CommandRequestImpl(message, application_manager), - expected_chs_count_(0), - received_chs_count_(0), - error_from_hmi_(false) { -} + const MessageSharedPtr& message, ApplicationManager& application_manager) + : CommandRequestImpl(message, application_manager) + , expected_chs_count_(0) + , received_chs_count_(0) + , error_from_hmi_(false) {} CreateInteractionChoiceSetRequest::~CreateInteractionChoiceSetRequest() { LOG4CXX_AUTO_TRACE(logger_); @@ -60,8 +59,7 @@ CreateInteractionChoiceSetRequest::~CreateInteractionChoiceSetRequest() { void CreateInteractionChoiceSetRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); using namespace mobile_apis; - ApplicationSharedPtr app = application_manager_.application( - connection_key()); + ApplicationSharedPtr app = application_manager_.application(connection_key()); if (!app) { LOG4CXX_ERROR(logger_, "NULL pointer"); @@ -73,32 +71,37 @@ void CreateInteractionChoiceSetRequest::Run() { ++i) { Result::eType verification_result_image = Result::SUCCESS; Result::eType verification_result_secondary_image = Result::SUCCESS; - if ((*message_)[strings::msg_params] - [strings::choice_set][i].keyExists(strings::image)) { + if ((*message_)[strings::msg_params][strings::choice_set][i].keyExists( + strings::image)) { verification_result_image = MessageHelper::VerifyImage( - (*message_)[strings::msg_params][strings::choice_set] - [i][strings::image], app, application_manager_); + (*message_)[strings::msg_params][strings::choice_set][i] + [strings::image], + app, + application_manager_); } - if ((*message_)[strings::msg_params] - [strings::choice_set][i].keyExists(strings::secondary_image)) { + if ((*message_)[strings::msg_params][strings::choice_set][i].keyExists( + strings::secondary_image)) { verification_result_secondary_image = MessageHelper::VerifyImage( - (*message_)[strings::msg_params][strings::choice_set] - [i][strings::secondary_image], app, application_manager_); + (*message_)[strings::msg_params][strings::choice_set][i] + [strings::secondary_image], + app, + application_manager_); } if (verification_result_image == Result::INVALID_DATA || verification_result_secondary_image == Result::INVALID_DATA) { LOG4CXX_ERROR(logger_, "Image verification failed."); - SendResponse(false, Result::INVALID_DATA); + SendResponse(false, Result::INVALID_DATA); return; } } - choice_set_id_ = (*message_)[strings::msg_params] - [strings::interaction_choice_set_id].asInt(); + choice_set_id_ = + (*message_)[strings::msg_params][strings::interaction_choice_set_id] + .asInt(); if (app->FindChoiceSet(choice_set_id_)) { - LOG4CXX_ERROR(logger_, "Choice set with id " << choice_set_id_ << - " is not found."); + LOG4CXX_ERROR(logger_, + "Choice set with id " << choice_set_id_ << " is not found."); SendResponse(false, Result::INVALID_ID); return; } @@ -115,7 +118,7 @@ void CreateInteractionChoiceSetRequest::Run() { } mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( - ApplicationConstSharedPtr app) { + ApplicationConstSharedPtr app) { using namespace smart_objects; LOG4CXX_AUTO_TRACE(logger_); @@ -130,15 +133,15 @@ mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( std::pair::iterator, bool> ins_res = choice_id_set.insert((*choice_set_it)[strings::choice_id].asInt()); if (!ins_res.second) { - LOG4CXX_ERROR(logger_, "Choise with ID " - << (*choice_set_it)[strings::choice_id].asInt() - << " already exists"); + LOG4CXX_ERROR(logger_, + "Choise with ID " + << (*choice_set_it)[strings::choice_id].asInt() + << " already exists"); return mobile_apis::Result::INVALID_ID; } if (IsWhiteSpaceExist(*choice_set_it)) { - LOG4CXX_ERROR(logger_, - "Incoming choice set has contains \t\n \\t \\n"); + LOG4CXX_ERROR(logger_, "Incoming choice set has contains \t\n \\t \\n"); return mobile_apis::Result::INVALID_DATA; } } @@ -146,24 +149,26 @@ mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( } bool CreateInteractionChoiceSetRequest::compareSynonyms( - const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice1, - const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice2) { + const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice1, + const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice2) { smart_objects::SmartArray* vr_cmds_1 = - choice1[strings::vr_commands].asArray(); + choice1[strings::vr_commands].asArray(); DCHECK(vr_cmds_1 != NULL); smart_objects::SmartArray* vr_cmds_2 = - choice2[strings::vr_commands].asArray(); + choice2[strings::vr_commands].asArray(); DCHECK(vr_cmds_2 != NULL); smart_objects::SmartArray::iterator it; - it = std::find_first_of(vr_cmds_1->begin(), vr_cmds_1->end(), - vr_cmds_2->begin(), vr_cmds_2->end(), + it = std::find_first_of(vr_cmds_1->begin(), + vr_cmds_1->end(), + vr_cmds_2->begin(), + vr_cmds_2->end(), CreateInteractionChoiceSetRequest::compareStr); - if (it != vr_cmds_1->end()) { - LOG4CXX_INFO(logger_, "Incoming choice set has duplicated VR synonyms " - << it->asString()); + LOG4CXX_INFO(logger_, + "Incoming choice set has duplicated VR synonyms " + << it->asString()); return true; } @@ -171,13 +176,13 @@ bool CreateInteractionChoiceSetRequest::compareSynonyms( } bool CreateInteractionChoiceSetRequest::compareStr( - const NsSmartDeviceLink::NsSmartObjects::SmartObject& str1, - const NsSmartDeviceLink::NsSmartObjects::SmartObject& str2) { + const NsSmartDeviceLink::NsSmartObjects::SmartObject& str1, + const NsSmartDeviceLink::NsSmartObjects::SmartObject& str2) { return 0 == strcasecmp(str1.asCharArray(), str2.asCharArray()); } bool CreateInteractionChoiceSetRequest::IsWhiteSpaceExist( - const smart_objects::SmartObject& choice_set) { + const smart_objects::SmartObject& choice_set) { LOG4CXX_AUTO_TRACE(logger_); const char* str = NULL; @@ -204,8 +209,7 @@ bool CreateInteractionChoiceSetRequest::IsWhiteSpaceExist( } if (choice_set.keyExists(strings::vr_commands)) { - const size_t len = - choice_set[strings::vr_commands].length(); + const size_t len = choice_set[strings::vr_commands].length(); for (size_t i = 0; i < len; ++i) { str = choice_set[strings::vr_commands][i].asCharArray(); @@ -227,8 +231,9 @@ bool CreateInteractionChoiceSetRequest::IsWhiteSpaceExist( if (choice_set.keyExists(strings::secondary_image)) { str = choice_set[strings::secondary_image][strings::value].asCharArray(); if (!CheckSyntax(str)) { - LOG4CXX_ERROR(logger_, "Invalid secondary_image value. " - "Syntax check failed"); + LOG4CXX_ERROR(logger_, + "Invalid secondary_image value. " + "Syntax check failed"); return true; } } @@ -236,15 +241,15 @@ bool CreateInteractionChoiceSetRequest::IsWhiteSpaceExist( } void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests( - application_manager::ApplicationSharedPtr const app) { + application_manager::ApplicationSharedPtr const app) { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject& choice_set = (*message_)[strings::msg_params]; - smart_objects::SmartObject msg_params = smart_objects::SmartObject( - smart_objects::SmartType_Map); + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); msg_params[strings::type] = hmi_apis::Common_VRCommandType::Choice; msg_params[strings::app_id] = app->app_id(); - msg_params[strings::grammar_id] = choice_set[strings::grammar_id]; + msg_params[strings::grammar_id] = choice_set[strings::grammar_id]; const uint32_t choice_count = choice_set[strings::choice_set].length(); SetAllowedToTerminate(false); @@ -254,17 +259,18 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests( { sync_primitives::AutoLock error_lock(error_from_hmi_lock_); if (error_from_hmi_) { - LOG4CXX_WARN(logger_, "Error from HMI received. Stop sending VRCommands"); + LOG4CXX_WARN(logger_, + "Error from HMI received. Stop sending VRCommands"); break; } } msg_params[strings::cmd_id] = - choice_set[strings::choice_set][chs_num][strings::choice_id]; - msg_params[strings::vr_commands] = smart_objects::SmartObject( - smart_objects::SmartType_Array); + choice_set[strings::choice_set][chs_num][strings::choice_id]; + msg_params[strings::vr_commands] = + smart_objects::SmartObject(smart_objects::SmartType_Array); msg_params[strings::vr_commands] = - choice_set[strings::choice_set][chs_num][strings::vr_commands]; + choice_set[strings::choice_set][chs_num][strings::vr_commands]; sync_primitives::AutoLock commands_lock(vr_commands_lock_); const uint32_t vr_cmd_id = msg_params[strings::cmd_id].asUInt(); @@ -273,8 +279,9 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests( VRCommandInfo vr_command(vr_cmd_id); sent_commands_map_[vr_corr_id] = vr_command; - LOG4CXX_DEBUG(logger_, "VR_command sent corr_id " - << vr_corr_id << " cmd_id " << vr_corr_id); + LOG4CXX_DEBUG(logger_, + "VR_command sent corr_id " << vr_corr_id << " cmd_id " + << vr_corr_id); } expected_chs_count_ = chs_num; LOG4CXX_DEBUG(logger_, "expected_chs_count_ = " << expected_chs_count_); @@ -289,12 +296,13 @@ void CreateInteractionChoiceSetRequest::on_event( const smart_objects::SmartObject& message = event.smart_object(); if (event.id() == hmi_apis::FunctionID::VR_AddCommand) { received_chs_count_++; - LOG4CXX_DEBUG(logger_, "Got VR.AddCommand response, there are " - << expected_chs_count_ - received_chs_count_ - << " more to wait."); + LOG4CXX_DEBUG(logger_, + "Got VR.AddCommand response, there are " + << expected_chs_count_ - received_chs_count_ + << " more to wait."); - uint32_t corr_id = static_cast(message[strings::params] - [strings::correlation_id].asUInt()); + uint32_t corr_id = static_cast( + message[strings::params][strings::correlation_id].asUInt()); { sync_primitives::AutoLock commands_lock(vr_commands_lock_); SentCommandsMap::iterator it = sent_commands_map_.find(corr_id); @@ -303,21 +311,20 @@ void CreateInteractionChoiceSetRequest::on_event( return; } - Common_Result::eType vr_result = static_cast( - message[strings::params][hmi_response::code].asInt()); + Common_Result::eType vr_result = static_cast( + message[strings::params][hmi_response::code].asInt()); - const bool is_vr_no_error = - Compare( - vr_result, - Common_Result::SUCCESS, - Common_Result::WARNINGS); + const bool is_vr_no_error = Compare( + vr_result, Common_Result::SUCCESS, Common_Result::WARNINGS); if (is_vr_no_error) { VRCommandInfo& vr_command = it->second; vr_command.succesful_response_received_ = true; } else { - LOG4CXX_DEBUG(logger_, "Hmi response is not Success: " << vr_result - << ". Stop sending VRAddCommand requests"); + LOG4CXX_DEBUG(logger_, + "Hmi response is not Success: " + << vr_result + << ". Stop sending VRAddCommand requests"); if (!error_from_hmi_) { error_from_hmi_ = true; SendResponse(false, GetMobileResultCode(vr_result)); @@ -346,15 +353,14 @@ void CreateInteractionChoiceSetRequest::onTimeOut() { // according to SDLAQ-CRS-2976 sync_primitives::AutoLock timeout_lock_(is_timed_out_lock_); is_timed_out_ = true; - application_manager_.TerminateRequest( - connection_key(), correlation_id()); + application_manager_.TerminateRequest(connection_key(), correlation_id()); } void CreateInteractionChoiceSetRequest::DeleteChoices() { LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr application = - application_manager_.application(connection_key()); + application_manager_.application(connection_key()); if (!application) { LOG4CXX_ERROR(logger_, "NULL pointer"); return; @@ -372,9 +378,9 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() { msg_param[strings::cmd_id] = vr_command_info.cmd_id_; SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_param); } else { - LOG4CXX_WARN( - logger_, "Succesfull response has not been received for cmd_id = " - << vr_command_info.cmd_id_); + LOG4CXX_WARN(logger_, + "Succesfull response has not been received for cmd_id = " + << vr_command_info.cmd_id_); } } sent_commands_map_.clear(); @@ -397,8 +403,7 @@ void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() { DeleteChoices(); } - application_manager_.TerminateRequest( - connection_key(), correlation_id()); + application_manager_.TerminateRequest(connection_key(), correlation_id()); } } // namespace commands -- cgit v1.2.1