diff options
Diffstat (limited to 'src/components/application_manager')
5 files changed, 56 insertions, 48 deletions
diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index b15cf0c615..f370cc6966 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -855,43 +855,19 @@ class MessageHelper { */ static smart_objects::SmartObjectSPtr CreateMessageForHMI( hmi_apis::messageType::eType message_type, const uint32_t correlation_id); - - // Check whether each choice has the vrCommands field - // returns -1 for failure, 0 if all choice include vrCommands, and 1 if none - // do - // vrCommands is an all-or-none deal - static int CheckChoiceSet_VRCommands( - const smart_objects::SmartObject& choice_set) { - // if this becomes true, someone doesn't have vrCommands - bool all_have = true; - // if this is true, no one has vrCommands - bool none_have = true; - smart_objects::SmartArray::const_iterator current_choice_set_it = - choice_set.asArray()->begin(); - // Iterate through choices - for (; choice_set.asArray()->end() != current_choice_set_it; - ++current_choice_set_it) { - // if the vrCommands is present - if (current_choice_set_it->keyExists( - application_manager::strings::vr_commands)) { - // this one has the parameter - none_have = false; - } else { - // this one doesn't - all_have = false; - } - } - // everyone has it - if (all_have) { - return 0; - } - // No one has it - if (none_have) { - return 1; - } - // mix-and-match, this is an error - return -1; - } + + enum ChoiceSetVRCommandsStatus { + MIXED, ALL, NONE + }; + + /** + * @brief Check whether each choice in the set has the vrCommands parameter + * vrCommands is an all-or-none deal + * @param choice set to check + * @return -1 for mixed, 0 if all choice include vrCommands, and 1 if none do + */ + static ChoiceSetVRCommandsStatus CheckChoiceSetVRCommands( + const smart_objects::SmartObject& choice_set); private: /** diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h index 8c98a4ff30..4ae6c90a62 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h @@ -220,7 +220,7 @@ class PerformInteractionRequest * @param choice_set_id_list array of choice set ids * @return returns false request has choice sets with no vrCommands */ - bool CheckChoiceSetList_VRCommands(app_mngr::ApplicationSharedPtr app); + bool CheckChoiceSetListVRCommands(app_mngr::ApplicationSharedPtr app); /** * @brief Tells if there are sent requests without responses diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc index 0d6114cc50..92c15afd6d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc @@ -123,17 +123,16 @@ void CreateInteractionChoiceSetRequest::Run() { SendResponse(false, result); return; } - int vr_status = MessageHelper::CheckChoiceSet_VRCommands( + auto vr_status = MessageHelper::CheckChoiceSetVRCommands( (*message_)[strings::msg_params][strings::choice_set]); - if (vr_status == -1) { + if (vr_status == MessageHelper::ChoiceSetVRCommandsStatus::MIXED) { // this is an error SendResponse(false, Result::INVALID_DATA, "Some choices don't contain VR commands. Either all or none " "must have voice commands."); return; // exit now, this is a bad set - - } else if (vr_status == 0) { + } else if (vr_status == MessageHelper::ChoiceSetVRCommandsStatus::ALL) { // everyone had a vr command, setup the grammar uint32_t grammar_id = application_manager_.GenerateGrammarID(); (*message_)[strings::msg_params][strings::grammar_id] = grammar_id; @@ -141,10 +140,11 @@ void CreateInteractionChoiceSetRequest::Run() { // continue on as usual app->AddChoiceSet(choice_set_id_, (*message_)[strings::msg_params]); - if (vr_status == 0) { + if (vr_status == MessageHelper::ChoiceSetVRCommandsStatus::ALL) { // we have VR commands SendVRAddCommandRequests(app); } else { + // we have none, just return with success SendResponse(true, Result::SUCCESS); } } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc index d013244f57..a9370845ad 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc @@ -186,7 +186,7 @@ void PerformInteractionRequest::Run() { LOG4CXX_DEBUG(logger_, "Interaction Mode: BOTH"); if (!CheckChoiceSetVRSynonyms(app) || !CheckChoiceSetMenuNames(app) || !CheckVrHelpItemPositions(app) || - !CheckChoiceSetList_VRCommands(app)) { + !CheckChoiceSetListVRCommands(app)) { return; } break; @@ -202,7 +202,7 @@ void PerformInteractionRequest::Run() { case mobile_apis::InteractionMode::VR_ONLY: { LOG4CXX_DEBUG(logger_, "Interaction Mode: VR_ONLY"); if (!CheckChoiceSetVRSynonyms(app) || !CheckVrHelpItemPositions(app) || - !CheckChoiceSetList_VRCommands(app)) { + !CheckChoiceSetListVRCommands(app)) { return; } break; @@ -952,7 +952,7 @@ bool PerformInteractionRequest::CheckChoiceIDFromResponse( return false; } -bool PerformInteractionRequest::CheckChoiceSetList_VRCommands( +bool PerformInteractionRequest::CheckChoiceSetListVRCommands( ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); @@ -974,10 +974,10 @@ bool PerformInteractionRequest::CheckChoiceSetList_VRCommands( const smart_objects::SmartObject& choices_list = (*choice_set)[strings::choice_set]; - int vr_status = MessageHelper::CheckChoiceSet_VRCommands(choices_list); + auto vr_status = MessageHelper::CheckChoiceSetVRCommands(choices_list); // if not all choices have vr commands - if (vr_status != 0) { + if (vr_status != MessageHelper::ChoiceSetVRCommandsStatus::ALL) { LOG4CXX_ERROR(logger_, "PerformInteraction has choice sets with " "missing vrCommands, not in MANUAL_ONLY mode"); diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 978724a671..31622bc911 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -326,6 +326,38 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI( return message; } +MessageHelper::ChoiceSetVRCommandsStatus MessageHelper::CheckChoiceSetVRCommands(const smart_objects::SmartObject& choice_set) { + // if this is false, someone doesn't have vrCommands + bool all_have = true; + // if this is false, someone has vrCommands + bool none_have = true; + smart_objects::SmartArray::const_iterator current_choice_set_it = + choice_set.asArray()->begin(); + // Iterate through choices + for (; choice_set.asArray()->end() != current_choice_set_it; + ++current_choice_set_it) { + // if the vrCommands is present + if (current_choice_set_it->keyExists( + application_manager::strings::vr_commands)) { + // this one has the parameter + none_have = false; + } else { + // this one doesn't + all_have = false; + } + } + // everyone has it + if (all_have) { + return MessageHelper::ChoiceSetVRCommandsStatus::ALL; + } + // No one has it + if (none_have) { + return MessageHelper::ChoiceSetVRCommandsStatus::NONE; + } + // mix-and-match, this is an error + return MessageHelper::ChoiceSetVRCommandsStatus::MIXED; +} + smart_objects::SmartObjectSPtr MessageHelper::CreateHashUpdateNotification( const uint32_t app_id) { LOG4CXX_AUTO_TRACE(logger_); |