summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Oleynik <AOleynik@luxoft.com>2016-01-17 20:01:24 +0200
committerHerasym Oleh <oolleehh@gmail.com>2016-02-02 18:11:20 +0200
commite586369e6bec4eceb1976924626fe7190713ae52 (patch)
tree8cf819c1c93e333ce8c5f2e22b86d566fe6882a3
parenta989c65f388cc51c4306ee2de38cd243db84d713 (diff)
downloadsdl_core-e586369e6bec4eceb1976924626fe7190713ae52.tar.gz
Fixes subsciptions for responses of GetLanguages request.
Correlation_id is necessary to subscribe for responses. Changed implementation to make new logic able to do this. Implements: APPLINK-20560 Conflicts: src/components/application_manager/src/hmi_capabilities.cc
-rw-r--r--src/components/application_manager/include/application_manager/hmi_language_handler.h3
-rw-r--r--src/components/application_manager/src/commands/hmi/tts_get_language_response.cc4
-rw-r--r--src/components/application_manager/src/commands/hmi/ui_get_language_response.cc4
-rw-r--r--src/components/application_manager/src/commands/hmi/vr_get_language_response.cc4
-rw-r--r--src/components/application_manager/src/hmi_capabilities.cc14
-rw-r--r--src/components/application_manager/src/hmi_language_handler.cc43
6 files changed, 62 insertions, 10 deletions
diff --git a/src/components/application_manager/include/application_manager/hmi_language_handler.h b/src/components/application_manager/include/application_manager/hmi_language_handler.h
index ce62ba309b..ea8681fed4 100644
--- a/src/components/application_manager/include/application_manager/hmi_language_handler.h
+++ b/src/components/application_manager/include/application_manager/hmi_language_handler.h
@@ -52,6 +52,9 @@ public:
void on_event(const event_engine::Event& event) OVERRIDE;
+ void set_handle_response_for(
+ const event_engine::smart_objects::SmartObject& request);
+
private:
void VerifyRegisteredApps() const;
diff --git a/src/components/application_manager/src/commands/hmi/tts_get_language_response.cc b/src/components/application_manager/src/commands/hmi/tts_get_language_response.cc
index e1149e1e92..442f4135ff 100644
--- a/src/components/application_manager/src/commands/hmi/tts_get_language_response.cc
+++ b/src/components/application_manager/src/commands/hmi/tts_get_language_response.cc
@@ -54,7 +54,11 @@ void TTSGetLanguageResponse::Run() {
static_cast<hmi_apis::Common_Language::eType>(
(*message_)[strings::msg_params][hmi_response::language].asInt()));
+ LOG4CXX_DEBUG(logger_, "Raising event for function_id "
+ << function_id()
+ << " and correlation_id " << correlation_id());
event_engine::Event event(hmi_apis::FunctionID::TTS_GetLanguage);
+ event.set_smart_object(*message_);
event.raise();
}
diff --git a/src/components/application_manager/src/commands/hmi/ui_get_language_response.cc b/src/components/application_manager/src/commands/hmi/ui_get_language_response.cc
index 153a8d29bd..937cae7903 100644
--- a/src/components/application_manager/src/commands/hmi/ui_get_language_response.cc
+++ b/src/components/application_manager/src/commands/hmi/ui_get_language_response.cc
@@ -55,7 +55,11 @@ void UIGetLanguageResponse::Run() {
static_cast<hmi_apis::Common_Language::eType>(
(*message_)[strings::msg_params][hmi_response::language].asInt()));
+ LOG4CXX_DEBUG(logger_, "Raising event for function_id "
+ << function_id()
+ << " and correlation_id " << correlation_id());
event_engine::Event event(hmi_apis::FunctionID::UI_GetLanguage);
+ event.set_smart_object(*message_);
event.raise();
}
diff --git a/src/components/application_manager/src/commands/hmi/vr_get_language_response.cc b/src/components/application_manager/src/commands/hmi/vr_get_language_response.cc
index 6fbfd91946..ba01040dd5 100644
--- a/src/components/application_manager/src/commands/hmi/vr_get_language_response.cc
+++ b/src/components/application_manager/src/commands/hmi/vr_get_language_response.cc
@@ -54,7 +54,11 @@ void VRGetLanguageResponse::Run() {
static_cast<hmi_apis::Common_Language::eType>(
(*message_)[strings::msg_params][hmi_response::language].asInt()));
+ LOG4CXX_DEBUG(logger_, "Raising event for function_id "
+ << function_id()
+ << " and correlation_id " << correlation_id());
event_engine::Event event(hmi_apis::FunctionID::VR_GetLanguage);
+ event.set_smart_object(*message_);
event.raise();
}
diff --git a/src/components/application_manager/src/hmi_capabilities.cc b/src/components/application_manager/src/hmi_capabilities.cc
index d0bb6705a6..7c7664f9e3 100644
--- a/src/components/application_manager/src/hmi_capabilities.cc
+++ b/src/components/application_manager/src/hmi_capabilities.cc
@@ -328,8 +328,8 @@ void HMICapabilities::set_is_vr_cooperating(bool value) {
is_vr_cooperating_ = value;
if (is_vr_cooperating_) {
utils::SharedPtr<smart_objects::SmartObject> get_language(
- MessageHelper::CreateModuleInfoSO(
- hmi_apis::FunctionID::VR_GetLanguage));
+ MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetLanguage));
+ hmi_language_handler_.set_handle_response_for(*get_language.get());
app_mngr_->ManageHMICommand(get_language);
utils::SharedPtr<smart_objects::SmartObject> get_all_languages(
MessageHelper::CreateModuleInfoSO(
@@ -347,8 +347,9 @@ void HMICapabilities::set_is_tts_cooperating(bool value) {
is_tts_cooperating_ = value;
if (is_tts_cooperating_) {
utils::SharedPtr<smart_objects::SmartObject> get_language(
- MessageHelper::CreateModuleInfoSO(
- hmi_apis::FunctionID::TTS_GetLanguage));
+ MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::TTS_GetLanguage));
+ hmi_language_handler_.set_handle_response_for(*get_language.get());
app_mngr_->ManageHMICommand(get_language);
utils::SharedPtr<smart_objects::SmartObject> get_all_languages(
MessageHelper::CreateModuleInfoSO(
@@ -366,8 +367,9 @@ void HMICapabilities::set_is_ui_cooperating(bool value) {
is_ui_cooperating_ = value;
if (is_ui_cooperating_) {
utils::SharedPtr<smart_objects::SmartObject> get_language(
- MessageHelper::CreateModuleInfoSO(
- hmi_apis::FunctionID::UI_GetLanguage));
+ MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::UI_GetLanguage));
+ hmi_language_handler_.set_handle_response_for(*get_language.get());
app_mngr_->ManageHMICommand(get_language);
utils::SharedPtr<smart_objects::SmartObject> get_all_languages(
MessageHelper::CreateModuleInfoSO(
diff --git a/src/components/application_manager/src/hmi_language_handler.cc b/src/components/application_manager/src/hmi_language_handler.cc
index 5344840c0f..e56308b47e 100644
--- a/src/components/application_manager/src/hmi_language_handler.cc
+++ b/src/components/application_manager/src/hmi_language_handler.cc
@@ -34,6 +34,7 @@
#include "application_manager/hmi_language_handler.h"
#include "application_manager/message_helper.h"
#include "application_manager/hmi_capabilities.h"
+#include "utils/helpers.h"
#include "resumption/last_state.h"
static const std::string LanguagesKey = "Languages";
@@ -49,9 +50,6 @@ HMILanguageHandler::HMILanguageHandler()
: is_ui_language_received_(false),
is_vr_language_received_(false),
is_tts_language_received_(false) {
- subscribe_on_event(hmi_apis::FunctionID::UI_GetLanguage);
- subscribe_on_event(hmi_apis::FunctionID::VR_GetLanguage);
- subscribe_on_event(hmi_apis::FunctionID::TTS_GetLanguage);
}
void HMILanguageHandler::set_ui_language(
@@ -104,7 +102,8 @@ hmi_apis::Common_Language::eType HMILanguageHandler::get_tts_language() const {
using namespace hmi_apis;
if (LastState::instance()->dictionary.isMember(LanguagesKey)) {
if (LastState::instance()->dictionary[LanguagesKey].isMember(TTSKey)) {
- Common_Language::eType tts_language =
+ // Web HMI returns -1 which causes assert for debug
+ Common_Language::eType tts_language = //Common_Language::EN_US;
static_cast<Common_Language::eType>(
LastState::instance()->dictionary[LanguagesKey][TTSKey].asUInt());
@@ -139,6 +138,42 @@ void HMILanguageHandler::on_event(const event_engine::Event& event) {
}
}
+void HMILanguageHandler::set_handle_response_for(
+ const event_engine::smart_objects::SmartObject& request) {
+ using namespace helpers;
+ if (!request.keyExists(strings::params)) {
+ return;
+ }
+
+ if (!request[strings::params].keyExists(strings::function_id)) {
+ return;
+ }
+
+ if (!request[strings::params].keyExists(strings::correlation_id)) {
+ return;
+ }
+
+ hmi_apis::FunctionID::eType function_id =
+ static_cast<hmi_apis::FunctionID::eType>(
+ request[strings::params][strings::function_id].asInt());
+
+ if (!Compare<hmi_apis::FunctionID::eType, ONE, EQ>(
+ function_id,
+ hmi_apis::FunctionID::UI_GetLanguage,
+ hmi_apis::FunctionID::VR_GetLanguage,
+ hmi_apis::FunctionID::TTS_GetLanguage)) {
+ return;
+ }
+
+ uint32_t correlation_id =
+ request[strings::params][strings::correlation_id].asUInt();
+
+ subscribe_on_event(function_id, correlation_id);
+
+ LOG4CXX_DEBUG(logger_, "Subscribed for function_id " << function_id <<
+ " and correlation_id " << correlation_id);
+}
+
void HMILanguageHandler::VerifyRegisteredApps() const {
LOG4CXX_AUTO_TRACE(logger_);
HMICapabilities& hmi_capabilities =