diff options
Diffstat (limited to 'src/components/application_manager/src/commands/mobile')
93 files changed, 942 insertions, 521 deletions
diff --git a/src/components/application_manager/src/commands/mobile/add_command_request.cc b/src/components/application_manager/src/commands/mobile/add_command_request.cc index 35cc619895..da44d0e7c4 100644 --- a/src/components/application_manager/src/commands/mobile/add_command_request.cc +++ b/src/components/application_manager/src/commands/mobile/add_command_request.cc @@ -56,13 +56,13 @@ AddCommandRequest::~AddCommandRequest() { } void AddCommandRequest::onTimeOut() { - LOG4CXX_INFO(logger_, "AddCommandRequest::onTimeOut"); + LOG4CXX_AUTO_TRACE(logger_); RemoveCommand(); CommandRequestImpl::onTimeOut(); } void AddCommandRequest::Run() { - LOG4CXX_INFO(logger_, "AddCommandRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( (*message_)[strings::params][strings::connection_key].asUInt()); @@ -198,7 +198,8 @@ bool AddCommandRequest::CheckCommandName(ApplicationConstSharedPtr app) { return false; } - const CommandsMap& commands = app->commands_map(); + const DataAccessor<CommandsMap> accessor = app->commands_map(); + const CommandsMap& commands = accessor.GetData(); CommandsMap::const_iterator i = commands.begin(); uint32_t saved_parent_id = 0; uint32_t parent_id = 0; @@ -235,7 +236,8 @@ bool AddCommandRequest::CheckCommandVRSynonym(ApplicationConstSharedPtr app) { return false; } - const CommandsMap& commands = app->commands_map(); + const DataAccessor<CommandsMap> accessor = app->commands_map(); + const CommandsMap& commands = accessor.GetData(); CommandsMap::const_iterator it = commands.begin(); for (; commands.end() != it; ++it) { @@ -284,10 +286,22 @@ bool AddCommandRequest::CheckCommandParentId(ApplicationConstSharedPtr app) { } void AddCommandRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "AddCommandRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + smart_objects::SmartObject msg_param(smart_objects::SmartType_Map); + msg_param[strings::cmd_id] = (*message_)[strings::msg_params][strings::cmd_id]; + msg_param[strings::app_id] = application->app_id(); + switch (event.id()) { case hmi_apis::FunctionID::UI_AddCommand: { LOG4CXX_INFO(logger_, "Received UI_AddCommand event"); @@ -296,8 +310,8 @@ void AddCommandRequest::on_event(const event_engine::Event& event) { message[strings::params][hmi_response::code].asInt()); if (hmi_apis::Common_Result::SUCCESS != ui_result_) { - (*message_)[strings::msg_params].erase(strings::menu_params); - } + (*message_)[strings::msg_params].erase(strings::menu_params); + } break; } case hmi_apis::FunctionID::VR_AddCommand: { @@ -318,18 +332,18 @@ void AddCommandRequest::on_event(const event_engine::Event& event) { } if (!IsPendingResponseExist()) { + ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(connection_key()); - if (!application) { - LOG4CXX_ERROR(logger_, "NULL pointer"); - return; - } - if (hmi_apis::Common_Result::REJECTED == ui_result_) { RemoveCommand(); } + smart_objects::SmartObject msg_params(smart_objects::SmartType_Map); + msg_params[strings::cmd_id] = (*message_)[strings::msg_params][strings::cmd_id]; + msg_params[strings::app_id] = application->app_id(); + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; bool result = ((hmi_apis::Common_Result::SUCCESS == ui_result_) && @@ -348,6 +362,39 @@ void AddCommandRequest::on_event(const event_engine::Event& event) { std::max(ui_result_, vr_result_)); } + if (BothSend() && hmi_apis::Common_Result::SUCCESS == vr_result_) { + if (hmi_apis::Common_Result::SUCCESS != ui_result_ && + hmi_apis::Common_Result::WARNINGS != ui_result_ && + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE != ui_result_) { + + result_code = + (ui_result_ == hmi_apis::Common_Result::REJECTED) ? + mobile_apis::Result::REJECTED : mobile_apis::Result::GENERIC_ERROR; + + msg_params[strings::grammar_id] = application->get_grammar_id(); + msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; + + SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params); + application->RemoveCommand((*message_)[strings::msg_params] + [strings::cmd_id].asUInt()); + result = false; + } + } + + if(BothSend() && hmi_apis::Common_Result::SUCCESS == ui_result_ && + hmi_apis::Common_Result::SUCCESS != vr_result_) { + + result_code = + (vr_result_ == hmi_apis::Common_Result::REJECTED) ? + mobile_apis::Result::REJECTED : mobile_apis::Result::GENERIC_ERROR; + + SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params); + + application->RemoveCommand((*message_)[strings::msg_params] + [strings::cmd_id].asUInt()); + result = false; + } + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); if (true == result) { application->UpdateHash(); @@ -360,7 +407,7 @@ bool AddCommandRequest::IsPendingResponseExist() { } bool AddCommandRequest::IsWhiteSpaceExist() { - LOG4CXX_INFO(logger_, "AddCommandRequest::IsWhiteSpaceExist"); + LOG4CXX_AUTO_TRACE(logger_); const char* str = NULL; if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) { @@ -397,16 +444,42 @@ bool AddCommandRequest::IsWhiteSpaceExist() { return false; } +bool AddCommandRequest::BothSend() const { + return send_vr_ && send_ui_; +} + void AddCommandRequest::RemoveCommand() { - LOG4CXX_INFO(logger_, "AddCommandRequest::RemoveCommand"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( connection_key()); if (!app.valid()) { LOG4CXX_ERROR(logger_, "No application associated with session key"); return; } + + smart_objects::SmartObject msg_params(smart_objects::SmartType_Map); + msg_params[strings::cmd_id] = (*message_)[strings::msg_params][strings::cmd_id]; + msg_params[strings::app_id] = app->app_id(); + app->RemoveCommand((*message_)[strings::msg_params] [strings::cmd_id].asUInt()); + + if (BothSend() && !(is_vr_received_ || is_ui_received_)) { + // in case we have send bth UI and VR and no one respond + // we have nothing to remove from HMI so no DeleteCommand expected + return; + } + + if (BothSend() && !is_vr_received_) { + SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params); + } + + if (BothSend() && !is_ui_received_) { + msg_params[strings::grammar_id] = app->get_grammar_id(); + msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; + SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params); + } + } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/add_command_response.cc b/src/components/application_manager/src/commands/mobile/add_command_response.cc index 0c135af076..51684c065b 100644 --- a/src/components/application_manager/src/commands/mobile/add_command_response.cc +++ b/src/components/application_manager/src/commands/mobile/add_command_response.cc @@ -46,7 +46,7 @@ AddCommandResponse::~AddCommandResponse() { } void AddCommandResponse::Run() { - LOG4CXX_INFO(logger_, "AddCommandResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc b/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc index ce6fa3fc51..7e0e6aeca4 100644 --- a/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc +++ b/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc @@ -47,7 +47,7 @@ AddSubMenuRequest::~AddSubMenuRequest() { } void AddSubMenuRequest::Run() { - LOG4CXX_INFO(logger_, "AddSubMenuRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( (*message_)[strings::params][strings::connection_key].asUInt()); @@ -95,7 +95,7 @@ void AddSubMenuRequest::Run() { } void AddSubMenuRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "AddSubMenuRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { diff --git a/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc b/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc index bcd7df2888..ff37a6a998 100644 --- a/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc +++ b/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc @@ -47,7 +47,7 @@ AddSubMenuResponse::~AddSubMenuResponse() { } void AddSubMenuResponse::Run() { - LOG4CXX_INFO(logger_, "AddSubMenuResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc index abb5bc7f3c..77d2211157 100644 --- a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc +++ b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc @@ -52,7 +52,7 @@ AlertManeuverRequest::~AlertManeuverRequest() { } void AlertManeuverRequest::Run() { - LOG4CXX_INFO(logger_, "AlertManeuverRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); if ((!(*message_)[strings::msg_params].keyExists(strings::soft_buttons)) && (!(*message_)[strings::msg_params].keyExists(strings::tts_chunks))) { @@ -127,7 +127,7 @@ void AlertManeuverRequest::Run() { } void AlertManeuverRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "AlertManeuverRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; @@ -206,7 +206,7 @@ void AlertManeuverRequest::on_event(const event_engine::Event& event) { } bool AlertManeuverRequest::IsWhiteSpaceExist() { - LOG4CXX_INFO(logger_, "AlertManeuverRequest::IsWhiteSpaceExist"); + LOG4CXX_AUTO_TRACE(logger_); const char* str = NULL; if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) { diff --git a/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc b/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc index 99fcde69a8..8f9c73267f 100644 --- a/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc +++ b/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc @@ -47,7 +47,7 @@ AlertManeuverResponse::~AlertManeuverResponse() { } void AlertManeuverResponse::Run() { - LOG4CXX_INFO(logger_, "AlertManeuverResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/alert_request.cc b/src/components/application_manager/src/commands/mobile/alert_request.cc index c08b7c32d7..ccabe4e177 100644 --- a/src/components/application_manager/src/commands/mobile/alert_request.cc +++ b/src/components/application_manager/src/commands/mobile/alert_request.cc @@ -84,7 +84,7 @@ bool AlertRequest::Init() { } void AlertRequest::Run() { - LOG4CXX_INFO(logger_, "AlertRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); uint32_t app_id = (*message_)[strings::params][strings::connection_key] .asInt(); @@ -116,7 +116,7 @@ void AlertRequest::onTimeOut() { } void AlertRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "AlertRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { @@ -198,20 +198,12 @@ void AlertRequest::on_event(const event_engine::Event& event) { response_success_ = true; } - // If timeout is not set, watchdog will not track request timeout and - // HMI is responsible for response returning. In this case, if ABORTED will - // be rerurned from HMI, success should be sent to mobile. - if (mobile_apis::Result::ABORTED == response_result_ && - 0 == default_timeout_) { - response_success_ = true; - } - - if (mobile_apis::Result::ABORTED == tts_speak_response_ && + if (((mobile_apis::Result::ABORTED == tts_speak_response_ )|| + (mobile_apis::Result::REJECTED == tts_speak_response_)) && (!flag_other_component_sent_)) { response_success_ = false; response_result_ = tts_speak_response_; } - SendResponse(response_success_, response_result_, response_info.empty() ? NULL : response_info.c_str(), &response_params_); @@ -332,39 +324,38 @@ void AlertRequest::SendAlertRequest(int32_t app_id) { } void AlertRequest::SendSpeakRequest(int32_t app_id) { - + using namespace hmi_apis; + using namespace smart_objects; // crate HMI speak request - smart_objects::SmartObject msg_params = smart_objects::SmartObject( - smart_objects::SmartType_Map); + SmartObject msg_params = smart_objects::SmartObject(SmartType_Map); - msg_params[hmi_request::tts_chunks] = smart_objects::SmartObject( - smart_objects::SmartType_Array); + msg_params[hmi_request::tts_chunks] = smart_objects::SmartObject(SmartType_Array); msg_params[hmi_request::tts_chunks] = (*message_)[strings::msg_params][strings::tts_chunks]; msg_params[strings::app_id] = app_id; - msg_params[hmi_request::speak_type] = - hmi_apis::Common_SpeakType::ALERT; - SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, &msg_params, true); + msg_params[hmi_request::speak_type] = Common_MethodName::ALERT; + SendHMIRequest(FunctionID::TTS_Speak, &msg_params, true); } void AlertRequest::SendPlayToneNotification(int32_t app_id) { - LOG4CXX_INFO(logger_, "AlertRequest::SendPlayToneNotification"); + LOG4CXX_AUTO_TRACE(logger_); + using namespace hmi_apis; + using namespace smart_objects; // check playtone parameter if ((*message_)[strings::msg_params].keyExists(strings::play_tone)) { if ((*message_)[strings::msg_params][strings::play_tone].asBool()) { // crate HMI basic communication playtone request - smart_objects::SmartObject msg_params = smart_objects::SmartObject( - smart_objects::SmartType_Map); - - CreateHMINotification(hmi_apis::FunctionID::BasicCommunication_PlayTone, - msg_params); + SmartObject msg_params = smart_objects::SmartObject(SmartType_Map); + msg_params[strings::app_id] = app_id; + msg_params[strings::method_name] = Common_MethodName::ALERT; + CreateHMINotification(FunctionID::BasicCommunication_PlayTone, msg_params); } } } bool AlertRequest::CheckStringsOfAlertRequest() { - LOG4CXX_INFO(logger_, "AlertRequest::CheckStringsOfAlertRequest"); + LOG4CXX_AUTO_TRACE(logger_); const char* str = NULL; if ((*message_)[strings::msg_params].keyExists(strings::alert_text1)) { diff --git a/src/components/application_manager/src/commands/mobile/alert_response.cc b/src/components/application_manager/src/commands/mobile/alert_response.cc index 5b8cd6557b..dac086a8b1 100644 --- a/src/components/application_manager/src/commands/mobile/alert_response.cc +++ b/src/components/application_manager/src/commands/mobile/alert_response.cc @@ -49,7 +49,7 @@ AlertResponse::~AlertResponse() { } void AlertResponse::Run() { - LOG4CXX_INFO(logger_, "AlertResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/change_registration_request.cc b/src/components/application_manager/src/commands/mobile/change_registration_request.cc index 9780aad7bb..89b2dbaf00 100644 --- a/src/components/application_manager/src/commands/mobile/change_registration_request.cc +++ b/src/components/application_manager/src/commands/mobile/change_registration_request.cc @@ -55,7 +55,7 @@ ChangeRegistrationRequest::~ChangeRegistrationRequest() { } void ChangeRegistrationRequest::Run() { - LOG4CXX_INFO(logger_, "ChangeRegistrationRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl* instance = ApplicationManagerImpl::instance(); const HMICapabilities& hmi_capabilities = instance->hmi_capabilities(); @@ -166,19 +166,19 @@ void ChangeRegistrationRequest::Run() { &tts_params, true); } -bool ChangeRegistrationRequest::WasAnySuccess( +bool ChangeRegistrationRequest::AllHmiResponsesSuccess( const hmi_apis::Common_Result::eType ui, const hmi_apis::Common_Result::eType vr, const hmi_apis::Common_Result::eType tts) { return - hmi_apis::Common_Result::SUCCESS == ui || - hmi_apis::Common_Result::SUCCESS == vr || + hmi_apis::Common_Result::SUCCESS == ui && + hmi_apis::Common_Result::SUCCESS == vr && hmi_apis::Common_Result::SUCCESS == tts; } void ChangeRegistrationRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "ChangeRegistrationRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); hmi_apis::FunctionID::eType event_id = event.id(); @@ -237,7 +237,7 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) { (*message_)[strings::params][strings::function_id] = mobile_apis::FunctionID::eType::ChangeRegistrationID; - SendResponse(WasAnySuccess(ui_result_, vr_result_, tts_result_), + SendResponse(AllHmiResponsesSuccess(ui_result_, vr_result_, tts_result_), static_cast<mobile_apis::Result::eType>(greates_result_code), NULL, &(message[strings::msg_params])); } else { @@ -374,21 +374,20 @@ bool ChangeRegistrationRequest::IsWhiteSpaceExist() { } mobile_apis::Result::eType ChangeRegistrationRequest::CheckCoincidence() { - LOG4CXX_INFO(logger_, "ChangeRegistrationRequest::CheckCoincidence"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; ApplicationManagerImpl::ApplicationListAccessor accessor; - const std::set<ApplicationSharedPtr> applications = accessor.applications(); - std::set<ApplicationSharedPtr>::const_iterator it = applications.begin(); std::string app_name; uint32_t app_id = connection_key(); if (msg_params.keyExists(strings::app_name)) { app_name = msg_params[strings::app_name].asString(); } - for (; applications.end() != it; ++it) { + ApplicationManagerImpl::ApplictionSetConstIt it = accessor.begin(); + for (; accessor.end() != it; ++it) { if (app_id == (*it)->app_id()) { continue; } diff --git a/src/components/application_manager/src/commands/mobile/change_registration_response.cc b/src/components/application_manager/src/commands/mobile/change_registration_response.cc index 13c926ec82..557614f173 100644 --- a/src/components/application_manager/src/commands/mobile/change_registration_response.cc +++ b/src/components/application_manager/src/commands/mobile/change_registration_response.cc @@ -47,7 +47,7 @@ ChangeRegistrationResponse::~ChangeRegistrationResponse() { } void ChangeRegistrationResponse::Run() { - LOG4CXX_INFO(logger_, "ChangeRegistrationResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } 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 583f0a0460..e980068fd7 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 @@ -53,7 +53,7 @@ CreateInteractionChoiceSetRequest::~CreateInteractionChoiceSetRequest() { } void CreateInteractionChoiceSetRequest::Run() { - LOG4CXX_INFO(logger_, "CreateInteractionChoiceSetRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( (*message_)[strings::params][strings::connection_key].asUInt()); @@ -114,7 +114,7 @@ void CreateInteractionChoiceSetRequest::Run() { mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( ApplicationConstSharedPtr app) { - LOG4CXX_INFO(logger_, "CreateInteractionChoiceSetRequest::CheckChoiceSet"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartArray* new_choice_set_array = (*message_)[strings::msg_params][strings::choice_set].asArray(); @@ -141,7 +141,8 @@ mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( } // Check new choice set params along with already registered choice sets - const ChoiceSetMap& app_choice_set_map = app->choice_set_map(); + const DataAccessor<ChoiceSetMap> 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) { @@ -257,7 +258,7 @@ bool CreateInteractionChoiceSetRequest::compareStr( bool CreateInteractionChoiceSetRequest::IsWhiteSpaceExist( const smart_objects::SmartObject& choice_set) { - LOG4CXX_INFO(logger_, "CreateInteractionChoiceSetRequest::IsWhiteSpaceExist"); + LOG4CXX_AUTO_TRACE(logger_); const char* str = NULL; str = choice_set[strings::menu_name].asCharArray(); @@ -316,21 +317,21 @@ bool CreateInteractionChoiceSetRequest::IsWhiteSpaceExist( void CreateInteractionChoiceSetRequest::SendVRAddCommandRequest( application_manager::ApplicationSharedPtr const app) { - smart_objects::SmartObject* choice_set = &(*message_)[strings::msg_params]; + smart_objects::SmartObject& choice_set = (*message_)[strings::msg_params]; - for (size_t j = 0; j < (*choice_set)[strings::choice_set].length(); ++j) { + for (size_t j = 0; j < choice_set[strings::choice_set].length(); ++j) { smart_objects::SmartObject msg_params = smart_objects::SmartObject( smart_objects::SmartType_Map); msg_params[strings::app_id] = app->app_id(); msg_params[strings::cmd_id] = - (*choice_set)[strings::choice_set][j][strings::choice_id]; + choice_set[strings::choice_set][j][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][j][strings::vr_commands]; + choice_set[strings::choice_set][j][strings::vr_commands]; msg_params[strings::type] = hmi_apis::Common_VRCommandType::Choice; - msg_params[strings::grammar_id] = (*choice_set)[strings::grammar_id]; + msg_params[strings::grammar_id] = choice_set[strings::grammar_id]; SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &msg_params); } diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_response.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_response.cc index 8d6ea1b348..bc81206088 100644 --- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_response.cc +++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_response.cc @@ -49,7 +49,7 @@ CreateInteractionChoiceSetResponse::~CreateInteractionChoiceSetResponse() { } void CreateInteractionChoiceSetResponse::Run() { - LOG4CXX_INFO(logger_, "CreateInteractionChoiceSetResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); // check if response false if (true == (*message_)[strings::msg_params].keyExists(strings::success)) { diff --git a/src/components/application_manager/src/commands/mobile/delete_command_request.cc b/src/components/application_manager/src/commands/mobile/delete_command_request.cc index 3c3ee88203..e76422d50e 100644 --- a/src/components/application_manager/src/commands/mobile/delete_command_request.cc +++ b/src/components/application_manager/src/commands/mobile/delete_command_request.cc @@ -55,7 +55,7 @@ DeleteCommandRequest::~DeleteCommandRequest() { } void DeleteCommandRequest::Run() { - LOG4CXX_INFO(logger_, "DeleteCommandRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application( (*message_)[strings::params][strings::connection_key].asUInt()); @@ -109,7 +109,7 @@ void DeleteCommandRequest::Run() { } void DeleteCommandRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "DeleteCommandRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { diff --git a/src/components/application_manager/src/commands/mobile/delete_command_response.cc b/src/components/application_manager/src/commands/mobile/delete_command_response.cc index 812e587430..75178bcb4d 100644 --- a/src/components/application_manager/src/commands/mobile/delete_command_response.cc +++ b/src/components/application_manager/src/commands/mobile/delete_command_response.cc @@ -46,7 +46,7 @@ DeleteCommandResponse::~DeleteCommandResponse() { } void DeleteCommandResponse::Run() { - LOG4CXX_INFO(logger_, "DeleteCommandResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/delete_file_request.cc b/src/components/application_manager/src/commands/mobile/delete_file_request.cc index ca5a4395fc..4c753871ce 100644 --- a/src/components/application_manager/src/commands/mobile/delete_file_request.cc +++ b/src/components/application_manager/src/commands/mobile/delete_file_request.cc @@ -49,7 +49,7 @@ DeleteFileRequest::~DeleteFileRequest() { } void DeleteFileRequest::Run() { - LOG4CXX_INFO(logger_, "DeleteFileRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(connection_key()); diff --git a/src/components/application_manager/src/commands/mobile/delete_file_response.cc b/src/components/application_manager/src/commands/mobile/delete_file_response.cc index 81470ccf6b..1bbb18313f 100644 --- a/src/components/application_manager/src/commands/mobile/delete_file_response.cc +++ b/src/components/application_manager/src/commands/mobile/delete_file_response.cc @@ -47,7 +47,7 @@ DeleteFileResponse::~DeleteFileResponse() { } void DeleteFileResponse::Run() { - LOG4CXX_INFO(logger_, "DeleteFileResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); uint32_t app_id = (*message_)[strings::params][strings::connection_key] .asUInt(); ApplicationSharedPtr app = diff --git a/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc index 1fcd4b33d8..6c61bfd2a2 100644 --- a/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc +++ b/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc @@ -50,7 +50,7 @@ DeleteInteractionChoiceSetRequest::~DeleteInteractionChoiceSetRequest() { } void DeleteInteractionChoiceSetRequest::Run() { - LOG4CXX_INFO(logger_, "DeleteInteractionChoiceSetRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( (*message_)[strings::params][strings::connection_key].asUInt()); @@ -94,8 +94,9 @@ void DeleteInteractionChoiceSetRequest::Run() { bool DeleteInteractionChoiceSetRequest::ChoiceSetInUse(ApplicationConstSharedPtr app) { if (app->is_perform_interaction_active()) { // retrieve stored choice sets for perform interaction - const PerformChoiceSetMap& choice_set_map = app - ->performinteraction_choice_set_map(); + const DataAccessor<PerformChoiceSetMap> accessor = + app->performinteraction_choice_set_map(); + const PerformChoiceSetMap& choice_set_map = accessor.GetData(); PerformChoiceSetMap::const_iterator it = choice_set_map.begin(); for (; choice_set_map.end() != it; ++it) { diff --git a/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_response.cc b/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_response.cc index d260add7cc..f9ee513b94 100644 --- a/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_response.cc +++ b/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_response.cc @@ -50,7 +50,7 @@ DeleteInteractionChoiceSetResponse::~DeleteInteractionChoiceSetResponse() { } void DeleteInteractionChoiceSetResponse::Run() { - LOG4CXX_INFO(logger_, "DeleteInteractionChoiceSetResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); // check if response false if (true == (*message_)[strings::msg_params].keyExists(strings::success)) { diff --git a/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc b/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc index d91e742687..6b6bd3fbda 100644 --- a/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc +++ b/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc @@ -48,7 +48,7 @@ DeleteSubMenuRequest::~DeleteSubMenuRequest() { } void DeleteSubMenuRequest::Run() { - LOG4CXX_INFO(logger_, "DeleteSubMenuRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( (*message_)[strings::params][strings::connection_key].asUInt()); @@ -77,9 +77,10 @@ void DeleteSubMenuRequest::Run() { } void DeleteSubMenuRequest::DeleteSubMenuVRCommands(ApplicationConstSharedPtr app) { - LOG4CXX_INFO(logger_, "DeleteSubMenuRequest::DeleteSubMenuVRCommands"); + LOG4CXX_AUTO_TRACE(logger_); - const CommandsMap& commands = app->commands_map(); + const DataAccessor<CommandsMap> accessor = app->commands_map(); + const CommandsMap& commands = accessor.GetData(); CommandsMap::const_iterator it = commands.begin(); for (; commands.end() != it; ++it) { @@ -104,14 +105,16 @@ void DeleteSubMenuRequest::DeleteSubMenuVRCommands(ApplicationConstSharedPtr app } void DeleteSubMenuRequest::DeleteSubMenuUICommands(ApplicationSharedPtr const app) { - LOG4CXX_INFO(logger_, "DeleteSubMenuRequest::DeleteSubMenuUICommands"); + LOG4CXX_AUTO_TRACE(logger_); - const CommandsMap& commands = app->commands_map(); + const DataAccessor<CommandsMap> accessor(app->commands_map()); + const CommandsMap& commands = accessor.GetData(); CommandsMap::const_iterator it = commands.begin(); while (commands.end() != it) { - if (!(*it->second).keyExists(strings::menu_params)) { + LOG4CXX_ERROR(logger_, "menu_params not exist"); + ++it; continue; } @@ -122,9 +125,7 @@ void DeleteSubMenuRequest::DeleteSubMenuUICommands(ApplicationSharedPtr const ap smart_objects::SmartType_Map); msg_params[strings::app_id] = app->app_id(); msg_params[strings::cmd_id] = (*it->second)[strings::cmd_id].asInt(); - app->RemoveCommand((*it->second)[strings::cmd_id].asInt()); - it = commands.begin(); // Can not relay on // iterators after erase was called @@ -136,7 +137,7 @@ void DeleteSubMenuRequest::DeleteSubMenuUICommands(ApplicationSharedPtr const ap } void DeleteSubMenuRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "DeleteSubMenuRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { diff --git a/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc b/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc index 0a25a11610..05795e5908 100644 --- a/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc +++ b/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc @@ -46,7 +46,7 @@ DeleteSubMenuResponse::~DeleteSubMenuResponse() { } void DeleteSubMenuResponse::Run() { - LOG4CXX_INFO(logger_, "DeleteSubMenuResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); diff --git a/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc b/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc index 75016c05fb..7b5cf5fd9a 100644 --- a/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc +++ b/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc @@ -48,7 +48,7 @@ DiagnosticMessageRequest::~DiagnosticMessageRequest() { } void DiagnosticMessageRequest::Run() { - LOG4CXX_INFO(logger_, "DiagnosticMessageRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( connection_key()); @@ -68,7 +68,7 @@ void DiagnosticMessageRequest::Run() { } void DiagnosticMessageRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "DiagnosticMessageRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { diff --git a/src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc b/src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc index 2a8b234fff..9c399a00c8 100644 --- a/src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc +++ b/src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc @@ -46,7 +46,7 @@ DiagnosticMessageResponse::~DiagnosticMessageResponse() { } void DiagnosticMessageResponse::Run() { - LOG4CXX_INFO(logger_, "DiagnosticMessageResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/dial_number_request.cc b/src/components/application_manager/src/commands/mobile/dial_number_request.cc index 140f43128d..749b19a520 100644 --- a/src/components/application_manager/src/commands/mobile/dial_number_request.cc +++ b/src/components/application_manager/src/commands/mobile/dial_number_request.cc @@ -47,7 +47,7 @@ DialNumberRequest::~DialNumberRequest() { } void DialNumberRequest::Run() { - LOG4CXX_INFO(logger_, "DialNumberRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); SendResponse(false, mobile_apis::Result::UNSUPPORTED_REQUEST); } diff --git a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc index eedc9f813e..78a867a6d8 100644 --- a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc +++ b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc @@ -47,13 +47,13 @@ EndAudioPassThruRequest::~EndAudioPassThruRequest() { } void EndAudioPassThruRequest::Run() { - LOG4CXX_INFO(logger_, "EndAudioPassThruRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); SendHMIRequest(hmi_apis::FunctionID::UI_EndAudioPassThru, NULL, true); } void EndAudioPassThruRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "EndAudioPassThruRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { diff --git a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc index 128d921f9f..0ac1a00bd4 100644 --- a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc +++ b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc @@ -47,7 +47,7 @@ EndAudioPassThruResponse::~EndAudioPassThruResponse() { } void EndAudioPassThruResponse::Run() { - LOG4CXX_INFO(logger_, "EndAudioPassThruResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc b/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc index 9a81f94db1..8e2a0222f7 100644 --- a/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc +++ b/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc @@ -48,7 +48,7 @@ GetDTCsRequest::~GetDTCsRequest() { } void GetDTCsRequest::Run() { - LOG4CXX_INFO(logger_, "GetDTCsRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( (*message_)[strings::params][strings::connection_key].asUInt()); @@ -82,7 +82,7 @@ void GetDTCsRequest::Run() { } void GetDTCsRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "GetDTCsRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { diff --git a/src/components/application_manager/src/commands/mobile/get_dtcs_response.cc b/src/components/application_manager/src/commands/mobile/get_dtcs_response.cc index 2ed7a92952..523711c975 100644 --- a/src/components/application_manager/src/commands/mobile/get_dtcs_response.cc +++ b/src/components/application_manager/src/commands/mobile/get_dtcs_response.cc @@ -46,7 +46,7 @@ GetDTCsResponse::~GetDTCsResponse() { } void GetDTCsResponse::Run() { - LOG4CXX_INFO(logger_, "GetDTCsResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc index a3d08a15ff..546b14853c 100644 --- a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc +++ b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc @@ -54,7 +54,7 @@ GetVehicleDataRequest::~GetVehicleDataRequest() { } void GetVehicleDataRequest::Run() { - LOG4CXX_INFO(logger_, "GetVehicleDataRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); int32_t app_id = (*message_)[strings::params][strings::connection_key].asUInt(); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); @@ -213,7 +213,7 @@ GetVehicleDataRequest::~GetVehicleDataRequest() { } void GetVehicleDataRequest::Run() { - LOG4CXX_INFO(logger_, "GetVehicleDataRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); int32_t app_id = (*message_)[strings::params][strings::connection_key].asUInt(); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); @@ -260,7 +260,7 @@ void GetVehicleDataRequest::Run() { } void GetVehicleDataRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "GetVehicleDataRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject message = event.smart_object(); switch (event.id()) { diff --git a/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc b/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc index d9087fdc61..5491e9b1aa 100644 --- a/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc +++ b/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc @@ -47,7 +47,7 @@ GetVehicleDataResponse::~GetVehicleDataResponse() { } void GetVehicleDataResponse::Run() { - LOG4CXX_INFO(logger_, "GetVehicleDataResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/list_files_request.cc b/src/components/application_manager/src/commands/mobile/list_files_request.cc index d0fa71d466..427443e3e9 100644 --- a/src/components/application_manager/src/commands/mobile/list_files_request.cc +++ b/src/components/application_manager/src/commands/mobile/list_files_request.cc @@ -50,7 +50,7 @@ ListFilesRequest::~ListFilesRequest() { } void ListFilesRequest::Run() { - LOG4CXX_INFO(logger_, "ListFilesRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(connection_key()); diff --git a/src/components/application_manager/src/commands/mobile/list_files_response.cc b/src/components/application_manager/src/commands/mobile/list_files_response.cc index 6ffbec1ac4..42bd1e6f07 100644 --- a/src/components/application_manager/src/commands/mobile/list_files_response.cc +++ b/src/components/application_manager/src/commands/mobile/list_files_response.cc @@ -47,7 +47,7 @@ ListFilesResponse::~ListFilesResponse() { } void ListFilesResponse::Run() { - LOG4CXX_INFO(logger_, "ListFilesResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc b/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc index ebd0d6aac1..e3e51faa6e 100644 --- a/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc @@ -47,7 +47,7 @@ OnAppInterfaceUnregisteredNotification::~OnAppInterfaceUnregisteredNotification( } void OnAppInterfaceUnregisteredNotification::Run() { - LOG4CXX_INFO(logger_, "OnAppInterfaceUnregisteredNotification::Run"); + LOG4CXX_AUTO_TRACE(logger_); SendNotification(); } diff --git a/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc b/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc index 2515f591b1..d1329bf8ea 100644 --- a/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc @@ -45,7 +45,7 @@ OnAudioPassThruNotification::~OnAudioPassThruNotification() { } void OnAudioPassThruNotification::Run() { - LOG4CXX_INFO(logger_, "OnAudioPassThruNotification::Run"); + LOG4CXX_AUTO_TRACE(logger_); SendNotification(); } diff --git a/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc b/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc index 55b9b8818d..62cf11d76d 100644 --- a/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc @@ -51,7 +51,7 @@ OnButtonEventNotification::~OnButtonEventNotification() { } void OnButtonEventNotification::Run() { - LOG4CXX_INFO(logger_, "OnButtonEventNotification::Run"); + LOG4CXX_AUTO_TRACE(logger_); const uint32_t btn_id = static_cast<uint32_t>( @@ -124,18 +124,19 @@ void OnButtonEventNotification::Run() { } void OnButtonEventNotification::SendButtonEvent(ApplicationConstSharedPtr app) { - smart_objects::SmartObject* on_btn_event = new smart_objects::SmartObject(); - - if (!on_btn_event) { + if (!app) { LOG4CXX_ERROR_EXT(logger_, "OnButtonEvent NULL pointer"); return; } - if (!app) { + smart_objects::SmartObjectSPtr on_btn_event = new smart_objects::SmartObject(); + + if (!on_btn_event) { LOG4CXX_ERROR_EXT(logger_, "OnButtonEvent NULL pointer"); return; } + (*on_btn_event)[strings::params][strings::connection_key] = app->app_id(); (*on_btn_event)[strings::params][strings::function_id] = @@ -152,7 +153,7 @@ void OnButtonEventNotification::SendButtonEvent(ApplicationConstSharedPtr app) { (*message_)[strings::msg_params][strings::custom_button_id]; } - message_.reset(on_btn_event); + message_ = on_btn_event; SendNotification(); } diff --git a/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc b/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc index cfafc7af1c..86fe664f86 100644 --- a/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc @@ -51,7 +51,7 @@ OnButtonPressNotification::~OnButtonPressNotification() { } void OnButtonPressNotification::Run() { - LOG4CXX_INFO(logger_, "OnButtonPressNotification::Run"); + LOG4CXX_AUTO_TRACE(logger_); const uint32_t btn_id = static_cast<uint32_t>( @@ -124,18 +124,19 @@ void OnButtonPressNotification::Run() { } void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) { - smart_objects::SmartObject* on_btn_press = new smart_objects::SmartObject(); - - if (!on_btn_press) { + if (!app) { LOG4CXX_ERROR_EXT(logger_, "OnButtonPress NULL pointer"); return; } - if (!app) { + smart_objects::SmartObjectSPtr on_btn_press = new smart_objects::SmartObject(); + + if (!on_btn_press) { LOG4CXX_ERROR_EXT(logger_, "OnButtonPress NULL pointer"); return; } + (*on_btn_press)[strings::params][strings::connection_key] = app->app_id(); (*on_btn_press)[strings::params][strings::function_id] = @@ -152,7 +153,7 @@ void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) { (*message_)[strings::msg_params][strings::custom_button_id]; } - message_.reset(on_btn_press); + message_ = on_btn_press; SendNotification(); } diff --git a/src/components/application_manager/src/commands/mobile/on_command_notification.cc b/src/components/application_manager/src/commands/mobile/on_command_notification.cc index 8342d05a45..9bba1851f6 100644 --- a/src/components/application_manager/src/commands/mobile/on_command_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_command_notification.cc @@ -47,7 +47,7 @@ OnCommandNotification::~OnCommandNotification() { } void OnCommandNotification::Run() { - LOG4CXX_INFO(logger_, "OnCommandNotification::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( (*message_)[strings::msg_params][strings::app_id].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/on_driver_distraction_notification.cc b/src/components/application_manager/src/commands/mobile/on_driver_distraction_notification.cc index fc92c17e94..e9145520f4 100644 --- a/src/components/application_manager/src/commands/mobile/on_driver_distraction_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_driver_distraction_notification.cc @@ -51,7 +51,7 @@ OnDriverDistractionNotification::~OnDriverDistractionNotification() { } void OnDriverDistractionNotification::Run() { - LOG4CXX_INFO(logger_, "OnDriverDistractionNotification::Run"); + LOG4CXX_AUTO_TRACE(logger_); SendNotification(); } diff --git a/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc b/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc index b9ee1339bb..10f3eb1ab6 100644 --- a/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc @@ -37,7 +37,6 @@ #include "application_manager/application_impl.h" #include "interfaces/MOBILE_API.h" #include <string> -#include <sstream> namespace application_manager { @@ -54,7 +53,7 @@ OnHashChangeNotification::~OnHashChangeNotification() { } void OnHashChangeNotification::Run() { - LOG4CXX_INFO(logger_, "OnHashChangeNotification::Run"); + LOG4CXX_AUTO_TRACE(logger_); (*message_)[strings::params][strings::message_type] = static_cast<int32_t>(application_manager::MessageType::kNotification); @@ -62,10 +61,13 @@ void OnHashChangeNotification::Run() { int32_t app_id; app_id = (*message_)[strings::params][strings::connection_key].asInt(); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); - std::stringstream stream; - stream << app->curHash(); - (*message_)[strings::msg_params][strings::hash_id] = stream.str(); - SendNotification(); + if (app) { + (*message_)[strings::msg_params][strings::hash_id] = app->curHash(); + SendNotification(); + } else { + LOG4CXX_WARN(logger_, "Application with app_id " << app_id << " does not exist"); + } + } } //namespace mobile diff --git a/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc b/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc index 9c03c0f623..e4a2d7c340 100644 --- a/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc @@ -49,16 +49,17 @@ OnHMIStatusNotification::~OnHMIStatusNotification() { } void OnHMIStatusNotification::Run() { - LOG4CXX_INFO(logger_, "OnHMIStatusNotification::Run"); + LOG4CXX_AUTO_TRACE(logger_); (*message_)[strings::params][strings::message_type] = static_cast<int32_t> ( application_manager::MessageType::kNotification); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( - (*message_)[strings::params][strings::connection_key].asUInt()); + connection_key()); if (!app.valid()) { LOG4CXX_ERROR(logger_, "OnHMIStatusNotification application doesn't exist"); return; } + mobile_apis::HMILevel::eType hmi_level = static_cast<mobile_apis::HMILevel::eType>( (*message_)[strings::msg_params][strings::hmi_level].asInt()); @@ -74,7 +75,8 @@ void OnHMIStatusNotification::Run() { (mobile_apis::HMILevel::HMI_LIMITED == hmi_level)) { if (!(app->tts_properties_in_full())) { app->set_tts_properties_in_full(true); - LOG4CXX_INFO(logger_, "OnHMIStatusNotification AddAppToTTSGlobalPropertiesList"); + LOG4CXX_INFO(logger_, + "OnHMIStatusNotification AddAppToTTSGlobalPropertiesList"); ApplicationManagerImpl::instance()->AddAppToTTSGlobalPropertiesList( app->app_id()); } diff --git a/src/components/application_manager/src/commands/mobile/on_hmi_status_notification_from_mobile.cc b/src/components/application_manager/src/commands/mobile/on_hmi_status_notification_from_mobile.cc new file mode 100644 index 0000000000..443175a5ee --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/on_hmi_status_notification_from_mobile.cc @@ -0,0 +1,81 @@ +/* + + Copyright (c) 2013, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/commands/mobile/on_hmi_status_notification_from_mobile.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/message_helper.h" +#include "application_manager/message.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { +namespace commands { + +bool OnHMIStatusNotificationFromMobile::is_apps_requested_ = false; + +OnHMIStatusNotificationFromMobile::OnHMIStatusNotificationFromMobile( + const MessageSharedPtr& message) + : CommandNotificationFromMobileImpl(message) { +} + +OnHMIStatusNotificationFromMobile::~OnHMIStatusNotificationFromMobile() { +} + +void OnHMIStatusNotificationFromMobile::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + (*message_)[strings::params][strings::message_type] = static_cast<int32_t> ( + application_manager::MessageType::kNotification); + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + connection_key()); + if (!app.valid()) { + LOG4CXX_ERROR(logger_, + "OnHMIStatusNotificationFromMobile application doesn't exist"); + return; + } + + // In case if this notification will be received from mobile side, it will + // mean, that app is in foreground on mobile. This should trigger remote + // apps list query for SDL 4.0 app + if (is_apps_requested_) { + LOG4CXX_DEBUG(logger_, "Remote apps list had been requested already."); + return; + } + if (ProtocolVersion::kV4 == app->protocol_version()) { + MessageHelper::SendQueryApps(connection_key()); + is_apps_requested_ = true; + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc b/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc index 969885ab16..b8c6d6f114 100644 --- a/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc @@ -51,7 +51,7 @@ OnKeyBoardInputNotification::~OnKeyBoardInputNotification() { } void OnKeyBoardInputNotification::Run() { - LOG4CXX_INFO(logger_, "OnKeyBoardInputNotification::Run"); + LOG4CXX_AUTO_TRACE(logger_); const std::vector<ApplicationSharedPtr>& applications = ApplicationManagerImpl::instance()->applications_with_navi(); diff --git a/src/components/application_manager/src/commands/mobile/on_language_change_notification.cc b/src/components/application_manager/src/commands/mobile/on_language_change_notification.cc index f550df8748..43b1b5b921 100644 --- a/src/components/application_manager/src/commands/mobile/on_language_change_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_language_change_notification.cc @@ -46,7 +46,7 @@ OnLanguageChangeNotification::~OnLanguageChangeNotification() { } void OnLanguageChangeNotification::Run() { - LOG4CXX_INFO(logger_, "OnLanguageChangeNotification::Run"); + LOG4CXX_AUTO_TRACE(logger_); SendNotification(); } diff --git a/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc b/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc index 37c81085eb..62ea1af1fc 100644 --- a/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc @@ -48,7 +48,7 @@ OnPermissionsChangeNotification::~OnPermissionsChangeNotification() { } void OnPermissionsChangeNotification::Run() { - LOG4CXX_INFO(logger_, "OnPermissionsChangeNotification::Run"); + LOG4CXX_AUTO_TRACE(logger_); (*message_)[strings::params][strings::message_type] = static_cast<int32_t>(application_manager::MessageType::kNotification); diff --git a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc index ebf98cd7e8..7e5c381bef 100644 --- a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc @@ -50,7 +50,7 @@ OnSystemRequestNotification::~OnSystemRequestNotification() { } void OnSystemRequestNotification::Run() { - LOG4CXX_INFO(logger_, "OnSystemRequestNotification::Run"); + LOG4CXX_AUTO_TRACE(logger_); mobile_apis::RequestType::eType request_type = static_cast<mobile_apis::RequestType::eType> ((*message_)[strings::msg_params][strings::request_type].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/on_tbt_client_state_notification.cc b/src/components/application_manager/src/commands/mobile/on_tbt_client_state_notification.cc index 05494c6144..99a5d665db 100644 --- a/src/components/application_manager/src/commands/mobile/on_tbt_client_state_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_tbt_client_state_notification.cc @@ -49,7 +49,7 @@ OnTBTClientStateNotification::~OnTBTClientStateNotification() { } void OnTBTClientStateNotification::Run() { - LOG4CXX_INFO(logger_, "OnTBTClientStateNotification::Run"); + LOG4CXX_AUTO_TRACE(logger_); (*message_)[strings::params][strings::message_type] = static_cast<int32_t>(application_manager::MessageType::kNotification); diff --git a/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc b/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc index 250faa8f38..6db54289eb 100644 --- a/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc @@ -50,7 +50,7 @@ OnTouchEventNotification::~OnTouchEventNotification() { } void OnTouchEventNotification::Run() { - LOG4CXX_INFO(logger_, "OnTouchEventNotification::Run"); + LOG4CXX_AUTO_TRACE(logger_); const std::vector<ApplicationSharedPtr>& applications = ApplicationManagerImpl::instance()->applications_with_navi(); diff --git a/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc b/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc index 420c42f30c..044bb16b40 100644 --- a/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc @@ -50,7 +50,7 @@ OnVehicleDataNotification::~OnVehicleDataNotification() { } void OnVehicleDataNotification::Run() { - LOG4CXX_INFO(logger_, "OnVehicleDataNotification::Run"); + LOG4CXX_AUTO_TRACE(logger_); const VehicleData& vehicle_data = MessageHelper::vehicle_data(); VehicleData::const_iterator it = vehicle_data.begin(); diff --git a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc index a730995f5d..b3d57d6be0 100644 --- a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc +++ b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc @@ -55,7 +55,7 @@ PerformAudioPassThruRequest::~PerformAudioPassThruRequest() { } void PerformAudioPassThruRequest::onTimeOut() { - LOG4CXX_INFO(logger_, "PerformAudioPassThruRequest::onTimeOut"); + LOG4CXX_AUTO_TRACE(logger_); if (ApplicationManagerImpl::instance()->end_audio_pass_thru()) { ApplicationManagerImpl::instance()->StopAudioPassThru(connection_key()); @@ -73,7 +73,7 @@ bool PerformAudioPassThruRequest::Init() { } void PerformAudioPassThruRequest::Run() { - LOG4CXX_INFO(logger_, "PerformAudioPassThruRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(connection_key()); @@ -111,7 +111,7 @@ void PerformAudioPassThruRequest::Run() { } void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "PerformAudioPassThruRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { @@ -177,8 +177,10 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) { void PerformAudioPassThruRequest::SendSpeakRequest() { // crate HMI TTS speak request - smart_objects::SmartObject msg_params = smart_objects::SmartObject( - smart_objects::SmartType_Map); + using namespace hmi_apis; + using namespace smart_objects; + + SmartObject msg_params = smart_objects::SmartObject(SmartType_Map); if ((*message_)[str::msg_params].keyExists(str::initial_prompt) && (0 < (*message_)[str::msg_params][str::initial_prompt].length())) { @@ -192,8 +194,9 @@ void PerformAudioPassThruRequest::SendSpeakRequest() { } // app_id msg_params[strings::app_id] = connection_key(); + msg_params[hmi_request::speak_type] = Common_MethodName::AUDIO_PASS_THRU; is_active_tts_speak_ = true; - SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, &msg_params, true); + SendHMIRequest(FunctionID::TTS_Speak, &msg_params, true); } } @@ -260,7 +263,7 @@ void PerformAudioPassThruRequest::StartMicrophoneRecording() { } bool PerformAudioPassThruRequest::IsWhiteSpaceExist() { - LOG4CXX_INFO(logger_, "PerformAudioPassThruRequest::IsWhiteSpaceExist"); + LOG4CXX_AUTO_TRACE(logger_); const char* str = NULL; if ((*message_)[strings::msg_params].keyExists(strings::initial_prompt)) { diff --git a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc index a10eaac9f3..585383889d 100644 --- a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc +++ b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc @@ -48,7 +48,7 @@ PerformAudioPassThruResponse::~PerformAudioPassThruResponse() { } void PerformAudioPassThruResponse::Run() { - LOG4CXX_INFO(logger_, "PerformAudioPassThruResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc index 12514626a6..949fcab015 100644 --- a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc +++ b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc @@ -49,11 +49,11 @@ namespace commands { PerformInteractionRequest::PerformInteractionRequest( const MessageSharedPtr& message) : CommandRequestImpl(message), - timer_("PerformInteractionReq", this, &PerformInteractionRequest::onTimer), vr_perform_interaction_code_(mobile_apis::Result::INVALID_ENUM), interaction_mode_(mobile_apis::InteractionMode::INVALID_ENUM), - ui_response_recived(false), - vr_response_recived(false) { + ui_response_recived_(false), + vr_response_recived_(false), + app_pi_was_active_before_(false) { subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); subscribe_on_event(hmi_apis::FunctionID::VR_OnCommand); @@ -63,10 +63,6 @@ PerformInteractionRequest::PerformInteractionRequest( PerformInteractionRequest::~PerformInteractionRequest() { } -void PerformInteractionRequest::onTimer() { - LOG4CXX_INFO(logger_, "PerformInteractionRequest::onTimer"); -} - bool PerformInteractionRequest::Init() { /* Timeout in milliseconds. @@ -75,19 +71,19 @@ bool PerformInteractionRequest::Init() { default_timeout_ = (*message_)[strings::msg_params][strings::timeout].asUInt(); } - mobile_apis::InteractionMode::eType mode = - static_cast<mobile_apis::InteractionMode::eType>( + + interaction_mode_ = static_cast<mobile_apis::InteractionMode::eType>( (*message_)[strings::msg_params][strings::interaction_mode].asInt()); - if (mobile_apis::InteractionMode::BOTH == mode || - mobile_apis::InteractionMode::MANUAL_ONLY == mode) { - default_timeout_ *= 2; - } + if (mobile_apis::InteractionMode::BOTH == interaction_mode_ || + mobile_apis::InteractionMode::MANUAL_ONLY == interaction_mode_) { + default_timeout_ *= 2; + } return true; } void PerformInteractionRequest::Run() { - LOG4CXX_INFO(logger_, "PerformInteractionRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(connection_key()); @@ -98,52 +94,51 @@ void PerformInteractionRequest::Run() { return; } + if (app->is_perform_interaction_active()) { + LOG4CXX_INFO(logger_, "Application has active PerformInteraction"); + app_pi_was_active_before_ = true; + } + + smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; mobile_apis::LayoutMode::eType interaction_layout = mobile_apis::LayoutMode::INVALID_ENUM; - if ((*message_)[strings::msg_params].keyExists( - hmi_request::interaction_layout)) { + + if (msg_params.keyExists(hmi_request::interaction_layout)) { interaction_layout = static_cast<mobile_apis::LayoutMode::eType>( - (*message_)[strings::msg_params][hmi_request::interaction_layout].asInt()); + msg_params[hmi_request::interaction_layout].asInt()); } - if ((mobile_apis::InteractionMode::VR_ONLY == - static_cast<mobile_apis::InteractionMode::eType>( - (*message_)[strings::msg_params][strings::interaction_mode].asInt())) && + if ((mobile_apis::InteractionMode::VR_ONLY == interaction_mode_) && (mobile_apis::LayoutMode::KEYBOARD == interaction_layout)) { - LOG4CXX_ERROR_EXT( - logger_, - "PerformInteraction contains InteractionMode = VR_ONLY and " - "interactionLayout=KEYBOARD"); + LOG4CXX_ERROR_EXT(logger_, "PerformInteraction contains InteractionMode" + "=VR_ONLY and interactionLayout=KEYBOARD"); SendResponse(false, mobile_apis::Result::INVALID_DATA); return; } - if ((0 == (*message_) - [strings::msg_params][strings::interaction_choice_set_id_list].length()) && - (mobile_apis::InteractionMode::BOTH == - static_cast<mobile_apis::InteractionMode::eType>( - (*message_)[strings::msg_params][strings::interaction_mode].asInt()))) { - LOG4CXX_ERROR_EXT( - logger_, - "interactionChoiceSetIDList is empty and InteractionMode=BOTH"); - SendResponse(false, mobile_apis::Result::INVALID_DATA); - return; - } + const size_t choice_set_id_list_length = + msg_params[strings::interaction_choice_set_id_list].length(); - if ((0 == (*message_) - [strings::msg_params][strings::interaction_choice_set_id_list].length()) && - (mobile_apis::LayoutMode::KEYBOARD != interaction_layout)) { - LOG4CXX_ERROR_EXT( - logger_, - "interactionChoiceSetIDList is empty and without parameter" - "interactionLayout=KEYBOARD"); - SendResponse(false, mobile_apis::Result::INVALID_DATA); - return; + if (0 == choice_set_id_list_length) { + if (mobile_apis::LayoutMode::KEYBOARD == interaction_layout) { + if (mobile_apis::InteractionMode::BOTH == interaction_mode_) { + LOG4CXX_ERROR_EXT(logger_,"interactionChoiceSetIDList is empty," + " InteractionMode=BOTH and" + " interactionLayout=KEYBOARD"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } else { + LOG4CXX_ERROR_EXT(logger_,"interactionChoiceSetIDList is empty" + " and interactionLayout!=KEYBOARD"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } } - if ((*message_)[strings::msg_params].keyExists(strings::vr_help)) { + if (msg_params.keyExists(strings::vr_help)) { if (mobile_apis::Result::SUCCESS != MessageHelper::VerifyImageVrHelpItems( - (*message_)[strings::msg_params][strings::vr_help], app)) { + msg_params[strings::vr_help], app)) { LOG4CXX_ERROR_EXT( logger_, "MessageHelper::VerifyImageVrHelpItems return INVALID_DATA!"); @@ -153,7 +148,7 @@ void PerformInteractionRequest::Run() { } smart_objects::SmartObject& choice_list = - (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; + msg_params[strings::interaction_choice_set_id_list]; for (size_t i = 0; i < choice_list.length(); ++i) { if (!app->FindChoiceSet(choice_list[i].asInt())) { @@ -170,67 +165,31 @@ void PerformInteractionRequest::Run() { return; } - int32_t mode = - (*message_)[strings::msg_params][strings::interaction_mode].asInt(); - - app->set_perform_interaction_mode(mode); - - interaction_mode_ = static_cast<mobile_apis::InteractionMode::eType>(mode); - switch (interaction_mode_) { case mobile_apis::InteractionMode::BOTH: { LOG4CXX_INFO(logger_, "Interaction Mode: BOTH"); - if (!CheckChoiceSetVRSynonyms(app)) { - return; - } - - if (!CheckChoiceSetMenuNames(app)) { + if (!CheckChoiceSetVRSynonyms(app) || + !CheckChoiceSetMenuNames(app) || + !CheckVrHelpItemPositions(app)) { return; } - - if (!CheckVrHelpItemPositions(app)) { - return; - } - - app->set_perform_interaction_active(correlation_id()); - SendVRPerformInteractionRequest(app); - SendUIPerformInteractionRequest(app); break; } case mobile_apis::InteractionMode::MANUAL_ONLY: { LOG4CXX_INFO(logger_, "Interaction Mode: MANUAL_ONLY"); - - if (!CheckChoiceSetVRSynonyms(app)) { - return; - } - - if (!CheckChoiceSetMenuNames(app)) { - return; - } - - if (!CheckVrHelpItemPositions(app)) { + if (!CheckChoiceSetVRSynonyms(app) || + !CheckChoiceSetMenuNames(app) || + !CheckVrHelpItemPositions(app)) { return; } - - app->set_perform_interaction_active(correlation_id()); - SendVRPerformInteractionRequest(app); - SendUIPerformInteractionRequest(app); break; } case mobile_apis::InteractionMode::VR_ONLY: { LOG4CXX_INFO(logger_, "Interaction Mode: VR_ONLY"); - if (!CheckChoiceSetVRSynonyms(app)) { - return; - } - - if (!CheckVrHelpItemPositions(app)) { + if (!CheckChoiceSetVRSynonyms(app) || + !CheckVrHelpItemPositions(app)) { return; } - - // TODO(DK): need to implement timeout - app->set_perform_interaction_active(correlation_id()); - SendVRPerformInteractionRequest(app); - SendUIPerformInteractionRequest(app); break; } default: { @@ -239,27 +198,32 @@ void PerformInteractionRequest::Run() { } } - // TODO(DK): need to implement timeout TTS speak request. + app->set_perform_interaction_mode(static_cast<int32_t>(interaction_mode_)); + app->set_perform_interaction_active(true); + SendVRPerformInteractionRequest(app); + SendUIPerformInteractionRequest(app); } void PerformInteractionRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "PerformInteractionRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); switch (event.id()) { case hmi_apis::FunctionID::UI_OnResetTimeout: { LOG4CXX_INFO(logger_, "Received UI_OnResetTimeout event"); ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(), - correlation_id(), - default_timeout()); + correlation_id(), + default_timeout()); break; } case hmi_apis::FunctionID::UI_PerformInteraction: { LOG4CXX_INFO(logger_, "Received UI_PerformInteraction event"); + ui_response_recived_ = true; ProcessPerformInteractionResponse(event.smart_object()); break; } case hmi_apis::FunctionID::VR_PerformInteraction: { - LOG4CXX_INFO(logger_, "Received TTS_PerformInteraction"); + LOG4CXX_INFO(logger_, "Received VR_PerformInteraction"); + vr_response_recived_ = true; ProcessVRResponse(event.smart_object()); break; } @@ -271,11 +235,11 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) { } void PerformInteractionRequest::onTimeOut() { - LOG4CXX_INFO(logger_, "PerformInteractionRequest::onTimeOut"); + LOG4CXX_AUTO_TRACE(logger_); switch (interaction_mode_) { case mobile_apis::InteractionMode::BOTH: { - if (true == vr_response_recived) { + if (true == vr_response_recived_) { unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction); DisablePerformInteraction(); CommandRequestImpl::onTimeOut(); @@ -308,37 +272,56 @@ void PerformInteractionRequest::onTimeOut() { void PerformInteractionRequest::ProcessVRResponse( const smart_objects::SmartObject& message) { - LOG4CXX_INFO(logger_, "PerformInteractionRequest::ProcessVRResponse"); - const uint32_t app_id = connection_key(); - ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); + LOG4CXX_AUTO_TRACE(logger_); + using namespace mobile_apis; + using namespace mobile_apis::Result; + using namespace smart_objects; + + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->application(connection_key()); + if (!app.get()) { LOG4CXX_ERROR(logger_, "NULL pointer"); return; } - vr_response_recived = true; - vr_perform_interaction_code_ = static_cast<mobile_apis::Result::eType>( + vr_perform_interaction_code_ = static_cast<eType>( message[strings::params][hmi_response::code].asInt()); - if (mobile_apis::Result::ABORTED == vr_perform_interaction_code_ || - mobile_apis::Result::TIMED_OUT == vr_perform_interaction_code_) { + if (ABORTED == vr_perform_interaction_code_ || + TIMED_OUT == vr_perform_interaction_code_) { LOG4CXX_INFO(logger_, "VR response aborted"); - if (mobile_apis::InteractionMode::VR_ONLY == interaction_mode_) { + if (InteractionMode::VR_ONLY == interaction_mode_) { LOG4CXX_INFO(logger_, "Aborted or Timeout Send Close Popup"); TerminatePerformInteraction(); SendResponse(false, vr_perform_interaction_code_); return; } else { LOG4CXX_INFO(logger_, "Update timeout for UI"); - ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(), - correlation_id(), - default_timeout()); + ApplicationManagerImpl::instance()-> + updateRequestTimeout(connection_key(), + correlation_id(), + default_timeout()); return; } } - smart_objects::SmartObject msg_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - smart_objects::SmartObject* ptr_msg_params = NULL; + if (REJECTED == vr_perform_interaction_code_) { + LOG4CXX_INFO(logger_, "VR had been rejected."); + TerminatePerformInteraction(); + SendResponse(false, vr_perform_interaction_code_); + return; + } + + if (SUCCESS == vr_perform_interaction_code_ && + InteractionMode::MANUAL_ONLY == interaction_mode_) { + LOG4CXX_INFO(logger_, "VR response SUCCESS in MANUAL_ONLY mode " << + "Wait for UI response"); + // in case MANUAL_ONLY mode VR.PI SUCCESS just return + return; + } + + SmartObject msg_params = SmartObject(SmartType_Map); + SmartObject* ptr_msg_params = NULL; if (message[strings::msg_params].keyExists(strings::choice_id)) { if (CheckChoiceIDFromResponse( app, message[strings::msg_params][strings::choice_id].asInt())) { @@ -348,22 +331,21 @@ void PerformInteractionRequest::ProcessVRResponse( } else { LOG4CXX_ERROR(logger_, "Wrong choiceID was received from HMI"); TerminatePerformInteraction(); - SendResponse(false, mobile_apis::Result::GENERIC_ERROR, - "Wrong choiceID was received from HMI"); + SendResponse(false, GENERIC_ERROR,"Wrong choiceID was received from HMI"); return; } } - mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; - if (mobile_apis::Result::UNSUPPORTED_RESOURCE == - vr_perform_interaction_code_) { + eType result_code = INVALID_ENUM; + + if (UNSUPPORTED_RESOURCE == vr_perform_interaction_code_) { LOG4CXX_INFO(logger_, "VR response WARNINGS"); - result_code = mobile_apis::Result::WARNINGS; + result_code = WARNINGS; } else { LOG4CXX_INFO(logger_, "VR response SUCCESS"); - result_code = mobile_apis::Result::SUCCESS; + result_code = SUCCESS; msg_params[strings::trigger_source] = - static_cast<int32_t>(mobile_apis::TriggerSource::TS_VR); + static_cast<int32_t>(TriggerSource::TS_VR); ptr_msg_params = &msg_params; } TerminatePerformInteraction(); @@ -372,60 +354,57 @@ void PerformInteractionRequest::ProcessVRResponse( void PerformInteractionRequest::ProcessPerformInteractionResponse( const smart_objects::SmartObject& message) { - LOG4CXX_INFO(logger_, - "PerformInteractionRequest::ProcessPerformInteractionResponse"); - const uint32_t app_id = connection_key(); - ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->application(connection_key()); if (!app.get()) { LOG4CXX_ERROR(logger_, "NULL pointer"); return; } - ui_response_recived = true; + + bool result = false; + std::string info; smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); - msg_params = message[strings::msg_params]; - bool result = false; mobile_apis::Result::eType result_code = GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asUInt())); - if ((mobile_apis::Result::SUCCESS == result_code) || - (mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code)) { - if (message[strings::msg_params].keyExists(strings::choice_id) && - !(CheckChoiceIDFromResponse( - app, message[strings::msg_params][strings::choice_id].asInt()))) { - DisablePerformInteraction(); - SendResponse(false, mobile_apis::Result::GENERIC_ERROR, - "Wrong choiceID was received from HMI"); - return; - } - if (message[strings::msg_params].keyExists(strings::manual_text_entry)) { - msg_params[strings::trigger_source] = mobile_apis::TriggerSource::TS_KEYBOARD; - } else { - msg_params[strings::trigger_source] = mobile_apis::TriggerSource::TS_MENU; - } - DisablePerformInteraction(); + if (mobile_apis::Result::SUCCESS == result_code) { + result = true; + } + + if (mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) { result = true; - } else if (mobile_apis::Result::REJECTED == result_code) { - LOG4CXX_ERROR(logger_, "Request was rejected"); + result_code = mobile_apis::Result::WARNINGS; + info = "Unsupported phoneme type was sent in an item"; } - const char* return_info = NULL; if (result) { - if (mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) { - result_code = mobile_apis::Result::WARNINGS; - return_info = - std::string("Unsupported phoneme type sent in any item").c_str(); + // result code must be GENERIC_ERROR in case wrong choice_id + if (message[strings::msg_params].keyExists(strings::choice_id)) { + if (!CheckChoiceIDFromResponse(app, message[strings::msg_params] + [strings::choice_id].asInt())) { + result_code = mobile_apis::Result::GENERIC_ERROR; + info = "Wrong choiceID was received from HMI"; + } else { + msg_params = message[strings::msg_params]; + msg_params[strings::trigger_source] = mobile_apis::TriggerSource::TS_MENU; + if (message[strings::msg_params].keyExists(strings::manual_text_entry)) { + msg_params[strings::trigger_source] = mobile_apis::TriggerSource::TS_KEYBOARD; + } + } } } - if (mobile_apis::Result::TIMED_OUT == result_code) { - DisablePerformInteraction(); - } + DisablePerformInteraction(); - SendResponse(result, result_code, return_info, &(msg_params)); + const char* return_info = (info.empty()) ? NULL : info.c_str(); + const smart_objects::SmartObject* response_params = (msg_params.empty()) ? NULL : &msg_params; + SendResponse(result, result_code, return_info, response_params); } void PerformInteractionRequest::SendUIPerformInteractionRequest( @@ -565,6 +544,7 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( smart_objects::SmartObject item(smart_objects::SmartType_Map); // Since there is no custom data from application side, SDL should // construct prompt and append delimiter to each item + item[strings::type] = hmi_apis::Common_SpeechCapabilities::SC_TEXT; item[strings::text] = vr_commands[0].asString() + profile::Profile::instance()->tts_delimiter(); msg_params[strings::help_prompt][index++] = item; @@ -744,15 +724,16 @@ void PerformInteractionRequest::DisablePerformInteraction() { return; } - if (app->is_perform_interaction_active()) { - app->set_perform_interaction_active(0); + if (app->is_perform_interaction_active() && + (!app_pi_was_active_before_)) { + app->set_perform_interaction_active(false); app->set_perform_interaction_mode(-1); app->DeletePerformInteractionChoiceSetMap(); } } bool PerformInteractionRequest::IsWhiteSpaceExist() { - LOG4CXX_INFO(logger_, "PerformInteractionRequest::IsWhiteSpaceExist"); + LOG4CXX_AUTO_TRACE(logger_); const char* str = NULL; str = (*message_)[strings::msg_params][strings::initial_text].asCharArray(); @@ -847,9 +828,10 @@ void PerformInteractionRequest::TerminatePerformInteraction() { bool PerformInteractionRequest::CheckChoiceIDFromResponse( ApplicationSharedPtr app, int32_t choice_id) { - LOG4CXX_INFO(logger_, "PerformInteractionRequest::CheckChoiceIDFromResponse"); - const PerformChoiceSetMap& choice_set_map = app - ->performinteraction_choice_set_map(); + LOG4CXX_AUTO_TRACE(logger_); + const DataAccessor<PerformChoiceSetMap> accessor = + app->performinteraction_choice_set_map(); + const PerformChoiceSetMap& choice_set_map = accessor.GetData(); for (PerformChoiceSetMap::const_iterator it = choice_set_map.begin(); choice_set_map.end() != it; ++it) { diff --git a/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc b/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc index 4ceb4ce3b3..59d706926d 100644 --- a/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc +++ b/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc @@ -47,7 +47,7 @@ PerformInteractionResponse::~PerformInteractionResponse() { } void PerformInteractionResponse::Run() { - LOG4CXX_INFO(logger_, "PerformInteractionResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/put_file_request.cc b/src/components/application_manager/src/commands/mobile/put_file_request.cc index 1da7e08e47..88743e3668 100644 --- a/src/components/application_manager/src/commands/mobile/put_file_request.cc +++ b/src/components/application_manager/src/commands/mobile/put_file_request.cc @@ -55,7 +55,7 @@ PutFileRequest::~PutFileRequest() { } void PutFileRequest::Run() { - LOG4CXX_INFO(logger_, "PutFileRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(connection_key()); @@ -224,7 +224,7 @@ void PutFileRequest::Run() { break; } default: - LOG4CXX_INFO(logger_, "Save in unsuccessful. Result = " << save_result); + LOG4CXX_WARN(logger_, "Save in unsuccessful. Result = " << save_result); SendResponse(false, save_result, "Can't save file", &response_params); break; } @@ -232,7 +232,7 @@ void PutFileRequest::Run() { void PutFileRequest::SendOnPutFileNotification() { LOG4CXX_INFO(logger_, "SendOnPutFileNotification" ); - smart_objects::SmartObject* notification = new smart_objects::SmartObject( + smart_objects::SmartObjectSPtr notification = new smart_objects::SmartObject( smart_objects::SmartType_Map); smart_objects::SmartObject& message = *notification; @@ -250,7 +250,7 @@ void PutFileRequest::SendOnPutFileNotification() { message[strings::msg_params][strings::length] = length_; message[strings::msg_params][strings::persistent_file] = is_persistent_file_; message[strings::msg_params][strings::file_type] = file_type_; - ApplicationManagerImpl::instance()->ManageHMICommand(&message); + ApplicationManagerImpl::instance()->ManageHMICommand(notification); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/put_file_response.cc b/src/components/application_manager/src/commands/mobile/put_file_response.cc index 4ab950d7a8..52598fda16 100644 --- a/src/components/application_manager/src/commands/mobile/put_file_response.cc +++ b/src/components/application_manager/src/commands/mobile/put_file_response.cc @@ -48,7 +48,7 @@ PutFileResponse::~PutFileResponse() { } void PutFileResponse::Run() { - LOG4CXX_INFO(logger_, "PutFileResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); uint32_t app_id = (*message_)[strings::params][strings::connection_key] .asUInt(); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); diff --git a/src/components/application_manager/src/commands/mobile/read_did_request.cc b/src/components/application_manager/src/commands/mobile/read_did_request.cc index 1de080df4c..5a066aab4d 100644 --- a/src/components/application_manager/src/commands/mobile/read_did_request.cc +++ b/src/components/application_manager/src/commands/mobile/read_did_request.cc @@ -49,7 +49,7 @@ ReadDIDRequest::~ReadDIDRequest() { } void ReadDIDRequest::Run() { - LOG4CXX_INFO(logger_, "ReadDIDRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); uint32_t app_id = (*message_)[strings::params][strings::connection_key] .asUInt(); @@ -96,7 +96,7 @@ void ReadDIDRequest::Run() { } void ReadDIDRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "ReadDIDRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { diff --git a/src/components/application_manager/src/commands/mobile/read_did_response.cc b/src/components/application_manager/src/commands/mobile/read_did_response.cc index 888b590758..1133fe89ed 100644 --- a/src/components/application_manager/src/commands/mobile/read_did_response.cc +++ b/src/components/application_manager/src/commands/mobile/read_did_response.cc @@ -46,7 +46,7 @@ ReadDIDResponse::~ReadDIDResponse() { } void ReadDIDResponse::Run() { - LOG4CXX_INFO(logger_, "ReadDIDResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index f62e0d4b84..0c4070611c 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -1,6 +1,6 @@ -/* +/* - Copyright (c) 2013, Ford Motor Company + Copyright (c) 2015, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without @@ -116,6 +116,18 @@ struct CheckMissedTypes { const policy::StringArray& policy_app_types_; std::string& log_; }; + +struct IsSameNickname { + IsSameNickname(const std::string& app_id): + app_id_(app_id) { + } + bool operator()(const policy::StringArray::value_type nickname) const { + return !strcasecmp(app_id_.c_str(), nickname.c_str()); + } + +private: + const std::string& app_id_; +}; } namespace application_manager { @@ -124,14 +136,15 @@ namespace commands { RegisterAppInterfaceRequest::RegisterAppInterfaceRequest( const MessageSharedPtr& message) - : CommandRequestImpl(message) { + : CommandRequestImpl(message), + result_checking_app_hmi_type_(mobile_apis::Result::INVALID_ENUM) { } RegisterAppInterfaceRequest::~RegisterAppInterfaceRequest() { } bool RegisterAppInterfaceRequest::Init() { - LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::Init"); + LOG4CXX_AUTO_TRACE(logger_); return true; } @@ -139,8 +152,9 @@ void RegisterAppInterfaceRequest::Run() { LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::Run " << connection_key()); // Fix problem with SDL and HMI HTML. This problem is not actual for HMI PASA. - // Flag conditional compilation "CUSTOMER_PASA" is used in order to exclude hit code + // Flag conditional compilation specific to customer is used in order to exclude hit code // to RTC + // FIXME(EZamakhov): on shutdown - get freez if (true == profile::Profile::instance()->launch_hmi()) { // wait till HMI started while (!ApplicationManagerImpl::instance()->IsHMICooperating()) { @@ -189,13 +203,6 @@ void RegisterAppInterfaceRequest::Run() { return; } - mobile_apis::Result::eType restriction_result = CheckRestrictions(); - if (mobile_apis::Result::SUCCESS != restriction_result) { - LOG4CXX_ERROR_EXT(logger_, "Param names restrictions check failed."); - SendResponse(false, restriction_result); - return; - } - if (IsWhiteSpaceExist()) { LOG4CXX_INFO(logger_, "Incoming register app interface has contains \t\n \\t \\n"); @@ -254,7 +261,7 @@ void RegisterAppInterfaceRequest::Run() { if (mobile_apis::AppHMIType::NAVIGATION == static_cast<mobile_apis::AppHMIType::eType>( app_type.getElement(i).asUInt())) { - app->set_allowed_support_navigation(true); + app->set_is_navi(true); } if (mobile_apis::AppHMIType::COMMUNICATION == static_cast<mobile_apis::AppHMIType::eType>( @@ -281,38 +288,12 @@ void RegisterAppInterfaceRequest::Run() { device_info); SendRegisterAppInterfaceResponseToMobile(); - - MessageHelper::SendLockScreenIconUrlNotification( - (*message_)[strings::params][strings::connection_key].asInt()); - - policy::PolicyHandler::instance()->PTExchangeAtRegistration(mobile_app_id); - } -} - -void RegisterAppInterfaceRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::on_event"); - switch (event.id()) { - case hmi_apis::FunctionID::TTS_Speak: { - const smart_objects::SmartObject& message = event.smart_object(); - - mobile_apis::Result::eType tts_result = - static_cast<mobile_apis::Result::eType>( - message[strings::params][hmi_response::code].asInt()); - - SendRegisterAppInterfaceResponseToMobile(tts_result); - break; - } - default: { - LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); - break; - } } } void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( mobile_apis::Result::eType result) { - smart_objects::SmartObject* params = new smart_objects::SmartObject( - smart_objects::SmartType_Map); + smart_objects::SmartObject response_params(smart_objects::SmartType_Map); ApplicationManagerImpl* app_manager = ApplicationManagerImpl::instance(); const HMICapabilities& hmi_capabilities = app_manager->hmi_capabilities(); @@ -320,14 +301,12 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(key); - if (!application.valid()) { + if (!application) { LOG4CXX_ERROR(logger_, "There is no application for such connection key" << key); return; } - smart_objects::SmartObject& response_params = *params; - response_params[strings::sync_msg_version][strings::major_version] = APIVersion::kAPIV3; response_params[strings::sync_msg_version][strings::minor_version] = @@ -467,17 +446,17 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( } ResumeCtrl& resumer = ApplicationManagerImpl::instance()->resume_controller(); - uint32_t hash_id = 0; + std::string hash_id = ""; - const char* add_info = ""; - const bool resumption = (*message_)[strings::msg_params].keyExists(strings::hash_id); + std::string add_info(""); + bool resumption = (*message_)[strings::msg_params].keyExists(strings::hash_id); bool need_restore_vr = resumption; if (resumption) { - hash_id = (*message_)[strings::msg_params][strings::hash_id].asUInt(); + hash_id = (*message_)[strings::msg_params][strings::hash_id].asString(); if (!resumer.CheckApplicationHash(application, hash_id)) { - LOG4CXX_WARN(logger_, "Hash does not matches"); + LOG4CXX_WARN(logger_, "Hash does not match"); result = mobile_apis::Result::RESUME_FAILED; - add_info = "Hash does not matches"; + add_info = "Hash does not match"; need_restore_vr = false; } else if (!resumer.CheckPersistenceFilesForResumption(application)) { LOG4CXX_WARN(logger_, "Persistent data is missed"); @@ -488,8 +467,16 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( add_info = " Resume Succeed"; } } + if ((mobile_apis::Result::SUCCESS == result) && + (mobile_apis::Result::INVALID_ENUM != result_checking_app_hmi_type_)) { + add_info += response_info_; + result = result_checking_app_hmi_type_; + } - SendResponse(true, result, add_info, params); + // in case application exist in resumption we need to send resumeVrgrammars + if (false == resumption) { + resumption = resumer.IsApplicationSaved(application->mobile_app_id()); + } MessageHelper::SendOnAppRegisteredNotificationToHMI(*(application.get()), resumption, @@ -497,6 +484,7 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( MessageHelper::SendChangeRegistrationRequestToHMI(application); + SendResponse(true, result, add_info.c_str(), &response_params); if (result != mobile_apis::Result::RESUME_FAILED) { resumer.StartResumption(application, hash_id); } else { @@ -506,17 +494,17 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence() { - LOG4CXX_TRACE_ENTER(logger_); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; ApplicationManagerImpl::ApplicationListAccessor accessor; - const std::set<ApplicationSharedPtr> applications = accessor.applications(); - std::set<ApplicationSharedPtr>::const_iterator it = applications.begin(); + ApplicationManagerImpl::ApplictionSetConstIt it = + accessor.begin(); const std::string app_name = msg_params[strings::app_name].asString(); - for (; applications.end() != it; ++it) { + for (; accessor.end() != it; ++it) { // name check const std::string& cur_name = (*it)->name(); @@ -577,9 +565,10 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() { } if (!app_nicknames.empty()) { - policy::StringArray::const_iterator it = std::find( - app_nicknames.begin(), app_nicknames.end(), + IsSameNickname compare( message[strings::msg_params][strings::app_name].asString()); + policy::StringArray::const_iterator it = std::find_if( + app_nicknames.begin(), app_nicknames.end(), compare); if (app_nicknames.end() == it) { LOG4CXX_WARN(logger_, "Application name was not found in nicknames list."); @@ -608,7 +597,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() { if (!log.empty()) { response_info_ = "Following AppHMITypes are not present in policy " "table:" + log; - result = mobile_apis::Result::WARNINGS; + result_checking_app_hmi_type_ = mobile_apis::Result::WARNINGS; } } // Replace AppHMITypes in request with values allowed by policy table @@ -661,91 +650,22 @@ void RegisterAppInterfaceRequest::FillDeviceInfo( } } -mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckRestrictions() const { - - LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::CheckRestrictions"); - - const smart_objects::SmartObject& msg_params = - (*message_)[strings::msg_params]; - - const std::string& app_name = msg_params[strings::app_name].asString(); - - if (ClearParamName(app_name).empty()) { - printf("Application name is empty.\n"); - return mobile_apis::Result::INVALID_DATA; - } - - if ((app_name[0] == '\n') || - ((app_name[0] == '\\') && (app_name[1] == 'n'))) { - - printf("Application name has invalid characters."); - return mobile_apis::Result::INVALID_DATA; - } - - if (msg_params.keyExists(strings::tts_name)) { - - const smart_objects::SmartArray* tts = - msg_params[strings::tts_name].asArray(); - - smart_objects::SmartArray::const_iterator it = tts->begin(); - smart_objects::SmartArray::const_iterator it_end = tts->end(); - - for (; it != it_end; ++it) { - - const std::string& tts_name = (*it)[strings::text].asString(); - - if (ClearParamName(tts_name).empty()) { - printf("TTS value is empty."); - return mobile_apis::Result::INVALID_DATA; - } - - if ((tts_name[0] == '\n') || - ((tts_name[0] == '\\') && (tts_name[1] == 'n'))) { - - printf("TTS value(s) has invalid characters."); - return mobile_apis::Result::INVALID_DATA; - } - } - } - - return mobile_apis::Result::SUCCESS; -} - -std::string -RegisterAppInterfaceRequest::ClearParamName(std::string param_name) const { - - // Expecting for chars different from newlines and spaces in the appName - // - // There is an agreement, that "\n" is not allowed symbols, so we have to - // check for this case also - - std::string newline = "\\n"; - while (std::string::npos != param_name.find(newline)) { - param_name.erase(param_name.find(newline), newline.length()); - } - - std::string::iterator param_name_new_end = - std::remove_if(param_name.begin(), param_name.end(), ::isspace); - - return std::string(param_name.begin(), param_name_new_end); -} - bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() { LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::" "IsApplicationWithSameAppIdRegistered"); const std::string mobile_app_id = (*message_)[strings::msg_params] - [strings::app_id].asString(); + [strings::app_id].asString(); ApplicationManagerImpl::ApplicationListAccessor accessor; - const std::set<ApplicationSharedPtr> applications = accessor.applications(); + const ApplicationManagerImpl::ApplictionSet applications = accessor.applications(); - std::set<ApplicationSharedPtr>::const_iterator it = applications.begin(); - std::set<ApplicationSharedPtr>::const_iterator it_end = applications.end(); + ApplicationManagerImpl::ApplictionSetConstIt it = applications.begin(); + ApplicationManagerImpl::ApplictionSetConstIt it_end = applications.end(); for (; it != it_end; ++it) { - if (mobile_app_id == (*it)->mobile_app_id()->asString()) { + if (!strcasecmp(mobile_app_id.c_str(),(*it)->mobile_app_id().c_str())) { return true; } } @@ -754,7 +674,7 @@ bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() { } bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() { - LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::IsWhiteSpaceExist"); + LOG4CXX_AUTO_TRACE(logger_); const char* str = NULL; str = (*message_)[strings::msg_params][strings::app_name].asCharArray(); diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc index fe6f3a925a..25de8d3ef4 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc @@ -42,7 +42,7 @@ namespace application_manager { namespace commands { void RegisterAppInterfaceResponse::Run() { - LOG4CXX_INFO(logger_, "RegisterAppInterfaceResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; bool success = (*message_)[strings::msg_params][strings::success].asBool(); @@ -67,7 +67,7 @@ void RegisterAppInterfaceResponse::Run() { application(connection_key); if (app.valid()) { policy::PolicyHandler *policy_handler = policy::PolicyHandler::instance(); - std::string mobile_app_id = app->mobile_app_id()->asString(); + std::string mobile_app_id = app->mobile_app_id(); policy_handler->AddApplication(mobile_app_id); SetHeartBeatTimeout(connection_key, mobile_app_id); } @@ -75,10 +75,11 @@ void RegisterAppInterfaceResponse::Run() { void RegisterAppInterfaceResponse::SetHeartBeatTimeout( uint32_t connection_key, const std::string& mobile_app_id) { - LOG4CXX_TRACE_ENTER(logger_); + LOG4CXX_AUTO_TRACE(logger_); policy::PolicyHandler *policy_handler = policy::PolicyHandler::instance(); if (policy_handler->PolicyEnabled()) { - const int32_t timeout = policy_handler->HeartBeatTimeout(mobile_app_id); + const int32_t timeout = policy_handler->HeartBeatTimeout(mobile_app_id) / + date_time::DateTime::MILLISECONDS_IN_SECOND; if (timeout > 0) { application_manager::ApplicationManagerImpl::instance()-> connection_handler()->SetHeartBeatTimeout(connection_key, timeout); @@ -86,7 +87,6 @@ void RegisterAppInterfaceResponse::SetHeartBeatTimeout( } else { LOG4CXX_INFO(logger_, "Policy is turn off"); } - LOG4CXX_TRACE_EXIT(logger_); } } // namespace commands 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 5e62b789d8..9f6e84b55b 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 @@ -58,7 +58,7 @@ ResetGlobalPropertiesRequest::~ResetGlobalPropertiesRequest() { } void ResetGlobalPropertiesRequest::Run() { - LOG4CXX_INFO(logger_, "ResetGlobalPropertiesRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); uint32_t app_id = (*message_)[strings::params][strings::connection_key].asUInt(); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); @@ -125,7 +125,7 @@ void ResetGlobalPropertiesRequest::Run() { smart_objects::SmartType_Map); if (vr_help_title_items) { - smart_objects::SmartObject* vr_help = MessageHelper::CreateAppVrHelp(app); + smart_objects::SmartObjectSPtr vr_help = MessageHelper::CreateAppVrHelp(app); if (!vr_help) { return; } @@ -236,7 +236,7 @@ bool ResetGlobalPropertiesRequest::ResetVrHelpTitleItems( } void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "ResetGlobalPropertiesRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { diff --git a/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc b/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc index aeacabf9d5..8e562956ae 100644 --- a/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc +++ b/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc @@ -47,7 +47,7 @@ ResetGlobalPropertiesResponse::~ResetGlobalPropertiesResponse() { } void ResetGlobalPropertiesResponse::Run() { - LOG4CXX_INFO(logger_, "ResetGlobalPropertiesResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc b/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc index 5b3cfa67ac..10f080e0e7 100644 --- a/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc +++ b/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc @@ -68,7 +68,7 @@ bool ScrollableMessageRequest::Init() { } void ScrollableMessageRequest::Run() { - LOG4CXX_INFO(logger_, "ScrollableMessageRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance() ->application((*message_)[strings::params][strings::connection_key].asUInt()); @@ -113,7 +113,7 @@ void ScrollableMessageRequest::Run() { } void ScrollableMessageRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "ScrollableMessageRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { @@ -133,8 +133,7 @@ void ScrollableMessageRequest::on_event(const event_engine::Event& event) { HMICapabilities& hmi_capabilities = ApplicationManagerImpl::instance()->hmi_capabilities(); bool result = false; - if (mobile_apis::Result::SUCCESS == result_code || - mobile_apis::Result::ABORTED == result_code) { + if (mobile_apis::Result::SUCCESS == result_code) { result = true; } else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) && hmi_capabilities.is_ui_cooperating()) { diff --git a/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc b/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc index d9692359d0..212a3ba912 100644 --- a/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc +++ b/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc @@ -46,7 +46,7 @@ ScrollableMessageResponse::ScrollableMessageResponse( } void ScrollableMessageResponse::Run() { - LOG4CXX_INFO(logger_, "ScrollableMessageResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); mobile_apis::Result::eType result_code = static_cast<mobile_apis::Result::eType>( (*message_)[strings::msg_params][strings::result_code].asInt()); ApplicationSharedPtr application = diff --git a/src/components/application_manager/src/commands/mobile/send_location_request.cc b/src/components/application_manager/src/commands/mobile/send_location_request.cc index b5c2e8a9a5..b77b4afd0f 100644 --- a/src/components/application_manager/src/commands/mobile/send_location_request.cc +++ b/src/components/application_manager/src/commands/mobile/send_location_request.cc @@ -46,17 +46,39 @@ SendLocationRequest::~SendLocationRequest() { } void SendLocationRequest::Run() { - LOG4CXX_INFO(logger_, "SendLocationRequest::Run"); + using namespace hmi_apis; + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance() ->application(connection_key()); if (!app) { - LOG4CXX_ERROR_EXT( - logger_, "An application " << app->name() << " is not registered."); + LOG4CXX_ERROR_EXT(logger_, + "An application with connection key " << connection_key() + << " is not registered."); SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); return; } + const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; + + std::list<Common_TextFieldName::eType> fields_to_check; + if (msg_params.keyExists(strings::location_name)) { + fields_to_check.push_back(Common_TextFieldName::locationName); + } + if (msg_params.keyExists(strings::location_description)) { + fields_to_check.push_back(Common_TextFieldName::locationDescription); + } + if (msg_params.keyExists(strings::address_lines)) { + fields_to_check.push_back(Common_TextFieldName::addressLines); + } + if (msg_params.keyExists(strings::phone_number)) { + fields_to_check.push_back(Common_TextFieldName::phoneNumber); + } + + if (!CheckHMICapabilities(fields_to_check)) { + SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE); + return; + } if (IsWhiteSpaceExist()) { LOG4CXX_ERROR(logger_, "Strings contain invalid characters"); @@ -90,7 +112,10 @@ void SendLocationRequest::on_event(const event_engine::Event& event) { mobile_apis::Result::eType result_code = GetMobileResultCode( static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asUInt())); - bool result = mobile_apis::Result::SUCCESS == result_code; + bool result = + mobile_apis::Result::SUCCESS == result_code || + mobile_apis::Result::WARNINGS == result_code || + mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code ; SendResponse(result, result_code, NULL, &(message[strings::msg_params])); break; } @@ -161,6 +186,39 @@ bool SendLocationRequest::IsWhiteSpaceExist() { return false; } +bool SendLocationRequest::CheckHMICapabilities(std::list<hmi_apis::Common_TextFieldName::eType>& fields_names) { + using namespace smart_objects; + using namespace hmi_apis; + + ApplicationManagerImpl* instance = ApplicationManagerImpl::instance(); + const HMICapabilities& hmi_capabilities = instance->hmi_capabilities(); + if (!hmi_capabilities.is_ui_cooperating()) { + LOG4CXX_ERROR_EXT(logger_, "UI is not supported."); + return false; + } + const size_t size_before = fields_names.size(); + if (hmi_capabilities.display_capabilities()) { + const SmartObject disp_cap = (*hmi_capabilities.display_capabilities()); + const SmartObject& text_fields = disp_cap.getElement(hmi_response::text_fields); + const size_t len = text_fields.length(); + for (size_t i = 0; i < len; ++i) { + const SmartObject& text_field = text_fields[i]; + const Common_TextFieldName::eType filed_name = + static_cast<Common_TextFieldName::eType>(text_field.getElement(strings::name).asInt()); + const std::list<Common_TextFieldName::eType>::iterator it = + std::find(fields_names.begin(), fields_names.end(), filed_name); + if (it != fields_names.end()) { + fields_names.erase(it); + } + } + } + if (fields_names.size() == size_before) { + LOG4CXX_ERROR_EXT(logger_, "Some fields are not supported by capabilities"); + return false; + } + return true; +} + } // namespace commands } // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/send_location_response.cc b/src/components/application_manager/src/commands/mobile/send_location_response.cc index a13b67dc06..32756c999d 100644 --- a/src/components/application_manager/src/commands/mobile/send_location_response.cc +++ b/src/components/application_manager/src/commands/mobile/send_location_response.cc @@ -48,7 +48,7 @@ SendLocationResponse::~SendLocationResponse() { } void SendLocationResponse::Run() { - LOG4CXX_INFO(logger_, "SendLocationResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc new file mode 100644 index 0000000000..9851bce3f2 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc @@ -0,0 +1,235 @@ +/* + + Copyright (c) 2013, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/commands/mobile/set_app_icon_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "config_profile/profile.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" +#include "utils/file_system.h" + +namespace application_manager { + +namespace commands { + +SetAppIconRequest::SetAppIconRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +SetAppIconRequest::~SetAppIconRequest() { +} + +void SetAppIconRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + const std::string& sync_file_name = + (*message_)[strings::msg_params][strings::sync_file_name].asString(); + + std::string full_file_path = + file_system::CurrentWorkingDirectory() + "/" + + profile::Profile::instance()->app_storage_folder() + "/"; + full_file_path += app->folder_name(); + full_file_path += "/"; + full_file_path += sync_file_name; + + if (!file_system::FileExists(full_file_path)) { + LOG4CXX_ERROR(logger_, "No such file " << full_file_path); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + CopyToIconStorage(full_file_path); + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + msg_params[strings::app_id] = app->app_id(); + msg_params[strings::sync_file_name] = smart_objects::SmartObject( + smart_objects::SmartType_Map); + +// Panasonic requres unchanged path value without encoded special characters + const std::string full_file_path_for_hmi = file_system::ConvertPathForURL( + full_file_path); + + msg_params[strings::sync_file_name][strings::value] = full_file_path_for_hmi; + + // TODO(VS): research why is image_type hardcoded + msg_params[strings::sync_file_name][strings::image_type] = + static_cast<int32_t> (SetAppIconRequest::ImageType::DYNAMIC); + + // for further use in on_event function + (*message_)[strings::msg_params][strings::sync_file_name] = + msg_params[strings::sync_file_name]; + + SendHMIRequest(hmi_apis::FunctionID::UI_SetAppIcon, &msg_params, true); +} + +void SetAppIconRequest::CopyToIconStorage( + const std::string& path_to_file) const { + if (!profile::Profile::instance()->enable_protocol_4()) { + LOG4CXX_WARN(logger_, + "Icon copying skipped, since protocol ver. 4 is not enabled."); + return; + } + + std::vector<uint8_t> file_content; + if(!file_system::ReadBinaryFile(path_to_file, file_content)) { + LOG4CXX_ERROR(logger_, "Can't read icon file: " << path_to_file); + return; + } + + const std::string icon_storage = + profile::Profile::instance()->app_icons_folder(); + const uint64_t storage_max_size = + static_cast<uint64_t>( + profile::Profile::instance()->app_icons_folder_max_size()); + const uint64_t file_size = file_system::FileSize(path_to_file); + const uint64_t storage_size = static_cast<uint64_t>( + file_system::DirectorySize(icon_storage)); + if (storage_max_size < (file_size + storage_size)) { + RemoveOldestIcons(icon_storage, + profile::Profile::instance()-> + app_icons_amount_to_remove()); + } + ApplicationConstSharedPtr app = + application_manager::ApplicationManagerImpl::instance()-> + application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "Can't get application for connection key: " + << connection_key()); + return; + } + + const std::string icon_path = + icon_storage + "/" + app->mobile_app_id(); + if (!file_system::CreateFile(icon_path)) { + LOG4CXX_ERROR(logger_, "Can't create icon: " << icon_path); + return; + } + + if (!file_system::Write(icon_path, file_content)) { + LOG4CXX_ERROR(logger_, "Can't write icon: " << icon_path); + return; + } + + LOG4CXX_DEBUG(logger_, "Icon was successfully copied from :" << path_to_file + << " to " << icon_path); + + return; +} + +void SetAppIconRequest::RemoveOldestIcons(const std::string& storage, + const uint32_t icons_amount) const { + if (!icons_amount) { + LOG4CXX_DEBUG(logger_, + "No icons will be deleted, since amount of files is zero."); + return; + } + const std::vector<std::string> icons_list = file_system::ListFiles(storage); + std::map<uint64_t, std::string> icon_modification_time; + std::vector<std::string>::const_iterator it = icons_list.begin(); + for (;it != icons_list.end(); ++it) { + const std::string file_name = *it; + const std::string file_path = storage + "/" + file_name; + if (!file_system::FileExists(file_path)) { + continue; + } + const uint64_t time = file_system::GetFileModificationTime(file_path); + icon_modification_time[time] = file_name; + } + + for (size_t counter = 0; counter < icons_amount; ++counter) { + const std::string file_name = icon_modification_time.begin()->second; + const std::string file_path = storage + "/" + file_name; + if (!file_system::DeleteFile(file_path)) { + LOG4CXX_DEBUG(logger_, "Error while deleting icon " << file_path); + } + LOG4CXX_DEBUG(logger_, "Old icon " << file_path + << " was deleted successfully."); + } +} + +void SetAppIconRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_SetAppIcon: { + mobile_apis::Result::eType result_code = + static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + bool result = mobile_apis::Result::SUCCESS == result_code; + + if (result) { + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!message_.valid() || !app.valid()) { + LOG4CXX_ERROR(logger_, "NULL pointer."); + return; + } + + const std::string path = (*message_)[strings::msg_params] + [strings::sync_file_name] + [strings::value].asString(); + app->set_app_icon_path(path); + + LOG4CXX_INFO(logger_, + "Icon path was set to '" << app->app_icon_path() << "'"); + } + + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/set_app_icon_response.cc b/src/components/application_manager/src/commands/mobile/set_app_icon_response.cc new file mode 100644 index 0000000000..563490bd46 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/set_app_icon_response.cc @@ -0,0 +1,56 @@ +/* + + Copyright (c) 2013, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/commands/mobile/set_app_icon_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +SetAppIconResponse::SetAppIconResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +SetAppIconResponse::~SetAppIconResponse() { +} + +void SetAppIconResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc b/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc index 60a2583287..b59a631d8d 100644 --- a/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc @@ -49,7 +49,7 @@ SetDisplayLayoutRequest::~SetDisplayLayoutRequest() { } void SetDisplayLayoutRequest::Run() { - LOG4CXX_INFO(logger_, "SetDisplayLayoutRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationConstSharedPtr app = ApplicationManagerImpl::instance() ->application(connection_key()); @@ -66,7 +66,7 @@ void SetDisplayLayoutRequest::Run() { } void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "SetDisplayLayoutRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { diff --git a/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc b/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc index 51f8c1f35b..3844b3bf05 100644 --- a/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc +++ b/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc @@ -48,7 +48,7 @@ SetDisplayLayoutResponse::~SetDisplayLayoutResponse() { } void SetDisplayLayoutResponse::Run() { - LOG4CXX_INFO(logger_, "SetDisplayLayoutResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); diff --git a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc index f7216c818c..ff46e041ff 100644 --- a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc @@ -59,7 +59,7 @@ SetGlobalPropertiesRequest::~SetGlobalPropertiesRequest() { } void SetGlobalPropertiesRequest::Run() { - LOG4CXX_INFO(logger_, "SetGlobalPropertiesRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; @@ -197,7 +197,8 @@ void SetGlobalPropertiesRequest::Run() { SendHMIRequest(hmi_apis::FunctionID::UI_SetGlobalProperties, ¶ms, true); } else if (!is_vr_help_title_present && !is_vr_help_present) { - const CommandsMap& cmdMap = app->commands_map(); + const DataAccessor<CommandsMap> accessor = app->commands_map(); + const CommandsMap& cmdMap = accessor.GetData(); CommandsMap::const_iterator command_it = cmdMap.begin(); int32_t index = 0; @@ -304,7 +305,7 @@ bool SetGlobalPropertiesRequest::CheckVrHelpItemsOrder() { } void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "SetGlobalPropertiesRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(CommandRequestImpl::connection_key()); @@ -383,7 +384,7 @@ bool SetGlobalPropertiesRequest::ValidateConditionalMandatoryParameters( } bool SetGlobalPropertiesRequest::IsWhiteSpaceExist() { - LOG4CXX_INFO(logger_, "SetGlobalPropertiesRequest::IsWhiteSpaceExist"); + LOG4CXX_AUTO_TRACE(logger_); const char* str; const smart_objects::SmartObject& msg_params = diff --git a/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc b/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc index 5f0b62fb4d..759333385d 100644 --- a/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc +++ b/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc @@ -48,7 +48,7 @@ SetGlobalPropertiesResponse::~SetGlobalPropertiesResponse() { } void SetGlobalPropertiesResponse::Run() { - LOG4CXX_INFO(logger_, "SetGlobalPropertiesResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc index c9b2eb5ef5..536bb755ed 100644 --- a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc @@ -49,7 +49,7 @@ SetMediaClockRequest::~SetMediaClockRequest() { } void SetMediaClockRequest::Run() { - LOG4CXX_INFO(logger_, "SetMediaClockRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(connection_key()); @@ -81,7 +81,7 @@ void SetMediaClockRequest::Run() { } void SetMediaClockRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "SetMediaClockRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { diff --git a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc index 73923b0021..da6f204da4 100644 --- a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc +++ b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc @@ -47,7 +47,7 @@ SetMediaClockTimerResponse::~SetMediaClockTimerResponse() { } void SetMediaClockTimerResponse::Run() { - LOG4CXX_INFO(logger_, "SetMediaClockTimerResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc b/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc index f4e70c53ac..1e861d14ce 100644 --- a/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc +++ b/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc @@ -51,7 +51,7 @@ ShowConstantTBTRequest::~ShowConstantTBTRequest() { } void ShowConstantTBTRequest::Run() { - LOG4CXX_INFO(logger_, "ShowConstantTBTRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( (*message_)[strings::params][strings::connection_key].asUInt()); @@ -175,7 +175,7 @@ void ShowConstantTBTRequest::Run() { void ShowConstantTBTRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "ShowConstantTBTRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { @@ -206,7 +206,7 @@ void ShowConstantTBTRequest::on_event(const event_engine::Event& event) { } bool ShowConstantTBTRequest::IsWhiteSpaceExist() { - LOG4CXX_INFO(logger_, "ShowConstantTBTRequest::IsWhiteSpaceExist"); + LOG4CXX_AUTO_TRACE(logger_); const char* str = NULL; if ((*message_)[strings::msg_params].keyExists(strings::turn_icon)) { diff --git a/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc b/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc index d5539d148c..e45cd760df 100644 --- a/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc +++ b/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc @@ -48,7 +48,7 @@ ShowConstantTBTResponse::~ShowConstantTBTResponse() { } void ShowConstantTBTResponse::Run() { - LOG4CXX_INFO(logger_, "ShowConstantTBTResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/show_request.cc b/src/components/application_manager/src/commands/mobile/show_request.cc index eeef60101e..0a136e0ac2 100644 --- a/src/components/application_manager/src/commands/mobile/show_request.cc +++ b/src/components/application_manager/src/commands/mobile/show_request.cc @@ -50,7 +50,7 @@ ShowRequest::~ShowRequest() { } void ShowRequest::Run() { - LOG4CXX_INFO(logger_, "ShowRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance() ->application( @@ -216,7 +216,7 @@ void ShowRequest::Run() { } void ShowRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "ShowRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { @@ -251,7 +251,7 @@ void ShowRequest::on_event(const event_engine::Event& event) { } bool ShowRequest::CheckStringsOfShowRequest() { - LOG4CXX_INFO(logger_, "ShowRequest::CheckStringsOfShowRequest"); + LOG4CXX_AUTO_TRACE(logger_); const char* str; if ((*message_)[strings::msg_params].keyExists(strings::main_field_4)) { diff --git a/src/components/application_manager/src/commands/mobile/show_response.cc b/src/components/application_manager/src/commands/mobile/show_response.cc index 1f9c59c6fc..0c46cdd83c 100644 --- a/src/components/application_manager/src/commands/mobile/show_response.cc +++ b/src/components/application_manager/src/commands/mobile/show_response.cc @@ -48,7 +48,7 @@ ShowResponse::~ShowResponse() { } void ShowResponse::Run() { - LOG4CXX_INFO(logger_, "ShowResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/slider_request.cc b/src/components/application_manager/src/commands/mobile/slider_request.cc index 52f3c7dee7..78a9bb6aac 100644 --- a/src/components/application_manager/src/commands/mobile/slider_request.cc +++ b/src/components/application_manager/src/commands/mobile/slider_request.cc @@ -60,7 +60,7 @@ bool SliderRequest::Init() { } void SliderRequest::Run() { - LOG4CXX_INFO(logger_, "SliderRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr application = application_manager::ApplicationManagerImpl::instance()->application( @@ -110,7 +110,7 @@ void SliderRequest::Run() { } void SliderRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "SliderRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); const event_engine::Event::EventID event_id = event.id(); @@ -131,18 +131,16 @@ void SliderRequest::on_event(const event_engine::Event& event) { const int response_code = message[strings::params][hmi_response::code].asInt(); - smart_objects::SmartObject response_msg_params = message[strings::msg_params]; - if (response_code == hmi_apis::Common_Result::ABORTED) { + if (response_code == hmi_apis::Common_Result::ABORTED && + message[strings::params][strings::data].keyExists(strings::slider_position)) { //Copy slider_position info to msg_params section - response_msg_params[strings::slider_position] = + response_msg_params[strings::slider_position] = message[strings::params][strings::data][strings::slider_position]; } const bool is_response_success = - (mobile_apis::Result::SUCCESS == response_code) || - //Aborted has slider_position data - (mobile_apis::Result::ABORTED == response_code); + (mobile_apis::Result::SUCCESS == response_code); SendResponse(is_response_success, mobile_apis::Result::eType(response_code), diff --git a/src/components/application_manager/src/commands/mobile/slider_response.cc b/src/components/application_manager/src/commands/mobile/slider_response.cc index bfb6b0a1e6..7f0c10b068 100644 --- a/src/components/application_manager/src/commands/mobile/slider_response.cc +++ b/src/components/application_manager/src/commands/mobile/slider_response.cc @@ -46,7 +46,7 @@ SliderResponse::~SliderResponse() { } void SliderResponse::Run() { - LOG4CXX_INFO(logger_, "SliderResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/speak_request.cc b/src/components/application_manager/src/commands/mobile/speak_request.cc index de37e8b49e..b2f112a64a 100644 --- a/src/components/application_manager/src/commands/mobile/speak_request.cc +++ b/src/components/application_manager/src/commands/mobile/speak_request.cc @@ -49,7 +49,7 @@ SpeakRequest::~SpeakRequest() { } void SpeakRequest::Run() { - LOG4CXX_INFO(logger_, "SpeakRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance() ->application(connection_key()); @@ -70,13 +70,13 @@ void SpeakRequest::Run() { (*message_)[strings::msg_params][strings::app_id] = app->app_id(); (*message_)[strings::msg_params][hmi_request::speak_type] = - hmi_apis::Common_SpeakType::SPEAK; + hmi_apis::Common_MethodName::SPEAK; SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, &message_->getElement(strings::msg_params), true); } void SpeakRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "SpeakRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); switch (event.id()) { case hmi_apis::FunctionID::TTS_Speak: { LOG4CXX_INFO(logger_, "Received TTS_Speak event"); @@ -100,7 +100,7 @@ void SpeakRequest::on_event(const event_engine::Event& event) { void SpeakRequest::ProcessTTSSpeakResponse( const smart_objects::SmartObject& message) { - LOG4CXX_INFO(logger_, "SpeakRequest::ProcessTTSSpeakResponse"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application( connection_key()); @@ -134,7 +134,7 @@ void SpeakRequest::ProcessTTSSpeakResponse( } bool SpeakRequest::IsWhiteSpaceExist() { - LOG4CXX_INFO(logger_, "SpeakRequest::IsWhiteSpaceExist"); + LOG4CXX_AUTO_TRACE(logger_); const char* str = NULL; if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) { diff --git a/src/components/application_manager/src/commands/mobile/speak_response.cc b/src/components/application_manager/src/commands/mobile/speak_response.cc index 92b85bbb84..d99b1d0952 100644 --- a/src/components/application_manager/src/commands/mobile/speak_response.cc +++ b/src/components/application_manager/src/commands/mobile/speak_response.cc @@ -48,7 +48,7 @@ SpeakResponse::~SpeakResponse() { } void SpeakResponse::Run() { - LOG4CXX_INFO(logger_, "SpeakResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc index b6a4d8a28e..abd0662547 100644 --- a/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc +++ b/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc @@ -48,7 +48,7 @@ SubscribeButtonRequest::~SubscribeButtonRequest() { } void SubscribeButtonRequest::Run() { - LOG4CXX_INFO(logger_, "SubscribeButtonRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(connection_key()); diff --git a/src/components/application_manager/src/commands/mobile/subscribe_button_response.cc b/src/components/application_manager/src/commands/mobile/subscribe_button_response.cc index 6253f8ca3d..a3452ef19f 100644 --- a/src/components/application_manager/src/commands/mobile/subscribe_button_response.cc +++ b/src/components/application_manager/src/commands/mobile/subscribe_button_response.cc @@ -46,7 +46,7 @@ SubscribeButtonResponse::~SubscribeButtonResponse() { } void SubscribeButtonResponse::Run() { - LOG4CXX_INFO(logger_, "SubscribeButtonResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); // check if response false if (true == (*message_)[strings::msg_params].keyExists(strings::success)) { diff --git a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc index 35595c2df6..1640f0b497 100644 --- a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc +++ b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc @@ -84,7 +84,7 @@ namespace { #endif // #ifdef HMI_DBUS_API void SubscribeVehicleDataRequest::Run() { - LOG4CXX_INFO(logger_, "SubscribeVehicleDataRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( CommandRequestImpl::connection_key()); @@ -172,7 +172,7 @@ void SubscribeVehicleDataRequest::Run() { } void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "SubscribeVehicleDataRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); diff --git a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc index 972a654188..c0554c62eb 100644 --- a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc +++ b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc @@ -48,7 +48,7 @@ SubscribeVehicleDataResponse::~SubscribeVehicleDataResponse() { } void SubscribeVehicleDataResponse::Run() { - LOG4CXX_INFO(logger_, "SubscribeVehicleDataResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/system_request.cc b/src/components/application_manager/src/commands/mobile/system_request.cc index 2765aad8d7..25fbe6e3fd 100644 --- a/src/components/application_manager/src/commands/mobile/system_request.cc +++ b/src/components/application_manager/src/commands/mobile/system_request.cc @@ -40,6 +40,8 @@ Copyright (c) 2013, Ford Motor Company #include "interfaces/MOBILE_API.h" #include "config_profile/profile.h" #include "utils/file_system.h" +#include "formatters/CFormatterJsonBase.hpp" +#include "json/json.h" namespace application_manager { @@ -55,7 +57,7 @@ SystemRequest::~SystemRequest() { } void SystemRequest::Run() { - LOG4CXX_INFO(logger_, "SystemRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(connection_key()); @@ -66,12 +68,14 @@ void SystemRequest::Run() { return; } - mobile_apis::RequestType::eType request_type = + const mobile_apis::RequestType::eType request_type = static_cast<mobile_apis::RequestType::eType>( (*message_)[strings::msg_params][strings::request_type].asInt()); if (!(*message_)[strings::params].keyExists(strings::binary_data) && - mobile_apis::RequestType::PROPRIETARY == request_type) { + (mobile_apis::RequestType::PROPRIETARY == request_type || + mobile_apis::RequestType::QUERY_APPS == request_type)) { + LOG4CXX_ERROR(logger_, "Binary data empty"); SendResponse(false, mobile_apis::Result::INVALID_DATA); @@ -83,6 +87,18 @@ void SystemRequest::Run() { binary_data = (*message_)[strings::params][strings::binary_data].asBinary(); } + if (mobile_apis::RequestType::QUERY_APPS == request_type) { + using namespace NsSmartDeviceLink::NsJSONHandler::Formatters; + + smart_objects::SmartObject sm_object; + CFormatterJsonBase::jsonValueToObj(Json::Value( + std::string(binary_data.begin(), + binary_data.end())), + sm_object); + ApplicationManagerImpl::instance()->ProcessQueryApp(sm_object); + return; + } + std::string file_path = profile::Profile::instance()->system_files_path(); if (!file_system::CreateDirectoryRecursively(file_path)) { LOG4CXX_ERROR(logger_, "Cann't create folder."); @@ -125,7 +141,7 @@ void SystemRequest::Run() { } if (mobile_apis::RequestType::PROPRIETARY != request_type) { - msg_params[strings::app_id] = (application->mobile_app_id())->asString(); + msg_params[strings::app_id] = (application->mobile_app_id()); } msg_params[strings::request_type] = (*message_)[strings::msg_params][strings::request_type]; diff --git a/src/components/application_manager/src/commands/mobile/system_response.cc b/src/components/application_manager/src/commands/mobile/system_response.cc index e77ab08450..8b4fdafd1b 100644 --- a/src/components/application_manager/src/commands/mobile/system_response.cc +++ b/src/components/application_manager/src/commands/mobile/system_response.cc @@ -46,7 +46,7 @@ SystemResponse::~SystemResponse() { } void SystemResponse::Run() { - LOG4CXX_INFO(logger_, "SystemResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } diff --git a/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc index a07cfcd8f0..6199818dbe 100644 --- a/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc @@ -40,7 +40,7 @@ namespace application_manager { namespace commands { void UnregisterAppInterfaceRequest::Run() { - LOG4CXX_INFO(logger_, "UnregisterAppInterfaceRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl* app_manager = ApplicationManagerImpl::instance(); diff --git a/src/components/application_manager/src/commands/mobile/unregister_app_interface_response.cc b/src/components/application_manager/src/commands/mobile/unregister_app_interface_response.cc index 8ef0eb3ed0..49d9276d35 100644 --- a/src/components/application_manager/src/commands/mobile/unregister_app_interface_response.cc +++ b/src/components/application_manager/src/commands/mobile/unregister_app_interface_response.cc @@ -38,7 +38,7 @@ namespace application_manager { namespace commands { void UnregisterAppInterfaceResponse::Run() { - LOG4CXX_INFO(logger_, "UnregisterAppInterfaceResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); SendResponse((*message_)[strings::msg_params][strings::success].asBool()); } diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc index f22d1c0a2f..08a27dedfa 100644 --- a/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc @@ -50,7 +50,7 @@ UnsubscribeButtonRequest::~UnsubscribeButtonRequest() { } void UnsubscribeButtonRequest::Run() { - LOG4CXX_INFO(logger_, "UnsubscribeButtonRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( (*message_)[str::params][str::connection_key].asUInt()); diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc index 1331eac27f..8bece66157 100644 --- a/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc @@ -47,7 +47,7 @@ UnsubscribeButtonResponse::~UnsubscribeButtonResponse() { } void UnsubscribeButtonResponse::Run() { - LOG4CXX_INFO(logger_, "UnsubscribeButtonResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); namespace smart_objects = NsSmartDeviceLink::NsSmartObjects; diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc index fc7145078f..7d05ce328f 100644 --- a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc @@ -88,7 +88,7 @@ namespace { #endif // #ifdef HMI_DBUS_API void UnsubscribeVehicleDataRequest::Run() { - LOG4CXX_INFO(logger_, "UnsubscribeVehicleDataRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( CommandRequestImpl::connection_key()); @@ -176,7 +176,7 @@ void UnsubscribeVehicleDataRequest::Run() { } void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "UnsubscribeVehicleDataRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc index 60f7077da7..87b2e6e5e1 100644 --- a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc @@ -45,7 +45,7 @@ UnsubscribeVehicleDataResponse::~UnsubscribeVehicleDataResponse() { } void UnsubscribeVehicleDataResponse::Run() { - LOG4CXX_INFO(logger_, "UnsubscribeVehicleDataResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); namespace smart_objects = NsSmartDeviceLink::NsSmartObjects; diff --git a/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc index 9447772568..650e698bf4 100644 --- a/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc +++ b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc @@ -51,7 +51,7 @@ UpdateTurnListRequest::~UpdateTurnListRequest() { } void UpdateTurnListRequest::Run() { - LOG4CXX_INFO(logger_, "UpdateTurnListRequest::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( (*message_)[strings::params][strings::connection_key].asUInt()); @@ -141,7 +141,7 @@ void UpdateTurnListRequest::Run() { } void UpdateTurnListRequest::on_event(const event_engine::Event& event) { - LOG4CXX_INFO(logger_, "UpdateTurnListRequest::on_event"); + LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { @@ -188,7 +188,7 @@ bool UpdateTurnListRequest::CheckTurnListArray() { } bool UpdateTurnListRequest::IsWhiteSpaceExist() { - LOG4CXX_INFO(logger_, "UpdateTurnListRequest::IsWhiteSpaceExist"); + LOG4CXX_AUTO_TRACE(logger_); const char* str = NULL; if ((*message_)[strings::msg_params].keyExists(strings::turn_list)) { diff --git a/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc b/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc index ec1e0bce8a..26e5c460d3 100644 --- a/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc +++ b/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc @@ -47,7 +47,7 @@ UpdateTurnListResponse::~UpdateTurnListResponse() { } void UpdateTurnListResponse::Run() { - LOG4CXX_INFO(logger_, "UpdateTurnListResponse::Run"); + LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->SendMessageToMobile(message_); } |