diff options
author | Conlain Kelly <conlain.k@gmail.com> | 2018-07-19 09:47:22 -0400 |
---|---|---|
committer | Conlain Kelly <conlain.k@gmail.com> | 2018-07-19 09:47:22 -0400 |
commit | 325bf4094287e4ab3cf8bd0fee43aef3e585d218 (patch) | |
tree | 782f8a7e851b9dac854b9441d74ac70f4589652b /src/components/application_manager/rpc_plugins/sdl_rpc_plugin | |
parent | 4f21cbafb247664bd7b89bf2d39944764b1763b1 (diff) | |
download | sdl_core-325bf4094287e4ab3cf8bd0fee43aef3e585d218.tar.gz |
first run at making vrcommands optional
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin')
3 files changed, 74 insertions, 4 deletions
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 40e706b851..02ea6945f7 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 @@ -211,6 +211,20 @@ class PerformInteractionRequest app_mngr::ApplicationSharedPtr app, const size_t choice_set_id_list_length, const smart_objects::SmartObject& choice_set_id_list) const; + + + /** + * @brief Checks each choice in each set for having a VRcommands parameter + * @param app contains pointer to application. + * @param choice_set_id_list_length contains amount + * of choice set ids. + * @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, + const size_t choice_set_id_list_length, + const smart_objects::SmartObject& choice_set_id_list) const; /** * @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 7451ea7905..31f4deb50c 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 @@ -124,10 +124,19 @@ void CreateInteractionChoiceSetRequest::Run() { SendResponse(false, result); return; } - uint32_t grammar_id = application_manager_.GenerateGrammarID(); - (*message_)[strings::msg_params][strings::grammar_id] = grammar_id; + int vr_status = MessageHelper::CheckChoiceSet_VRCommands((*message_)[strings::msg_params][strings::choice_set]); + if (vr_status == -1) { + // this is an error + SendResponse(false, Result::INVALID_DATA, "Some choices don't contain VR commands."); + + } else if (vr_status == 0) { + // everyone had a vr command, setup the grammar + uint32_t grammar_id = application_manager_.GenerateGrammarID(); + (*message_)[strings::msg_params][strings::grammar_id] = grammar_id; + SendVRAddCommandRequests(app); + } + // continue on as usual app->AddChoiceSet(choice_set_id_, (*message_)[strings::msg_params]); - SendVRAddCommandRequests(app); } mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( 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 8710f3c3d6..bac700f89c 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 @@ -163,7 +163,18 @@ void PerformInteractionRequest::Run() { SendResponse(false, mobile_apis::Result::INVALID_ID); return; } - + if (!CheckChoiceSetList_VRCommands( + app, + choice_set_id_list_length, + msg_params[strings::interaction_choice_set_id_list])) { + LOG4CXX_ERROR(logger_, + "PerformInteraction has choice sets with " + "missing vrCommands"); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "Some choices don't contain VR commands."); + return; + } if (msg_params.keyExists(strings::vr_help)) { if (mobile_apis::Result::SUCCESS != MessageHelper::VerifyImageVrHelpItems( @@ -942,6 +953,35 @@ bool PerformInteractionRequest::CheckChoiceIDFromResponse( return false; } + +bool PerformInteractionRequest::CheckChoiceSetList_VRCommands( + ApplicationSharedPtr app, + const size_t choice_set_id_list_length, + const smart_objects::SmartObject& choice_set_id_list) const { + LOG4CXX_AUTO_TRACE(logger_); + + smart_objects::SmartObject* choice_set = 0; + std::pair<std::set<uint32_t>::iterator, bool> ins_res; + + for (size_t i = 0; i < choice_set_id_list_length; ++i) { + choice_set = app->FindChoiceSet(choice_set_id_list[i].asInt()); + if (!choice_set) { + LOG4CXX_ERROR( + logger_, + "Couldn't find choiceset_id = " << choice_set_id_list[i].asInt()); + return false; + } + + + int vr_status = MessageHelper::CheckChoiceSet_VRCommands(*choice_set); + // if not all choices have vr commands + if (vr_status != 0) { + return false; + } + } + return true; +} + bool PerformInteractionRequest::CheckChoiceIDFromRequest( ApplicationSharedPtr app, const size_t choice_set_id_list_length, @@ -961,6 +1001,13 @@ bool PerformInteractionRequest::CheckChoiceIDFromRequest( "Couldn't find choiset_id = " << choice_set_id_list[i].asInt()); return false; } + + + int vr_status = MessageHelper::CheckChoiceSet_VRCommands(*choice_set); + // if not all choices have vr commands + if (vr_status != 0) { + + } choice_list_length = (*choice_set)[strings::choice_set].length(); const smart_objects::SmartObject& choices_list = (*choice_set)[strings::choice_set]; |