diff options
Diffstat (limited to 'src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc')
-rw-r--r-- | src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc | 107 |
1 files changed, 57 insertions, 50 deletions
diff --git a/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc index e47ed01f51..a7c2db0e65 100644 --- a/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc +++ b/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc @@ -46,10 +46,6 @@ namespace commands { ResetGlobalPropertiesRequest::ResetGlobalPropertiesRequest( const MessageSharedPtr& message, ApplicationManager& application_manager) : CommandRequestImpl(message, application_manager) - , is_ui_send_(false) - , is_tts_send_(false) - , is_ui_received_(false) - , is_tts_received_(false) , ui_result_(hmi_apis::Common_Result::INVALID_ENUM) , tts_result_(hmi_apis::Common_Result::INVALID_ENUM) {} @@ -111,11 +107,11 @@ void ResetGlobalPropertiesRequest::Run() { if (vr_help_title_items || menu_name || menu_icon || is_key_board_properties) { - is_ui_send_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); } if (timeout_prompt || helpt_promt) { - is_tts_send_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); } app->set_reset_global_properties_active(true); @@ -242,22 +238,21 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); - ApplicationSharedPtr application = - application_manager_.application(connection_key()); - switch (event.id()) { case hmi_apis::FunctionID::UI_SetGlobalProperties: { LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event"); - is_ui_received_ = true; + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); ui_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); + GetInfo(message, ui_response_info_); break; } case hmi_apis::FunctionID::TTS_SetGlobalProperties: { LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event"); - is_tts_received_ = true; + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); tts_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); + GetInfo(message, tts_response_info_); break; } default: { @@ -266,53 +261,65 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { } } - if (!IsPendingResponseExist()) { - bool result = - ((hmi_apis::Common_Result::SUCCESS == ui_result_) && - (hmi_apis::Common_Result::SUCCESS == tts_result_ || - hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_)) || - ((hmi_apis::Common_Result::SUCCESS == ui_result_) && - (hmi_apis::Common_Result::INVALID_ENUM == tts_result_)) || - ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_) && - (hmi_apis::Common_Result::SUCCESS == tts_result_)); - - mobile_apis::Result::eType result_code; - const char* return_info = NULL; - - if (result) { - if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_) { - result_code = mobile_apis::Result::WARNINGS; - return_info = - std::string("Unsupported phoneme type sent in a prompt").c_str(); - } else { - result_code = static_cast<mobile_apis::Result::eType>( - std::max(ui_result_, tts_result_)); - } - } else { - result_code = static_cast<mobile_apis::Result::eType>( - std::max(ui_result_, tts_result_)); - } + if (IsPendingResponseExist()) { + LOG4CXX_DEBUG(logger_, "Waiting for remaining responses"); + return; + } - SendResponse(result, - static_cast<mobile_apis::Result::eType>(result_code), - return_info, - &(message[strings::msg_params])); + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; + std::string response_info; + const bool result = PrepareResponseParameters(result_code, response_info); - if (!application) { - LOG4CXX_ERROR(logger_, "NULL pointer"); - return; - } + SendResponse(result, + static_cast<mobile_apis::Result::eType>(result_code), + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); +} - if (result) { - application->UpdateHash(); - } +bool ResetGlobalPropertiesRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +bool ResetGlobalPropertiesRequest::PrepareResponseParameters( + mobile_apis::Result::eType& out_result_code, + std::string& out_response_info) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + + bool result = false; + ResponseInfo ui_properties_info( + ui_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); + ResponseInfo tts_properties_info( + tts_result_, HmiInterfaces::HMI_INTERFACE_TTS, application_manager_); + + HmiInterfaces::InterfaceState tts_interface_state = + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_TTS); + + if (hmi_apis::Common_Result::SUCCESS == ui_result_ && + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_ && + HmiInterfaces::STATE_AVAILABLE == tts_interface_state) { + result = true; + out_result_code = mobile_apis::Result::WARNINGS; + out_response_info = "Unsupported phoneme type sent in a prompt"; } else { - LOG4CXX_WARN(logger_, "unable to find application: " << connection_key()); + result = + PrepareResultForMobileResponse(ui_properties_info, tts_properties_info); + out_result_code = + PrepareResultCodeForResponse(ui_properties_info, tts_properties_info); + out_response_info = MergeInfos(tts_properties_info, + tts_response_info_, + ui_properties_info, + ui_response_info_); } + + return result; } bool ResetGlobalPropertiesRequest::IsPendingResponseExist() { - return is_ui_send_ != is_ui_received_ || is_tts_send_ != is_tts_received_; + return IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_TTS) || + IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI); } } // namespace commands |