summaryrefslogtreecommitdiff
path: root/SDL_Core/src/components/application_manager/src/commands/mobile
diff options
context:
space:
mode:
Diffstat (limited to 'SDL_Core/src/components/application_manager/src/commands/mobile')
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/add_command_request.cc364
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/add_command_response.cc56
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc145
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc57
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc198
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc57
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/alert_request.cc303
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/alert_response.cc59
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/change_registration_request.cc288
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/change_registration_response.cc57
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc244
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_response.cc68
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/delete_command_request.cc180
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/delete_command_response.cc56
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/delete_file_request.cc96
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/delete_file_response.cc67
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc115
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_response.cc77
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc178
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc57
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc81
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc56
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/dial_number_request.cc57
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/encoded_sync_pdata_request.cc113
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/encoded_sync_pdata_response.cc65
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc88
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc57
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/generic_response.cc65
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc104
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/get_dtcs_response.cc56
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc294
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc57
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/list_files_request.cc90
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/list_files_response.cc56
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc58
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc56
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc120
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc120
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/on_command_notification.cc76
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/on_driver_distraction_notification.cc73
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/on_encoded_sync_pdata_notification.cc105
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc74
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc60
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc73
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/on_language_change_notification.cc56
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc61
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/on_sync_pdata_notification.cc105
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc60
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/on_tbt_client_state_notification.cc72
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc72
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc88
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc193
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc58
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc763
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc57
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/put_file_request.cc188
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/put_file_response.cc69
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/read_did_request.cc111
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/read_did_response.cc56
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc573
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc72
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc339
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc57
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc159
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc55
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc109
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc59
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc350
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc58
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/set_icon_request.cc139
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/set_icon_response.cc56
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc149
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc57
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc192
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc58
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/show_request.cc261
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/show_response.cc58
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/slider_request.cc148
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/slider_response.cc56
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/speak_request.cc120
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/speak_response.cc58
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc80
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/subscribe_button_response.cc66
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc276
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc56
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/sync_pdata_request.cc103
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/sync_pdata_response.cc67
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/system_request.cc72
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/system_response.cc56
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc59
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/unregister_app_interface_response.cc47
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc79
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc69
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc272
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc66
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc172
-rw-r--r--SDL_Core/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc57
97 files changed, 11565 insertions, 0 deletions
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/add_command_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/add_command_request.cc
new file mode 100644
index 000000000..78bc47c06
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/add_command_request.cc
@@ -0,0 +1,364 @@
+/*
+
+ 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 <string>
+#include "application_manager/commands/mobile/add_command_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application.h"
+#include "application_manager/message_helper.h"
+#include "utils/file_system.h"
+
+namespace application_manager {
+
+namespace commands {
+
+AddCommandRequest::AddCommandRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message),
+ is_ui_send_(false),
+ is_vr_send_(false),
+ is_ui_received_(false),
+ is_vr_received_(false),
+ ui_result_(hmi_apis::Common_Result::INVALID_ENUM),
+ vr_result_(hmi_apis::Common_Result::INVALID_ENUM) {
+}
+
+AddCommandRequest::~AddCommandRequest() {
+}
+
+void AddCommandRequest::Run() {
+ LOG4CXX_INFO(logger_, "AddCommandRequest::Run");
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::params][strings::connection_key].asUInt());
+
+ if (!app) {
+ LOG4CXX_ERROR_EXT(logger_, "No application associated with session key");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ mobile_apis::Result::eType verification_result =
+ MessageHelper::VerifyImageFiles((*message_)[strings::msg_params], app);
+
+ if (mobile_apis::Result::SUCCESS != verification_result) {
+ LOG4CXX_ERROR_EXT(
+ logger_,
+ "MessageHelper::VerifyImageFiles return " << verification_result);
+ SendResponse(false, verification_result);
+ return;
+ }
+
+ if (!((*message_)[strings::msg_params].keyExists(strings::cmd_id))) {
+ LOG4CXX_ERROR_EXT(logger_, "INVALID_DATA");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+
+ if (app->FindCommand(
+ (*message_)[strings::msg_params][strings::cmd_id].asUInt())) {
+ LOG4CXX_ERROR_EXT(logger_, "INVALID_ID");
+ SendResponse(false, mobile_apis::Result::INVALID_ID);
+ return;
+ }
+
+ bool data_exist = false;
+
+ if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) {
+ if (!CheckCommandName(app)) {
+ SendResponse(false, mobile_apis::Result::DUPLICATE_NAME);
+ return;
+ }
+ if ((*message_)[strings::msg_params][strings::menu_params].keyExists(
+ hmi_request::parent_id)) {
+ if (!CheckCommandParentId(app)) {
+ SendResponse(false, mobile_apis::Result::INVALID_ID,
+ "Parent ID doesn't exist");
+ return;
+ }
+ }
+ data_exist = true;
+ }
+
+ if (((*message_)[strings::msg_params].keyExists(strings::vr_commands))
+ && ((*message_)[strings::msg_params]
+ [strings::vr_commands].length() > 0)) {
+
+ if (!CheckCommandVRSynonym(app)) {
+ SendResponse(false, mobile_apis::Result::DUPLICATE_NAME);
+ return;
+ }
+
+ if (!CheckVRCommandsNames()) {
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+ data_exist = true;
+ }
+
+ if (!data_exist) {
+ LOG4CXX_ERROR_EXT(logger_, "INVALID_DATA");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+
+ if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) {
+ if (!CheckMenuName()) {
+ LOG4CXX_ERROR_EXT(logger_, "MenuName is invalid");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ msg_params[strings::cmd_id] =
+ (*message_)[strings::msg_params][strings::cmd_id];
+ msg_params[strings::menu_params] =
+ (*message_)[strings::msg_params][strings::menu_params];
+
+ msg_params[strings::app_id] = app->app_id();
+
+ if ( ((*message_)[strings::msg_params].keyExists(strings::cmd_icon))
+ && ((*message_)[strings::msg_params][strings::cmd_icon].keyExists(strings::value))
+ && (0 < (*message_)[strings::msg_params][strings::cmd_icon]
+ [strings::value].length())) {
+ msg_params[strings::cmd_icon] =
+ (*message_)[strings::msg_params][strings::cmd_icon];
+ }
+
+ is_ui_send_ = true;
+
+ SendHMIRequest(hmi_apis::FunctionID::UI_AddCommand, &msg_params, true);
+ }
+
+ if ((*message_)[strings::msg_params].keyExists(strings::vr_commands)) {
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ msg_params[strings::cmd_id] =
+ (*message_)[strings::msg_params][strings::cmd_id];
+ msg_params[strings::vr_commands] =
+ (*message_)[strings::msg_params][strings::vr_commands];
+ msg_params[strings::app_id] = app->app_id();
+
+ is_vr_send_ = true;
+
+ SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &msg_params, true);
+ }
+}
+
+bool AddCommandRequest::CheckCommandName(ApplicationConstSharedPtr app) {
+ if (!app) {
+ return false;
+ }
+
+ const CommandsMap& commands = app->commands_map();
+ CommandsMap::const_iterator i = commands.begin();
+
+ for (; commands.end() != i; ++i) {
+
+ if(!(*i->second).keyExists(strings::menu_params)) {
+ continue;
+ }
+
+ if ((*i->second)[strings::menu_params][strings::menu_name].asString()
+ == (*message_)[strings::msg_params][strings::menu_params]
+ [strings::menu_name].asString()) {
+ LOG4CXX_INFO(logger_, "AddCommandRequest::CheckCommandName received"
+ " command name already exist");
+ return false;
+ }
+ }
+ return true;
+}
+
+bool AddCommandRequest::CheckCommandVRSynonym(ApplicationConstSharedPtr app) {
+ if (!app) {
+ return false;
+ }
+
+ const CommandsMap& commands = app->commands_map();
+ CommandsMap::const_iterator it = commands.begin();
+
+ for (; commands.end() != it; ++it) {
+
+ if(!(*it->second).keyExists(strings::vr_commands)) {
+ continue;
+ }
+
+ for (size_t i = 0; i < (*it->second)[strings::vr_commands].length(); ++i) {
+ for (size_t j = 0;
+ j < (*message_)[strings::msg_params][strings::vr_commands].length();
+ ++j) {
+ std::string vr_cmd_i =
+ (*it->second)[strings::vr_commands][i].asString();
+ std::string vr_cmd_j =
+ (*message_)[strings::msg_params]
+ [strings::vr_commands][j].asString();
+
+ if (0 == strcasecmp(vr_cmd_i.c_str(), vr_cmd_j.c_str())) {
+ LOG4CXX_INFO(logger_, "AddCommandRequest::CheckCommandVRSynonym"
+ " received command vr synonym already exist");
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+}
+
+bool AddCommandRequest::CheckVRCommandsNames() {
+ for (size_t i = 0;
+ i < (*message_)[strings::msg_params][strings::vr_commands].length();
+ ++i) {
+ const std::string& str =
+ (*message_)[strings::msg_params][strings::vr_commands][i].asString();
+
+ if (!CheckSyntax(str)) {
+ LOG4CXX_INFO(logger_, "Invalid command name.");
+ return false;
+ }
+ }
+ return true;
+}
+
+bool AddCommandRequest::CheckMenuName() {
+ const std::string& str = (*message_)[strings::msg_params][strings::menu_params]
+ [strings::menu_name].asString();
+ if (!CheckSyntax(str)) {
+ LOG4CXX_INFO(logger_, "Invalid menu name.");
+ return false;
+ }
+ return true;
+}
+
+bool AddCommandRequest::CheckCommandParentId(ApplicationConstSharedPtr app) {
+ if (!app) {
+ return false;
+ }
+
+ const int32_t parent_id =
+ (*message_)[strings::msg_params][strings::menu_params]
+ [hmi_request::parent_id].asInt();
+ smart_objects::SmartObject* parent = app->FindSubMenu(parent_id);
+
+ if (!parent) {
+ LOG4CXX_INFO(logger_, "AddCommandRequest::CheckCommandParentId received"
+ " submenu doesn't exist");
+ return false;
+ }
+ return true;
+}
+
+void AddCommandRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "AddCommandRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::UI_AddCommand: {
+ LOG4CXX_INFO(logger_, "Received UI_AddCommand event");
+ is_ui_received_ = true;
+ ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+
+ if (hmi_apis::Common_Result::SUCCESS != ui_result_) {
+ (*message_)[strings::msg_params].erase(strings::menu_params);
+ }
+ break;
+ }
+ case hmi_apis::FunctionID::VR_AddCommand: {
+ LOG4CXX_INFO(logger_, "Received VR_AddCommand event");
+ is_vr_received_ = true;
+ vr_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+
+ if (hmi_apis::Common_Result::SUCCESS != vr_result_) {
+ (*message_)[strings::msg_params].erase(strings::vr_commands);
+ }
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_,"Received unknown event" << event.id());
+ return;
+ }
+ }
+
+ if (!IsPendingResponseExist()) {
+ ApplicationSharedPtr application =
+ ApplicationManagerImpl::instance()->application(connection_key());
+
+ if (!application) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ return;
+ }
+
+ smart_objects::SmartObject* command = application->FindCommand(
+ (*message_)[strings::msg_params][strings::cmd_id].asInt());
+
+ if (!command) {
+ if ((((*message_)[strings::msg_params].keyExists(strings::menu_params)) ||
+ ((*message_)[strings::msg_params].keyExists(strings::vr_commands))) &&
+ (hmi_apis::Common_Result::REJECTED != ui_result_)) {
+ application->AddCommand((*message_)[strings::msg_params]
+ [strings::cmd_id].asInt(),
+ (*message_)[strings::msg_params]);
+ }
+
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+
+ bool result = ((hmi_apis::Common_Result::SUCCESS == ui_result_) &&
+ (hmi_apis::Common_Result::SUCCESS == vr_result_)) ||
+ ((hmi_apis::Common_Result::SUCCESS == ui_result_) &&
+ (hmi_apis::Common_Result::INVALID_ENUM == vr_result_)) ||
+ ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_) &&
+ (hmi_apis::Common_Result::SUCCESS == vr_result_));
+
+ if (!result && (hmi_apis::Common_Result::REJECTED == ui_result_)) {
+ result_code = static_cast<mobile_apis::Result::eType>(ui_result_);
+ } else {
+ result_code = static_cast<mobile_apis::Result::eType>(
+ std::max(ui_result_, vr_result_));
+ }
+
+ ApplicationSharedPtr application =
+ ApplicationManagerImpl::instance()->application(connection_key());
+ SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ application->UpdateHash();
+ }
+ }
+}
+
+bool AddCommandRequest::IsPendingResponseExist() {
+ return is_ui_send_ != is_ui_received_ || is_vr_send_ != is_vr_received_;
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/add_command_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/add_command_response.cc
new file mode 100644
index 000000000..0c135af07
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/add_command_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/add_command_response.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+AddCommandResponse::AddCommandResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+AddCommandResponse::~AddCommandResponse() {
+}
+
+void AddCommandResponse::Run() {
+ LOG4CXX_INFO(logger_, "AddCommandResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc
new file mode 100644
index 000000000..b3a8b90f4
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc
@@ -0,0 +1,145 @@
+/*
+
+ 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/add_sub_menu_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application.h"
+
+namespace application_manager {
+
+namespace commands {
+
+AddSubMenuRequest::AddSubMenuRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+AddSubMenuRequest::~AddSubMenuRequest() {
+}
+
+void AddSubMenuRequest::Run() {
+ LOG4CXX_INFO(logger_, "AddSubMenuRequest::Run");
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::params][strings::connection_key].asUInt());
+
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ if (app->FindSubMenu(
+ (*message_)[strings::msg_params][strings::menu_id].asInt())) {
+ LOG4CXX_ERROR(logger_, "INVALID_ID");
+ SendResponse(false, mobile_apis::Result::INVALID_ID);
+ return;
+ }
+
+ if (app->IsSubMenuNameAlreadyExist(
+ (*message_)[strings::msg_params][strings::menu_name].asString())) {
+ LOG4CXX_ERROR(logger_, "DUPLICATE_NAME");
+ SendResponse(false, mobile_apis::Result::DUPLICATE_NAME);
+ return;
+ }
+
+ if (!CheckSubMenuName()) {
+ LOG4CXX_ERROR(logger_, "SubMenuName is not valid");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+
+ msg_params[strings::menu_id] =
+ (*message_)[strings::msg_params][strings::menu_id];
+ if ((*message_)[strings::msg_params].keyExists(strings::position)) {
+ msg_params[strings::menu_params][strings::position] =
+ (*message_)[strings::msg_params][strings::position];
+ }
+ msg_params[strings::menu_params][strings::menu_name] =
+ (*message_)[strings::msg_params][strings::menu_name];
+ msg_params[strings::app_id] = app->app_id();
+
+ SendHMIRequest(hmi_apis::FunctionID::UI_AddSubMenu, &msg_params, true);
+}
+
+void AddSubMenuRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "AddSubMenuRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::UI_AddSubMenu: {
+ 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;
+
+ ApplicationSharedPtr application =
+ ApplicationManagerImpl::instance()->application(connection_key());
+
+ if (!application) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ return;
+ }
+
+ if (result) {
+ application->AddSubMenu((*message_)[strings::msg_params]
+ [strings::menu_id].asInt(),
+ (*message_)[strings::msg_params]);
+ }
+
+ SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+}
+
+bool AddSubMenuRequest::CheckSubMenuName() {
+ const std::string& str =
+ (*message_)[strings::msg_params][strings::menu_name].asString();
+ if (!CheckSyntax(str)) {
+ LOG4CXX_INFO(logger_, "Invalid subMenu name.");
+ return false;
+ }
+ return true;
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc
new file mode 100644
index 000000000..bcd7df288
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc
@@ -0,0 +1,57 @@
+/*
+
+ 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/add_sub_menu_response.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+AddSubMenuResponse::AddSubMenuResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+AddSubMenuResponse::~AddSubMenuResponse() {
+}
+
+void AddSubMenuResponse::Run() {
+ LOG4CXX_INFO(logger_, "AddSubMenuResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc
new file mode 100644
index 000000000..4707d460d
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc
@@ -0,0 +1,198 @@
+/*
+
+ 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/alert_maneuver_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
+
+namespace application_manager {
+
+namespace commands {
+
+AlertManeuverRequest::AlertManeuverRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message),
+ result_(mobile_apis::Result::INVALID_ENUM),
+ tts_speak_result_code_(mobile_apis::Result::INVALID_ENUM),
+ navi_alert_maneuver_result_code_(mobile_apis::Result::INVALID_ENUM) {
+}
+
+AlertManeuverRequest::~AlertManeuverRequest() {
+}
+
+void AlertManeuverRequest::Run() {
+ LOG4CXX_INFO(logger_, "AlertManeuverRequest::Run");
+
+ if ((!(*message_)[strings::msg_params].keyExists(strings::soft_buttons)) &&
+ (!(*message_)[strings::msg_params].keyExists(strings::tts_chunks))) {
+ LOG4CXX_ERROR(logger_, "AlertManeuverRequest::Request without parameters!");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::params][strings::connection_key].asUInt());
+
+ if (NULL == app.get()) {
+ LOG4CXX_ERROR(logger_, "Application is not registered");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ mobile_apis::Result::eType processing_result =
+ MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app);
+
+ if (mobile_apis::Result::SUCCESS != processing_result) {
+ if (mobile_apis::Result::INVALID_DATA == processing_result) {
+ LOG4CXX_ERROR(logger_, "Wrong soft buttons parameters!");
+ SendResponse(false, processing_result);
+ return;
+ }
+ if (mobile_apis::Result::UNSUPPORTED_RESOURCE == processing_result) {
+ LOG4CXX_ERROR(logger_, "UNSUPPORTED_RESOURCE!");
+ result_ = processing_result;
+ }
+ }
+
+ // Checking parameters and how many HMI requests should be sent
+ bool tts_is_ok = false;
+
+ // check TTSChunk parameter
+ if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) {
+ if (0 < (*message_)[strings::msg_params][strings::tts_chunks].length()) {
+ pending_requests_.Add(hmi_apis::FunctionID::TTS_Speak);
+ tts_is_ok = true;
+ }
+ }
+
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+
+ if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) {
+ msg_params[hmi_request::soft_buttons] =
+ (*message_)[strings::msg_params][strings::soft_buttons];
+ }
+
+ pending_requests_.Add(hmi_apis::FunctionID::Navigation_AlertManeuver);
+ SendHMIRequest(hmi_apis::FunctionID::Navigation_AlertManeuver,
+ &msg_params,
+ true);
+
+ if (tts_is_ok) {
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+
+ msg_params[hmi_request::tts_chunks] =
+ (*message_)[strings::msg_params][strings::tts_chunks];
+
+ msg_params[strings::app_id] = app->app_id();
+ SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, &msg_params, true);
+ }
+}
+
+void AlertManeuverRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "AlertManeuverRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+ hmi_apis::FunctionID::eType event_id = event.id();
+ switch (event_id) {
+ case hmi_apis::FunctionID::Navigation_AlertManeuver: {
+ LOG4CXX_INFO(logger_, "Received Navigation_AlertManeuver event");
+
+ pending_requests_.Remove(event_id);
+
+ navi_alert_maneuver_result_code_ =
+ static_cast<mobile_apis::Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+
+ break;
+ }
+ case hmi_apis::FunctionID::TTS_Speak: {
+ LOG4CXX_INFO(logger_, "Received TTS_Speak event");
+
+ pending_requests_.Remove(event_id);
+
+ tts_speak_result_code_ =
+ static_cast<mobile_apis::Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_,"Received unknown event" << event.id());
+ SendResponse(false, result_code, "Received unknown event");
+ return;
+ }
+ }
+
+ if (pending_requests_.IsFinal(event_id)) {
+
+ bool result = ((hmi_apis::Common_Result::SUCCESS ==
+ static_cast<hmi_apis::Common_Result::eType>(tts_speak_result_code_)) &&
+ (hmi_apis::Common_Result::SUCCESS ==
+ static_cast<hmi_apis::Common_Result::eType>(navi_alert_maneuver_result_code_))) ||
+ ((hmi_apis::Common_Result::INVALID_ENUM ==
+ static_cast<hmi_apis::Common_Result::eType>(tts_speak_result_code_)) &&
+ (hmi_apis::Common_Result::SUCCESS ==
+ static_cast<hmi_apis::Common_Result::eType>(navi_alert_maneuver_result_code_)));
+
+ mobile_apis::Result::eType result_code =
+ static_cast<mobile_apis::Result::eType>(std::max(tts_speak_result_code_,
+ navi_alert_maneuver_result_code_));
+
+ const char* return_info = NULL;
+
+ if (result) {
+ if (mobile_apis::Result::INVALID_ENUM != result_) {
+ result_code = result_;
+ } else if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE ==
+ static_cast<hmi_apis::Common_Result::eType>(result_code)) {
+ result_code = mobile_apis::Result::WARNINGS;
+ return_info =
+ std::string("Unsupported phoneme type sent in a prompt").c_str();
+ }
+ }
+
+ SendResponse(result, result_code, return_info,
+ &(message[strings::msg_params]));
+ } else {
+ LOG4CXX_INFO(logger_,
+ "There are some pending responses from HMI."
+ "AlertManeuverRequest still waiting.");
+ }
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc
new file mode 100644
index 000000000..99fcde69a
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc
@@ -0,0 +1,57 @@
+/*
+
+ 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/alert_maneuver_response.h"
+#include "application_manager/application_manager_impl.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+AlertManeuverResponse::AlertManeuverResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+AlertManeuverResponse::~AlertManeuverResponse() {
+}
+
+void AlertManeuverResponse::Run() {
+ LOG4CXX_INFO(logger_, "AlertManeuverResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/alert_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/alert_request.cc
new file mode 100644
index 000000000..3201669a9
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/alert_request.cc
@@ -0,0 +1,303 @@
+/*
+
+ 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/alert_request.h"
+
+#include "application_manager/application_impl.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/message_helper.h"
+#include <interfaces/HMI_API.h>
+
+namespace application_manager {
+
+namespace commands {
+
+namespace smart_objects = NsSmartDeviceLink::NsSmartObjects;
+
+AlertRequest::AlertRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message),
+ awaiting_ui_alert_response_(false),
+ awaiting_tts_speak_response_(false),
+ awaiting_tts_stop_speaking_response_(false),
+ response_success_(false),
+ flag_other_component_sent_(false),
+ response_result_(mobile_apis::Result::SUCCESS),
+ tts_speak_response_(mobile_apis::Result::INVALID_ENUM) {
+ subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout);
+}
+
+AlertRequest::~AlertRequest() {
+}
+
+bool AlertRequest::Init() {
+
+ /* Timeout in milliseconds.
+ If omitted a standard value of 10000 milliseconds is used.*/
+ if ((*message_)[strings::msg_params].keyExists(strings::duration)) {
+ default_timeout_ =
+ (*message_)[strings::msg_params][strings::duration].asUInt();
+ } else {
+ const int32_t def_value = 5000;
+ default_timeout_ = def_value;
+ }
+
+ return true;
+}
+
+void AlertRequest::Run() {
+ LOG4CXX_INFO(logger_, "AlertRequest::Run");
+
+ uint32_t app_id = (*message_)[strings::params][strings::connection_key]
+ .asInt();
+
+ if (!Validate(app_id)) {
+ // Invalid command, abort execution
+ return;
+ }
+
+ awaiting_ui_alert_response_ = true;
+ if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) {
+ if (0 < (*message_)[strings::msg_params][strings::tts_chunks].length()) {
+ awaiting_tts_speak_response_ = true;
+ }
+ }
+ SendAlertRequest(app_id);
+ SendPlayToneNotification(app_id);
+ if (awaiting_tts_speak_response_) {
+ SendSpeakRequest(app_id);
+ }
+}
+
+void AlertRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "AlertRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::UI_OnResetTimeout: {
+ LOG4CXX_INFO(logger_, "Received UI_OnResetTimeout event " << awaiting_tts_speak_response_ << " "
+ << awaiting_tts_stop_speaking_response_ << " " << awaiting_ui_alert_response_);
+ ApplicationManagerImpl::instance()->updateRequestTimeout(
+ connection_key(), correlation_id(), default_timeout());
+ break;
+ }
+ case hmi_apis::FunctionID::UI_Alert: {
+ LOG4CXX_INFO(logger_, "Received UI_Alert event");
+ DCHECK(awaiting_ui_alert_response_);
+ awaiting_ui_alert_response_ = false;
+
+ if (awaiting_tts_speak_response_) {
+ awaiting_tts_stop_speaking_response_ = true;
+ SendHMIRequest(hmi_apis::FunctionID::TTS_StopSpeaking, NULL, true);
+ }
+
+ mobile_apis::Result::eType result_code =
+ static_cast<mobile_apis::Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ // Mobile Alert request is successful when UI_Alert is successful
+ response_success_ = mobile_apis::Result::SUCCESS == result_code;
+ if (!response_success_) {
+ response_result_ = result_code;
+ }
+ response_params_ = message[strings::msg_params];
+ break;
+ }
+ case hmi_apis::FunctionID::TTS_Speak: {
+ LOG4CXX_INFO(logger_, "Received TTS_Speak event");
+ DCHECK(awaiting_tts_speak_response_);
+ awaiting_tts_speak_response_ = false;
+ tts_speak_response_ = static_cast<mobile_apis::Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ break;
+ }
+ case hmi_apis::FunctionID::TTS_StopSpeaking: {
+ LOG4CXX_INFO(logger_, "Received TTS_StopSpeaking event");
+ DCHECK(awaiting_tts_stop_speaking_response_);
+ awaiting_tts_stop_speaking_response_ = false;
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_,"Received unknown event" << event.id());
+ return;
+ }
+ }
+ if (!HasHmiResponsesToWait()) {
+ std::string response_info("");
+ if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == tts_speak_response_) &&
+ (!flag_other_component_sent_) && response_success_) {
+ response_success_ = false;
+ response_result_ = mobile_apis::Result::WARNINGS;
+ response_info = "Unsupported phoneme type sent in a prompt";
+ } else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE ==
+ tts_speak_response_) && (mobile_apis::Result::UNSUPPORTED_RESOURCE ==
+ response_result_) && response_success_) {
+ response_result_ = mobile_apis::Result::WARNINGS;
+ response_info = "Unsupported phoneme type sent in a prompt and "
+ "unsupported image sent in soft buttons";
+ } else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE ==
+ tts_speak_response_) && response_success_) {
+ response_result_ = mobile_apis::Result::WARNINGS;
+ response_info = "Unsupported phoneme type sent in a prompt";
+ }
+ SendResponse(response_success_, response_result_,
+ response_info.empty() ? NULL : response_info.c_str(),
+ &response_params_);
+ }
+}
+
+bool AlertRequest::Validate(uint32_t app_id) {
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+
+ if (!app) {
+ LOG4CXX_ERROR_EXT(logger_, "No application associated with session key");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return false;
+ }
+
+ mobile_apis::Result::eType processing_result =
+ MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app);
+
+ if (mobile_apis::Result::SUCCESS != processing_result) {
+ if (mobile_apis::Result::INVALID_DATA == processing_result) {
+ LOG4CXX_ERROR(logger_, "INVALID_DATA!");
+ SendResponse(false, processing_result);
+ return false;
+ }
+ if (mobile_apis::Result::UNSUPPORTED_RESOURCE == processing_result) {
+ LOG4CXX_ERROR(logger_, "UNSUPPORTED_RESOURCE!");
+ response_result_ = processing_result;
+ }
+ }
+
+ // check if mandatory params(alertText1 and TTSChunk) specified
+ if ((!(*message_)[strings::msg_params].keyExists(strings::alert_text1))
+ && (!(*message_)[strings::msg_params].keyExists(strings::alert_text2))
+ && (!(*message_)[strings::msg_params].keyExists(strings::tts_chunks)
+ && (1 > (*message_)[strings::msg_params]
+ [strings::tts_chunks].length()))) {
+ LOG4CXX_ERROR_EXT(logger_, "Mandatory parameters are missing");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA,
+ "Mandatory parameters are missing");
+ return false;
+ }
+
+ return true;
+}
+
+void AlertRequest::SendAlertRequest(int32_t app_id) {
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+
+ msg_params[hmi_request::alert_strings] = smart_objects::SmartObject(
+ smart_objects::SmartType_Array);
+
+ int32_t index = 0;
+ if ((*message_)[strings::msg_params].keyExists(strings::alert_text1)) {
+ msg_params[hmi_request::alert_strings][index][hmi_request::field_name] =
+ TextFieldName::ALERT_TEXT1;
+ msg_params[hmi_request::alert_strings][index][hmi_request::field_text] =
+ (*message_)[strings::msg_params][strings::alert_text1];
+ index++;
+ }
+ if ((*message_)[strings::msg_params].keyExists(strings::alert_text2)) {
+ msg_params[hmi_request::alert_strings][index][hmi_request::field_name] =
+ TextFieldName::ALERT_TEXT2;
+ msg_params[hmi_request::alert_strings][index][hmi_request::field_text] =
+ (*message_)[strings::msg_params][strings::alert_text2];
+ index++;
+ }
+ if ((*message_)[strings::msg_params].keyExists(strings::alert_text3)) {
+ msg_params[hmi_request::alert_strings][index][hmi_request::field_name] =
+ TextFieldName::ALERT_TEXT3;
+ msg_params[hmi_request::alert_strings][index][hmi_request::field_text] =
+ (*message_)[strings::msg_params][strings::alert_text3];
+ }
+
+ // softButtons
+ if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) {
+ msg_params[hmi_request::soft_buttons] =
+ (*message_)[strings::msg_params][strings::soft_buttons];
+ }
+ // app_id
+ msg_params[strings::app_id] = app_id;
+ msg_params[strings::duration] = default_timeout_;
+
+ // NAVI platform progressIndicator
+ if ((*message_)[strings::msg_params].keyExists(strings::progress_indicator)) {
+ msg_params[strings::progress_indicator] =
+ (*message_)[strings::msg_params][strings::progress_indicator];
+ }
+ if (msg_params[hmi_request::alert_strings].length() > 0 ||
+ msg_params.keyExists(hmi_request::soft_buttons)) {
+ flag_other_component_sent_ = true;
+ }
+ SendHMIRequest(hmi_apis::FunctionID::UI_Alert, &msg_params, true);
+}
+
+void AlertRequest::SendSpeakRequest(int32_t app_id) {
+
+ // crate HMI speak request
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+
+ msg_params[hmi_request::tts_chunks] = smart_objects::SmartObject(
+ smart_objects::SmartType_Array);
+ msg_params[hmi_request::tts_chunks] =
+ (*message_)[strings::msg_params][strings::tts_chunks];
+ msg_params[strings::app_id] = app_id;
+ SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, &msg_params, true);
+}
+
+void AlertRequest::SendPlayToneNotification(int32_t app_id) {
+ LOG4CXX_INFO(logger_, "AlertRequest::SendPlayToneNotification");
+
+ // 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);
+ }
+ }
+}
+
+bool AlertRequest::HasHmiResponsesToWait() {
+ return awaiting_ui_alert_response_ || awaiting_tts_speak_response_
+ || awaiting_tts_stop_speaking_response_;
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/alert_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/alert_response.cc
new file mode 100644
index 000000000..5b8cd6557
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/alert_response.cc
@@ -0,0 +1,59 @@
+/*
+
+ 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/alert_response.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+AlertResponse::AlertResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+AlertResponse::~AlertResponse() {
+}
+
+void AlertResponse::Run() {
+ LOG4CXX_INFO(logger_, "AlertResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/change_registration_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/change_registration_request.cc
new file mode 100644
index 000000000..67d307bd1
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/change_registration_request.cc
@@ -0,0 +1,288 @@
+/*
+
+ 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 <algorithm>
+#include "application_manager/commands/mobile/change_registration_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+ChangeRegistrationRequest::ChangeRegistrationRequest(
+ const MessageSharedPtr& message)
+ : CommandRequestImpl(message),
+ ui_result_(hmi_apis::Common_Result::INVALID_ENUM),
+ tts_result_(hmi_apis::Common_Result::INVALID_ENUM),
+ vr_result_(hmi_apis::Common_Result::INVALID_ENUM) {
+}
+
+ChangeRegistrationRequest::~ChangeRegistrationRequest() {
+}
+
+void ChangeRegistrationRequest::Run() {
+ LOG4CXX_INFO(logger_, "ChangeRegistrationRequest::Run");
+
+ ApplicationManagerImpl* instance = ApplicationManagerImpl::instance();
+ const HMICapabilities& hmi_capabilities = instance->hmi_capabilities();
+
+ ApplicationSharedPtr app = instance->application(connection_key());
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ if (!hmi_capabilities.is_ui_cooperating()) {
+ ui_result_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ }
+
+ if (!hmi_capabilities.is_vr_cooperating()) {
+ vr_result_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ }
+
+ if (!hmi_capabilities.is_tts_cooperating()) {
+ tts_result_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ }
+
+ const int32_t hmi_language =
+ (*message_)[strings::msg_params][strings::hmi_display_language].asInt();
+
+ const int32_t language =
+ (*message_)[strings::msg_params][strings::language].asInt();
+
+ if (false ==
+ (IsLanguageSupportedByUI(hmi_language) &&
+ IsLanguageSupportedByVR(language) &&
+ IsLanguageSupportedByTTS(language))) {
+ LOG4CXX_ERROR(logger_, "Language is not supported");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ return;
+ }
+
+ pending_requests_.Add(hmi_apis::FunctionID::UI_ChangeRegistration);
+ pending_requests_.Add(hmi_apis::FunctionID::VR_ChangeRegistration);
+ pending_requests_.Add(hmi_apis::FunctionID::TTS_ChangeRegistration);
+
+ // UI processing
+ smart_objects::SmartObject ui_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+
+ ui_params[strings::language] = hmi_language;
+ ui_params[strings::app_id] = app->app_id();
+
+ SendHMIRequest(hmi_apis::FunctionID::UI_ChangeRegistration,
+ &ui_params, true);
+
+ // VR processing
+ smart_objects::SmartObject vr_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ vr_params[strings::language] =
+ (*message_)[strings::msg_params][strings::language];
+
+ vr_params[strings::app_id] = app->app_id();
+
+ SendHMIRequest(hmi_apis::FunctionID::VR_ChangeRegistration,
+ &vr_params, true);
+
+ // TTS processing
+ smart_objects::SmartObject tts_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ tts_params[strings::language] =
+ (*message_)[strings::msg_params][strings::language];
+
+ tts_params[strings::app_id] = app->app_id();
+
+ SendHMIRequest(hmi_apis::FunctionID::TTS_ChangeRegistration,
+ &tts_params, true);
+}
+
+bool ChangeRegistrationRequest::WasAnySuccess(
+ 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 == tts;
+}
+
+void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "ChangeRegistrationRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ hmi_apis::FunctionID::eType event_id = event.id();
+
+ switch (event_id) {
+ case hmi_apis::FunctionID::UI_ChangeRegistration: {
+ LOG4CXX_INFO(logger_, "Received UI_ChangeRegistration event");
+ pending_requests_.Remove(event_id);
+ ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ break;
+ }
+ case hmi_apis::FunctionID::VR_ChangeRegistration: {
+ LOG4CXX_INFO(logger_, "Received VR_ChangeRegistration event");
+ pending_requests_.Remove(event_id);
+ vr_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ break;
+ }
+ case hmi_apis::FunctionID::TTS_ChangeRegistration: {
+ LOG4CXX_INFO(logger_, "Received TTS_ChangeRegistration event");
+ pending_requests_.Remove(event_id);
+ tts_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event_id);
+ return;
+ }
+ }
+
+ if (pending_requests_.IsFinal(event_id)) {
+ ApplicationSharedPtr application =
+ ApplicationManagerImpl::instance()->application(connection_key());
+
+ if (!application) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ return;
+ }
+
+ if (hmi_apis::Common_Result::SUCCESS == ui_result_) {
+ application->set_ui_language(static_cast<mobile_api::Language::eType>(
+ (*message_)[strings::msg_params][strings::hmi_display_language].asInt()));
+ }
+
+ if (hmi_apis::Common_Result::SUCCESS == vr_result_
+ || hmi_apis::Common_Result::SUCCESS == tts_result_) {
+ application->set_language(static_cast<mobile_api::Language::eType>(
+ (*message_)[strings::msg_params][strings::language].asInt()));
+ }
+
+ int32_t greates_result_code = std::max(std::max(ui_result_, vr_result_),
+ tts_result_);
+
+ (*message_)[strings::params][strings::function_id] =
+ mobile_apis::FunctionID::eType::ChangeRegistrationID;
+
+ SendResponse(WasAnySuccess(ui_result_, vr_result_, tts_result_),
+ static_cast<mobile_apis::Result::eType>(greates_result_code),
+ NULL, &(message[strings::msg_params]));
+ } else {
+ LOG4CXX_INFO(logger_,
+ "There are some pending responses from HMI."
+ "ChangeRegistrationRequest still waiting.");
+ }
+}
+
+bool ChangeRegistrationRequest::IsLanguageSupportedByUI(
+ const int32_t& hmi_display_lang) {
+
+ const HMICapabilities& hmi_capabilities =
+ ApplicationManagerImpl::instance()->hmi_capabilities();
+ const smart_objects::SmartObject* ui_languages =
+ hmi_capabilities.ui_supported_languages();
+
+ if (!ui_languages) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ return false;
+ }
+
+ for (size_t i = 0; i < ui_languages->length(); ++i) {
+ if (hmi_display_lang == ui_languages->getElement(i).asInt()) {
+ return true;
+ }
+ }
+
+ LOG4CXX_ERROR(logger_, "Language isn't supported by UI");
+
+ return false;
+}
+
+bool ChangeRegistrationRequest::IsLanguageSupportedByVR(
+ const int32_t& hmi_display_lang) {
+ const HMICapabilities& hmi_capabilities =
+ ApplicationManagerImpl::instance()->hmi_capabilities();
+ const smart_objects::SmartObject* vr_languages =
+ hmi_capabilities.vr_supported_languages();
+
+ if (!vr_languages) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ return false;
+ }
+
+ for (size_t i = 0; i < vr_languages->length(); ++i) {
+ if (hmi_display_lang == vr_languages->getElement(i).asInt()) {
+ return true;
+ }
+ }
+
+ LOG4CXX_ERROR(logger_, "Language isn't supported by VR");
+
+ return false;
+}
+
+bool ChangeRegistrationRequest::IsLanguageSupportedByTTS(
+ const int32_t& hmi_display_lang) {
+ const HMICapabilities& hmi_capabilities =
+ ApplicationManagerImpl::instance()->hmi_capabilities();
+ const smart_objects::SmartObject* tts_languages =
+ hmi_capabilities.tts_supported_languages();
+
+ if (!tts_languages) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ return false;
+ }
+
+ for (size_t i = 0; i < tts_languages->length(); ++i) {
+ if (hmi_display_lang == tts_languages->getElement(i).asInt()) {
+ return true;
+ break;
+ }
+ }
+
+ LOG4CXX_ERROR(logger_, "Language isn't supported by TTS");
+ return false;
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/change_registration_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/change_registration_response.cc
new file mode 100644
index 000000000..13c926ec8
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/change_registration_response.cc
@@ -0,0 +1,57 @@
+/*
+
+ 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/change_registration_response.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+ChangeRegistrationResponse::ChangeRegistrationResponse(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+ChangeRegistrationResponse::~ChangeRegistrationResponse() {
+}
+
+void ChangeRegistrationResponse::Run() {
+ LOG4CXX_INFO(logger_, "ChangeRegistrationResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc
new file mode 100644
index 000000000..ae8865679
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc
@@ -0,0 +1,244 @@
+/*
+
+ 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 <string.h>
+#include <string>
+#include <algorithm>
+#include <vector>
+#include "application_manager/commands/mobile/create_interaction_choice_set_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
+
+namespace application_manager {
+
+namespace commands {
+
+CreateInteractionChoiceSetRequest::CreateInteractionChoiceSetRequest(
+ const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+CreateInteractionChoiceSetRequest::~CreateInteractionChoiceSetRequest() {
+}
+
+void CreateInteractionChoiceSetRequest::Run() {
+ LOG4CXX_INFO(logger_, "CreateInteractionChoiceSetRequest::Run");
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::params][strings::connection_key].asUInt());
+
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ mobile_apis::Result::eType verification_result =
+ MessageHelper::VerifyImageFiles((*message_)[strings::msg_params], app);
+
+ mobile_apis::Result::eType result_ = mobile_apis::Result::SUCCESS;
+ if (mobile_apis::Result::SUCCESS != verification_result) {
+ if (mobile_apis::Result::INVALID_DATA == verification_result) {
+ LOG4CXX_ERROR(logger_, "VerifyImageFiles INVALID_DATA!");
+ SendResponse(false, verification_result);
+ return;
+ }
+ if (mobile_apis::Result::UNSUPPORTED_RESOURCE == verification_result) {
+ LOG4CXX_ERROR(logger_, "VerifyImageFiles UNSUPPORTED_RESOURCE!");
+ result_ = verification_result;
+ }
+ }
+
+ const int32_t choice_set_id = (*message_)[strings::msg_params]
+ [strings::interaction_choice_set_id].asInt();
+
+ if (app->FindChoiceSet(choice_set_id)) {
+ LOG4CXX_ERROR(logger_, "Invalid ID");
+ SendResponse(false, mobile_apis::Result::INVALID_ID);
+ return;
+ }
+
+ mobile_apis::Result::eType result = CheckChoiceSet(app);
+ if (mobile_apis::Result::SUCCESS != result) {
+ SendResponse(false, result);
+ return;
+ }
+
+ app->AddChoiceSet(choice_set_id, (*message_)[strings::msg_params]);
+
+ SendResponse(true, result_);
+ app->UpdateHash();
+}
+
+mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet(
+ ApplicationConstSharedPtr app) {
+ LOG4CXX_INFO(logger_, "CreateInteractionChoiceSetRequest::CheckChoiceSet");
+
+ const smart_objects::SmartArray* new_choice_set_array =
+ (*message_)[strings::msg_params][strings::choice_set].asArray();
+
+ smart_objects::SmartArray::const_iterator it_array =
+ new_choice_set_array->begin();
+
+ smart_objects::SmartArray::const_iterator it_array_end =
+ new_choice_set_array->end();
+
+ // Self check of new choice set for params coincidence
+ for (; it_array != it_array_end; ++it_array) {
+
+ CoincidencePredicateChoiceID c((*it_array)[strings::choice_id].asInt());
+ if (1 != std::count_if(
+ new_choice_set_array->begin(),
+ new_choice_set_array->end(),
+ c)) {
+
+ LOG4CXX_ERROR(logger_, "Incoming choice set has duplicate IDs.");
+ return mobile_apis::Result::INVALID_ID;
+ }
+
+ // Check new choice set params along with already registered choice sets
+ const ChoiceSetMap& app_choice_set_map = app->choice_set_map();
+ ChoiceSetMap::const_iterator it = app_choice_set_map.begin();
+ ChoiceSetMap::const_iterator itEnd = app_choice_set_map.end();
+ for (; it != itEnd; ++it) {
+ const smart_objects::SmartObject* app_choice_set = it->second;
+ if (NULL != app_choice_set) {
+
+ const smart_objects::SmartArray* curr_choice_set =
+ (*app_choice_set)[strings::choice_set].asArray();
+
+ if (0 != std::count_if(
+ curr_choice_set->begin(),
+ curr_choice_set->end(),
+ c)) {
+ LOG4CXX_ERROR(logger_, "Incoming choice ID already exists.");
+ return mobile_apis::Result::INVALID_ID;
+ }
+ }
+ }
+
+ CoincidencePredicateMenuName m((*it_array)[strings::menu_name].asString());
+ if (1 != std::count_if(
+ new_choice_set_array->begin(),
+ new_choice_set_array->end(),
+ m)) {
+
+ LOG4CXX_ERROR(logger_, "Incoming choice set has duplicate menu names.");
+ return mobile_apis::Result::DUPLICATE_NAME;
+ }
+
+ // Check coincidence inside the current choice
+ const smart_objects::SmartArray* vr_array =
+ (*it_array)[strings::vr_commands].asArray();
+
+ smart_objects::SmartArray::const_iterator it_vr = vr_array->begin();
+ smart_objects::SmartArray::const_iterator it_vr_end = vr_array->end();
+
+ for (; it_vr != it_vr_end; ++it_vr) {
+ CoincidencePredicateVRCommands v((*it_vr));
+ if (1 != std::count_if(vr_array->begin(), vr_array->end(), v)) {
+
+ LOG4CXX_ERROR(logger_,
+ "Incoming choice set has duplicate VR command(s)");
+
+ return mobile_apis::Result::DUPLICATE_NAME;
+ }
+ }
+
+ // Check along with VR commands in other choices in the new set
+ smart_objects::SmartArray::const_iterator it_same_array =
+ new_choice_set_array->begin();
+
+ smart_objects::SmartArray::const_iterator it_same_array_end =
+ new_choice_set_array->end();
+
+ for (; it_same_array != it_same_array_end; ++it_same_array) {
+
+ // Skip check for itself
+ if ((*it_array)[strings::choice_id] ==
+ (*it_same_array)[strings::choice_id]) {
+
+ continue;
+ }
+
+ if (compareSynonyms((*it_array), (*it_same_array))) {
+
+ LOG4CXX_ERROR(logger_,
+ "Incoming choice set has duplicate VR command(s).");
+
+ return mobile_apis::Result::DUPLICATE_NAME;
+ }
+ }
+ }
+
+ return mobile_apis::Result::SUCCESS;
+}
+
+bool CreateInteractionChoiceSetRequest::compareSynonyms(
+ const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice1,
+ const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice2) {
+
+ smart_objects::SmartArray* vr_cmds_1 =
+ choice1[strings::vr_commands].asArray();
+ DCHECK(vr_cmds_1 != NULL);
+ smart_objects::SmartArray* vr_cmds_2 =
+ choice2[strings::vr_commands].asArray();
+ DCHECK(vr_cmds_2 != NULL);
+
+ smart_objects::SmartArray::iterator it;
+ it = std::find_first_of(vr_cmds_1->begin(), vr_cmds_1->end(),
+ vr_cmds_2->begin(), vr_cmds_2->end(),
+ CreateInteractionChoiceSetRequest::compareStr);
+
+
+ if (it != vr_cmds_1->end()) {
+ LOG4CXX_INFO(logger_, "Incoming choice set has duplicated VR synonyms "
+ << it->asString());
+ return true;
+ }
+
+ return false;
+}
+
+bool CreateInteractionChoiceSetRequest::compareStr(
+ const NsSmartDeviceLink::NsSmartObjects::SmartObject& str1,
+ const NsSmartDeviceLink::NsSmartObjects::SmartObject& str2) {
+
+ return 0 == strcasecmp(str1.asCharArray(), str2.asCharArray());
+}
+
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_response.cc
new file mode 100644
index 000000000..8d6ea1b34
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_response.cc
@@ -0,0 +1,68 @@
+/*
+
+ 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/create_interaction_choice_set_response.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+CreateInteractionChoiceSetResponse::CreateInteractionChoiceSetResponse(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+CreateInteractionChoiceSetResponse::~CreateInteractionChoiceSetResponse() {
+}
+
+void CreateInteractionChoiceSetResponse::Run() {
+ LOG4CXX_INFO(logger_, "CreateInteractionChoiceSetResponse::Run");
+
+ // check if response false
+ if (true == (*message_)[strings::msg_params].keyExists(strings::success)) {
+ if ((*message_)[strings::msg_params][strings::success].asBool() == false) {
+ LOG4CXX_ERROR(logger_, "Success = false");
+ SendResponse(false);
+ return;
+ }
+ }
+
+ SendResponse(true);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/delete_command_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/delete_command_request.cc
new file mode 100644
index 000000000..3f5e39641
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/delete_command_request.cc
@@ -0,0 +1,180 @@
+/*
+
+ 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/delete_command_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+DeleteCommandRequest::DeleteCommandRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message),
+ is_ui_send_(false),
+ is_vr_send_(false),
+ is_ui_received_(false),
+ is_vr_received_(false),
+ ui_result_(hmi_apis::Common_Result::INVALID_ENUM),
+ vr_result_(hmi_apis::Common_Result::INVALID_ENUM) {
+}
+
+DeleteCommandRequest::~DeleteCommandRequest() {
+}
+
+void DeleteCommandRequest::Run() {
+ LOG4CXX_INFO(logger_, "DeleteCommandRequest::Run");
+
+ ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::params][strings::connection_key].asUInt());
+
+ if (!application) {
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ LOG4CXX_ERROR(logger_, "Application is not registered");
+ return;
+ }
+
+ smart_objects::SmartObject* command = application->FindCommand(
+ (*message_)[strings::msg_params][strings::cmd_id].asInt());
+
+ if (!command) {
+ SendResponse(false, mobile_apis::Result::INVALID_ID);
+ LOG4CXX_ERROR(logger_, "Invalid ID");
+ return;
+ }
+
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+
+ msg_params[strings::cmd_id] =
+ (*message_)[strings::msg_params][strings::cmd_id];
+ msg_params[strings::app_id] = application->app_id();
+
+ // we should specify amount of required responses in the 1st request
+ uint32_t chaining_counter = 0;
+ if ((*command).keyExists(strings::menu_params)) {
+ ++chaining_counter;
+ }
+
+ if ((*command).keyExists(strings::vr_commands)) {
+ ++chaining_counter;
+ }
+
+ if ((*command).keyExists(strings::menu_params)) {
+ is_ui_send_ = true;
+
+ SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params, true);
+ }
+ // check vr params
+ if ((*command).keyExists(strings::vr_commands)) {
+ is_vr_send_ = true;
+
+ SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params, true);
+ }
+}
+
+void DeleteCommandRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "DeleteCommandRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::UI_DeleteCommand: {
+ LOG4CXX_INFO(logger_, "Received UI_DeleteCommand event");
+ is_ui_received_ = true;
+ ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+
+ break;
+ }
+ case hmi_apis::FunctionID::VR_DeleteCommand: {
+ LOG4CXX_INFO(logger_, "Received VR_DeleteCommand event");
+ is_vr_received_ = true;
+ vr_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_,"Received unknown event" << event.id());
+ return;
+ }
+ }
+
+ if (!IsPendingResponseExist()) {
+ ApplicationSharedPtr application =
+ ApplicationManagerImpl::instance()->application(connection_key());
+
+ if (!application) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ return;
+ }
+
+ smart_objects::SmartObject* command = application->FindCommand(
+ (*message_)[strings::msg_params][strings::cmd_id].asInt());
+
+ if (command) {
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+
+ bool result = ((hmi_apis::Common_Result::SUCCESS == ui_result_) &&
+ (hmi_apis::Common_Result::SUCCESS == vr_result_)) ||
+ ((hmi_apis::Common_Result::SUCCESS == ui_result_) &&
+ (hmi_apis::Common_Result::INVALID_ENUM == vr_result_)) ||
+ ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_) &&
+ (hmi_apis::Common_Result::SUCCESS == vr_result_));
+
+ if (result) {
+ application->RemoveCommand(
+ (*message_)[strings::msg_params][strings::cmd_id].asInt());
+ }
+
+ if (!result && (hmi_apis::Common_Result::REJECTED == ui_result_)) {
+ result_code = static_cast<mobile_apis::Result::eType>(vr_result_);
+ } else {
+ result_code = static_cast<mobile_apis::Result::eType>(
+ std::max(ui_result_, vr_result_));
+ }
+
+ SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ }
+ }
+}
+
+bool DeleteCommandRequest::IsPendingResponseExist() {
+ return is_ui_send_ != is_ui_received_ || is_vr_send_ != is_vr_received_;
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/delete_command_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/delete_command_response.cc
new file mode 100644
index 000000000..812e58743
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/delete_command_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/delete_command_response.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+DeleteCommandResponse::DeleteCommandResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+DeleteCommandResponse::~DeleteCommandResponse() {
+}
+
+void DeleteCommandResponse::Run() {
+ LOG4CXX_INFO(logger_, "DeleteCommandResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/delete_file_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/delete_file_request.cc
new file mode 100644
index 000000000..9fc89b25d
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/delete_file_request.cc
@@ -0,0 +1,96 @@
+/*
+
+ 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/delete_file_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "config_profile/profile.h"
+#include "utils/file_system.h"
+
+namespace application_manager {
+
+namespace commands {
+
+DeleteFileRequest::DeleteFileRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+DeleteFileRequest::~DeleteFileRequest() {
+}
+
+void DeleteFileRequest::Run() {
+ LOG4CXX_INFO(logger_, "DeleteFileRequest::Run");
+
+ ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::params][strings::connection_key].asUInt());
+
+ if (!application) {
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ LOG4CXX_ERROR(logger_, "Application is not registered");
+ return;
+ }
+
+ if (mobile_api::HMILevel::HMI_NONE == application->hmi_level() &&
+ profile::Profile::instance()->delete_file_in_none() <= application->delete_file_in_none_count()) {
+ // If application is in the HMI_NONE level the quantity of allowed
+ // DeleteFile request is limited by the configuration profile
+ LOG4CXX_ERROR(logger_, "Too many requests from the app with HMILevel HMI_NONE ");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ return;
+ }
+
+ const std::string& sync_file_name =
+ (*message_)[strings::msg_params][strings::sync_file_name].asString();
+
+ std::string relative_file_path = application->name();
+ relative_file_path += "/";
+ relative_file_path += sync_file_name;
+
+ std::string full_file_path = file_system::FullPath(relative_file_path);
+
+ if (file_system::FileExists(full_file_path)) {
+ if (file_system::DeleteFile(full_file_path)) {
+ application->DeleteFile(sync_file_name);
+ application->increment_delete_file_in_none_count();
+ SendResponse(true, mobile_apis::Result::SUCCESS);
+ } else {
+ SendResponse(false, mobile_apis::Result::GENERIC_ERROR);
+ }
+ } else {
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ }
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/delete_file_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/delete_file_response.cc
new file mode 100644
index 000000000..3892114f1
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/delete_file_response.cc
@@ -0,0 +1,67 @@
+/*
+
+ 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/delete_file_response.h"
+#include "utils/file_system.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+DeleteFileResponse::DeleteFileResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+DeleteFileResponse::~DeleteFileResponse() {
+}
+
+void DeleteFileResponse::Run() {
+ LOG4CXX_INFO(logger_, "DeleteFileResponse::Run");
+ uint32_t app_id = (*message_)[strings::params][strings::connection_key]
+ .asUInt();
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "Application not registered");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+ (*message_)[strings::msg_params][strings::space_available] =
+ static_cast<int32_t>(file_system::GetAvailableSpaceForApp(app->name()));
+ SendResponse((*message_)[strings::msg_params][strings::success].asBool());
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc
new file mode 100644
index 000000000..c98f16c97
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc
@@ -0,0 +1,115 @@
+/*
+
+ 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/delete_interaction_choice_set_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+DeleteInteractionChoiceSetRequest::DeleteInteractionChoiceSetRequest(
+ const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+DeleteInteractionChoiceSetRequest::~DeleteInteractionChoiceSetRequest() {
+}
+
+void DeleteInteractionChoiceSetRequest::Run() {
+ LOG4CXX_INFO(logger_, "DeleteInteractionChoiceSetRequest::Run");
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::params][strings::connection_key].asUInt());
+
+ if (!app) {
+ LOG4CXX_ERROR_EXT(logger_, "No application associated with session key");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ const int32_t choise_set_id =
+ (*message_)[strings::msg_params]
+ [strings::interaction_choice_set_id].asInt();
+
+ if (!app->FindChoiceSet(choise_set_id)) {
+ LOG4CXX_ERROR_EXT(logger_, "INVALID_ID");
+ SendResponse(false, mobile_apis::Result::INVALID_ID);
+ return;
+ }
+
+ if (ChoiceSetInUse(app)) {
+ LOG4CXX_ERROR_EXT(logger_, "Choice set currently in use");
+ SendResponse(false, mobile_apis::Result::IN_USE);
+ return;
+ }
+
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+
+ msg_params[strings::interaction_choice_set_id] = choise_set_id;
+ msg_params[strings::app_id] = app->app_id();
+
+ app->RemoveChoiceSet(choise_set_id);
+
+ SendResponse(true, mobile_apis::Result::SUCCESS);
+ /*CreateHMIRequest(hmi_apis::FunctionID::UI_DeleteInteractionChoiceSet,
+ msg_params, true);*/
+}
+
+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();
+
+ PerformChoiceSetMap::const_iterator it = choice_set_map.begin();
+ for (; choice_set_map.end() != it; ++it) {
+ if (it->first
+ == (*message_)[strings::msg_params]
+ [strings::interaction_choice_set_id].asInt()) {
+ LOG4CXX_ERROR_EXT(logger_,
+ "DeleteInteractionChoiceSetRequest::ChoiceSetInUse");
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_response.cc
new file mode 100644
index 000000000..d260add7c
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_response.cc
@@ -0,0 +1,77 @@
+/*
+
+ 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/delete_interaction_choice_set_response.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+DeleteInteractionChoiceSetResponse::DeleteInteractionChoiceSetResponse(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+DeleteInteractionChoiceSetResponse::~DeleteInteractionChoiceSetResponse() {
+}
+
+void DeleteInteractionChoiceSetResponse::Run() {
+ LOG4CXX_INFO(logger_, "DeleteInteractionChoiceSetResponse::Run");
+
+ // check if response false
+ if (true == (*message_)[strings::msg_params].keyExists(strings::success)) {
+ if ((*message_)[strings::msg_params][strings::success].asBool() == false) {
+ LOG4CXX_ERROR(logger_, "Success = false");
+ SendResponse(false);
+ return;
+ }
+ }
+
+ const int32_t code =
+ (*message_)[strings::msg_params][strings::result_code].asInt();
+
+ if (hmi_apis::Common_Result::SUCCESS == code) {
+ SendResponse(true);
+ } else {
+ // TODO(DK): Some logic
+ SendResponse(false);
+ }
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc
new file mode 100644
index 000000000..bcd55a38f
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc
@@ -0,0 +1,178 @@
+/*
+
+ 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/delete_sub_menu_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+DeleteSubMenuRequest::DeleteSubMenuRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+DeleteSubMenuRequest::~DeleteSubMenuRequest() {
+}
+
+void DeleteSubMenuRequest::Run() {
+ LOG4CXX_INFO(logger_, "DeleteSubMenuRequest::Run");
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::params][strings::connection_key].asUInt());
+
+ if (!app) {
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ LOG4CXX_ERROR(logger_, "Application is not registered");
+ return;
+ }
+
+ if (!app->FindSubMenu(
+ (*message_)[strings::msg_params][strings::menu_id].asInt())) {
+ SendResponse(false, mobile_apis::Result::INVALID_ID);
+ LOG4CXX_ERROR(logger_, "Invalid ID");
+ return;
+ }
+
+ // delete sub menu items from SDL and HMI
+ DeleteSubMenuVRCommands(app);
+ DeleteSubMenuUICommands(app);
+
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+
+ msg_params[strings::menu_id] =
+ (*message_)[strings::msg_params][strings::menu_id];
+ msg_params[strings::app_id] = app->app_id();
+
+ SendHMIRequest(hmi_apis::FunctionID::UI_DeleteSubMenu, &msg_params, true);
+}
+
+void DeleteSubMenuRequest::DeleteSubMenuVRCommands(ApplicationConstSharedPtr app) {
+ LOG4CXX_INFO(logger_, "DeleteSubMenuRequest::DeleteSubMenuVRCommands");
+
+ const CommandsMap& commands = app->commands_map();
+ CommandsMap::const_iterator it = commands.begin();
+
+ for (; commands.end() != it; ++it) {
+
+ if (!(*it->second).keyExists(strings::vr_commands)) {
+ continue;
+ }
+
+ if ((*message_)[strings::msg_params][strings::menu_id].asInt()
+ == (*it->second)[strings::menu_params]
+ [hmi_request::parent_id].asInt()) {
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ msg_params[strings::cmd_id] = (*it->second)[strings::cmd_id].asInt();
+ msg_params[strings::app_id] = app->app_id();
+
+ SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params);
+ }
+ }
+}
+
+void DeleteSubMenuRequest::DeleteSubMenuUICommands(ApplicationSharedPtr const app) {
+ LOG4CXX_INFO(logger_, "DeleteSubMenuRequest::DeleteSubMenuUICommands");
+
+ const CommandsMap& commands = app->commands_map();
+ CommandsMap::const_iterator it = commands.begin();
+
+ while (commands.end() != it) {
+
+ if (!(*it->second).keyExists(strings::menu_params)) {
+ continue;
+ }
+
+ if ((*message_)[strings::msg_params][strings::menu_id].asInt()
+ == (*it->second)[strings::menu_params]
+ [hmi_request::parent_id].asInt()) {
+ 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] = (*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
+
+ SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params);
+ } else {
+ ++it;
+ }
+ }
+}
+
+void DeleteSubMenuRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "DeleteSubMenuRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::UI_DeleteSubMenu: {
+ 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;
+
+ ApplicationSharedPtr application =
+ ApplicationManagerImpl::instance()->application(connection_key());
+
+ if (!application) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ return;
+ }
+
+ if (result) {
+ application->RemoveSubMenu(
+ (*message_)[strings::msg_params][strings::menu_id].asInt());
+ }
+
+ 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/SDL_Core/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc
new file mode 100644
index 000000000..0a25a1161
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc
@@ -0,0 +1,57 @@
+/*
+
+ 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/delete_sub_menu_response.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+DeleteSubMenuResponse::DeleteSubMenuResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+DeleteSubMenuResponse::~DeleteSubMenuResponse() {
+}
+
+void DeleteSubMenuResponse::Run() {
+ LOG4CXX_INFO(logger_, "DeleteSubMenuResponse::Run");
+
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc
new file mode 100644
index 000000000..162d1cdc3
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/diagnostic_message_request.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/diagnostic_message_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+DiagnosticMessageRequest::DiagnosticMessageRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+DiagnosticMessageRequest::~DiagnosticMessageRequest() {
+}
+
+void DiagnosticMessageRequest::Run() {
+ LOG4CXX_INFO(logger_, "DiagnosticMessageRequest::Run");
+
+ SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage,
+ &(*message_), true);
+}
+
+void DiagnosticMessageRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "DiagnosticMessageRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage: {
+ 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;
+
+ 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/SDL_Core/src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc
new file mode 100644
index 000000000..2a8b234ff
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/diagnostic_message_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/diagnostic_message_response.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+DiagnosticMessageResponse::DiagnosticMessageResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+DiagnosticMessageResponse::~DiagnosticMessageResponse() {
+}
+
+void DiagnosticMessageResponse::Run() {
+ LOG4CXX_INFO(logger_, "DiagnosticMessageResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/dial_number_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/dial_number_request.cc
new file mode 100644
index 000000000..140f43128
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/dial_number_request.cc
@@ -0,0 +1,57 @@
+/*
+
+ 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/dial_number_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+DialNumberRequest::DialNumberRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+DialNumberRequest::~DialNumberRequest() {
+}
+
+void DialNumberRequest::Run() {
+ LOG4CXX_INFO(logger_, "DialNumberRequest::Run");
+
+ SendResponse(false, mobile_apis::Result::UNSUPPORTED_REQUEST);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/encoded_sync_pdata_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/encoded_sync_pdata_request.cc
new file mode 100644
index 000000000..53dc83c25
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/encoded_sync_pdata_request.cc
@@ -0,0 +1,113 @@
+/*
+
+ 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/encoded_sync_pdata_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+#include "utils/file_system.h"
+#include "encryption/Base64.h"
+
+namespace application_manager {
+
+namespace commands {
+
+const std::string EncodedSyncPDataRequest::TEMPORARY_HARDCODED_FILENAME =
+ "policy_sync_data.dat";
+const std::string EncodedSyncPDataRequest::TEMPORARY_HARDCODED_FOLDERNAME =
+ "policies";
+
+EncodedSyncPDataRequest::EncodedSyncPDataRequest(
+ const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+EncodedSyncPDataRequest::~EncodedSyncPDataRequest() {
+}
+
+void EncodedSyncPDataRequest::Run() {
+ LOG4CXX_INFO(logger_, "EncodedSyncPDataRequest::Run");
+
+ ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(
+ connection_key());
+
+ if (!application) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ const std::string& sync_file_name = TEMPORARY_HARDCODED_FILENAME;
+
+ size_t data_array_size = (*message_)[strings::msg_params][strings::data].
+ length();
+
+ std::string encoded_string_pdata;
+ for (size_t i = 0; i < data_array_size; ++i) {
+ encoded_string_pdata += (*message_)[strings::msg_params][strings::data][i]
+ .asString();
+ }
+
+ LOG4CXX_INFO(logger_, "encoded_string_pdata = " << encoded_string_pdata);
+
+ const std::string string_pdata = base64_decode(encoded_string_pdata);
+
+ LOG4CXX_INFO(logger_, "string_pdata = " << string_pdata);
+
+ const std::vector<uint8_t> file_data(string_pdata.begin(),
+ string_pdata.end());
+
+ std::string relative_file_path = file_system::CreateDirectory(
+ TEMPORARY_HARDCODED_FOLDERNAME);
+ relative_file_path += "/";
+ relative_file_path += sync_file_name;
+
+ mobile_apis::Result::eType save_result =
+ ApplicationManagerImpl::instance()->SaveBinary(
+ application->name(),
+ file_data,
+ relative_file_path);
+
+ switch(save_result) {
+ case mobile_apis::Result::SUCCESS:
+ SendResponse(true, save_result);
+ break;
+ default:
+ SendResponse(false, save_result);
+ break;
+ }
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/encoded_sync_pdata_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/encoded_sync_pdata_response.cc
new file mode 100644
index 000000000..0c738bf3c
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/encoded_sync_pdata_response.cc
@@ -0,0 +1,65 @@
+/*
+
+ 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/encoded_sync_pdata_response.h"
+
+namespace application_manager {
+
+namespace commands {
+
+EncodedSyncPDataResponse::EncodedSyncPDataResponse(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+EncodedSyncPDataResponse::~EncodedSyncPDataResponse() {
+}
+
+void EncodedSyncPDataResponse::Run() {
+ LOG4CXX_INFO(logger_, "EncodedSyncPDataResponse::Run");
+
+ // check if response false
+ if (true == (*message_)[strings::msg_params].keyExists(strings::success)) {
+ if ((*message_)[strings::msg_params][strings::success].asBool() == false) {
+ LOG4CXX_ERROR(logger_, "Success = false");
+ SendResponse(false);
+ return;
+ }
+ }
+
+ SendResponse(true);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc
new file mode 100644
index 000000000..71eec0e77
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc
@@ -0,0 +1,88 @@
+/*
+
+ 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/end_audio_pass_thru_request.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+EndAudioPassThruRequest::EndAudioPassThruRequest(
+ const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+EndAudioPassThruRequest::~EndAudioPassThruRequest() {
+}
+
+void EndAudioPassThruRequest::Run() {
+ LOG4CXX_INFO(logger_, "EndAudioPassThruRequest::Run");
+ bool ended_successfully = ApplicationManagerImpl::instance()->end_audio_pass_thru();
+
+ if (ended_successfully) {
+ SendHMIRequest(hmi_apis::FunctionID::UI_EndAudioPassThru, NULL, true);
+ int32_t session_key =
+ (*message_)[strings::params][strings::connection_key].asInt();
+ ApplicationManagerImpl::instance()->StopAudioPassThru(session_key);
+ } else {
+ SendResponse(false, mobile_apis::Result::REJECTED,
+ "No PerformAudioPassThru is now active");
+ }
+}
+
+void EndAudioPassThruRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "EndAudioPassThruRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::UI_EndAudioPassThru: {
+ 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;
+
+ 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/SDL_Core/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc
new file mode 100644
index 000000000..128d921f9
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc
@@ -0,0 +1,57 @@
+/*
+
+ 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/end_audio_pass_thru_response.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+EndAudioPassThruResponse::EndAudioPassThruResponse(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+EndAudioPassThruResponse::~EndAudioPassThruResponse() {
+}
+
+void EndAudioPassThruResponse::Run() {
+ LOG4CXX_INFO(logger_, "EndAudioPassThruResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/generic_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/generic_response.cc
new file mode 100644
index 000000000..69c841b2f
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/generic_response.cc
@@ -0,0 +1,65 @@
+/*
+
+ 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/generic_response.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+void GenericResponse::Run() {
+ /*NsSmartDeviceLink::NsSmartObjects::SmartObject response;
+
+ response[strings::params][strings::correlation_id] =
+ (*message_)[strings::params][strings::correlation_id];
+ response[strings::params][strings::protocol_version] =
+ (*message_)[strings::params][strings::protocol_version];
+ response[strings::params][strings::connection_key] =
+ (*message_)[strings::params][strings::connection_key];
+
+ response[strings::msg_params][strings::success] = false;
+ */
+
+ (*message_)[strings::params][strings::message_type] = MessageType::kResponse;
+ (*message_)[strings::msg_params][strings::success] = false;
+ (*message_)[strings::msg_params][strings::result_code] =
+ mobile_apis::Result::INVALID_DATA;
+
+ SendResponse(false);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc
new file mode 100644
index 000000000..f0c91db64
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc
@@ -0,0 +1,104 @@
+/*
+
+ 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/get_dtcs_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+GetDTCsRequest::GetDTCsRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+GetDTCsRequest::~GetDTCsRequest() {
+}
+
+void GetDTCsRequest::Run() {
+ LOG4CXX_INFO(logger_, "GetDTCsRequest::Run");
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::params][strings::connection_key].asUInt());
+
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ if (mobile_api::HMILevel::HMI_NONE == app->hmi_level()) {
+ LOG4CXX_ERROR(logger_, "App has not been activated");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ return;
+ }
+
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+
+ msg_params[strings::ecu_name] =
+ (*message_)[strings::msg_params][strings::ecu_name];
+ msg_params[strings::dtc_mask] =
+ (*message_)[strings::msg_params][strings::dtc_mask];
+ msg_params[strings::app_id] = app->app_id();
+
+ SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_GetDTCs, &msg_params, true);
+}
+
+void GetDTCsRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "GetDTCsRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::VehicleInfo_GetDTCs: {
+ 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;
+
+ 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/SDL_Core/src/components/application_manager/src/commands/mobile/get_dtcs_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/get_dtcs_response.cc
new file mode 100644
index 000000000..2ed7a9295
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/get_dtcs_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/get_dtcs_response.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+GetDTCsResponse::GetDTCsResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+GetDTCsResponse::~GetDTCsResponse() {
+}
+
+void GetDTCsResponse::Run() {
+ LOG4CXX_INFO(logger_, "GetDTCsResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc
new file mode 100644
index 000000000..7292dfa99
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc
@@ -0,0 +1,294 @@
+/*
+
+ 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 <string>
+#include "application_manager/commands/mobile/get_vehicle_data_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
+#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+namespace str = strings;
+
+#ifdef WEB_HMI
+GetVehicleDataRequest::GetVehicleDataRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+GetVehicleDataRequest::~GetVehicleDataRequest() {
+}
+
+void GetVehicleDataRequest::Run() {
+ LOG4CXX_INFO(logger_, "GetVehicleDataRequest::Run");
+
+ int32_t app_id = (*message_)[strings::params][strings::connection_key].asUInt();
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ if (mobile_api::HMILevel::HMI_NONE == app->hmi_level()) {
+ LOG4CXX_ERROR(logger_, "app in HMI level HMI_NONE");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ return;
+ }
+
+ const VehicleData& vehicle_data = MessageHelper::vehicle_data();
+ VehicleData::const_iterator it = vehicle_data.begin();
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ msg_params[strings::app_id] = app->app_id();
+ const int32_t min_length_msg_params = 1;
+ for (; vehicle_data.end() != it; ++it) {
+ if (true == (*message_)[str::msg_params].keyExists(it->first)
+ && true == (*message_)[str::msg_params][it->first].asBool()) {
+ msg_params[it->first] = (*message_)[strings::msg_params][it->first];
+ }
+ }
+ if (msg_params.length() > min_length_msg_params) {
+ SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_GetVehicleData,
+ &msg_params, true);
+ return;
+ }
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+}
+
+void GetVehicleDataRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "GetVehicleDataRequest::on_event");
+ smart_objects::SmartObject message = event.smart_object();
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::VehicleInfo_GetVehicleData: {
+ mobile_apis::Result::eType result_code =
+ static_cast<mobile_apis::Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ bool result = false;
+ if (mobile_apis::Result::SUCCESS == result_code ||
+ (hmi_apis::Common_Result::DATA_NOT_AVAILABLE ==
+ static_cast<hmi_apis::Common_Result::eType>(result_code)
+ && message[strings::msg_params].length() > 1)) {
+ result = true;
+ }
+ const char *info = NULL;
+ std::string error_message;
+ if (true ==
+ message[strings::msg_params].keyExists(hmi_response::method)) {
+ message[strings::msg_params].erase(hmi_response::method);
+ }
+ if (true == message[strings::params].keyExists(strings::error_msg)) {
+ error_message = message[strings::params][strings::error_msg].asString();
+ info = error_message.c_str();
+ }
+ SendResponse(result, result_code, info, &(message[strings::msg_params]));
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+}
+
+#endif // #ifdef WEB_HMI
+#ifdef QT_HMI
+GetVehicleDataRequest::GetVehicleDataRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+GetVehicleDataRequest::~GetVehicleDataRequest() {
+}
+
+void GetVehicleDataRequest::Run() {
+ LOG4CXX_INFO(logger_, "GetVehicleDataRequest::Run");
+
+ int32_t app_id = (*message_)[strings::params][strings::connection_key].asUInt();
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ if (mobile_api::HMILevel::HMI_NONE == app->hmi_level()) {
+ LOG4CXX_ERROR(logger_, "app in HMI level HMI_NONE");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ return;
+ }
+
+ const VehicleData& vehicle_data = MessageHelper::vehicle_data();
+ VehicleData::const_iterator it = vehicle_data.begin();
+
+ for (; vehicle_data.end() != it; ++it) {
+ if (true == (*message_)[str::msg_params].keyExists(it->first)
+ && true == (*message_)[str::msg_params][it->first].asBool()) {
+ SendRequestsToHmi(app->app_id());
+ return;
+ }
+ }
+
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+}
+
+namespace {
+ struct Subrequest {
+ hmi_apis::FunctionID::eType func_id;
+ const char* str;
+ };
+ Subrequest subrequests[] = {
+ { hmi_apis::FunctionID::VehicleInfo_GetGpsData, str::gps},
+ { hmi_apis::FunctionID::VehicleInfo_GetSpeed, str::speed},
+ { hmi_apis::FunctionID::VehicleInfo_GetRpm, str::rpm},
+ { hmi_apis::FunctionID::VehicleInfo_GetFuelLevel, str::fuel_level},
+ { hmi_apis::FunctionID::VehicleInfo_GetFuelLevelState, str::fuel_level_state},
+ { hmi_apis::FunctionID::VehicleInfo_GetInstantFuelConsumption, str::instant_fuel_consumption},
+ { hmi_apis::FunctionID::VehicleInfo_GetExternalTemperature, str::external_temp},
+ { hmi_apis::FunctionID::VehicleInfo_GetVin, str::vin},
+ { hmi_apis::FunctionID::VehicleInfo_GetPrndl, str::prndl},
+ { hmi_apis::FunctionID::VehicleInfo_GetTirePressure, str::tire_pressure},
+ { hmi_apis::FunctionID::VehicleInfo_GetOdometer, str::odometer},
+ { hmi_apis::FunctionID::VehicleInfo_GetBeltStatus, str::belt_status},
+ { hmi_apis::FunctionID::VehicleInfo_GetBodyInformation, str::body_information},
+ { hmi_apis::FunctionID::VehicleInfo_GetDeviceStatus, str::device_status},
+ { hmi_apis::FunctionID::VehicleInfo_GetDriverBraking, str::driver_braking},
+ { hmi_apis::FunctionID::VehicleInfo_GetWiperStatus, str::wiper_status},
+ { hmi_apis::FunctionID::VehicleInfo_GetHeadLampStatus, str::head_lamp_status},
+ { hmi_apis::FunctionID::VehicleInfo_GetEngineTorque, str::engine_torque},
+ { hmi_apis::FunctionID::VehicleInfo_GetAccPedalPosition, str::acc_pedal_pos},
+ { hmi_apis::FunctionID::VehicleInfo_GetSteeringWheelAngle, str::steering_wheel_angle},
+ { hmi_apis::FunctionID::VehicleInfo_GetECallInfo, str::e_call_info},
+ { hmi_apis::FunctionID::VehicleInfo_GetAirbagStatus, str::airbag_status},
+ { hmi_apis::FunctionID::VehicleInfo_GetEmergencyEvent, str::emergency_event},
+ { hmi_apis::FunctionID::VehicleInfo_GetClusterModeStatus, str::cluster_mode_status},
+ { hmi_apis::FunctionID::VehicleInfo_GetMyKey, str::my_key},
+ };
+}
+
+void GetVehicleDataRequest::SendRequestsToHmi(const int32_t app_id) {
+ smart_objects::SmartObject msg_params(smart_objects::SmartType_Map);
+ msg_params[strings::app_id] = app_id;
+
+ for (int32_t i = 0; i < sizeof(subrequests) / sizeof(subrequests[0]); ++i) {
+ const Subrequest& sr = subrequests[i];
+ if (true == (*message_)[str::msg_params].keyExists(sr.str)
+ && true == (*message_)[str::msg_params][sr.str].asBool()) {
+ HmiRequest hmi_request;
+ hmi_request.str = sr.str;
+ hmi_request.func_id = sr.func_id;
+ hmi_request.complete = false;
+ hmi_requests_.push_back(hmi_request);
+ }
+ }
+
+ LOG4CXX_INFO(logger_,
+ hmi_requests_.size() << " requests are going to be sent to HMI");
+
+ for (HmiRequests::const_iterator it = hmi_requests_.begin();
+ it != hmi_requests_.end(); ++it) {
+ SendHMIRequest(it->func_id, &msg_params, true);
+ }
+}
+
+void GetVehicleDataRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "GetVehicleDataRequest::on_event " << event.id());
+
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ for (HmiRequests::iterator it = hmi_requests_.begin();
+ it != hmi_requests_.end(); ++it) {
+ HmiRequest & hmi_request = *it;
+ if (hmi_request.func_id == event.id()) {
+ hmi_request.status =
+ static_cast<hmi_apis::Common_Result::eType>(message[strings::params][hmi_response::code]
+ .asInt());
+ if (hmi_apis::Common_Result::SUCCESS == hmi_request.status)
+ hmi_request.value = message[str::msg_params][hmi_request.str];
+ hmi_request.complete = true;
+ break;
+ }
+ }
+
+ bool all_complete = true;
+ bool any_arg_success = false;
+ mobile_api::Result::eType status = mobile_api::Result::eType::SUCCESS;
+ for (HmiRequests::const_iterator it = hmi_requests_.begin();
+ it != hmi_requests_.end(); ++it) {
+ if (!it->complete) {
+ all_complete = false;
+ break;
+ }
+ if (hmi_apis::Common_Result::SUCCESS != it->status) {
+ if (mobile_api::Result::SUCCESS == status) {
+ status = static_cast<mobile_apis::Result::eType>(it->status);
+ } else if (status
+ != static_cast<mobile_apis::Result::eType>(it->status)) {
+ status = mobile_api::Result::eType::GENERIC_ERROR;
+ }
+ LOG4CXX_TRACE(logger_, "Status from HMI: " << it->status << ", so response status become " << status);
+ } else {
+ any_arg_success = true;
+ }
+ }
+
+ if (all_complete) {
+ smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
+ if (any_arg_success) {
+ for (HmiRequests::const_iterator it = hmi_requests_.begin();
+ it != hmi_requests_.end(); ++it) {
+ response_params[it->str] = it->value;
+ }
+ }
+ LOG4CXX_INFO(
+ logger_, "All HMI requests are complete");
+ const char *info = NULL;
+ std::string error_message;
+ if (true == message[strings::params].keyExists(strings::error_msg)) {
+ error_message = message[strings::params][strings::error_msg].asString();
+ info = error_message.c_str();
+ }
+ SendResponse( any_arg_success, status, info, &response_params);
+ }
+}
+#endif // #ifdef QT_HMI
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc
new file mode 100644
index 000000000..d9087fdc6
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc
@@ -0,0 +1,57 @@
+/*
+
+ 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/get_vehicle_data_response.h"
+#include "application_manager/application_manager_impl.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+GetVehicleDataResponse::GetVehicleDataResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+GetVehicleDataResponse::~GetVehicleDataResponse() {
+}
+
+void GetVehicleDataResponse::Run() {
+ LOG4CXX_INFO(logger_, "GetVehicleDataResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/list_files_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/list_files_request.cc
new file mode 100644
index 000000000..530fd1c92
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/list_files_request.cc
@@ -0,0 +1,90 @@
+/*
+
+ 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/list_files_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "config_profile/profile.h"
+#include "application_manager/mobile_command_factory.h"
+#include "utils/file_system.h"
+
+namespace application_manager {
+
+namespace commands {
+
+ListFilesRequest::ListFilesRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+ListFilesRequest::~ListFilesRequest() {
+}
+
+void ListFilesRequest::Run() {
+ LOG4CXX_INFO(logger_, "ListFilesRequest::Run");
+
+ ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::params][strings::connection_key].asUInt());
+
+ if (!application) {
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ LOG4CXX_ERROR(logger_, "Application is not registered");
+ return;
+ }
+
+ if (mobile_api::HMILevel::HMI_NONE == application->hmi_level() &&
+ profile::Profile::instance()->list_files_in_none() <= application->list_files_in_none_count()) {
+ // If application is in the HMI_NONE level the quantity of allowed
+ // DeleteFile request is limited by the configuration profile
+ LOG4CXX_ERROR(logger_, "Too many requests from the app with HMILevel HMI_NONE ");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ return;
+ }
+
+ application->increment_list_files_in_none_count();
+
+ (*message_)[strings::msg_params][strings::space_available] =
+ static_cast<int32_t>(file_system::GetAvailableSpaceForApp(application->name()));
+ int32_t i = 0;
+ const AppFilesMap& app_files = application->getAppFiles();
+ for (AppFilesMap::const_iterator it = app_files.begin();
+ it != app_files.end(); ++it) {
+ (*message_)[strings::msg_params][strings::filenames][i++] = it->second.file_name;
+ }
+ (*message_)[strings::params][strings::message_type] =
+ application_manager::MessageType::kResponse;
+ SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &(*message_)[strings::msg_params]);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/list_files_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/list_files_response.cc
new file mode 100644
index 000000000..52e8d26e9
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/list_files_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/list_files_response.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+ListFilesResponse::ListFilesResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+ListFilesResponse::~ListFilesResponse() {
+}
+
+void ListFilesResponse::Run() {
+ LOG4CXX_INFO(logger_, "ListFilesResponse::Run");
+ SendResponse(true);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc
new file mode 100644
index 000000000..6063c8cc5
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc
@@ -0,0 +1,58 @@
+/*
+
+ 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_app_interface_unregistered_notification.h"
+#include "application_manager/message.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+OnAppInterfaceUnregisteredNotification::OnAppInterfaceUnregisteredNotification(
+ const MessageSharedPtr& message)
+ : CommandNotificationImpl(message) {
+}
+
+OnAppInterfaceUnregisteredNotification::~OnAppInterfaceUnregisteredNotification() {
+}
+
+void OnAppInterfaceUnregisteredNotification::Run() {
+ LOG4CXX_INFO(logger_, "OnAppInterfaceUnregisteredNotification::Run");
+
+ SendNotification();
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc
new file mode 100644
index 000000000..dd000ca11
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.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/on_audio_pass_thru_notification.h"
+
+namespace application_manager {
+
+namespace commands {
+
+OnAudioPassThruNotification::OnAudioPassThruNotification(
+ const MessageSharedPtr& message)
+ : CommandNotificationImpl(message) {
+}
+
+OnAudioPassThruNotification::~OnAudioPassThruNotification() {
+}
+
+void OnAudioPassThruNotification::Run() {
+ LOG4CXX_INFO(logger_, "OnAudioPassThruNotification::Run");
+
+ SendNotification();
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc
new file mode 100644
index 000000000..53fd0cf62
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc
@@ -0,0 +1,120 @@
+/*
+
+ 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_button_event_notification.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+namespace mobile {
+
+OnButtonEventNotification::OnButtonEventNotification(
+ const MessageSharedPtr& message)
+ : CommandNotificationImpl(message) {
+}
+
+OnButtonEventNotification::~OnButtonEventNotification() {
+}
+
+void OnButtonEventNotification::Run() {
+ LOG4CXX_INFO(logger_, "OnButtonEventNotification::Run");
+
+ const uint32_t btn_id =
+ static_cast<uint32_t>(
+ (*message_)[strings::msg_params][hmi_response::button_name].asInt());
+
+ const std::vector<ApplicationSharedPtr>& subscribedApps =
+ ApplicationManagerImpl::instance()->applications_by_button(btn_id);
+
+ std::vector<ApplicationSharedPtr>::const_iterator it = subscribedApps.begin();
+ for (; subscribedApps.end() != it; ++it) {
+ ApplicationSharedPtr subscribed_app = *it;
+ if (!subscribed_app) {
+ LOG4CXX_WARN_EXT(logger_, "Null pointer to subscribed app.");
+ continue;
+ }
+
+ if ((mobile_api::HMILevel::HMI_FULL == subscribed_app->hmi_level())
+ || (mobile_api::HMILevel::HMI_LIMITED == subscribed_app->hmi_level()
+ && static_cast<uint32_t>(mobile_apis::ButtonName::OK) !=
+ btn_id)) {
+ SendButtonEvent(subscribed_app);
+ } else {
+ LOG4CXX_WARN_EXT(logger_, "OnButtonEvent in HMI_BACKGROUND or NONE");
+ continue;
+ }
+ }
+}
+
+void OnButtonEventNotification::SendButtonEvent(ApplicationConstSharedPtr app) {
+ smart_objects::SmartObject* on_btn_event = new smart_objects::SmartObject();
+
+ if (!on_btn_event) {
+ LOG4CXX_ERROR_EXT(logger_, "OnButtonEvent NULL pointer");
+ return;
+ }
+
+ if (!app) {
+ 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] =
+ static_cast<int32_t>(mobile_apis::FunctionID::eType::OnButtonEventID);
+
+ (*on_btn_event)[strings::msg_params][strings::button_name] =
+ (*message_)[strings::msg_params][hmi_response::button_name];
+ (*on_btn_event)[strings::msg_params][strings::button_event_mode] =
+ (*message_)[strings::msg_params][hmi_response::button_mode];
+
+ if ((*message_)[strings::msg_params].keyExists(
+ hmi_response::custom_button_id)) {
+ (*on_btn_event)[strings::msg_params][strings::custom_button_id] =
+ (*message_)[strings::msg_params][strings::custom_button_id];
+ }
+
+ message_.reset(on_btn_event);
+ SendNotification();
+}
+
+} // namespace mobile
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc
new file mode 100644
index 000000000..64844f011
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc
@@ -0,0 +1,120 @@
+/*
+
+ 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_button_press_notification.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+namespace mobile {
+
+OnButtonPressNotification::OnButtonPressNotification(
+ const MessageSharedPtr& message)
+ : CommandNotificationImpl(message) {
+}
+
+OnButtonPressNotification::~OnButtonPressNotification() {
+}
+
+void OnButtonPressNotification::Run() {
+ LOG4CXX_INFO(logger_, "OnButtonPressNotification::Run");
+
+ const uint32_t btn_id =
+ static_cast<uint32_t>(
+ (*message_)[strings::msg_params][hmi_response::button_name].asInt());
+
+ const std::vector<ApplicationSharedPtr>& subscribedApps =
+ ApplicationManagerImpl::instance()->applications_by_button(btn_id);
+
+ std::vector<ApplicationSharedPtr>::const_iterator it = subscribedApps.begin();
+ for (; subscribedApps.end() != it; ++it) {
+ ApplicationSharedPtr subscribed_app = *it;
+ if (!subscribed_app) {
+ LOG4CXX_WARN_EXT(logger_, "Null pointer to subscribed app.");
+ continue;
+ }
+
+ if ((mobile_api::HMILevel::HMI_FULL == subscribed_app->hmi_level())
+ || (mobile_api::HMILevel::HMI_LIMITED == subscribed_app->hmi_level()
+ && static_cast<uint32_t>(mobile_apis::ButtonName::OK) !=
+ btn_id)) {
+ SendButtonPress(subscribed_app);
+ } else {
+ LOG4CXX_WARN_EXT(logger_, "OnButtonEvent in HMI_BACKGROUND or NONE");
+ continue;
+ }
+ }
+}
+
+void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) {
+ smart_objects::SmartObject* on_btn_press = new smart_objects::SmartObject();
+
+ if (!on_btn_press) {
+ LOG4CXX_ERROR_EXT(logger_, "OnButtonPress NULL pointer");
+ return;
+ }
+
+ if (!app) {
+ 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] =
+ static_cast<int32_t>(mobile_apis::FunctionID::eType::OnButtonPressID);
+
+ (*on_btn_press)[strings::msg_params][strings::button_name] =
+ (*message_)[strings::msg_params][hmi_response::button_name];
+ (*on_btn_press)[strings::msg_params][strings::button_press_mode] =
+ (*message_)[strings::msg_params][hmi_response::button_mode];
+
+ if ((*message_)[strings::msg_params].keyExists(
+ hmi_response::custom_button_id)) {
+ (*on_btn_press)[strings::msg_params][strings::custom_button_id] =
+ (*message_)[strings::msg_params][strings::custom_button_id];
+ }
+
+ message_.reset(on_btn_press);
+ SendNotification();
+}
+
+} // namespace mobile
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/on_command_notification.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/on_command_notification.cc
new file mode 100644
index 000000000..34f5d8ed4
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/on_command_notification.cc
@@ -0,0 +1,76 @@
+/*
+
+ 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_command_notification.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+OnCommandNotification::OnCommandNotification(const MessageSharedPtr& message)
+ : CommandNotificationImpl(message) {
+}
+
+OnCommandNotification::~OnCommandNotification() {
+}
+
+void OnCommandNotification::Run() {
+ LOG4CXX_INFO(logger_, "OnCommandNotification::Run");
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::msg_params][strings::app_id].asInt());
+
+ if (!app) {
+ LOG4CXX_ERROR_EXT(logger_, "No application associated with session key");
+ return;
+ }
+
+ const uint32_t cmd_id = (*message_)[strings::msg_params][strings::cmd_id]
+ .asUInt();
+
+ if (!app->FindCommand(cmd_id)) {
+ LOG4CXX_ERROR_EXT(logger_,
+ " No applications found for the command " << cmd_id);
+ return;
+ }
+
+ (*message_)[strings::params][strings::connection_key] = app->app_id();
+
+ SendNotification();
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/on_driver_distraction_notification.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/on_driver_distraction_notification.cc
new file mode 100644
index 000000000..2f836a088
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/on_driver_distraction_notification.cc
@@ -0,0 +1,73 @@
+/*
+
+ 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_driver_distraction_notification.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+namespace mobile {
+
+OnDriverDistractionNotification::OnDriverDistractionNotification(
+ const MessageSharedPtr& message)
+ : CommandNotificationImpl(message) {
+}
+
+OnDriverDistractionNotification::~OnDriverDistractionNotification() {
+}
+
+void OnDriverDistractionNotification::Run() {
+ LOG4CXX_INFO(logger_, "OnDriverDistractionNotification::Run");
+
+ const std::set<ApplicationSharedPtr>& applications =
+ ApplicationManagerImpl::instance()->applications();
+
+ std::set<ApplicationSharedPtr>::iterator it = applications.begin();
+ for (; applications.end() != it; ++it) {
+ ApplicationSharedPtr app = *it;
+ if (mobile_apis::HMILevel::eType::HMI_NONE != app->hmi_level()) {
+ (*message_)[strings::params][strings::connection_key] = app->app_id();
+ SendNotification();
+ }
+ }
+}
+
+} // namespace mobile
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/on_encoded_sync_pdata_notification.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/on_encoded_sync_pdata_notification.cc
new file mode 100644
index 000000000..f22f9de3b
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/on_encoded_sync_pdata_notification.cc
@@ -0,0 +1,105 @@
+/*
+
+ 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 <string>
+#include <vector>
+#include "application_manager/commands/mobile/on_encoded_sync_pdata_notification.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+#include "utils/file_system.h"
+#include "encryption/Base64.h"
+
+namespace application_manager {
+
+namespace commands {
+
+OnEncodedSyncPDataNotification::OnEncodedSyncPDataNotification(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message),
+ timer_(this, &OnEncodedSyncPDataNotification::onTimer) {
+}
+
+OnEncodedSyncPDataNotification::~OnEncodedSyncPDataNotification() {
+}
+
+void OnEncodedSyncPDataNotification::Run() {
+ LOG4CXX_INFO(logger_, "OnEncodedSyncPDataNotification::Run");
+
+ const std::string fileName =
+ (*message_)[strings::params][hmi_notification::file_name].asString();
+
+ if (!file_system::FileExists(fileName)) {
+ (*message_)[strings::msg_params][strings::success] = false;
+ (*message_)[strings::msg_params][strings::result_code] =
+ static_cast<int32_t>(mobile_apis::Result::FILE_NOT_FOUND);
+
+ SendResponse(false);
+ LOG4CXX_ERROR(logger_, "File not found");
+ return;
+ }
+
+ const char* timeout = mobile_notification::syncp_timeout;
+ if ((*message_)[strings::msg_params].keyExists(timeout)) {
+ ApplicationManagerImpl::instance()->addNotification(this);
+ timer_.start((*message_)[strings::msg_params][timeout].asInt());
+ } else {
+ SendEncodedPData();
+ }
+}
+
+void OnEncodedSyncPDataNotification::onTimer() {
+ LOG4CXX_INFO(logger_, "OnEncodedSyncPDataNotification::onTimer");
+
+ SendEncodedPData();
+}
+
+void OnEncodedSyncPDataNotification::SendEncodedPData() {
+ const std::string fileName =
+ (*message_)[strings::params][hmi_notification::file_name].asString();
+
+ std::vector<uint8_t> pData;
+ file_system::ReadBinaryFile(fileName, pData);
+ const std::string string_pdata = base64_decode(
+ std::string(pData.begin(), pData.end()));
+
+ (*message_)[strings::params][strings::data] = string_pdata;
+
+ SendResponse(true);
+ ApplicationManagerImpl::instance()->removeNotification(this);
+}
+
+} // namespace commands
+
+} // namespace application_manager
+
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc
new file mode 100644
index 000000000..1f30231bc
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc
@@ -0,0 +1,74 @@
+
+/*
+
+ 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_hash_change_notification.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+#include <string>
+
+namespace application_manager {
+
+namespace commands {
+
+namespace mobile {
+
+OnHashChangeNotification::OnHashChangeNotification(
+ const MessageSharedPtr& message)
+ : CommandNotificationImpl(message) {
+}
+
+OnHashChangeNotification::~OnHashChangeNotification() {
+}
+
+void OnHashChangeNotification::Run() {
+ LOG4CXX_INFO(logger_, "OnHashChangeNotification::Run");
+
+ (*message_)[strings::params][strings::message_type] =
+ static_cast<int32_t>(application_manager::MessageType::kNotification);
+
+ 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();
+}
+
+} //namespace mobile
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc
new file mode 100644
index 000000000..4208d6b35
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc
@@ -0,0 +1,60 @@
+/*
+
+ 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.h"
+#include "application_manager/message.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+OnHMIStatusNotification::OnHMIStatusNotification(
+ const MessageSharedPtr& message)
+ : CommandNotificationImpl(message) {
+}
+
+OnHMIStatusNotification::~OnHMIStatusNotification() {
+}
+
+void OnHMIStatusNotification::Run() {
+ LOG4CXX_INFO(logger_, "OnHMIStatusNotification::Run");
+
+ (*message_)[strings::params][strings::message_type] = static_cast<int32_t> (
+ application_manager::MessageType::kNotification);
+ SendNotification();
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc
new file mode 100644
index 000000000..969885ab1
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc
@@ -0,0 +1,73 @@
+/*
+
+ 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_keyboard_input_notification.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+namespace mobile {
+
+OnKeyBoardInputNotification::OnKeyBoardInputNotification(
+ const MessageSharedPtr& message)
+ : CommandNotificationImpl(message) {
+}
+
+OnKeyBoardInputNotification::~OnKeyBoardInputNotification() {
+}
+
+void OnKeyBoardInputNotification::Run() {
+ LOG4CXX_INFO(logger_, "OnKeyBoardInputNotification::Run");
+
+ const std::vector<ApplicationSharedPtr>& applications =
+ ApplicationManagerImpl::instance()->applications_with_navi();
+
+ std::vector<ApplicationSharedPtr>::const_iterator it = applications.begin();
+ for (; applications.end() != it; ++it) {
+ ApplicationSharedPtr app = *it;
+ if (mobile_apis::HMILevel::eType::HMI_NONE != app->hmi_level()) {
+ (*message_)[strings::params][strings::connection_key] = app->app_id();
+ SendNotification();
+ }
+ }
+}
+
+} // namespace mobile
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/on_language_change_notification.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/on_language_change_notification.cc
new file mode 100644
index 000000000..f550df874
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/on_language_change_notification.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/on_language_change_notification.h"
+
+namespace application_manager {
+
+namespace commands {
+
+OnLanguageChangeNotification::OnLanguageChangeNotification(
+ const MessageSharedPtr& message)
+ : CommandNotificationImpl(message) {
+}
+
+OnLanguageChangeNotification::~OnLanguageChangeNotification() {
+}
+
+void OnLanguageChangeNotification::Run() {
+ LOG4CXX_INFO(logger_, "OnLanguageChangeNotification::Run");
+
+ SendNotification();
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc
new file mode 100644
index 000000000..37c81085e
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc
@@ -0,0 +1,61 @@
+/*
+
+ 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_permissions_change_notification.h"
+#include "application_manager/message.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+OnPermissionsChangeNotification::OnPermissionsChangeNotification(
+ const MessageSharedPtr& message)
+ : CommandNotificationImpl(message) {
+}
+
+OnPermissionsChangeNotification::~OnPermissionsChangeNotification() {
+}
+
+void OnPermissionsChangeNotification::Run() {
+ LOG4CXX_INFO(logger_, "OnPermissionsChangeNotification::Run");
+
+ (*message_)[strings::params][strings::message_type] =
+ static_cast<int32_t>(application_manager::MessageType::kNotification);
+
+ SendNotification();
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/on_sync_pdata_notification.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/on_sync_pdata_notification.cc
new file mode 100644
index 000000000..bbfa3e576
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/on_sync_pdata_notification.cc
@@ -0,0 +1,105 @@
+/*
+
+ 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 <string>
+#include <vector>
+#include "application_manager/commands/mobile/on_sync_pdata_notification.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+#include "utils/file_system.h"
+#include "encryption/Base64.h"
+
+namespace application_manager {
+
+namespace commands {
+
+OnSyncPDataNotification::OnSyncPDataNotification(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message),
+ timer_(this, &OnSyncPDataNotification::onTimer) {
+}
+
+OnSyncPDataNotification::~OnSyncPDataNotification() {
+}
+
+void OnSyncPDataNotification::Run() {
+ LOG4CXX_INFO(logger_, "OnSyncPDataNotification::Run");
+
+ const std::string fileName =
+ (*message_)[strings::params][hmi_notification::file_name].asString();
+
+ if (!file_system::FileExists(fileName)) {
+ (*message_)[strings::msg_params][strings::success] = false;
+ (*message_)[strings::msg_params][strings::result_code] =
+ static_cast<int32_t>(mobile_apis::Result::FILE_NOT_FOUND);
+
+ LOG4CXX_ERROR(logger_, "File not found");
+ SendResponse(false);
+ return;
+ }
+
+ const char* timeout = mobile_notification::syncp_timeout;
+ if ((*message_)[strings::msg_params].keyExists(timeout)) {
+ ApplicationManagerImpl::instance()->addNotification(this);
+ timer_.start((*message_)[strings::msg_params][timeout].asInt());
+ } else {
+ SendPData();
+ }
+}
+
+void OnSyncPDataNotification::onTimer() {
+ LOG4CXX_INFO(logger_, "OnSyncPDataNotification::onTimer");
+
+ SendPData();
+}
+
+void OnSyncPDataNotification::SendPData() {
+ LOG4CXX_INFO(logger_, "OnSyncPDataNotification::SendPData");
+
+ const std::string fileName =
+ (*message_)[strings::params][hmi_notification::file_name].asString();
+
+ std::vector<uint8_t> pData;
+ file_system::ReadBinaryFile(fileName, pData);
+ const std::string string_pdata = std::string(pData.begin(), pData.end());
+ (*message_)[strings::params][strings::data] = string_pdata;
+
+ SendResponse(true);
+ ApplicationManagerImpl::instance()->removeNotification(this);
+}
+
+} // namespace commands
+
+} // namespace application_manager
+
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
new file mode 100644
index 000000000..a40f1c1b1
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
@@ -0,0 +1,60 @@
+/*
+
+ 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_system_request_notification.h"
+
+namespace application_manager {
+
+namespace commands {
+
+namespace mobile {
+
+OnSystemRequestNotification::OnSystemRequestNotification(
+ const MessageSharedPtr& message)
+ : CommandNotificationImpl(message) {
+}
+
+OnSystemRequestNotification::~OnSystemRequestNotification() {
+}
+
+void OnSystemRequestNotification::Run() {
+ LOG4CXX_INFO(logger_, "OnSystemRequestNotification::Run");
+
+ SendNotification();
+}
+
+} //namespace mobile
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/on_tbt_client_state_notification.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/on_tbt_client_state_notification.cc
new file mode 100644
index 000000000..05494c614
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/on_tbt_client_state_notification.cc
@@ -0,0 +1,72 @@
+/*
+
+ 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_tbt_client_state_notification.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+OnTBTClientStateNotification::OnTBTClientStateNotification(
+ const MessageSharedPtr& message)
+ : CommandNotificationImpl(message) {
+}
+
+OnTBTClientStateNotification::~OnTBTClientStateNotification() {
+}
+
+void OnTBTClientStateNotification::Run() {
+ LOG4CXX_INFO(logger_, "OnTBTClientStateNotification::Run");
+
+ (*message_)[strings::params][strings::message_type] =
+ static_cast<int32_t>(application_manager::MessageType::kNotification);
+
+ const std::vector<ApplicationSharedPtr>& applications =
+ ApplicationManagerImpl::instance()->applications_with_navi();
+
+ std::vector<ApplicationSharedPtr>::const_iterator it = applications.begin();
+ for (; applications.end() != it; ++it) {
+ ApplicationSharedPtr app = *it;
+ if (mobile_apis::HMILevel::eType::HMI_NONE != app->hmi_level()) {
+ (*message_)[strings::params][strings::connection_key] = app->app_id();
+ SendNotification();
+ }
+ }
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc
new file mode 100644
index 000000000..dd2431bb6
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc
@@ -0,0 +1,72 @@
+/*
+
+ 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_touch_event_notification.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+namespace mobile {
+
+OnTouchEventNotification::OnTouchEventNotification(
+ const MessageSharedPtr& message)
+ : CommandNotificationImpl(message) {
+}
+
+OnTouchEventNotification::~OnTouchEventNotification() {
+}
+
+void OnTouchEventNotification::Run() {
+ LOG4CXX_INFO(logger_, "OnTouchEventNotification::Run");
+
+ const std::vector<ApplicationSharedPtr>& applications =
+ ApplicationManagerImpl::instance()->applications_with_navi();
+
+ std::vector<ApplicationSharedPtr>::const_iterator it = applications.begin();
+ for (; applications.end() != it; ++it) {
+ ApplicationSharedPtr app = *it;
+ if (mobile_apis::HMILevel::eType::HMI_NONE != app->hmi_level()) {
+ (*message_)[strings::params][strings::connection_key] = app->app_id();
+ SendNotification();
+ }
+ }
+}
+
+} // namespace mobile
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc
new file mode 100644
index 000000000..46ed25cb1
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc
@@ -0,0 +1,88 @@
+/*
+
+ 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_vehicle_data_notification.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+OnVehicleDataNotification::OnVehicleDataNotification(
+ const MessageSharedPtr& message)
+ : CommandNotificationImpl(message) {
+}
+
+OnVehicleDataNotification::~OnVehicleDataNotification() {
+}
+
+void OnVehicleDataNotification::Run() {
+ LOG4CXX_INFO(logger_, "OnVehicleDataNotification::Run");
+
+ const VehicleData& vehicle_data = MessageHelper::vehicle_data();
+ VehicleData::const_iterator it = vehicle_data.begin();
+
+ for (; vehicle_data.end() != it; ++it) {
+ if (true == (*message_)[strings::msg_params].keyExists(it->first)) {
+ const std::vector<ApplicationSharedPtr>& applications =
+ ApplicationManagerImpl::instance()->applications_by_ivi((static_cast<uint32_t>(it->second)));
+
+ std::vector<ApplicationSharedPtr>::const_iterator it = applications.begin();
+ for (; applications.end() != it; ++it) {
+ ApplicationSharedPtr app = *it;
+ if (!app) {
+ LOG4CXX_ERROR_EXT(logger_, "NULL pointer");
+ continue;
+ }
+
+ LOG4CXX_INFO(
+ logger_,
+ "Send OnVehicleData PRNDL notification to " << app->name()
+ << " application id " << app->app_id());
+
+ (*message_)[strings::params][strings::connection_key] = app->app_id();
+
+ SendNotification();
+ }
+
+ return;
+ }
+ }
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc
new file mode 100644
index 000000000..07ce5cf15
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc
@@ -0,0 +1,193 @@
+/*
+
+ 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/perform_audio_pass_thru_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
+
+namespace application_manager {
+
+namespace commands {
+
+namespace str = strings;
+
+PerformAudioPassThruRequest::PerformAudioPassThruRequest(
+ const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+PerformAudioPassThruRequest::~PerformAudioPassThruRequest() {
+}
+
+bool PerformAudioPassThruRequest::Init() {
+ default_timeout_ += (*message_)[str::msg_params][str::max_duration].asInt();
+ return true;
+}
+
+void PerformAudioPassThruRequest::Run() {
+ LOG4CXX_INFO(logger_, "PerformAudioPassThruRequest::Run");
+
+ if (ApplicationManagerImpl::instance()->begin_audio_pass_thru() == false) {
+ // Audio pass thru already active
+ LOG4CXX_ERROR_EXT(logger_, "REJECTED");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ return;
+ }
+
+ uint32_t app_id = (*message_)[strings::params][strings::connection_key]
+ .asUInt();
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+
+ if (!app) {
+ LOG4CXX_ERROR_EXT(logger_, "APPLICATION_NOT_REGISTERED");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ if (mobile_api::HMILevel::HMI_NONE == app->hmi_level()) {
+ LOG4CXX_ERROR_EXT(logger_, "application isn't activated");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ return;
+ }
+
+ SendSpeakRequest(app->app_id());
+
+ // create HMI request
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+
+ msg_params[str::app_id] = app_id;
+
+ msg_params[hmi_request::audio_pass_display_texts] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+
+ if ((*message_)[str::msg_params].keyExists(str::audio_pass_display_text1)) {
+ msg_params[hmi_request::audio_pass_display_texts]
+ [0][hmi_request::field_name] = static_cast<int32_t>
+ (application_manager::TextFieldName::AUDIO_DISPLAY_TEXT1);
+ msg_params[hmi_request::audio_pass_display_texts]
+ [0][hmi_request::field_text] =
+ (*message_)[str::msg_params][str::audio_pass_display_text1];
+ }
+
+ if ((*message_)[str::msg_params].keyExists(str::audio_pass_display_text2)) {
+ msg_params[hmi_request::audio_pass_display_texts]
+ [1][hmi_request::field_name] = static_cast<int32_t>
+ (application_manager::TextFieldName::AUDIO_DISPLAY_TEXT2);
+ msg_params[hmi_request::audio_pass_display_texts]
+ [1][hmi_request::field_text] =
+ (*message_)[str::msg_params][str::audio_pass_display_text2];
+ }
+
+ // duration
+ msg_params[hmi_request::max_duration] =
+ (*message_)[str::msg_params][str::max_duration];
+
+ msg_params[strings::app_id] = app->app_id();
+
+ SendHMIRequest(hmi_apis::FunctionID::UI_PerformAudioPassThru,
+ &msg_params, true);
+
+ ApplicationManagerImpl::instance()->StartAudioPassThruThread(
+ (*message_)[str::params][str::connection_key].asInt(),
+ (*message_)[str::params][str::correlation_id].asInt(),
+ (*message_)[str::msg_params][str::max_duration].asInt(),
+ (*message_)[str::msg_params][str::sampling_rate].asInt(),
+ (*message_)[str::msg_params][str::bits_per_sample].asInt(),
+ (*message_)[str::msg_params][str::audio_type].asInt());
+}
+
+void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "PerformAudioPassThruRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::UI_PerformAudioPassThru: {
+ 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 ||
+ mobile_apis::Result::RETRY == result_code;
+
+ if (ApplicationManagerImpl::instance()->end_audio_pass_thru()) {
+ int32_t session_key =
+ (*message_)[strings::params][strings::connection_key].asUInt();
+ ApplicationManagerImpl::instance()->StopAudioPassThru(session_key);
+ }
+
+ const char* return_info = NULL;
+
+ if (result) {
+ if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE ==
+ static_cast<hmi_apis::Common_Result::eType>(result_code)) {
+ result_code = mobile_apis::Result::WARNINGS;
+ return_info = std::string("Unsupported phoneme type sent in a prompt").c_str();
+ }
+ }
+
+ SendResponse(result, result_code, return_info, &(message[strings::msg_params]));
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+}
+
+void PerformAudioPassThruRequest::SendSpeakRequest(const int32_t app_id) {
+ // crate HMI TTS speak request
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+
+
+ if ((*message_)[str::msg_params].keyExists(str::initial_prompt) &&
+ (0 < (*message_)[str::msg_params][str::initial_prompt].length())) {
+ for (int32_t i = 0;
+ i < (*message_)[str::msg_params][str::initial_prompt].length();
+ ++i) {
+ msg_params[hmi_request::tts_chunks][i][str::text] =
+ (*message_)[str::msg_params][str::initial_prompt][i][str::text];
+ }
+ // app_id
+ msg_params[strings::app_id] = app_id;
+
+ SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, &msg_params);
+ }
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc
new file mode 100644
index 000000000..a10eaac9f
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc
@@ -0,0 +1,58 @@
+/*
+
+ 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/perform_audio_pass_thru_response.h"
+#include "application_manager/application_manager_impl.h"
+
+
+namespace application_manager {
+
+namespace commands {
+
+PerformAudioPassThruResponse::PerformAudioPassThruResponse(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+PerformAudioPassThruResponse::~PerformAudioPassThruResponse() {
+}
+
+void PerformAudioPassThruResponse::Run() {
+ LOG4CXX_INFO(logger_, "PerformAudioPassThruResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc
new file mode 100644
index 000000000..e46161d24
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc
@@ -0,0 +1,763 @@
+/*
+
+ 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 <string.h>
+#include <string>
+#include "application_manager/commands/mobile/perform_interaction_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.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 {
+
+PerformInteractionRequest::PerformInteractionRequest(
+ const MessageSharedPtr& message)
+: CommandRequestImpl(message),
+ timer_(this, &PerformInteractionRequest::onTimer),
+ tts_perform_interaction_code_(mobile_apis::Result::INVALID_ENUM) {
+
+ subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout);
+ subscribe_on_event(hmi_apis::FunctionID::VR_OnCommand);
+ subscribe_on_event(hmi_apis::FunctionID::Buttons_OnButtonPress);
+ subscribe_on_event(
+ hmi_apis::FunctionID::BasicCommunication_OnAppUnregistered);
+}
+
+PerformInteractionRequest::~PerformInteractionRequest() {
+}
+
+void PerformInteractionRequest::onTimer() {
+ LOG4CXX_INFO(logger_, "PerformInteractionRequest::onTimer");
+}
+
+bool PerformInteractionRequest::Init() {
+
+ /* Timeout in milliseconds.
+ If omitted a standard value of 10000 milliseconds is used.*/
+ if ((*message_)[strings::msg_params].keyExists(strings::timeout)) {
+ default_timeout_ =
+ (*message_)[strings::msg_params][strings::timeout].asUInt();
+ }
+ mobile_apis::InteractionMode::eType 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;
+ }
+ return true;
+}
+
+void PerformInteractionRequest::Run() {
+ LOG4CXX_INFO(logger_, "PerformInteractionRequest::Run");
+
+ // timer_.start(2);
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::params][strings::connection_key].asUInt());
+
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "Application is not registered");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ if (0 != app->is_perform_interaction_active()) {
+ LOG4CXX_INFO(logger_, "Another perform interaction is running!");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ return;
+ }
+
+ mobile_apis::Result::eType verification_result =
+ MessageHelper::VerifyImageFiles((*message_)[strings::msg_params], app);
+
+ if ((mobile_apis::Result::SUCCESS != verification_result) &&
+ (mobile_apis::Result::UNSUPPORTED_RESOURCE != verification_result)) {
+ LOG4CXX_ERROR_EXT(
+ logger_,
+ "MessageHelper::VerifyImageFiles return " << verification_result);
+ SendResponse(false, verification_result);
+ return;
+ }
+
+ smart_objects::SmartObject& choice_list =
+ (*message_)[strings::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())) {
+ LOG4CXX_ERROR(logger_, "Invalid ID");
+ SendResponse(false, mobile_apis::Result::INVALID_ID);
+ return;
+ }
+ }
+
+ uint32_t correlation_id =
+ (*message_)[strings::params][strings::correlation_id].asUInt();
+
+ int32_t mode =
+ (*message_)[strings::msg_params][strings::interaction_mode].asInt();
+
+ app->set_perform_interaction_mode(mode);
+
+ mobile_apis::InteractionMode::eType 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)) {
+ return;
+ }
+
+ if (!CheckVrHelpItemPositions(app)) {
+ return;
+ }
+
+ app->set_perform_interaction_active(correlation_id);
+ SendVRAddCommandRequest(app);
+ SendTTSPerformInteractionRequest(app);
+ SendUIPerformInteractionRequest(app);
+ break;
+ }
+ case mobile_apis::InteractionMode::MANUAL_ONLY: {
+ LOG4CXX_INFO(logger_, "Interaction Mode: MANUAL_ONLY");
+ if (!CheckChoiceSetMenuNames(app)) {
+ return;
+ }
+
+ app->set_perform_interaction_active(correlation_id);
+ SendTTSPerformInteractionRequest(app);
+ SendUIPerformInteractionRequest(app);
+ break;
+ }
+ case mobile_apis::InteractionMode::VR_ONLY: {
+ LOG4CXX_INFO(logger_, "Interaction Mode: VR_ONLY");
+ if (!CheckChoiceSetVRSynonyms(app)) {
+ return;
+ }
+
+ if (!CheckVrHelpItemPositions(app)) {
+ return;
+ }
+
+ // TODO(DK): need to implement timeout
+ app->set_perform_interaction_active(correlation_id);
+ SendVRAddCommandRequest(app);
+ SendTTSPerformInteractionRequest(app);
+ SendUIPerformInteractionRequest(app);
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Unknown interaction mode");
+ return;
+ }
+ }
+
+ // TODO(DK): need to implement timeout TTS speak request.
+}
+
+void PerformInteractionRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "PerformInteractionRequest::on_event");
+
+ 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());
+ break;
+ }
+ case hmi_apis::FunctionID::VR_OnCommand: {
+ LOG4CXX_INFO(logger_, "Received VR_OnCommand event");
+ ProcessVRNotification(event.smart_object());
+ break;
+ }
+ case hmi_apis::FunctionID::UI_PerformInteraction: {
+ LOG4CXX_INFO(logger_, "Received UI_PerformInteraction event");
+ ProcessPerformInteractionResponse(event.smart_object());
+ break;
+ }
+ case hmi_apis::FunctionID::BasicCommunication_OnAppUnregistered: {
+ LOG4CXX_INFO(logger_, "Received OnAppUnregistered event");
+ ProcessAppUnregisteredNotification(event.smart_object());
+ break;
+ }
+ case hmi_apis::FunctionID::TTS_PerformInteraction: {
+ LOG4CXX_INFO(logger_, "Received TTS_PerformInteraction");
+ tts_perform_interaction_code_ = static_cast<mobile_apis::Result::eType>(
+ event.smart_object()[strings::params][hmi_response::code].asInt());
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ break;
+ }
+ }
+}
+
+void PerformInteractionRequest::onTimeOut() {
+ LOG4CXX_INFO(logger_, "PerformInteractionRequest::onTimeOut");
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::params][strings::connection_key].asUInt());
+ if (app) {
+
+ // Unsubscribe from event on UIPerformInteractionResponse to
+ // avoid of double execution of SendVrDeleteCommand()
+ unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction);
+ SendVrDeleteCommand(app);
+ app->set_perform_interaction_active(0);
+ app->set_perform_interaction_mode(-1);
+ app->DeletePerformInteractionChoiceSetMap();
+ }
+ CommandRequestImpl::onTimeOut();
+}
+
+void PerformInteractionRequest::ProcessVRNotification(
+ const smart_objects::SmartObject& message) {
+ LOG4CXX_INFO(logger_, "PerformInteractionRequest::ProcessVRNotification");
+ const uint32_t app_id = message[strings::msg_params][strings::app_id]
+ .asUInt();
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ return;
+ }
+ int32_t cmd_id = message[strings::msg_params][strings::cmd_id].asInt();
+ const PerformChoiceSetMap& choice_set_map = app
+ ->performinteraction_choice_set_map();
+ bool choice_id_chosen = false;
+ LOG4CXX_INFO(logger_, "If command was choice id");
+ for (PerformChoiceSetMap::const_iterator it = choice_set_map.begin();
+ choice_set_map.end() != it; ++it) {
+ const smart_objects::SmartObject& choice_set = (*it->second).getElement(
+ strings::choice_set);
+ for (size_t j = 0; j < choice_set.length(); ++j) {
+ if (cmd_id ==
+ choice_set.getElement(j).getElement(strings::choice_id).asInt()) {
+ choice_id_chosen = true;
+ break;
+ }
+ }
+ }
+ if (choice_id_chosen) {
+ LOG4CXX_INFO(logger_, "Command was choice id!");
+ smart_objects::SmartObject c_p_request_so = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ c_p_request_so[hmi_request::method_name] = "UI.PerformInteraction";
+ SendHMIRequest(hmi_apis::FunctionID::UI_ClosePopUp, &(c_p_request_so));
+ SendVrDeleteCommand(app);
+ app->set_perform_interaction_mode(-1);
+ app->DeletePerformInteractionChoiceSetMap();
+ app->set_perform_interaction_active(0);
+
+ (*message_)[strings::params][strings::function_id] =
+ static_cast<int32_t>(mobile_apis::FunctionID::PerformInteractionID);
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ msg_params[strings::choice_id] = cmd_id;
+ msg_params[strings::trigger_source] =
+ static_cast<int32_t>(mobile_apis::TriggerSource::TS_VR);
+ SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &(msg_params));
+
+ } else {
+ LOG4CXX_INFO(logger_, "Sending OnCommand notification");
+ smart_objects::SmartObject* notification_so =
+ new smart_objects::SmartObject(smart_objects::SmartType_Map);
+ if (!notification_so) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Failed to allocate memory for perform interaction response.");
+ return;
+ }
+ smart_objects::SmartObject& notification = *notification_so;
+ notification = message;
+ notification[strings::params][strings::function_id] =
+ static_cast<int32_t>(mobile_apis::FunctionID::eType::OnCommandID);
+ notification[strings::msg_params][strings::trigger_source] =
+ static_cast<int32_t>(mobile_apis::TriggerSource::TS_VR);
+ ApplicationManagerImpl::instance()->ManageMobileCommand(notification_so);
+ }
+}
+
+void PerformInteractionRequest::ProcessAppUnregisteredNotification
+ (const smart_objects::SmartObject& message) {
+ LOG4CXX_INFO(logger_,
+ "PerformInteractionRequest::ProcessAppUnregisteredNotification");
+ const uint32_t app_id = (*message_)[strings::params]
+ [strings::connection_key].asUInt();
+ if (app_id == message[strings::msg_params][strings::app_id].asUInt()) {
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ return;
+ }
+ if (app->is_perform_interaction_active()) {
+ if (static_cast<int32_t>(mobile_apis::InteractionMode::MANUAL_ONLY) !=
+ app->perform_interaction_mode()) {
+ SendVrDeleteCommand(app);
+ }
+ app->set_perform_interaction_mode(-1);
+ app->DeletePerformInteractionChoiceSetMap();
+ app->set_perform_interaction_active(0);
+ }
+ } else {
+ LOG4CXX_INFO(logger_, "Notification was sent from another application");
+ }
+}
+
+void PerformInteractionRequest::SendVrDeleteCommand(
+ application_manager::ApplicationSharedPtr const app) {
+ LOG4CXX_INFO(logger_, "PerformInteractionRequest::SendVrDeleteCommand");
+ const PerformChoiceSetMap& choice_set_map = app
+ ->performinteraction_choice_set_map();
+ PerformChoiceSetMap::const_iterator it = choice_set_map.begin();
+ for (; choice_set_map.end() != it; ++it) {
+ const smart_objects::SmartObject& choice_set = (*it->second).getElement(
+ strings::choice_set);
+ for (size_t j = 0; j < 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.getElement(j).getElement(
+ strings::choice_id);
+ SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params);
+ }
+ }
+}
+
+void PerformInteractionRequest::ProcessPerformInteractionResponse(
+ const smart_objects::SmartObject& message) {
+ LOG4CXX_INFO(logger_,
+ "PerformInteractionRequest::ProcessPerformInteractionResponse");
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::params][strings::connection_key].asUInt());
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ return;
+ }
+ if (app->is_perform_interaction_active()) {
+ if (static_cast<int32_t>(mobile_apis::InteractionMode::MANUAL_ONLY)
+ != app->perform_interaction_mode()) {
+ SendVrDeleteCommand(app);
+ }
+ app->set_perform_interaction_mode(-1);
+ app->DeletePerformInteractionChoiceSetMap();
+ app->set_perform_interaction_active(0);
+ }
+ (*message_)[strings::params][strings::function_id] =
+ static_cast<int32_t>(mobile_apis::FunctionID::PerformInteractionID);
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ msg_params = message[strings::msg_params];
+ bool result = false;
+ int32_t hmi_response_code =
+ message[strings::params][hmi_response::code].asInt();
+ if (hmi_apis::Common_Result::SUCCESS ==
+ hmi_apis::Common_Result::eType(hmi_response_code)) {
+ 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;
+ }
+ result = true;
+ }
+
+ const char* return_info = NULL;
+ mobile_apis::Result::eType result_code =
+ static_cast<mobile_apis::Result::eType>(hmi_response_code);
+ if (result) {
+ if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE ==
+ hmi_apis::Common_Result::eType(hmi_response_code)) {
+ result_code = mobile_apis::Result::WARNINGS;
+ return_info = std::string(
+ "Unsupported phoneme type sent in any item").c_str();
+ }
+ }
+
+ SendResponse(result,
+ result_code,
+ return_info,
+ &(msg_params));
+}
+
+void PerformInteractionRequest::SendVRAddCommandRequest(
+ application_manager::ApplicationSharedPtr const app) {
+ smart_objects::SmartObject& choice_list =
+ (*message_)[strings::msg_params][strings::interaction_choice_set_id_list];
+
+ mobile_apis::InteractionMode::eType mode =
+ static_cast<mobile_apis::InteractionMode::eType>(
+ (*message_)[strings::msg_params][strings::interaction_mode].asInt());
+
+ if (mobile_apis::InteractionMode::VR_ONLY == mode) {
+ // TODO(DK): We need subscribe perform interaction with on command
+ // notification
+ /*CreateHMIRequest(hmi_apis::FunctionID::UI_PerformInteraction,
+ smart_objects::SmartObject(smart_objects::SmartType_Map), true, 1);*/
+ }
+
+ for (size_t i = 0; i < choice_list.length(); ++i) {
+ smart_objects::SmartObject* choice_set = app->FindChoiceSet(
+ choice_list[i].asInt());
+
+ if (choice_set) {
+ 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];
+ 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];
+ SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &msg_params);
+ }
+ }
+ }
+}
+
+void PerformInteractionRequest::SendUIPerformInteractionRequest(
+ application_manager::ApplicationSharedPtr const app) {
+ smart_objects::SmartObject& choice_set_id_list =
+ (*message_)[strings::msg_params][strings::interaction_choice_set_id_list];
+
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+
+ mobile_apis::InteractionMode::eType mode =
+ static_cast<mobile_apis::InteractionMode::eType>(
+ (*message_)[strings::msg_params][strings::interaction_mode].asInt());
+
+ if (mobile_apis::InteractionMode::VR_ONLY != mode) {
+ msg_params[hmi_request::initial_text][hmi_request::field_name] =
+ static_cast<int32_t>(application_manager::TextFieldName::
+ INITIAL_INTERACTION_TEXT);
+ msg_params[hmi_request::initial_text][hmi_request::field_text] =
+ (*message_)[strings::msg_params][hmi_request::initial_text];
+ }
+ bool is_vr_help_item = false;
+ if (mobile_apis::InteractionMode::MANUAL_ONLY != mode) {
+ msg_params[strings::vr_help_title] =
+ (*message_)[strings::msg_params][strings::initial_text].asString();
+ if ((*message_)[strings::msg_params].keyExists(strings::vr_help)) {
+ is_vr_help_item = true;
+ msg_params[strings::vr_help] =
+ (*message_)[strings::msg_params][strings::vr_help];
+ }
+ }
+
+ if (mobile_apis::InteractionMode::BOTH == mode ||
+ mobile_apis::InteractionMode::MANUAL_ONLY == mode) {
+ msg_params[strings::timeout] = default_timeout_/2;
+ } else {
+ msg_params[strings::timeout] = default_timeout_;
+ }
+ msg_params[strings::app_id] = app->app_id();
+ if (mobile_apis::InteractionMode::VR_ONLY != mode) {
+ msg_params[strings::choice_set] = smart_objects::SmartObject(
+ smart_objects::SmartType_Array);
+ }
+ int32_t index_array_of_vr_help = 0;
+ for (size_t i = 0; i < choice_set_id_list.length(); ++i) {
+ smart_objects::SmartObject* choice_set = app->FindChoiceSet(
+ choice_set_id_list[i].asInt());
+ if (choice_set) {
+ // save perform interaction choice set
+ app->AddPerformInteractionChoiceSet(choice_set_id_list[i].asInt(),
+ *choice_set);
+ for (size_t j = 0; j < (*choice_set)[strings::choice_set].length(); ++j) {
+ if (mobile_apis::InteractionMode::VR_ONLY != mode) {
+ size_t index = msg_params[strings::choice_set].length();
+ msg_params[strings::choice_set][index] =
+ (*choice_set)[strings::choice_set][j];
+ // vrCommands should be added via VR.AddCommand only
+ msg_params[strings::choice_set][index].erase(strings::vr_commands);
+ }
+ if (mobile_apis::InteractionMode::MANUAL_ONLY !=
+ mode && !is_vr_help_item) {
+ smart_objects::SmartObject& vr_commands =
+ (*choice_set)[strings::choice_set][j][strings::vr_commands];
+ if (0 < vr_commands.length()) {
+ // copy only first synonym
+ smart_objects::SmartObject item(smart_objects::SmartType_Map);
+ item[strings::text] = vr_commands[0].asString();
+ item[strings::position] = index_array_of_vr_help + 1;
+ msg_params[strings::vr_help][index_array_of_vr_help++] = item;
+ }
+ }
+ }
+ }
+ }
+ if ((*message_)[strings::msg_params]
+ .keyExists(hmi_request::interaction_layout)
+ && mobile_apis::InteractionMode::VR_ONLY != mode) {
+ msg_params[hmi_request::interaction_layout] =
+ (*message_)[strings::msg_params][hmi_request::interaction_layout].
+ asInt();
+ }
+ CreateUIPerformInteraction(msg_params, app);
+}
+
+void PerformInteractionRequest::CreateUIPerformInteraction(
+ const smart_objects::SmartObject& msg_params,
+ application_manager::ApplicationSharedPtr const app) {
+ SendHMIRequest(hmi_apis::FunctionID::UI_PerformInteraction,
+ &msg_params, true);
+}
+
+void PerformInteractionRequest::SendTTSPerformInteractionRequest(
+ application_manager::ApplicationSharedPtr const app) {
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ if ((*message_)[strings::msg_params].keyExists(strings::help_prompt)) {
+
+ msg_params[strings::help_prompt] =
+ (*message_)[strings::msg_params][strings::help_prompt];
+
+ DeleteParameterFromTTSChunk(&msg_params[strings::help_prompt]);
+ } else {
+
+ smart_objects::SmartObject& choice_list =
+ (*message_)[strings::msg_params][strings::interaction_choice_set_id_list];
+
+ msg_params[strings::help_prompt] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+
+ int32_t index = 0;
+ for (uint32_t i = 0; i < choice_list.length(); ++i) {
+ smart_objects::SmartObject* choice_set =
+ app->FindChoiceSet(choice_list[i].asInt());
+
+ if (choice_set) {
+ for (uint32_t j = 0;
+ j < (*choice_set)[strings::choice_set].length();
+ ++j) {
+ smart_objects::SmartObject& vr_commands =
+ (*choice_set)[strings::choice_set][j][strings::vr_commands];
+ if (0 < vr_commands.length()) {
+ // copy only first synonym
+ smart_objects::SmartObject item(smart_objects::SmartType_Map);
+ item[strings::text] = vr_commands[0].asString();
+ msg_params[strings::help_prompt][index++] = item;
+ }
+ }
+ }
+ }
+ }
+
+ if ((*message_)[strings::msg_params].keyExists(strings::timeout_prompt)) {
+ msg_params[strings::timeout_prompt] =
+ (*message_)[strings::msg_params][strings::timeout_prompt];
+
+ DeleteParameterFromTTSChunk(&msg_params[strings::timeout_prompt]);
+ } else {
+ msg_params[strings::timeout_prompt] = msg_params[strings::help_prompt];
+ }
+
+ if ((*message_)[strings::msg_params].keyExists(strings::initial_prompt)) {
+ msg_params[strings::initial_prompt] =
+ (*message_)[strings::msg_params][strings::initial_prompt];
+
+ DeleteParameterFromTTSChunk(&msg_params[strings::initial_prompt]);
+ }
+
+ mobile_apis::InteractionMode::eType 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) {
+ msg_params[strings::timeout] = default_timeout_/2;
+ } else {
+ msg_params[strings::timeout] = default_timeout_;
+ }
+
+ SendHMIRequest(hmi_apis::FunctionID::TTS_PerformInteraction, &msg_params,
+ true);
+}
+
+void PerformInteractionRequest::DeleteParameterFromTTSChunk
+(smart_objects::SmartObject* array_tts_chunk) {
+ int32_t length = array_tts_chunk->length();
+ for (int32_t i = 0; i < length; ++i) {
+ array_tts_chunk[i].erase(strings::type);
+ }
+}
+
+bool PerformInteractionRequest::CheckChoiceSetMenuNames(
+ application_manager::ApplicationSharedPtr const app) {
+ smart_objects::SmartObject& choice_list =
+ (*message_)[strings::msg_params][strings::interaction_choice_set_id_list];
+
+ for (size_t i = 0; i < choice_list.length(); ++i) {
+ // choice_set contains SmartObject msg_params
+ smart_objects::SmartObject* i_choice_set = app->FindChoiceSet(
+ choice_list[i].asInt());
+
+ for (size_t j = 0; j < choice_list.length(); ++j) {
+ smart_objects::SmartObject* j_choice_set = app->FindChoiceSet(
+ choice_list[j].asInt());
+
+ if (i == j) {
+ // skip check the same element
+ continue;
+ }
+
+ if (!i_choice_set || !j_choice_set) {
+ LOG4CXX_ERROR(logger_, "Invalid ID");
+ SendResponse(false, mobile_apis::Result::INVALID_ID);
+ return false;
+ }
+
+ size_t ii = 0;
+ size_t jj = 0;
+ for (; ii < (*i_choice_set)[strings::choice_set].length(); ++ii) {
+ for (; jj < (*j_choice_set)[strings::choice_set].length(); ++jj) {
+ std::string ii_menu_name =
+ (*i_choice_set)[strings::choice_set][ii][strings::menu_name]
+ .asString();
+ std::string jj_menu_name =
+ (*j_choice_set)[strings::choice_set][jj][strings::menu_name]
+ .asString();
+
+ if (ii_menu_name == jj_menu_name) {
+ LOG4CXX_ERROR(logger_, "Choice set has duplicated menu name");
+ SendResponse(false, mobile_apis::Result::DUPLICATE_NAME,
+ "Choice set has duplicated menu name");
+ return false;
+ }
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
+bool PerformInteractionRequest::CheckChoiceSetVRSynonyms(
+ application_manager::ApplicationSharedPtr const app) {
+ smart_objects::SmartObject& choice_list =
+ (*message_)[strings::msg_params][strings::interaction_choice_set_id_list];
+
+ for (size_t i = 0; i < choice_list.length(); ++i) {
+ // choice_set contains SmartObject msg_params
+ smart_objects::SmartObject* i_choice_set = app->FindChoiceSet(
+ choice_list[i].asInt());
+
+ for (size_t j = 0; j < choice_list.length(); ++j) {
+ smart_objects::SmartObject* j_choice_set = app->FindChoiceSet(
+ choice_list[j].asInt());
+
+ if (i == j) {
+ // skip check the same element
+ continue;
+ }
+
+ if ((!i_choice_set) || (!j_choice_set)) {
+ LOG4CXX_ERROR(logger_, "Invalid ID");
+ SendResponse(false, mobile_apis::Result::INVALID_ID);
+ return false;
+ }
+
+ size_t ii = 0;
+ size_t jj = 0;
+ for (; ii < (*i_choice_set)[strings::choice_set].length(); ++ii) {
+ for (; jj < (*j_choice_set)[strings::choice_set].length(); ++jj) {
+ // choice_set pointer contains SmartObject msg_params
+ smart_objects::SmartObject& ii_vr_commands =
+ (*i_choice_set)[strings::choice_set][ii][strings::vr_commands];
+
+ smart_objects::SmartObject& jj_vr_commands =
+ (*j_choice_set)[strings::choice_set][jj][strings::vr_commands];
+
+ for (size_t iii = 0; iii < ii_vr_commands.length(); ++iii) {
+ for (size_t jjj = 0; jjj < jj_vr_commands.length(); ++jjj) {
+ std::string vr_cmd_i = ii_vr_commands[iii].asString();
+ std::string vr_cmd_j = jj_vr_commands[jjj].asString();
+ if (0 == strcasecmp(vr_cmd_i.c_str(), vr_cmd_j.c_str())) {
+ LOG4CXX_ERROR(logger_, "Choice set has duplicated VR synonym");
+ SendResponse(false, mobile_apis::Result::DUPLICATE_NAME,
+ "Choice set has duplicated VR synonym");
+ return false;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
+bool PerformInteractionRequest::CheckVrHelpItemPositions(
+ application_manager::ApplicationSharedPtr const app) {
+
+ if (!(*message_)[strings::msg_params].keyExists(strings::vr_help)) {
+ LOG4CXX_INFO(logger_, ""
+ "PerformInteractionRequest::CheckVrHelpItemPositions vr_help omitted");
+ return true;
+ }
+
+ smart_objects::SmartObject& vr_help =
+ (*message_)[strings::msg_params][strings::vr_help];
+
+ int32_t position = 1;
+ for (size_t i = 0; i < vr_help.length(); ++i) {
+ if (position != vr_help[i][strings::position].asInt()) {
+ LOG4CXX_ERROR(logger_, "Non-sequential vrHelp item position");
+ SendResponse(false, mobile_apis::Result::REJECTED,
+ "Non-sequential vrHelp item position");
+ return false;
+ }
+ ++position;
+ }
+ return true;
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc
new file mode 100644
index 000000000..4ceb4ce3b
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc
@@ -0,0 +1,57 @@
+/*
+
+ 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/perform_interaction_response.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+PerformInteractionResponse::PerformInteractionResponse(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+PerformInteractionResponse::~PerformInteractionResponse() {
+}
+
+void PerformInteractionResponse::Run() {
+ LOG4CXX_INFO(logger_, "PerformInteractionResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/put_file_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/put_file_request.cc
new file mode 100644
index 000000000..12d7c386a
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/put_file_request.cc
@@ -0,0 +1,188 @@
+/*
+
+ 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/put_file_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "config_profile/profile.h"
+#include "utils/file_system.h"
+
+namespace application_manager {
+
+namespace commands {
+
+PutFileRequest::PutFileRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+PutFileRequest::~PutFileRequest() {
+}
+
+void PutFileRequest::Run() {
+ LOG4CXX_INFO(logger_, "PutFileRequest::Run");
+
+ ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(
+ connection_key());
+
+ if (!application) {
+ LOG4CXX_ERROR(logger_, "Application is not registered");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ if (mobile_api::HMILevel::HMI_NONE == application->hmi_level() &&
+ profile::Profile::instance()->put_file_in_none() <=
+ application->put_file_in_none_count()) {
+ // If application is in the HMI_NONE level the quantity of allowed
+ // PutFile request is limited by the configuration profile
+ LOG4CXX_ERROR(logger_,
+ "Too many requests from the app with HMILevel HMI_NONE ");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ return;
+ }
+
+ if (!(*message_)[strings::params].keyExists(strings::binary_data)) {
+ LOG4CXX_ERROR(logger_, "Binary data empty");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+
+ if (!(*message_)[strings::msg_params].keyExists(strings::sync_file_name)) {
+ LOG4CXX_ERROR(logger_, "No file name");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+
+ if (!(*message_)[strings::msg_params].keyExists(strings::file_type)) {
+ LOG4CXX_ERROR(logger_, "No file type");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+ const std::string& sync_file_name =
+ (*message_)[strings::msg_params][strings::sync_file_name].asString();
+ const mobile_apis::FileType::eType& file_type =
+ static_cast<mobile_apis::FileType::eType>(
+ (*message_)[strings::msg_params][strings::file_type].asInt());
+ const std::vector<uint8_t> binary_data =
+ (*message_)[strings::params][strings::binary_data].asBinary();
+
+ uint32_t offset = 0;
+ bool is_persistent_file = false;
+ bool is_system_file = false;
+ uint32_t length = binary_data.size();
+ bool is_download_compleate = true;
+ bool offset_exist = (*message_)[strings::msg_params].keyExists(strings::offset);
+
+ if (offset_exist) {
+ offset = (*message_)[strings::msg_params][strings::offset].asInt();
+ }
+ if ((*message_)[strings::msg_params].keyExists(strings::length)) {
+ length =
+ (*message_)[strings::msg_params][strings::length].asInt();
+ }
+ if ((*message_)[strings::msg_params].
+ keyExists(strings::persistent_file)) {
+ is_persistent_file =
+ (*message_)[strings::msg_params][strings::persistent_file].asBool();
+ }
+ if ((*message_)[strings::msg_params].
+ keyExists(strings::system_file)) {
+ is_system_file =
+ (*message_)[strings::msg_params][strings::system_file].asBool();
+ }
+
+ if (is_system_file & (file_type != mobile_apis::FileType::BINARY)) {
+ LOG4CXX_INFO(logger_, "File is System but not binary");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ }
+ std::string relative_file_path =
+ file_system::CreateDirectory(application->name());
+ relative_file_path += "/";
+ relative_file_path += sync_file_name;
+
+ mobile_apis::Result::eType save_result =
+ ApplicationManagerImpl::instance()->SaveBinary(
+ application->name(),
+ binary_data,
+ relative_file_path,
+ offset);
+
+ switch (save_result) {
+ case mobile_apis::Result::SUCCESS: {
+ AppFile file(sync_file_name, is_persistent_file, is_download_compleate, file_type);
+ if (offset == 0) {
+ LOG4CXX_INFO(logger_, "New file downloading");
+ if (!application->AddFile(file)) {
+ LOG4CXX_INFO(logger_, "Couldn't add file to application (File already Exist in application and was rewrited on fs) ");
+ // It can be first part of new big file, so we need tu update information about it's downloading status and percictency
+ if (!application->UpdateFile(file)) {
+ LOG4CXX_INFO(logger_, "Couldn't update file");
+ // If it is impossible to update file, application doesn't know about existing this file
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+ } else {
+ /* if file added - increment it's count ( may be application->AddFile have to incapsulate it? )
+ * Any way now this method evals not only in "none"*/
+ application->increment_put_file_in_none_count();
+ }
+ }
+// For future implementation ( when length will contains file size)
+// if (offset + binary_data.size() == length) {
+// LOG4CXX_INFO(logger_, "File is Fully downloaded");
+// if (!application->UpdateFile(file)) {
+// // If it is impossible to update file, application doesn't know about existing this file
+// SendResponse(false, mobile_apis::Result::INVALID_DATA);
+// return;
+// }
+// } else {
+// //TODO: Maybe need to save in AppFile information about downloading progress
+// }
+ SendResponse(true, save_result);
+ break;
+ }
+ default:
+ if (mobile_apis::Result::OUT_OF_MEMORY == save_result) {
+ if (file_system::FileExists(relative_file_path)) {
+ DCHECK(file_system::DeleteFile(relative_file_path));
+ }
+ }
+ LOG4CXX_INFO(logger_, "Save in unsuccesfull result = " << save_result);
+ SendResponse(false, save_result);
+ break;
+ }
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/put_file_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/put_file_response.cc
new file mode 100644
index 000000000..493061d73
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/put_file_response.cc
@@ -0,0 +1,69 @@
+/*
+
+ 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/put_file_response.h"
+#include "utils/file_system.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+PutFileResponse::PutFileResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+PutFileResponse::~PutFileResponse() {
+}
+
+void PutFileResponse::Run() {
+ LOG4CXX_INFO(logger_, "PutFileResponse::Run");
+ uint32_t app_id = (*message_)[strings::params][strings::connection_key]
+ .asUInt();
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "Application not registered");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ (*message_)[strings::msg_params][strings::space_available] =
+ static_cast<int32_t>(file_system::GetAvailableSpaceForApp(app->name()));
+
+ SendResponse((*message_)[strings::msg_params][strings::success].asBool());
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/read_did_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/read_did_request.cc
new file mode 100644
index 000000000..f8b7aed0d
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/read_did_request.cc
@@ -0,0 +1,111 @@
+/*
+
+ 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/read_did_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+ReadDIDRequest::ReadDIDRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+ReadDIDRequest::~ReadDIDRequest() {
+}
+
+void ReadDIDRequest::Run() {
+ LOG4CXX_INFO(logger_, "ReadDIDRequest::Run");
+
+ uint32_t app_id = (*message_)[strings::params][strings::connection_key]
+ .asUInt();
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+
+ if (!app) {
+ LOG4CXX_ERROR_EXT(logger_, "An application is not registered.");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ if (mobile_api::HMILevel::HMI_NONE == app->hmi_level()) {
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ LOG4CXX_ERROR(logger_, "Rejected");
+ return;
+ }
+
+ if (0 == (*message_)[strings::msg_params][strings::did_location].length()) {
+ LOG4CXX_ERROR_EXT(logger_, "INVALID_DATA");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ msg_params[strings::app_id] = app->app_id();
+ msg_params[strings::ecu_name] =
+ (*message_)[strings::msg_params][strings::ecu_name];
+ msg_params[strings::did_location] =
+ (*message_)[strings::msg_params][strings::did_location];
+
+ SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_ReadDID, &msg_params, true);
+}
+
+void ReadDIDRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "ReadDIDRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::VehicleInfo_ReadDID: {
+ 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;
+
+ 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/SDL_Core/src/components/application_manager/src/commands/mobile/read_did_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/read_did_response.cc
new file mode 100644
index 000000000..888b59075
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/read_did_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/read_did_response.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+ReadDIDResponse::ReadDIDResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+ReadDIDResponse::~ReadDIDResponse() {
+}
+
+void ReadDIDResponse::Run() {
+ LOG4CXX_INFO(logger_, "ReadDIDResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
new file mode 100644
index 000000000..620b38b28
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
@@ -0,0 +1,573 @@
+/*
+
+ 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/register_app_interface_request.h"
+
+#include <unistd.h>
+#include <algorithm>
+
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
+#include "config_profile/profile.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+RegisterAppInterfaceRequest::RegisterAppInterfaceRequest(
+ const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+RegisterAppInterfaceRequest::~RegisterAppInterfaceRequest() {
+}
+
+bool RegisterAppInterfaceRequest::Init() {
+ LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::Init");
+ return true;
+}
+
+void RegisterAppInterfaceRequest::Run() {
+ LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::Run "<< connection_key());
+
+ // wait till all HMI capabilities initialized
+ const HMICapabilities& hmi_capabilities =
+ ApplicationManagerImpl::instance()->hmi_capabilities();
+ while (!hmi_capabilities.is_hmi_capabilities_initialized()) {
+ sleep(1);
+ // TODO(DK): timer_->StartWait(1);
+ ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(),
+ correlation_id(),
+ default_timeout());
+ }
+
+ ApplicationSharedPtr application =
+ ApplicationManagerImpl::instance()->application(connection_key());
+
+ if (application) {
+ SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY);
+ return;
+ }
+
+ if (IsApplicationWithSameAppIdRegistered()) {
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ 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;
+ }
+
+ mobile_apis::Result::eType coincidence_result =
+ CheckCoincidence();
+
+ if (mobile_apis::Result::SUCCESS != coincidence_result) {
+ LOG4CXX_ERROR_EXT(logger_, "Coincidence check failed.");
+ SendResponse(false, coincidence_result);
+ return;
+ }
+
+ ApplicationSharedPtr app =
+ ApplicationManagerImpl::instance()->RegisterApplication(message_);
+
+ const smart_objects::SmartObject& msg_params =
+ (*message_)[strings::msg_params];
+
+ if (!app) {
+ LOG4CXX_ERROR_EXT(logger_, "Application " <<
+ msg_params[strings::app_name].asString() << " hasn't been registered!");
+ } else {
+ app->set_is_media_application(
+ msg_params[strings::is_media_application].asBool());
+
+ if (msg_params.keyExists(strings::vr_synonyms)) {
+ app->set_vr_synonyms(msg_params[strings::vr_synonyms]);
+ }
+
+ if (msg_params.keyExists(strings::ngn_media_screen_app_name)) {
+ app->set_ngn_media_screen_name(
+ msg_params[strings::ngn_media_screen_app_name]);
+ }
+
+ if (msg_params.keyExists(strings::tts_name)) {
+ app->set_tts_name(msg_params[strings::tts_name]);
+ }
+
+ if (msg_params.keyExists(strings::app_hmi_type)) {
+ app->set_app_types(msg_params[strings::app_hmi_type]);
+
+ // check if app is NAVI
+ const int32_t is_navi_type = mobile_apis::AppHMIType::NAVIGATION;
+ const smart_objects::SmartObject& app_type =
+ msg_params.getElement(strings::app_hmi_type);
+
+ for (size_t i = 0; i < app_type.length(); ++i) {
+ if (is_navi_type == app_type.getElement(i).asInt()) {
+ app->set_allowed_support_navigation(true);
+ }
+ }
+ }
+
+ MessageHelper::SendOnAppRegisteredNotificationToHMI(*app);
+ SendRegisterAppInterfaceResponseToMobile();
+
+ }
+}
+
+void RegisterAppInterfaceRequest::SendVrCommandsOnRegisterAppToHMI
+(const application_manager::Application& application_impl) {
+ uint32_t max_cmd_id = profile::Profile::instance()->max_cmd_id();
+ uint32_t app_id = application_impl.app_id();
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ msg_params[strings::cmd_id] = (max_cmd_id + app_id);
+ msg_params[strings::vr_commands] = *(application_impl.vr_synonyms());
+ if (0 < app_id) {
+ msg_params[strings::app_id] = app_id;
+ }
+ SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &msg_params);
+}
+
+void RegisterAppInterfaceRequest::SendTTSChunksToHMI
+(const application_manager::Application& application_impl) {
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ msg_params[strings::app_id] = application_impl.app_id();
+ msg_params[strings::tts_chunks] = *(application_impl.tts_name());
+ SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, &msg_params, true);
+}
+
+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);
+
+ if (!params) {
+ SendResponse(false, mobile_apis::Result::OUT_OF_MEMORY);
+ return;
+ }
+
+ ApplicationManagerImpl* app_manager = ApplicationManagerImpl::instance();
+ const HMICapabilities& hmi_capabilities = app_manager->hmi_capabilities();
+ ApplicationSharedPtr application =
+ ApplicationManagerImpl::instance()->application(connection_key());
+
+ smart_objects::SmartObject& response_params = *params;
+
+ response_params[strings::sync_msg_version][strings::major_version] =
+ APIVersion::kAPIV2;
+ response_params[strings::sync_msg_version][strings::minor_version] =
+ APIVersion::kAPIV2;
+
+ response_params[strings::language] = hmi_capabilities.active_vr_language();
+ response_params[strings::hmi_display_language] =
+ hmi_capabilities.active_ui_language();
+
+ const smart_objects::SmartObject& msg_params =
+ (*message_)[strings::msg_params];
+
+ if (msg_params[strings::language_desired].asInt() !=
+ hmi_capabilities.active_vr_language() ||
+ msg_params[strings::hmi_display_language_desired].asInt() !=
+ hmi_capabilities.active_ui_language()) {
+
+ LOG4CXX_WARN_EXT(
+ logger_,
+ "Wrong language on registering application " << application->name());
+
+ LOG4CXX_ERROR_EXT(
+ logger_,
+ "vr "
+ << msg_params[strings::language_desired].asInt()
+ << " - "
+ << hmi_capabilities.active_vr_language()
+ << "ui "
+ << msg_params[strings::hmi_display_language_desired].asInt()
+ << " - "
+ << hmi_capabilities.active_ui_language());
+
+ result = mobile_apis::Result::WRONG_LANGUAGE;
+ }
+
+ if (hmi_capabilities.display_capabilities()) {
+
+ response_params[hmi_response::display_capabilities] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ smart_objects::SmartObject& display_caps =
+ response_params[hmi_response::display_capabilities];
+
+ display_caps[hmi_response::display_type] =
+ hmi_capabilities.display_capabilities()->getElement(
+ hmi_response::display_type);
+
+ display_caps[hmi_response::text_fields] =
+ hmi_capabilities.display_capabilities()->getElement(
+ hmi_response::text_fields);
+
+ display_caps[hmi_response::media_clock_formats] =
+ hmi_capabilities.display_capabilities()->getElement(
+ hmi_response::media_clock_formats);
+
+ display_caps[hmi_response::templates_available] =
+ hmi_capabilities.display_capabilities()->getElement(
+ hmi_response::templates_available);
+
+ display_caps[hmi_response::screen_params] =
+ hmi_capabilities.display_capabilities()->getElement(
+ hmi_response::screen_params);
+
+ display_caps[hmi_response::num_custom_presets_available] =
+ hmi_capabilities.display_capabilities()->getElement(
+ hmi_response::num_custom_presets_available);
+
+ if (hmi_capabilities.display_capabilities()->getElement(
+ hmi_response::image_capabilities).length() > 0) {
+
+ display_caps[hmi_response::graphic_supported] = true;
+ } else {
+
+ display_caps[hmi_response::graphic_supported] = false;
+ }
+ }
+
+ if (hmi_capabilities.button_capabilities()) {
+ response_params[hmi_response::button_capabilities] =
+ *hmi_capabilities.button_capabilities();
+ }
+ if (hmi_capabilities.soft_button_capabilities()) {
+ response_params[hmi_response::soft_button_capabilities] =
+ *hmi_capabilities.soft_button_capabilities();
+ }
+ if (hmi_capabilities.preset_bank_capabilities()) {
+ response_params[hmi_response::preset_bank_capabilities] =
+ *hmi_capabilities.preset_bank_capabilities();
+ }
+ if (hmi_capabilities.hmi_zone_capabilities()) {
+ response_params[hmi_response::hmi_zone_capabilities] =
+ *hmi_capabilities.hmi_zone_capabilities();
+ }
+ if (hmi_capabilities.speech_capabilities()) {
+ response_params[strings::speech_capabilities] =
+ *hmi_capabilities.speech_capabilities();
+ }
+ if (hmi_capabilities.vr_capabilities()) {
+ response_params[strings::vr_capabilities] =
+ *hmi_capabilities.vr_capabilities();
+ }
+ if (hmi_capabilities.audio_pass_thru_capabilities()) {
+ response_params[strings::audio_pass_thru_capabilities] =
+ *hmi_capabilities.audio_pass_thru_capabilities();
+ }
+ if (hmi_capabilities.vehicle_type()) {
+ response_params[hmi_response::vehicle_type] =
+ *hmi_capabilities.vehicle_type();
+ }
+ if (hmi_capabilities.prerecorded_speech()) {
+ response_params[strings::prerecorded_speech] =
+ *(hmi_capabilities.prerecorded_speech());
+ }
+
+ const std::vector<uint32_t>& diag_modes =
+ profile::Profile::instance()->supported_diag_modes();
+ if (!diag_modes.empty()) {
+ std::vector<uint32_t>::const_iterator it = diag_modes.begin();
+ uint32_t index = 0;
+ for (; it != diag_modes.end(); ++it) {
+ response_params[strings::supported_diag_modes][index] = *it;
+ ++index;
+ }
+ }
+
+ ResumeCtrl& resumer = ApplicationManagerImpl::instance()->resume_controller();
+ uint32_t hash_id = 0;
+
+ if ((*message_)[strings::msg_params].keyExists(strings::hash_id)) {
+
+ hash_id = (*message_)[strings::msg_params][strings::hash_id].asUInt();
+ if (!resumer.CheckApplicationHash((*application->mobile_app_id()).asInt(),
+ hash_id)) {
+ result = mobile_apis::Result::RESUME_FAILED;
+ }
+ }
+
+ SendResponse(true, result, "", params);
+ resumer.StartResumption(application, hash_id);
+}
+
+mobile_apis::Result::eType
+RegisterAppInterfaceRequest::CheckCoincidence() {
+
+ LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::CheckCoincidence ");
+
+ const smart_objects::SmartObject& msg_params =
+ (*message_)[strings::msg_params];
+
+ ApplicationManagerImpl* app_manager = ApplicationManagerImpl::instance();
+
+ const std::set<ApplicationSharedPtr>& applications = app_manager->applications();
+ std::set<ApplicationSharedPtr>::const_iterator it = applications.begin();
+ const std::string app_name = msg_params[strings::app_name].asString();
+
+ for (; applications.end() != it; ++it) {
+
+ // name check
+ const std::string &cur_name = (*it)->name();
+ if (!strcasecmp(app_name.c_str(), cur_name.c_str())) {
+ LOG4CXX_ERROR(logger_, "Application name is known already.");
+ return mobile_apis::Result::DUPLICATE_NAME;
+ }
+
+ const smart_objects::SmartObject* tts = (*it)->tts_name();
+ std::vector<smart_objects::SmartObject>* curr_tts = NULL;
+ if (NULL != tts) {
+ curr_tts = tts->asArray();
+ CoincidencePredicateTTS t(app_name);
+
+ if (0 != std::count_if((*curr_tts).begin(), (*curr_tts).end(), t)) {
+ LOG4CXX_ERROR(logger_, "Application name is known already.");
+ return mobile_apis::Result::DUPLICATE_NAME;
+ }
+ }
+
+ const smart_objects::SmartObject* vr = (*it)->vr_synonyms();
+ const std::vector<smart_objects::SmartObject>* curr_vr = NULL;
+ if (NULL != vr) {
+ curr_vr = vr->asArray();
+ CoincidencePredicateVR v(app_name);
+
+ if (0 != std::count_if(curr_vr->begin(), curr_vr->end(), v )) {
+ LOG4CXX_ERROR(logger_, "Application name is known already.");
+ return mobile_apis::Result::DUPLICATE_NAME;
+ }
+ }
+
+
+ // tts check
+ if (msg_params.keyExists(strings::tts_name)) {
+
+ const std::vector<smart_objects::SmartObject>* new_tts =
+ msg_params[strings::tts_name].asArray();
+
+ std::vector<smart_objects::SmartObject>::const_iterator it_tts =
+ new_tts->begin();
+
+ std::vector<smart_objects::SmartObject>::const_iterator it_tts_End =
+ new_tts->end();
+
+ for (; it_tts != it_tts_End; ++it_tts) {
+ std::string text = (*it_tts)[strings::text].asString();
+ if (!strcasecmp(cur_name.c_str(), text.c_str())){
+ LOG4CXX_ERROR(logger_,
+ "Some TTS parameters names are known already.");
+ return mobile_apis::Result::DUPLICATE_NAME;
+ }
+
+ CoincidencePredicateTTS t((*it_tts)[strings::text].asString());
+ if (NULL != curr_tts
+ && 0 != std::count_if(curr_tts->begin(), curr_tts->end(), t)) {
+ LOG4CXX_ERROR(logger_,
+ "Some TTS parameters names are known already.");
+ return mobile_apis::Result::DUPLICATE_NAME;
+ }
+
+ CoincidencePredicateVR v((*it_tts)[strings::text].asString());
+ if (NULL != curr_vr
+ && 0 != std::count_if(curr_vr->begin(), curr_vr->end(), v)) {
+ LOG4CXX_ERROR(logger_,
+ "Some TTS parameters names are known already.");
+ return mobile_apis::Result::DUPLICATE_NAME;
+ }
+ }
+ } // end tts check
+
+ if (msg_params.keyExists(strings::vr_synonyms)) {
+
+ const std::vector<smart_objects::SmartObject>* new_vr =
+ msg_params[strings::vr_synonyms].asArray();
+
+ std::vector<smart_objects::SmartObject>::const_iterator it_vr =
+ new_vr->begin();
+
+ std::vector<smart_objects::SmartObject>::const_iterator it_vr_End =
+ new_vr->end();
+
+ for (; it_vr != it_vr_End; ++it_vr) {
+ std::string vr_synonym = it_vr->asString();
+ if (!strcasecmp(cur_name.c_str(), vr_synonym.c_str())) {
+ LOG4CXX_ERROR(logger_, "Some VR synonyms are known already.");
+ return mobile_apis::Result::DUPLICATE_NAME;
+ }
+
+ CoincidencePredicateTTS t(it_vr->asString());
+ if (NULL !=curr_tts
+ && 0 != std::count_if(curr_tts->begin(), curr_tts->end(), t)) {
+ LOG4CXX_ERROR(logger_, "Some VR synonyms are known already.");
+ return mobile_apis::Result::DUPLICATE_NAME;
+ }
+
+ CoincidencePredicateVR v(it_vr->asString());
+ if (NULL != curr_vr
+ && 0 != std::count_if(curr_vr->begin(), curr_vr->end(), v)) {
+ LOG4CXX_ERROR(logger_, "Some VR synonyms are known already.");
+ return mobile_apis::Result::DUPLICATE_NAME;
+ }
+ }
+ } // end vr check
+
+ } // application for end
+
+ return mobile_apis::Result::SUCCESS;
+} // method end
+
+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::IsApplicationRegistered");
+
+ int32_t mobile_app_id = (*message_)[strings::msg_params][strings::app_id].asInt();
+
+ const std::set<ApplicationSharedPtr>& applications =
+ ApplicationManagerImpl::instance()->applications();
+
+ std::set<ApplicationSharedPtr>::const_iterator it = applications.begin();
+ std::set<ApplicationSharedPtr>::const_iterator it_end = applications.end();
+
+ for (; it != it_end; ++it) {
+ if (mobile_app_id == (*it)->mobile_app_id()->asInt()) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc
new file mode 100644
index 000000000..3f35c44d6
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc
@@ -0,0 +1,72 @@
+/*
+
+ 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/register_app_interface_response.h"
+#include "interfaces/MOBILE_API.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
+
+namespace application_manager {
+
+namespace commands {
+
+void RegisterAppInterfaceResponse::Run() {
+ LOG4CXX_INFO(logger_, "RegisterAppInterfaceResponse::Run");
+
+ bool success = (*message_)[strings::msg_params][strings::success].asBool();
+
+ bool last_message = !success;
+ // Do not close connection in case of APPLICATION_NOT_REGISTERED despite it is an error
+ if (!success && (*message_)[strings::msg_params].keyExists(strings::result_code)) {
+ mobile_apis::Result::eType result_code =
+ mobile_apis::Result::eType((*message_)[strings::msg_params][strings::result_code].asInt());
+ if (result_code == mobile_apis::Result::APPLICATION_REGISTERED_ALREADY) {
+ last_message = false;
+ }
+ }
+
+ SendResponse(success, mobile_apis::Result::INVALID_ENUM, last_message);
+
+ if (success) {
+ ApplicationSharedPtr application =
+ ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::params][strings::connection_key].asInt());
+
+ MessageHelper::SendHMIStatusNotification(*application);
+ MessageHelper::SendChangeRegistrationRequestToHMI(application);
+ }
+}
+
+} // namespace commands
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc
new file mode 100644
index 000000000..4a8939a43
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc
@@ -0,0 +1,339 @@
+/*
+
+ 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/reset_global_properties_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
+#include "config_profile/profile.h"
+#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+ResetGlobalPropertiesRequest::ResetGlobalPropertiesRequest(
+ const MessageSharedPtr& message)
+ : CommandRequestImpl(message),
+ is_ui_send_(false),
+ is_tts_send_(false),
+ is_ui_received_(false),
+ is_tts_received_(false),
+ ui_result_(hmi_apis::Common_Result::INVALID_ENUM),
+ tts_result_(hmi_apis::Common_Result::INVALID_ENUM) {
+}
+
+ResetGlobalPropertiesRequest::~ResetGlobalPropertiesRequest() {
+}
+
+void ResetGlobalPropertiesRequest::Run() {
+ LOG4CXX_INFO(logger_, "ResetGlobalPropertiesRequest::Run");
+
+ uint32_t app_id = (*message_)[strings::params][strings::connection_key].asUInt();
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+
+ if (!app) {
+ LOG4CXX_ERROR_EXT(logger_, "No application associated with session key");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ size_t obj_length = (*message_)[strings::msg_params][strings::properties]
+ .length();
+
+ bool helpt_promt = false;
+ bool timeout_prompt = false;
+ bool vr_help_title = false;
+ bool vr_help_items = false;
+ bool menu_name = false;
+ bool menu_icon = false;
+ bool is_key_board_properties = false;
+
+ for (size_t i = 0; i < obj_length; ++i) {
+ switch ((*message_)[strings::msg_params][strings::properties][i].asInt()) {
+ case GlobalProperty::HELPPROMT: {
+ helpt_promt = ResetHelpPromt(app);
+ break;
+ }
+ case GlobalProperty::TIMEOUTPROMT: {
+ timeout_prompt = ResetTimeoutPromt(app);
+ break;
+ }
+ case GlobalProperty::VRHELPTITLE: {
+ vr_help_title = ResetVrHelpTitle(app);
+ break;
+ }
+ case GlobalProperty::VRHELPITEMS: {
+ vr_help_items = ResetVrHelpItems(app);
+ break;
+ }
+ case mobile_apis::GlobalProperty::MENUNAME: {
+ menu_name = true;
+ break;
+ }
+ case mobile_apis::GlobalProperty::MENUICON: {
+ menu_icon = true;
+ break;
+ }
+ case mobile_apis::GlobalProperty::KEYBOARDPROPERTIES: {
+ is_key_board_properties = true;
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(
+ logger_,
+ "Unknown global property 0x%02X value"
+ << (*message_)[strings::msg_params][strings::properties][i].asInt());
+ break;
+ }
+ }
+ }
+
+ if (vr_help_title || vr_help_items || menu_name || menu_icon
+ || is_key_board_properties) {
+ is_ui_send_ = true;
+ }
+
+ if (timeout_prompt || helpt_promt) {
+ is_tts_send_ = true;
+ }
+
+ app->set_reset_global_properties_active(true);
+
+ if (vr_help_title || vr_help_items || menu_name || menu_icon
+ || is_key_board_properties) {
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+
+ if (vr_help_title || vr_help_items) {
+ smart_objects::SmartObject* vr_help = MessageHelper::CreateAppVrHelp(app);
+ if (!vr_help) {
+ return;
+ }
+ msg_params = *vr_help;
+ }
+ if (menu_name) {
+ msg_params[hmi_request::menu_title] = "";
+ }
+ //TODO(DT): clarify the sending parameter menuIcon
+ //if (menu_icon) {
+ //}
+ if (is_key_board_properties) {
+ smart_objects::SmartObject key_board_properties = smart_objects::
+ SmartObject(smart_objects::SmartType_Map);
+ key_board_properties[strings::language] = static_cast<int32_t>
+ (hmi_apis::Common_Language::EN_US);
+ key_board_properties[hmi_request::keyboard_layout] = static_cast<int32_t>
+ (hmi_apis::Common_KeyboardLayout::QWERTY);
+ key_board_properties[hmi_request::send_dynamic_entry] = false;
+
+ // Look for APPLINK-4432 for details.
+ /*smart_objects::SmartObject limited_character_list = smart_objects::SmartObject(
+ smart_objects::SmartType_Array);
+ limited_character_list[0] = "";
+ key_board_properties[hmi_request::limited_character_list] =
+ limited_character_list;*/
+
+ key_board_properties[hmi_request::auto_complete_text] = "";
+ msg_params[hmi_request::keyboard_properties] = key_board_properties;
+ }
+
+ msg_params[strings::app_id] = app->app_id();
+ SendHMIRequest(hmi_apis::FunctionID::UI_SetGlobalProperties,
+ &msg_params, true);
+ }
+
+ if (timeout_prompt || helpt_promt) {
+ // create ui request
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+
+ if (helpt_promt) {
+ msg_params[strings::help_prompt] = (*app->help_prompt());
+ }
+
+ if (timeout_prompt) {
+ msg_params[strings::timeout_prompt] = (*app->timeout_prompt());
+ }
+
+ msg_params[strings::app_id] = app->app_id();
+
+ SendHMIRequest(hmi_apis::FunctionID::TTS_SetGlobalProperties,
+ &msg_params, true);
+ }
+}
+
+bool ResetGlobalPropertiesRequest::ResetHelpPromt(
+ application_manager::ApplicationSharedPtr app) {
+ if (!app) {
+ LOG4CXX_ERROR_EXT(logger_, "Null pointer");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return false;
+ }
+
+ const std::vector<std::string>& help_prompt = profile::Profile::instance()
+ ->help_prompt();
+
+ smart_objects::SmartObject so_help_prompt = smart_objects::SmartObject(
+ smart_objects::SmartType_Array);
+
+ for (uint32_t i = 0; i < help_prompt.size(); ++i) {
+ smart_objects::SmartObject helpPrompt = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ helpPrompt[strings::text] = help_prompt[i];
+ helpPrompt[strings::type] = hmi_apis::Common_SpeechCapabilities::SC_TEXT;
+ so_help_prompt[i] = helpPrompt;
+ }
+
+ app->set_help_prompt(so_help_prompt);
+
+ return true;
+}
+
+bool ResetGlobalPropertiesRequest::ResetTimeoutPromt(
+ application_manager::ApplicationSharedPtr const app) {
+ if (!app) {
+ LOG4CXX_ERROR_EXT(logger_, "Null pointer");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return false;
+ }
+
+ const std::vector<std::string>& time_out_promt = profile::Profile::instance()
+ ->time_out_promt();
+
+ smart_objects::SmartObject so_time_out_promt = smart_objects::SmartObject(
+ smart_objects::SmartType_Array);
+
+ for (uint32_t i = 0; i < time_out_promt.size(); ++i) {
+ smart_objects::SmartObject timeoutPrompt = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ timeoutPrompt[strings::text] = time_out_promt[i];
+ timeoutPrompt[strings::type] = hmi_apis::Common_SpeechCapabilities::SC_TEXT;
+ so_time_out_promt[i] = timeoutPrompt;
+ }
+
+ app->set_timeout_prompt(so_time_out_promt);
+
+ return true;
+}
+
+bool ResetGlobalPropertiesRequest::ResetVrHelpTitle(
+ application_manager::ApplicationSharedPtr const app) {
+ if (!app) {
+ LOG4CXX_ERROR_EXT(logger_, "Null pointer");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return false;
+ }
+ app->reset_vr_help_title();
+
+ return true;
+}
+
+bool ResetGlobalPropertiesRequest::ResetVrHelpItems(
+ application_manager::ApplicationSharedPtr const app) {
+ if (!app) {
+ LOG4CXX_ERROR_EXT(logger_, "Null pointer");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return false;
+ }
+ app->reset_vr_help();
+
+ return true;
+}
+
+void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "ResetGlobalPropertiesRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::UI_SetGlobalProperties: {
+ LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event");
+ is_ui_received_ = true;
+ ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ break;
+ }
+ case hmi_apis::FunctionID::TTS_SetGlobalProperties: {
+ LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event");
+ is_tts_received_ = true;
+ tts_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+
+ if (!IsPendingResponseExist()) {
+ bool result = ((hmi_apis::Common_Result::SUCCESS == ui_result_)
+ && (hmi_apis::Common_Result::SUCCESS == tts_result_ ||
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_))
+ || ((hmi_apis::Common_Result::SUCCESS == ui_result_)
+ && (hmi_apis::Common_Result::INVALID_ENUM == tts_result_))
+ || ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_)
+ && (hmi_apis::Common_Result::SUCCESS == tts_result_));
+
+ mobile_apis::Result::eType result_code;
+ const char* return_info = NULL;
+
+ if (result) {
+ if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_) {
+ result_code = mobile_apis::Result::WARNINGS;
+ return_info = std::string("Unsupported phoneme type sent in a prompt").c_str();
+ } else {
+ result_code = static_cast<mobile_apis::Result::eType>(
+ std::max(ui_result_, tts_result_));
+ }
+ } else {
+ result_code = static_cast<mobile_apis::Result::eType>(
+ std::max(ui_result_, tts_result_));
+ }
+
+ ApplicationSharedPtr application =
+ ApplicationManagerImpl::instance()->application(connection_key());
+ SendResponse(result, static_cast<mobile_apis::Result::eType>(result_code),
+ return_info, &(message[strings::msg_params]));
+ application->UpdateHash();
+ }
+}
+
+bool ResetGlobalPropertiesRequest::IsPendingResponseExist() {
+ return is_ui_send_ != is_ui_received_ || is_tts_send_ != is_tts_received_;
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc
new file mode 100644
index 000000000..aeacabf9d
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc
@@ -0,0 +1,57 @@
+/*
+
+ 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/reset_global_properties_response.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+ResetGlobalPropertiesResponse::ResetGlobalPropertiesResponse(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+ResetGlobalPropertiesResponse::~ResetGlobalPropertiesResponse() {
+}
+
+void ResetGlobalPropertiesResponse::Run() {
+ LOG4CXX_INFO(logger_, "ResetGlobalPropertiesResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc
new file mode 100644
index 000000000..e949b9888
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc
@@ -0,0 +1,159 @@
+/*
+
+ 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/scrollable_message_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
+#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+ScrollabelMessageRequest::ScrollabelMessageRequest(
+ const MessageSharedPtr& message)
+ : CommandRequestImpl(message),
+ result_(mobile_apis::Result::INVALID_ENUM) {
+
+ subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout);
+}
+
+ScrollabelMessageRequest::~ScrollabelMessageRequest() {
+}
+
+bool ScrollabelMessageRequest::Init() {
+
+ /* Timeout in milliseconds.
+ If omitted a standard value of 10000 milliseconds is used.*/
+ if ((*message_)[strings::msg_params].keyExists(strings::timeout)) {
+ default_timeout_ =
+ (*message_)[strings::msg_params][strings::timeout].asUInt();
+ } else {
+ const int32_t def_value = 30000;
+ default_timeout_ = def_value;
+ }
+
+ return true;
+}
+
+void ScrollabelMessageRequest::Run() {
+ LOG4CXX_INFO(logger_, "ScrollabelMessageRequest::Run");
+
+ ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance()
+ ->application((*message_)[strings::params][strings::connection_key].asUInt());
+
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "Application is not registered");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ mobile_apis::Result::eType processing_result =
+ MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app);
+
+ if (mobile_apis::Result::SUCCESS != processing_result) {
+ if (mobile_apis::Result::INVALID_DATA == processing_result) {
+ LOG4CXX_ERROR(logger_, "Wrong soft buttons parameters!");
+ SendResponse(false, processing_result);
+ return;
+ }
+ if (mobile_apis::Result::UNSUPPORTED_RESOURCE == processing_result) {
+ LOG4CXX_ERROR(logger_, "UNSUPPORTED_RESOURCE!");
+ result_ = processing_result;
+ }
+ }
+
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+
+ msg_params[hmi_request::message_text][hmi_request::field_name] =
+ static_cast<int32_t>(application_manager::TextFieldName::SCROLLABLE_MSG_BODY);
+ msg_params[hmi_request::message_text][hmi_request::field_text] =
+ (*message_)[strings::msg_params][strings::scroll_message_body];
+ msg_params[strings::app_id] = app->app_id();
+ msg_params[strings::timeout] = default_timeout_;
+
+ if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) {
+ msg_params[strings::soft_buttons] =
+ (*message_)[strings::msg_params][strings::soft_buttons];
+ }
+
+ SendHMIRequest(hmi_apis::FunctionID::UI_ScrollableMessage, &msg_params, true);
+}
+
+void ScrollabelMessageRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "ScrollabelMessageRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ 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());
+ break;
+ }
+ case hmi_apis::FunctionID::UI_ScrollableMessage: {
+ LOG4CXX_INFO(logger_, "Received UI_ScrollableMessage event");
+
+ mobile_apis::Result::eType result_code =
+ static_cast<mobile_apis::Result::eType>
+ (message[strings::params][hmi_response::code].asInt());
+
+ bool result = false;
+ if (mobile_apis::Result::SUCCESS == result_code) {
+ result = true;
+ }
+ if (mobile_apis::Result::ABORTED == result_code) {
+ result = true;
+ } else
+
+ if (mobile_apis::Result::INVALID_ENUM != result_) {
+ result_code = result_;
+ }
+
+ SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_,"Received unknown event" << event.id());
+ break;
+ }
+ }
+}
+
+} // namespace commands
+} // namespace application_manager
+
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc
new file mode 100644
index 000000000..45a8e991f
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc
@@ -0,0 +1,55 @@
+/*
+
+ 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/scrollable_message_response.h"
+#include "application_manager/application_manager_impl.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+ScrollableMessageResponse::ScrollableMessageResponse(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+void ScrollableMessageResponse::Run() {
+ LOG4CXX_INFO(logger_, "ScrollableMessageResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc
new file mode 100644
index 000000000..5ee701365
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc
@@ -0,0 +1,109 @@
+/*
+
+ 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_display_layout_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+
+
+namespace application_manager {
+
+namespace commands {
+
+SetDisplayLayoutRequest::SetDisplayLayoutRequest(
+ const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+SetDisplayLayoutRequest::~SetDisplayLayoutRequest() {
+}
+
+void SetDisplayLayoutRequest::Run() {
+ LOG4CXX_INFO(logger_, "SetDisplayLayoutRequest::Run");
+
+ ApplicationConstSharedPtr app = ApplicationManagerImpl::instance()
+ ->application(connection_key());
+
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "Application is not registered");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ (*message_)[strings::msg_params][strings::app_id] = app->app_id();
+
+ SendHMIRequest(hmi_apis::FunctionID::UI_SetDisplayLayout,
+ &((*message_)[strings::msg_params]), true);
+
+}
+
+void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "SetDisplayLayoutRequest::on_event");
+
+ const smart_objects::SmartObject& message = event.smart_object();
+ switch (event.id()) {
+ case hmi_apis::FunctionID::UI_SetDisplayLayout: {
+ LOG4CXX_INFO(logger_, "Received UI_SetDisplayLayout event");
+
+ mobile_apis::Result::eType result_code =
+ static_cast<mobile_apis::Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ bool response_success = mobile_apis::Result::SUCCESS == result_code;
+ if (response_success) {
+ HMICapabilities& hmi_capabilities =
+ ApplicationManagerImpl::instance()->hmi_capabilities();
+ if (message[strings::msg_params].keyExists(hmi_response::display_capabilities)) {
+ hmi_capabilities.set_display_capabilities(
+ message[strings::msg_params][hmi_response::display_capabilities]);
+ }
+
+ if (message[strings::msg_params].keyExists(
+ hmi_response::soft_button_capabilities)) {
+ hmi_capabilities.set_soft_button_capabilities(
+ message[strings::msg_params][hmi_response::soft_button_capabilities]);
+ }
+
+ }
+ SendResponse(response_success, 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/SDL_Core/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc
new file mode 100644
index 000000000..51f8c1f35
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc
@@ -0,0 +1,59 @@
+/*
+
+ 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_display_layout_response.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+SetDisplayLayoutResponse::SetDisplayLayoutResponse(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+SetDisplayLayoutResponse::~SetDisplayLayoutResponse() {
+}
+
+void SetDisplayLayoutResponse::Run() {
+ LOG4CXX_INFO(logger_, "SetDisplayLayoutResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc
new file mode 100644
index 000000000..cfb4be5af
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc
@@ -0,0 +1,350 @@
+/*
+
+ 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 <algorithm>
+#include "application_manager/commands/mobile/set_global_properties_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
+#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+SetGlobalPropertiesRequest::SetGlobalPropertiesRequest(
+ const MessageSharedPtr& message)
+ : CommandRequestImpl(message),
+ is_ui_send_(false),
+ is_tts_send_(false),
+ is_ui_received_(false),
+ is_tts_received_(false),
+ ui_result_(hmi_apis::Common_Result::INVALID_ENUM),
+ tts_result_(hmi_apis::Common_Result::INVALID_ENUM) {
+}
+
+SetGlobalPropertiesRequest::~SetGlobalPropertiesRequest() {
+}
+
+void SetGlobalPropertiesRequest::Run() {
+ LOG4CXX_INFO(logger_, "SetGlobalPropertiesRequest::Run");
+
+ const smart_objects::SmartObject& msg_params =
+ (*message_)[strings::msg_params];
+
+ uint32_t app_id =
+ (*message_)[strings::params][strings::connection_key].asUInt();
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+
+ if (!app) {
+ LOG4CXX_ERROR_EXT(logger_, "No application associated with session key");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ if (!ValidateConditionalMandatoryParameters(msg_params)) {
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
+ "There are no parameters present in request.");
+ return;
+ }
+
+ // Check for image file(s) in vrHelpItem
+ mobile_apis::Result::eType verification_result =
+ MessageHelper::VerifyImageFiles((*message_)[strings::msg_params], app);
+
+ if (mobile_apis::Result::SUCCESS != verification_result) {
+ LOG4CXX_ERROR_EXT(
+ logger_,
+ "MessageHelper::VerifyImageFiles return " << verification_result);
+ SendResponse(false, verification_result);
+ return;
+ }
+
+
+ bool is_help_prompt_present = msg_params.keyExists(strings::help_prompt);
+ bool is_timeout_prompt_present = msg_params.keyExists(
+ strings::timeout_prompt);
+ bool is_vr_help_title_present = msg_params.keyExists(strings::vr_help_title);
+ bool is_vr_help_present = msg_params.keyExists(strings::vr_help);
+ bool is_menu_title_present = msg_params.keyExists(hmi_request::menu_title);
+ bool is_menu_icon_present = msg_params.keyExists(hmi_request::menu_icon);
+ bool is_keyboard_props_present =
+ msg_params.keyExists(hmi_request::keyboard_properties);
+
+ // Media-only applications support API v2.1 with less parameters
+ if (!app->allowed_support_navigation() &&
+ (is_keyboard_props_present ||
+ is_menu_icon_present ||
+ is_menu_title_present)
+ ) {
+ const std::string app_type =
+ app->is_media_application() ? "media" : "non-media";
+
+ const std::string message =
+ "There are too many parameters for "+app_type+" application.";
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
+ message.c_str());
+ return;
+ }
+
+ if ((is_vr_help_title_present && is_vr_help_present) ||
+ (!is_vr_help_title_present && !is_vr_help_present)) {
+ is_ui_send_ = true;
+ }
+
+ if (is_help_prompt_present || is_timeout_prompt_present) {
+ is_tts_send_ = true;
+ }
+
+ if (is_vr_help_title_present && is_vr_help_present) {
+ // check vrhelpitem position index
+ if (!CheckVrHelpItemsOrder()) {
+ LOG4CXX_ERROR(logger_, "Request rejected");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ return;
+ }
+
+ app->set_vr_help_title(
+ msg_params.getElement(strings::vr_help_title));
+ app->set_vr_help(
+ msg_params.getElement(strings::vr_help));
+
+ smart_objects::SmartObject params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ params[strings::vr_help_title] = (*app->vr_help_title());
+ params[strings::vr_help] = (*app->vr_help());
+ params[strings::app_id] = app->app_id();
+ if (is_menu_title_present) {
+
+ params[hmi_request::menu_title] =
+ msg_params[hmi_request::menu_title].asString();
+ }
+ if (is_menu_icon_present) {
+
+ params[hmi_request::menu_icon] =
+ msg_params[hmi_request::menu_icon];
+ }
+ if (is_keyboard_props_present) {
+
+ params[hmi_request::keyboard_properties] =
+ msg_params[hmi_request::keyboard_properties];
+ }
+
+ SendHMIRequest(hmi_apis::FunctionID::UI_SetGlobalProperties,
+ &params, true);
+ } else if (!is_vr_help_title_present && !is_vr_help_present) {
+ const CommandsMap& cmdMap = app->commands_map();
+ CommandsMap::const_iterator command_it = cmdMap.begin();
+
+ int32_t index = 0;
+ smart_objects::SmartObject vr_help_items;
+ for (; cmdMap.end() != command_it; ++command_it) {
+ if (false == (*command_it->second).keyExists(strings::vr_commands)) {
+ LOG4CXX_ERROR(logger_, "VR synonyms are empty");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+ // use only first
+ vr_help_items[index][strings::position] = (index + 1);
+ vr_help_items[index++][strings::text] =
+ (*command_it->second)[strings::vr_commands][0];
+ }
+
+ app->set_vr_help_title(smart_objects::SmartObject(app->name()));
+ app->set_vr_help(vr_help_items);
+
+ smart_objects::SmartObject params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ params[strings::vr_help_title] = (*app->vr_help_title());
+ params[strings::vr_help] = (*app->vr_help());
+ params[strings::app_id] = app->app_id();
+ if (is_menu_title_present) {
+
+ params[hmi_request::menu_title] =
+ msg_params[hmi_request::menu_title].asString();
+ }
+ if (is_menu_icon_present) {
+
+ params[hmi_request::menu_icon] =
+ msg_params[hmi_request::menu_icon];
+ }
+ if (is_keyboard_props_present) {
+
+ params[hmi_request::keyboard_properties] =
+ msg_params[hmi_request::keyboard_properties];
+ }
+
+ SendHMIRequest(hmi_apis::FunctionID::UI_SetGlobalProperties,
+ &params, true);
+ } else {
+ LOG4CXX_ERROR(logger_, "Request rejected");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ return;
+ }
+
+ // check TTS params
+ if (is_help_prompt_present || is_timeout_prompt_present) {
+ smart_objects::SmartObject params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ if (is_help_prompt_present) {
+ app->set_help_prompt(
+ msg_params.getElement(strings::help_prompt));
+ params[strings::help_prompt] = (*app->help_prompt());
+ }
+
+ if (is_timeout_prompt_present) {
+ app->set_timeout_prompt(
+ msg_params.getElement(strings::timeout_prompt));
+ params[strings::timeout_prompt] = (*app->timeout_prompt());
+ }
+
+ params[strings::app_id] = app->app_id();
+
+ SendHMIRequest(hmi_apis::FunctionID::TTS_SetGlobalProperties,
+ &params, true);
+ }
+}
+
+bool SetGlobalPropertiesRequest::CheckVrHelpItemsOrder() {
+ const smart_objects::SmartObject vr_help = (*message_)[strings::msg_params]
+ .getElement(strings::vr_help);
+
+ // vr help item start position must be 1
+ const uint32_t vr_help_item_start_position = 1;
+
+ if (vr_help_item_start_position !=
+ vr_help.getElement(0).getElement(strings::position).asUInt()) {
+ LOG4CXX_ERROR(logger_, "VR help items start position is wrong");
+ return false;
+ }
+
+ // Check if VR Help Items contains sequential positionss
+ size_t i = 0;
+ for (size_t j = 1; j < vr_help.length(); ++i, ++j) {
+ if ((vr_help.getElement(i).getElement(strings::position).asInt() + 1)
+ != vr_help.getElement(j).getElement(strings::position).asInt()) {
+ LOG4CXX_ERROR(logger_, "VR help items order is wrong");
+ return false;
+ }
+ }
+
+ return true;
+}
+
+void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "SetGlobalPropertiesRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(CommandRequestImpl::connection_key());
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::UI_SetGlobalProperties: {
+ LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event");
+ is_ui_received_ = true;
+ ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ break;
+ }
+ case hmi_apis::FunctionID::TTS_SetGlobalProperties: {
+ LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event");
+ is_tts_received_ = true;
+ tts_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+
+ if (!IsPendingResponseExist()) {
+ bool result = ((hmi_apis::Common_Result::SUCCESS == ui_result_)
+ && (hmi_apis::Common_Result::SUCCESS == tts_result_ ||
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_))
+ || ((hmi_apis::Common_Result::SUCCESS == ui_result_)
+ && (hmi_apis::Common_Result::INVALID_ENUM == tts_result_))
+ || ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_)
+ && (hmi_apis::Common_Result::SUCCESS == tts_result_));
+
+ mobile_apis::Result::eType result_code;
+ const char* return_info = NULL;
+
+ if (result) {
+ if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_) {
+ result_code = mobile_apis::Result::WARNINGS;
+ return_info =
+ std::string("Unsupported phoneme type sent in a prompt").c_str();
+ } else {
+ result_code = static_cast<mobile_apis::Result::eType>(
+ std::max(ui_result_, tts_result_));
+ }
+ } else {
+ result_code = static_cast<mobile_apis::Result::eType>(
+ std::max(ui_result_, tts_result_));
+ }
+
+ ApplicationSharedPtr application =
+ ApplicationManagerImpl::instance()->application(connection_key());
+ SendResponse(result, static_cast<mobile_apis::Result::eType>(result_code),
+ return_info, &(message[strings::msg_params]));
+ application->UpdateHash();
+ }
+}
+
+bool SetGlobalPropertiesRequest::IsPendingResponseExist() {
+
+ return is_ui_send_ != is_ui_received_ || is_tts_send_ != is_tts_received_;
+}
+
+bool SetGlobalPropertiesRequest::ValidateConditionalMandatoryParameters(
+ const smart_objects::SmartObject& params) {
+ return params.keyExists(strings::help_prompt)
+ || params.keyExists(strings::timeout_prompt)
+ || params.keyExists(strings::vr_help_title)
+ || params.keyExists(strings::vr_help)
+ || params.keyExists(strings::menu_title)
+ || params.keyExists(strings::menu_icon)
+ || params.keyExists(strings::keyboard_properties);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc
new file mode 100644
index 000000000..5f0b62fb4
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc
@@ -0,0 +1,58 @@
+/*
+
+ 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_global_properties_response.h"
+#include "application_manager/application_manager_impl.h"
+
+
+namespace application_manager {
+
+namespace commands {
+
+SetGlobalPropertiesResponse::SetGlobalPropertiesResponse(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+SetGlobalPropertiesResponse::~SetGlobalPropertiesResponse() {
+}
+
+void SetGlobalPropertiesResponse::Run() {
+ LOG4CXX_INFO(logger_, "SetGlobalPropertiesResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/set_icon_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/set_icon_request.cc
new file mode 100644
index 000000000..73dc1bd0f
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/set_icon_request.cc
@@ -0,0 +1,139 @@
+/*
+
+ 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_icon_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
+#include "utils/file_system.h"
+
+namespace application_manager {
+
+namespace commands {
+
+SetIconRequest::SetIconRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+SetIconRequest::~SetIconRequest() {
+}
+
+void SetIconRequest::Run() {
+ LOG4CXX_INFO(logger_, "SetIconRequest::Run");
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::params][strings::connection_key].asUInt());
+
+ 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 relative_file_path = app->name();
+ relative_file_path += "/";
+ relative_file_path += sync_file_name;
+
+ std::string full_file_path = file_system::FullPath(relative_file_path);
+
+ if (!file_system::FileExists(full_file_path)) {
+ LOG4CXX_ERROR(logger_, "No such file");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+
+ 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);
+
+ 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> (SetIconRequest::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 SetIconRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "SetIconRequest::on_event");
+ 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());
+
+ 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/SDL_Core/src/components/application_manager/src/commands/mobile/set_icon_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/set_icon_response.cc
new file mode 100644
index 000000000..f1580823d
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/set_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_icon_response.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+SetIconResponse::SetIconResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+SetIconResponse::~SetIconResponse() {
+}
+
+void SetIconResponse::Run() {
+ LOG4CXX_INFO(logger_, "SetIconResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc
new file mode 100644
index 000000000..7daddce7a
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc
@@ -0,0 +1,149 @@
+/*
+
+ 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_media_clock_timer_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+SetMediaClockRequest::SetMediaClockRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+SetMediaClockRequest::~SetMediaClockRequest() {
+}
+
+void SetMediaClockRequest::Run() {
+ LOG4CXX_INFO(logger_, "SetMediaClockRequest::Run");
+
+ uint32_t app_id = (*message_)[strings::params][strings::connection_key]
+ .asUInt();
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+
+ if (!app) {
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ LOG4CXX_ERROR(logger_, "Application is not registered");
+ return;
+ }
+
+ if (!app->is_media_application()) {
+ LOG4CXX_ERROR(logger_, "Application is not media application");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ return;
+ }
+
+ if (isDataValid()) {
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ // copy entirely msg
+ msg_params = (*message_)[strings::msg_params];
+ msg_params[strings::app_id] = app->app_id();
+
+ SendHMIRequest(hmi_apis::FunctionID::UI_SetMediaClockTimer, &msg_params, true);
+ } else {
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ }
+}
+
+void SetMediaClockRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "SetMediaClockRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::UI_SetMediaClockTimer: {
+ 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;
+
+ SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+}
+
+bool SetMediaClockRequest::isDataValid() {
+ if (!(*message_)[strings::msg_params].keyExists(strings::start_time)
+ && ((*message_)[strings::msg_params][strings::update_mode]
+ == mobile_apis::UpdateMode::COUNTUP
+ || (*message_)[strings::msg_params][strings::update_mode]
+ == mobile_apis::UpdateMode::COUNTDOWN)) {
+ LOG4CXX_INFO(logger_, "Data is invalid");
+ return false;
+ } else if (((*message_)[strings::msg_params].keyExists(strings::start_time))
+ && ((*message_)[strings::msg_params][strings::update_mode]
+ == mobile_apis::UpdateMode::COUNTUP
+ || (*message_)[strings::msg_params][strings::update_mode]
+ == mobile_apis::UpdateMode::COUNTDOWN) &&
+ ((*message_)[strings::msg_params].keyExists(strings::end_time))) {
+ unsigned int start_time_in_seconds = 0;
+ unsigned int end_time_in_seconds = 0;
+ start_time_in_seconds = ((*message_)[strings::msg_params]
+ [strings::start_time][strings::hours].asUInt()) * 3600;
+ start_time_in_seconds += ((*message_)[strings::msg_params]
+ [strings::start_time][strings::minutes].asUInt()) * 60;
+ start_time_in_seconds += ((*message_)[strings::msg_params]
+ [strings::start_time][strings::seconds].asUInt());
+ end_time_in_seconds = ((*message_)[strings::msg_params]
+ [strings::end_time][strings::hours].asUInt()) * 3600;
+ end_time_in_seconds += ((*message_)[strings::msg_params]
+ [strings::end_time][strings::minutes].asUInt()) * 60;
+ end_time_in_seconds += ((*message_)[strings::msg_params]
+ [strings::end_time][strings::seconds].asUInt());
+ if (((end_time_in_seconds > start_time_in_seconds) &&
+ ((*message_)[strings::msg_params][strings::update_mode] ==
+ mobile_apis::UpdateMode::COUNTDOWN)) ||
+ ((end_time_in_seconds < start_time_in_seconds) &&
+ ((*message_)[strings::msg_params][strings::update_mode] ==
+ mobile_apis::UpdateMode::COUNTUP))) {
+ LOG4CXX_INFO(logger_, "Data is invalid");
+ return false;
+ }
+ }
+ LOG4CXX_INFO(logger_, "Data is valid");
+ return true;
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc
new file mode 100644
index 000000000..73923b002
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc
@@ -0,0 +1,57 @@
+/*
+
+ 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_media_clock_timer_response.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+SetMediaClockTimerResponse::SetMediaClockTimerResponse(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+SetMediaClockTimerResponse::~SetMediaClockTimerResponse() {
+}
+
+void SetMediaClockTimerResponse::Run() {
+ LOG4CXX_INFO(logger_, "SetMediaClockTimerResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc
new file mode 100644
index 000000000..27cb9f52a
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc
@@ -0,0 +1,192 @@
+/*
+
+ 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/show_constant_tbt_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
+#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+ShowConstantTBTRequest::ShowConstantTBTRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message),
+ result_(mobile_apis::Result::INVALID_ENUM) {
+}
+
+ShowConstantTBTRequest::~ShowConstantTBTRequest() {
+}
+
+void ShowConstantTBTRequest::Run() {
+ LOG4CXX_INFO(logger_, "ShowConstantTBTRequest::Run");
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::params][strings::connection_key].asUInt());
+
+ if (!app) {
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ LOG4CXX_ERROR(logger_, "Application is not registered");
+ return;
+ }
+
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ msg_params = (*message_)[strings::msg_params];
+
+ // TODO(DK): Missing mandatory param
+ if (!msg_params.keyExists(strings::soft_buttons)) {
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ LOG4CXX_ERROR(logger_, "INVALID_DATA");
+ return;
+ }
+
+ mobile_apis::Result::eType processing_result =
+ MessageHelper::ProcessSoftButtons(msg_params, app);
+
+ if (mobile_apis::Result::SUCCESS != processing_result) {
+ if (mobile_apis::Result::INVALID_DATA == processing_result) {
+ LOG4CXX_ERROR(logger_, "INVALID_DATA!");
+ SendResponse(false, processing_result);
+ return;
+ }
+ if (mobile_apis::Result::UNSUPPORTED_RESOURCE == processing_result) {
+ LOG4CXX_ERROR(logger_, "UNSUPPORTED_RESOURCE!");
+ result_ = processing_result;
+ }
+ }
+
+ mobile_apis::Result::eType verification_result =
+ MessageHelper::VerifyImageFiles(msg_params, app);
+
+ if (mobile_apis::Result::SUCCESS != verification_result) {
+ if (mobile_apis::Result::INVALID_DATA == verification_result) {
+ LOG4CXX_ERROR(logger_, "VerifyImageFiles INVALID_DATA!");
+ SendResponse(false, verification_result);
+ return;
+ }
+ if (mobile_apis::Result::UNSUPPORTED_RESOURCE == verification_result) {
+ LOG4CXX_ERROR(logger_, "VerifyImageFiles UNSUPPORTED_RESOURCE!");
+ result_ = verification_result;
+ }
+ }
+
+ msg_params[strings::app_id] = app->app_id();
+
+ msg_params[hmi_request::navi_texts] = smart_objects::SmartObject(
+ smart_objects::SmartType_Array);
+
+ int32_t index = 0;
+ if (msg_params.keyExists(strings::navigation_text_1)) {
+ // erase useless parametr
+ msg_params.erase(strings::navigation_text_1);
+ msg_params[hmi_request::navi_texts][index][hmi_request::field_name] =
+ static_cast<int32_t>(application_manager::TextFieldName::NAVI_TEXT1);
+ msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] =
+ (*message_)[strings::msg_params][strings::navigation_text_1];
+ }
+
+ if (msg_params.keyExists(strings::navigation_text_2)) {
+ // erase useless param
+ msg_params.erase(strings::navigation_text_2);
+ msg_params[hmi_request::navi_texts][index][hmi_request::field_name] =
+ static_cast<int32_t>(application_manager::TextFieldName::NAVI_TEXT2);
+ msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] =
+ (*message_)[strings::msg_params][strings::navigation_text_2];
+ }
+
+ if (msg_params.keyExists(strings::eta)) {
+ // erase useless param
+ msg_params.erase(strings::eta);
+ msg_params[hmi_request::navi_texts][index][hmi_request::field_name] =
+ static_cast<int32_t>(application_manager::TextFieldName::ETA);
+ msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] =
+ (*message_)[strings::msg_params][strings::eta];
+ }
+
+ if (msg_params.keyExists(strings::total_distance)) {
+ // erase useless param
+ msg_params.erase(strings::total_distance);
+ msg_params[hmi_request::navi_texts][index][hmi_request::field_name] =
+ static_cast<int32_t>(application_manager::TextFieldName::TOTAL_DISTANCE);
+ msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] =
+ (*message_)[strings::msg_params][strings::total_distance];
+ }
+
+ if (msg_params.keyExists(strings::time_to_destination)) {
+ // erase useless param
+ msg_params.erase(strings::time_to_destination);
+ msg_params[hmi_request::navi_texts][index][hmi_request::field_name] =
+ static_cast<int32_t>(hmi_apis::Common_TextFieldName::timeToDestination);
+ msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] =
+ (*message_)[strings::msg_params][strings::time_to_destination];
+ }
+
+ app->set_tbt_show_command(msg_params);
+ SendHMIRequest(hmi_apis::FunctionID::Navigation_ShowConstantTBT, &msg_params,
+ true);
+}
+
+
+void ShowConstantTBTRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "ShowConstantTBTRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::Navigation_ShowConstantTBT: {
+ LOG4CXX_INFO(logger_, "Received Navigation_ShowConstantTBT event");
+
+ 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 (mobile_apis::Result::INVALID_ENUM != result_) {
+ result_code = result_;
+ }
+
+ SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_,"Received unknown event" << event.id());
+ break;
+ }
+ }
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc
new file mode 100644
index 000000000..d5539d148
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc
@@ -0,0 +1,58 @@
+/*
+
+ 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/show_constant_tbt_response.h"
+#include "application_manager/application_manager_impl.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+ShowConstantTBTResponse::ShowConstantTBTResponse(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+ShowConstantTBTResponse::~ShowConstantTBTResponse() {
+}
+
+void ShowConstantTBTResponse::Run() {
+ LOG4CXX_INFO(logger_, "ShowConstantTBTResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/show_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/show_request.cc
new file mode 100644
index 000000000..bde57429e
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/show_request.cc
@@ -0,0 +1,261 @@
+/*
+
+ 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/show_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application.h"
+#include "application_manager/message_helper.h"
+#include "utils/file_system.h"
+
+namespace application_manager {
+
+namespace commands {
+
+ShowRequest::ShowRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message),
+ result_(mobile_apis::Result::INVALID_ENUM) {
+}
+
+ShowRequest::~ShowRequest() {
+}
+
+void ShowRequest::Run() {
+ LOG4CXX_INFO(logger_, "ShowRequest::Run");
+
+ ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance()
+ ->application(
+ (*message_)[strings::params][strings::connection_key].asInt());
+
+ if (!app) {
+ LOG4CXX_ERROR_EXT(
+ logger_, "An application " << app->name() << " is not registered.");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ mobile_apis::Result::eType processing_result =
+ MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app);
+
+ if (mobile_apis::Result::SUCCESS != processing_result) {
+ if (mobile_apis::Result::INVALID_DATA == processing_result) {
+ LOG4CXX_ERROR(logger_, "INVALID_DATA!");
+ SendResponse(false, processing_result);
+ return;
+ }
+ if (mobile_apis::Result::UNSUPPORTED_RESOURCE == processing_result) {
+ LOG4CXX_ERROR(logger_, "UNSUPPORTED_RESOURCE!");
+ result_ = processing_result;
+ }
+ }
+
+ mobile_apis::Result::eType verification_result =
+ MessageHelper::VerifyImageFiles((*message_)[strings::msg_params], app);
+
+ if (mobile_apis::Result::SUCCESS != verification_result) {
+ if (mobile_apis::Result::INVALID_DATA == verification_result) {
+ LOG4CXX_ERROR(logger_, "VerifyImageFiles INVALID_DATA!");
+ SendResponse(false, verification_result);
+ return;
+ }
+ if (mobile_apis::Result::UNSUPPORTED_RESOURCE == verification_result) {
+ LOG4CXX_ERROR(logger_, "VerifyImageFiles UNSUPPORTED_RESOURCE!");
+ result_ = verification_result;
+ }
+ }
+
+ if (!CheckMenuFieldsNames()) {
+ LOG4CXX_ERROR(logger_, "Bad menu name");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ msg_params[strings::app_id] = app->app_id();
+
+ msg_params[hmi_request::show_strings] = smart_objects::SmartObject(
+ smart_objects::SmartType_Array);
+
+ int32_t index = 0;
+ if ((*message_)[strings::msg_params].keyExists(strings::main_field_1)) {
+ msg_params[hmi_request::show_strings][index][hmi_request::field_name] =
+ static_cast<int32_t>(application_manager::TextFieldName::MAIN_FILED1);
+ msg_params[hmi_request::show_strings][index][hmi_request::field_text] =
+ (*message_)[strings::msg_params][strings::main_field_1];
+ ++index;
+ }
+
+ if ((*message_)[strings::msg_params].keyExists(strings::main_field_2)) {
+ msg_params[hmi_request::show_strings][index][hmi_request::field_name] =
+ static_cast<int32_t>(application_manager::TextFieldName::MAIN_FILED2);
+ msg_params[hmi_request::show_strings][index][hmi_request::field_text] =
+ (*message_)[strings::msg_params][strings::main_field_2];
+ ++index;
+ }
+
+ if ((*message_)[strings::msg_params].keyExists(strings::main_field_3)) {
+ msg_params[hmi_request::show_strings][index][hmi_request::field_name] =
+ static_cast<int32_t>(application_manager::TextFieldName::MAIN_FILED3);
+ msg_params[hmi_request::show_strings][index][hmi_request::field_text] =
+ (*message_)[strings::msg_params][strings::main_field_3];
+ ++index;
+ }
+
+ if ((*message_)[strings::msg_params].keyExists(strings::main_field_4)) {
+ msg_params[hmi_request::show_strings][index][hmi_request::field_name] =
+ static_cast<int32_t>(application_manager::TextFieldName::MAIN_FILED4);
+ msg_params[hmi_request::show_strings][index][hmi_request::field_text] =
+ (*message_)[strings::msg_params][strings::main_field_4];
+ ++index;
+ }
+
+ if ((*message_)[strings::msg_params].keyExists(strings::media_clock)) {
+ msg_params[hmi_request::show_strings][index][hmi_request::field_name] =
+ static_cast<int32_t>(application_manager::TextFieldName::MEDIA_CLOCK);
+ msg_params[hmi_request::show_strings][index][hmi_request::field_text] =
+ (*message_)[strings::msg_params][strings::media_clock];
+ ++index;
+ }
+
+ if ((*message_)[strings::msg_params].keyExists(strings::media_track)) {
+ msg_params[hmi_request::show_strings][index][hmi_request::field_name] =
+ static_cast<int32_t>(application_manager::TextFieldName::MEDIA_TRACK);
+ msg_params[hmi_request::show_strings][index][hmi_request::field_text] =
+ (*message_)[strings::msg_params][strings::media_track];
+ ++index;
+ }
+
+ if ((*message_)[strings::msg_params].keyExists(strings::status_bar)) {
+ msg_params[hmi_request::show_strings][index][hmi_request::field_name] =
+ static_cast<int32_t>(application_manager::TextFieldName::STATUS_BAR);
+ msg_params[hmi_request::show_strings][index][hmi_request::field_text] =
+ (*message_)[strings::msg_params][strings::status_bar];
+ ++index;
+ }
+
+ if ((*message_)[strings::msg_params].keyExists(strings::alignment)) {
+ msg_params[strings::alignment] =
+ (*message_)[strings::msg_params][strings::alignment];
+ }
+
+ if ((*message_)[strings::msg_params].keyExists(strings::graphic)) {
+ msg_params[strings::graphic] =
+ (*message_)[strings::msg_params][strings::graphic];
+ }
+
+ if ((*message_)[strings::msg_params].keyExists(strings::secondary_graphic)) {
+ msg_params[strings::secondary_graphic] =
+ (*message_)[strings::msg_params][strings::secondary_graphic];
+ }
+
+ if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) {
+ msg_params[strings::soft_buttons] =
+ (*message_)[strings::msg_params][strings::soft_buttons];
+ }
+
+ if ((*message_)[strings::msg_params].keyExists(strings::custom_presets)) {
+ msg_params[strings::custom_presets] =
+ (*message_)[strings::msg_params][strings::custom_presets];
+ }
+
+ SendHMIRequest(hmi_apis::FunctionID::UI_Show, &msg_params, true);
+
+ MessageSharedPtr persistentData = new smart_objects::SmartObject(msg_params);
+ app->set_show_command(*persistentData);
+}
+
+void ShowRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "ShowRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::UI_Show: {
+ LOG4CXX_INFO(logger_, "Received UI_Show event");
+
+ 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 (mobile_apis::Result::INVALID_ENUM != result_) {
+ result_code = result_;
+ }
+
+ SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_,"Received unknown event" << event.id());
+ break;
+ }
+ }
+}
+
+bool ShowRequest::CheckMenuFieldsNames() {
+ if ((*message_)[strings::msg_params].keyExists(strings::main_field_4)) {
+ const std::string& str = (*message_)[strings::msg_params]
+ [strings::main_field_4].asString();
+ if (!CheckSyntax(str, true)) {
+ LOG4CXX_INFO(logger_, "main_field_4 syntax check failed");
+ return false;
+ }
+ }
+ if ((*message_)[strings::msg_params].keyExists(strings::main_field_3)) {
+ const std::string& str = (*message_)[strings::msg_params]
+ [strings::main_field_3].asString();
+ if (!CheckSyntax(str, true)) {
+ LOG4CXX_INFO(logger_, "main_field_3 syntax check failed");
+ return false;
+ }
+ }
+ if ((*message_)[strings::msg_params].keyExists(strings::main_field_2)) {
+ const std::string& str = (*message_)[strings::msg_params]
+ [strings::main_field_2].asString();
+ if (!CheckSyntax(str, true)) {
+ LOG4CXX_INFO(logger_, "main_field_2 syntax check failed");
+ return false;
+ }
+ }
+ if ((*message_)[strings::msg_params].keyExists(strings::main_field_1)) {
+ const std::string& str = (*message_)[strings::msg_params]
+ [strings::main_field_1].asString();
+ if (!CheckSyntax(str, true)) {
+ LOG4CXX_INFO(logger_, "main_field_1 syntax check failed");
+ return false;
+ }
+ }
+ return true;
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/show_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/show_response.cc
new file mode 100644
index 000000000..1f9c59c6f
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/show_response.cc
@@ -0,0 +1,58 @@
+/*
+
+ 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/show_response.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+ShowResponse::ShowResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+ShowResponse::~ShowResponse() {
+}
+
+void ShowResponse::Run() {
+ LOG4CXX_INFO(logger_, "ShowResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/slider_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/slider_request.cc
new file mode 100644
index 000000000..6e0646262
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/slider_request.cc
@@ -0,0 +1,148 @@
+/*
+
+ 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/slider_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+SliderRequest::SliderRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+ subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout);
+}
+
+SliderRequest::~SliderRequest() {
+}
+
+bool SliderRequest::Init() {
+
+ /* Timeout in milliseconds.
+ If omitted a standard value of 10000 milliseconds is used.*/
+ if ((*message_)[strings::msg_params].keyExists(strings::timeout)) {
+ default_timeout_ =
+ (*message_)[strings::msg_params][strings::timeout].asUInt();
+ }
+
+ return true;
+}
+
+void SliderRequest::Run() {
+ LOG4CXX_INFO(logger_, "SliderRequest::Run");
+
+ ApplicationSharedPtr application =
+ application_manager::ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::params][strings::connection_key].asUInt());
+
+ if (!application) {
+ LOG4CXX_ERROR(logger_, "Application is not registered");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ if ((*message_)[strings::msg_params][strings::num_ticks].asInt()
+ < (*message_)[strings::msg_params][strings::position].asInt()) {
+ LOG4CXX_ERROR(logger_, "INVALID_DATA");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+
+ if ((*message_)[strings::msg_params].keyExists(strings::slider_footer)) {
+ if (1 < (*message_)[strings::msg_params][strings::slider_footer].length()) {
+ if ((*message_)[strings::msg_params][strings::num_ticks].asInt()
+ != (*message_)[strings::msg_params]
+ [strings::slider_footer].length()) {
+ LOG4CXX_ERROR(logger_, "INVALID_DATA");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+ }
+ }
+
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ msg_params = (*message_)[strings::msg_params];
+ msg_params[strings::app_id] = application->app_id();
+
+ if (!(*message_)[strings::msg_params].keyExists(strings::timeout)) {
+ msg_params[strings::timeout] = default_timeout_;
+ }
+
+ SendHMIRequest(hmi_apis::FunctionID::UI_Slider, &msg_params, true);
+}
+
+void SliderRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "SliderRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ const event_engine::Event::EventID event_id = event.id();
+ if (event_id == hmi_apis::FunctionID::UI_OnResetTimeout) {
+ LOG4CXX_INFO(logger_, "Received UI_OnResetTimeout event");
+ ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(),
+ correlation_id(),
+ default_timeout());
+ return;
+ }
+ if (event_id != hmi_apis::FunctionID::UI_Slider) {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+
+ //event_id == hmi_apis::FunctionID::UI_Slider:
+ LOG4CXX_INFO(logger_, "Received UI_Slider 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)
+ //Copy slider_position info to msg_params section
+ 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);
+
+ SendResponse(is_response_success,
+ mobile_apis::Result::eType(response_code),
+ 0,
+ &response_msg_params);
+}
+
+} // namespace commands
+} // namespace application_manager
+
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/slider_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/slider_response.cc
new file mode 100644
index 000000000..bfb6b0a1e
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/slider_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/slider_response.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+SliderResponse::SliderResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+SliderResponse::~SliderResponse() {
+}
+
+void SliderResponse::Run() {
+ LOG4CXX_INFO(logger_, "SliderResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/speak_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/speak_request.cc
new file mode 100644
index 000000000..05e4b2310
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/speak_request.cc
@@ -0,0 +1,120 @@
+/*
+
+ 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/speak_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+SpeakRequest::SpeakRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+SpeakRequest::~SpeakRequest() {
+}
+
+void SpeakRequest::Run() {
+ LOG4CXX_INFO(logger_, "SpeakRequest::Run");
+
+ ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance()
+ ->application(connection_key());
+
+ if (!app) {
+ LOG4CXX_ERROR_EXT(logger_, "NULL pointer");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ (*message_)[strings::msg_params][strings::app_id] = app->app_id();
+ 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");
+ switch (event.id()) {
+ case hmi_apis::FunctionID::TTS_Speak: {
+ LOG4CXX_INFO(logger_, "Received TTS_Speak event");
+
+ ProcessTTSSpeakResponse(event.smart_object());
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ break;
+ }
+ }
+}
+
+void SpeakRequest::ProcessTTSSpeakResponse(
+ const smart_objects::SmartObject& message) {
+ LOG4CXX_INFO(logger_, "SpeakRequest::ProcessTTSSpeakResponse");
+ ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(
+ connection_key());
+
+ if (!application) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ return;
+ }
+
+ bool result = false;
+ mobile_apis::Result::eType result_code =
+ static_cast<mobile_apis::Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ if (hmi_apis::Common_Result::SUCCESS ==
+ static_cast<hmi_apis::Common_Result::eType>(result_code)) {
+ result = true;
+ }
+ (*message_)[strings::params][strings::function_id] =
+ mobile_apis::FunctionID::SpeakID;
+
+ const char* return_info = NULL;
+
+ if (result) {
+ if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE ==
+ static_cast<hmi_apis::Common_Result::eType>(result_code)) {
+ result_code = mobile_apis::Result::WARNINGS;
+ return_info = std::string("Unsupported phoneme type sent in a prompt").c_str();
+ }
+ }
+
+ SendResponse(result, static_cast<mobile_apis::Result::eType>(result_code),
+ return_info, &(message[strings::msg_params]));
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/speak_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/speak_response.cc
new file mode 100644
index 000000000..92b85bbb8
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/speak_response.cc
@@ -0,0 +1,58 @@
+/*
+
+ 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/speak_response.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+SpeakResponse::SpeakResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+SpeakResponse::~SpeakResponse() {
+}
+
+void SpeakResponse::Run() {
+ LOG4CXX_INFO(logger_, "SpeakResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
new file mode 100644
index 000000000..9d014a25d
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
@@ -0,0 +1,80 @@
+/*
+
+ 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/subscribe_button_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+namespace str = strings;
+
+SubscribeButtonRequest::SubscribeButtonRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+SubscribeButtonRequest::~SubscribeButtonRequest() {
+}
+
+void SubscribeButtonRequest::Run() {
+ LOG4CXX_INFO(logger_, "SubscribeButtonRequest::Run");
+
+ uint32_t app_id = (*message_)[strings::params][strings::connection_key].asUInt();
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+
+ if (!app) {
+ LOG4CXX_ERROR_EXT(logger_, "APPLICATION_NOT_REGISTERED");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ const uint32_t btn_id = ((*message_)[str::msg_params][str::button_name]
+ .asUInt());
+
+ if (app->IsSubscribedToButton(static_cast<mobile_apis::ButtonName::eType>(btn_id))) {
+ LOG4CXX_ERROR_EXT(logger_, "Already subscribed to button " << btn_id);
+ SendResponse(false, mobile_apis::Result::IGNORED);
+ return;
+ }
+
+ app->SubscribeToButton(static_cast<mobile_apis::ButtonName::eType>(btn_id));
+ SendResponse(true, mobile_apis::Result::SUCCESS);
+
+ app->UpdateHash();
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/subscribe_button_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/subscribe_button_response.cc
new file mode 100644
index 000000000..6253f8ca3
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/subscribe_button_response.cc
@@ -0,0 +1,66 @@
+/*
+
+ 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/subscribe_button_response.h"
+
+namespace application_manager {
+
+namespace commands {
+
+SubscribeButtonResponse::SubscribeButtonResponse(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+SubscribeButtonResponse::~SubscribeButtonResponse() {
+}
+
+void SubscribeButtonResponse::Run() {
+ LOG4CXX_INFO(logger_, "SubscribeButtonResponse::Run");
+
+ // check if response false
+ if (true == (*message_)[strings::msg_params].keyExists(strings::success)) {
+ if ((*message_)[strings::msg_params][strings::success].asBool() == false) {
+ LOG4CXX_ERROR(logger_, "Success = false");
+ SendResponse(false);
+ return;
+ }
+ }
+
+ // TODO(DK): Some logic
+ SendResponse(true);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc
new file mode 100644
index 000000000..8c427bea1
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc
@@ -0,0 +1,276 @@
+/*
+
+ 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/subscribe_vehicle_data_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
+
+namespace application_manager {
+namespace commands {
+
+SubscribeVehicleDataRequest::SubscribeVehicleDataRequest(
+ const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+SubscribeVehicleDataRequest::~SubscribeVehicleDataRequest() {
+}
+
+#ifdef QT_HMI
+namespace {
+ struct Subrequest {
+ hmi_apis::FunctionID::eType func_id;
+ const char* str;
+ };
+ Subrequest subrequests[] = {
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeGps, strings::gps},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeSpeed, strings::speed},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeRpm, strings::rpm},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeFuelLevel, strings::fuel_level},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeFuelLevel_State, strings::fuel_level_state},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeInstantFuelConsumption, strings::instant_fuel_consumption},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeExternalTemperature, strings::external_temp},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeVin, strings::vin},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribePrndl, strings::prndl},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeTirePressure, strings::tire_pressure},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeOdometer, strings::odometer},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeBeltStatus, strings::belt_status},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeBodyInformation, strings::body_information},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeDeviceStatus, strings::device_status},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeDriverBraking, strings::driver_braking},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeWiperStatus, strings::wiper_status},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeHeadLampStatus, strings::head_lamp_status},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeEngineTorque, strings::engine_torque},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeAccPedalPosition, strings::acc_pedal_pos},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeSteeringWheelAngle, strings::steering_wheel_angle},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeECallInfo, strings::e_call_info},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeAirbagStatus, strings::airbag_status},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeEmergencyEvent, strings::emergency_event},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeClusterModeStatus, strings::cluster_mode_status},
+ { hmi_apis::FunctionID::VehicleInfo_SubscribeMyKey, strings::my_key},
+ };
+}
+#endif // #ifdef QT_HMI
+
+void SubscribeVehicleDataRequest::Run() {
+ LOG4CXX_INFO(logger_, "SubscribeVehicleDataRequest::Run");
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ CommandRequestImpl::connection_key());
+
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ // counter for items to subscribe
+ int32_t items_to_subscribe = 0;
+ // counter for subscribed items by application
+ int32_t subscribed_items = 0;
+
+ const VehicleData& vehicle_data = MessageHelper::vehicle_data();
+ VehicleData::const_iterator it = vehicle_data.begin();
+
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+
+ msg_params[strings::app_id] = app->app_id();
+
+ for (; vehicle_data.end() != it; ++it) {
+ std::string key_name = it->first;
+ if ((*message_)[strings::msg_params].keyExists(key_name)) {
+ bool is_key_enabled = (*message_)[strings::msg_params][key_name].asBool();
+ if (is_key_enabled) {
+ ++items_to_subscribe;
+ msg_params[key_name] = is_key_enabled;
+
+ VehicleDataType key_type = it->second;
+ if (app->SubscribeToIVI(static_cast<uint32_t>(key_type))) {
+ ++subscribed_items;
+ }
+ }
+ }
+ }
+
+ if (0 == items_to_subscribe) {
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
+ "No data in the request");
+ return;
+ } else if (0 == subscribed_items) {
+ SendResponse(false,
+ mobile_apis::Result::IGNORED,
+ "Already subscribed on provided VehicleData");
+ return;
+ }
+#ifdef WEB_HMI
+ SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData,
+ &msg_params, true);
+#endif // #ifdef WEB_HMI
+
+#ifdef QT_HMI
+ //Generate list of subrequests
+ for (int i = 0; i < sizeof(subrequests) / sizeof(subrequests[0]); ++i) {
+ const Subrequest& sr = subrequests[i];
+ if (true == (*message_)[strings::msg_params].keyExists(sr.str)
+ && true == (*message_)[strings::msg_params][sr.str].asBool()) {
+ HmiRequest hmi_request;
+ hmi_request.str = sr.str;
+ hmi_request.func_id = sr.func_id;
+ hmi_request.complete = false;
+ hmi_requests_.push_back(hmi_request);
+ }
+ }
+ LOG4CXX_INFO(logger_, hmi_requests_.size() << " requests are going to be sent to HMI");
+
+ //Send subrequests
+ for (HmiRequests::const_iterator it = hmi_requests_.begin(); it != hmi_requests_.end(); ++it)
+ SendHMIRequest(it->func_id, &msg_params, true);
+#endif // #ifdef QT_HMI
+}
+
+void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "SubscribeVehicleDataRequest::on_event");
+
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ CommandRequestImpl::connection_key());
+
+#ifdef WEB_HMI
+ hmi_apis::Common_Result::eType hmi_result =
+ static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+
+ bool result =
+ hmi_result == hmi_apis::Common_Result::SUCCESS;
+
+ mobile_apis::Result::eType result_code =
+ hmi_result == hmi_apis::Common_Result::SUCCESS
+ ? mobile_apis::Result::SUCCESS
+ : static_cast<mobile_apis::Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+
+ const char* return_info = NULL;
+ if (result) {
+ if (IsAnythingAlreadySubscribed()) {
+ result_code = mobile_apis::Result::WARNINGS;
+ return_info =
+ std::string("Unsupported phoneme type sent in a prompt").c_str();
+ }
+ }
+
+ SendResponse(result,
+ result_code,
+ return_info,
+ &(message[strings::msg_params]));
+ app->UpdateHash();
+#endif // #ifdef WEB_HMI
+#ifdef QT_HMI
+ for (HmiRequests::iterator it = hmi_requests_.begin();
+ it != hmi_requests_.end(); ++it) {
+ HmiRequest & hmi_request = *it;
+ if (hmi_request.func_id == event.id()) {
+ hmi_request.status =
+ static_cast<hmi_apis::Common_Result::eType>(message[strings::params][hmi_response::code]
+ .asInt());
+ if (hmi_apis::Common_Result::SUCCESS == hmi_request.status)
+ hmi_request.value = message[strings::msg_params][hmi_request.str];
+ hmi_request.complete = true;
+ break;
+ }
+ }
+ bool all_complete = true;
+ bool any_arg_success = false;
+ mobile_api::Result::eType status = mobile_api::Result::eType::SUCCESS;
+ for (HmiRequests::const_iterator it = hmi_requests_.begin();
+ it != hmi_requests_.end(); ++it) {
+ if (!it->complete) {
+ all_complete = false;
+ break;
+ }
+ if (hmi_apis::Common_Result::SUCCESS != it->status) {
+ if (mobile_api::Result::SUCCESS == status) {
+ status = static_cast<mobile_apis::Result::eType>(it->status);
+ } else if (status
+ != static_cast<mobile_apis::Result::eType>(it->status)) {
+ status = mobile_api::Result::eType::GENERIC_ERROR;
+ }
+ LOG4CXX_TRACE(logger_, "Status from HMI: " << it->status <<
+ ", so response status become " << status);
+ } else {
+ any_arg_success = true;
+ }
+ }
+
+ if (all_complete) {
+ smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
+ if (any_arg_success) {
+ for (HmiRequests::const_iterator it = hmi_requests_.begin();
+ it != hmi_requests_.end(); ++it) {
+ response_params[it->str] = it->value;
+ }
+ }
+ LOG4CXX_INFO(logger_, "All HMI requests are complete");
+ SendResponse(any_arg_success, status, NULL, &response_params);
+ app->UpdateHash();
+ }
+#endif // #ifdef QT_HMI
+}
+
+bool SubscribeVehicleDataRequest::IsAnythingAlreadySubscribed() {
+ LOG4CXX_INFO(logger_, "SubscribeVehicleDataRequest::Run");
+
+ const VehicleData& vehicle_data = MessageHelper::vehicle_data();
+ VehicleData::const_iterator it = vehicle_data.begin();
+
+ for (; vehicle_data.end() != it; ++it) {
+ if (true == (*message_)[strings::msg_params].keyExists(it->first)) {
+
+ if ((*message_)[strings::msg_params][it->first]
+ [strings::result_code].asInt() ==
+ hmi_apis::Common_VehicleDataResultCode::
+ VDRC_DATA_ALREADY_SUBSCRIBED) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+
+} // namespace commands
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc
new file mode 100644
index 000000000..972a65418
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_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/subscribe_vehicle_data_response.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace application_manager {
+namespace commands {
+
+SubscribeVehicleDataResponse::SubscribeVehicleDataResponse(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+SubscribeVehicleDataResponse::~SubscribeVehicleDataResponse() {
+}
+
+void SubscribeVehicleDataResponse::Run() {
+ LOG4CXX_INFO(logger_, "SubscribeVehicleDataResponse::Run");
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/sync_pdata_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/sync_pdata_request.cc
new file mode 100644
index 000000000..4fae27be5
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/sync_pdata_request.cc
@@ -0,0 +1,103 @@
+/*
+
+ 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/sync_pdata_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/MOBILE_API.h"
+#include "utils/file_system.h"
+#include "encryption/Base64.h"
+
+namespace application_manager {
+
+namespace commands {
+
+const std::string SyncPDataRequest::TEMPORARY_HARDCODED_FILENAME =
+ "policy_sync_data.dat";
+const std::string SyncPDataRequest::TEMPORARY_HARDCODED_FOLDERNAME =
+ "policies";
+
+SyncPDataRequest::SyncPDataRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+SyncPDataRequest::~SyncPDataRequest() {
+}
+
+void SyncPDataRequest::Run() {
+ LOG4CXX_INFO(logger_, "SyncPDataRequest::Run");
+
+ ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(
+ connection_key());
+
+ if (!application) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ if (!(*message_)[strings::params].keyExists(strings::binary_data)) {
+ LOG4CXX_ERROR(logger_, "Binary data is missed!");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+
+ const std::string& sync_file_name = TEMPORARY_HARDCODED_FILENAME;
+
+ const std::vector<uint8_t> file_data =
+ (*message_)[strings::params][strings::binary_data].asBinary();
+
+ std::string relative_file_path = file_system::CreateDirectory(
+ TEMPORARY_HARDCODED_FOLDERNAME);
+ relative_file_path += "/";
+ relative_file_path += sync_file_name;
+
+ mobile_apis::Result::eType save_result =
+ ApplicationManagerImpl::instance()->SaveBinary(
+ application->name(),
+ file_data,
+ relative_file_path);
+
+ switch(save_result) {
+ case mobile_apis::Result::SUCCESS:
+ SendResponse(true, save_result);
+ break;
+ default:
+ SendResponse(false, save_result);
+ break;
+ }
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/sync_pdata_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/sync_pdata_response.cc
new file mode 100644
index 000000000..751fd9eb6
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/sync_pdata_response.cc
@@ -0,0 +1,67 @@
+/*
+
+ 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/sync_pdata_response.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+SyncPDataResponse::SyncPDataResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+SyncPDataResponse::~SyncPDataResponse() {
+}
+
+void SyncPDataResponse::Run() {
+ LOG4CXX_INFO(logger_, "SyncPDataResponse::Run");
+
+ // check if response false
+ if (true == (*message_)[strings::msg_params].keyExists(strings::success)) {
+ if ((*message_)[strings::msg_params][strings::success].asBool() == false) {
+ LOG4CXX_ERROR(logger_, "Success = false");
+ SendResponse(false);
+ return;
+ }
+ }
+
+ SendResponse(true);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/system_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/system_request.cc
new file mode 100644
index 000000000..270907e55
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/system_request.cc
@@ -0,0 +1,72 @@
+/*
+
+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/system_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+SystemRequest::SystemRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+SystemRequest::~SystemRequest() {
+}
+
+void SystemRequest::Run() {
+ LOG4CXX_INFO(logger_, "SystemRequest::Run");
+
+ ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(
+ connection_key());
+
+ if (!application) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ if (!(*message_)[strings::params].keyExists(strings::binary_data)) {
+ LOG4CXX_ERROR(logger_, "Binary data is missed!");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+
+ SendResponse(true, mobile_apis::Result::SUCCESS);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/system_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/system_response.cc
new file mode 100644
index 000000000..e77ab0845
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/system_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/system_response.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+SystemResponse::SystemResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+SystemResponse::~SystemResponse() {
+}
+
+void SystemResponse::Run() {
+ LOG4CXX_INFO(logger_, "SystemResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc
new file mode 100644
index 000000000..0fc1d1fa0
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc
@@ -0,0 +1,59 @@
+/*
+
+ 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/unregister_app_interface_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/message_helper.h"
+
+namespace application_manager {
+
+namespace commands {
+
+void UnregisterAppInterfaceRequest::Run() {
+ LOG4CXX_INFO(logger_, "UnregisterAppInterfaceRequest::Run");
+
+ ApplicationManagerImpl* app_manager = ApplicationManagerImpl::instance();
+
+ if (!app_manager->application(connection_key())) {
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ LOG4CXX_ERROR(logger_, "Application is not registered");
+ return;
+ }
+
+ app_manager->UnregisterApplication(connection_key());
+ SendResponse(true, mobile_apis::Result::SUCCESS);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/unregister_app_interface_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/unregister_app_interface_response.cc
new file mode 100644
index 000000000..8ef0eb3ed
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/unregister_app_interface_response.cc
@@ -0,0 +1,47 @@
+/*
+
+ 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/unregister_app_interface_response.h"
+
+namespace application_manager {
+
+namespace commands {
+
+void UnregisterAppInterfaceResponse::Run() {
+ LOG4CXX_INFO(logger_, "UnregisterAppInterfaceResponse::Run");
+
+ SendResponse((*message_)[strings::msg_params][strings::success].asBool());
+}
+
+} // namespace commands
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc
new file mode 100644
index 000000000..f22d1c0a2
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc
@@ -0,0 +1,79 @@
+/*
+
+ 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/unsubscribe_button_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+namespace str = strings;
+
+UnsubscribeButtonRequest::UnsubscribeButtonRequest(
+ const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+UnsubscribeButtonRequest::~UnsubscribeButtonRequest() {
+}
+
+void UnsubscribeButtonRequest::Run() {
+ LOG4CXX_INFO(logger_, "UnsubscribeButtonRequest::Run");
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ (*message_)[str::params][str::connection_key].asUInt());
+
+ if (!app) {
+ LOG4CXX_ERROR_EXT(logger_, "APPLICATION_NOT_REGISTERED");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ const uint32_t btn_id = (*message_)[str::msg_params][str::button_name]
+ .asUInt();
+
+ if (!app->IsSubscribedToButton(static_cast<mobile_apis::ButtonName::eType>(btn_id))) {
+ LOG4CXX_ERROR_EXT(logger_, "App doesn't subscibe to button " << btn_id);
+ SendResponse(false, mobile_apis::Result::IGNORED);
+ return;
+ }
+
+ app->UnsubscribeFromButton(static_cast<mobile_apis::ButtonName::eType>(btn_id));
+ SendResponse(true, mobile_apis::Result::SUCCESS);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc
new file mode 100644
index 000000000..1331eac27
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc
@@ -0,0 +1,69 @@
+/*
+
+ 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/unsubscribe_button_response.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+UnsubscribeButtonResponse::UnsubscribeButtonResponse(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+UnsubscribeButtonResponse::~UnsubscribeButtonResponse() {
+}
+
+void UnsubscribeButtonResponse::Run() {
+ LOG4CXX_INFO(logger_, "UnsubscribeButtonResponse::Run");
+
+ namespace smart_objects = NsSmartDeviceLink::NsSmartObjects;
+
+ // check if response false
+ if (true == (*message_)[strings::msg_params].keyExists(strings::success)) {
+ if ((*message_)[strings::msg_params][strings::success].asBool() == false) {
+ LOG4CXX_ERROR(logger_, "Success = false");
+ SendResponse(false);
+ return;
+ }
+ }
+
+ // TODO(DK): Some logic
+ SendResponse(true);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc
new file mode 100644
index 000000000..5d2e33015
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc
@@ -0,0 +1,272 @@
+/*
+
+ 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/unsubscribe_vehicle_data_request.h"
+#include "application_manager/commands/command_impl.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
+#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
+#include "application_manager/smart_object_keys.h"
+
+namespace application_manager {
+namespace commands {
+
+UnsubscribeVehicleDataRequest::UnsubscribeVehicleDataRequest(
+ const MessageSharedPtr& message)
+ : CommandRequestImpl(message) {
+}
+
+UnsubscribeVehicleDataRequest::~UnsubscribeVehicleDataRequest() {
+}
+
+#ifdef QT_HMI
+namespace {
+ struct Subrequest {
+ hmi_apis::FunctionID::eType func_id;
+ const char* str;
+ };
+ Subrequest subrequests[] = {
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeGps, strings::gps},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeSpeed, strings::speed},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeRpm, strings::rpm},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeFuelLevel, strings::fuel_level},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeFuelLevel_State, strings::fuel_level_state},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeInstantFuelConsumption, strings::instant_fuel_consumption},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeExternalTemperature, strings::external_temp},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeVin, strings::vin},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribePrndl, strings::prndl},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeTirePressure, strings::tire_pressure},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeOdometer, strings::odometer},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeBeltStatus, strings::belt_status},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeBodyInformation, strings::body_information},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeDeviceStatus, strings::device_status},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeDriverBraking, strings::driver_braking},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeWiperStatus, strings::wiper_status},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeHeadLampStatus, strings::head_lamp_status},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeEngineTorque, strings::engine_torque},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeAccPedalPosition, strings::acc_pedal_pos},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeSteeringWheelAngle, strings::steering_wheel_angle},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeECallInfo, strings::e_call_info},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeAirbagStatus, strings::airbag_status},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeEmergencyEvent, strings::emergency_event},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeClusterModeStatus, strings::cluster_mode_status},
+ { hmi_apis::FunctionID::VehicleInfo_UnsubscribeMyKey, strings::my_key},
+ };
+}
+#endif // #ifdef QT_HMI
+
+void UnsubscribeVehicleDataRequest::Run() {
+ LOG4CXX_INFO(logger_, "UnsubscribeVehicleDataRequest::Run");
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ CommandRequestImpl::connection_key());
+
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ // counter for items to subscribe
+ int32_t items_to_unsubscribe = 0;
+ // counter for subscribed items by application
+ int32_t unsubscribed_items = 0;
+
+ const VehicleData& vehicle_data = MessageHelper::vehicle_data();
+ VehicleData::const_iterator it = vehicle_data.begin();
+
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+
+ msg_params[strings::app_id] = app->app_id();
+
+ for (; vehicle_data.end() != it; ++it) {
+ std::string key_name = it->first;
+ if ((*message_)[strings::msg_params].keyExists(key_name)) {
+ bool is_key_enabled = (*message_)[strings::msg_params][key_name].asBool();
+ if (is_key_enabled) {
+ ++items_to_unsubscribe;
+ msg_params[key_name] = is_key_enabled;
+
+ VehicleDataType key_type = it->second;
+ if (app->UnsubscribeFromIVI(static_cast<uint32_t>(key_type))) {
+ ++unsubscribed_items;
+ }
+ }
+ }
+ }
+
+ if (0 == items_to_unsubscribe) {
+ SendResponse(false, mobile_apis::Result::INVALID_DATA,
+ "No data in the request", &msg_params);
+ return;
+ } else if (0 == unsubscribed_items) {
+ SendResponse(false, mobile_apis::Result::IGNORED,
+ "Was not subscribed on any VehicleData", &msg_params);
+ return;
+ }
+
+#ifdef WEB_HMI
+ SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData,
+ &msg_params, true);
+#endif // #ifdef WEB_HMI
+
+#ifdef QT_HMI
+ //Generate list of subrequests
+ for (int i = 0; i < sizeof(subrequests) / sizeof(subrequests[0]); ++i) {
+ const Subrequest& sr = subrequests[i];
+ if (true == (*message_)[strings::msg_params].keyExists(sr.str)
+ && true == (*message_)[strings::msg_params][sr.str].asBool()) {
+ HmiRequest hmi_request;
+ hmi_request.str = sr.str;
+ hmi_request.func_id = sr.func_id;
+ hmi_request.complete = false;
+ hmi_requests_.push_back(hmi_request);
+ }
+ }
+ LOG4CXX_INFO(logger_,
+ hmi_requests_.size() << " requests are going to be sent to HMI");
+
+ //Send subrequests
+ for (HmiRequests::const_iterator it = hmi_requests_.begin();
+ it != hmi_requests_.end(); ++it)
+ SendHMIRequest(it->func_id, &msg_params, true);
+#endif // #ifdef QT_HMI
+}
+
+void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "UnsubscribeVehicleDataRequest::on_event");
+
+ const smart_objects::SmartObject& message = event.smart_object();
+
+#ifdef WEB_HMI
+ hmi_apis::Common_Result::eType hmi_result =
+ static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+
+ bool result =
+ hmi_result == hmi_apis::Common_Result::SUCCESS;
+
+ mobile_apis::Result::eType result_code =
+ hmi_result == hmi_apis::Common_Result::SUCCESS
+ ? mobile_apis::Result::SUCCESS
+ : static_cast<mobile_apis::Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+
+ const char* return_info = NULL;
+
+ if (result) {
+ if (IsAnythingAlreadyUnsubscribed()) {
+ result_code = mobile_apis::Result::WARNINGS;
+ return_info =
+ std::string("Unsupported phoneme type sent in a prompt").c_str();
+ }
+ }
+
+ SendResponse(result, result_code, return_info,
+ &(message[strings::msg_params]));
+#endif // #ifdef WEB_HMI
+#ifdef QT_HMI
+ for (HmiRequests::iterator it = hmi_requests_.begin();
+ it != hmi_requests_.end(); ++it) {
+ HmiRequest & hmi_request = *it;
+ if (hmi_request.func_id == event.id()) {
+ hmi_request.status =
+ static_cast<hmi_apis::Common_Result::eType>(message[strings::params][hmi_response::code]
+ .asInt());
+ if (hmi_apis::Common_Result::SUCCESS == hmi_request.status)
+ hmi_request.value = message[strings::msg_params][hmi_request.str];
+ hmi_request.complete = true;
+ break;
+ }
+ }
+ bool all_complete = true;
+ bool any_arg_success = false;
+ mobile_api::Result::eType status = mobile_api::Result::eType::SUCCESS;
+ for (HmiRequests::const_iterator it = hmi_requests_.begin();
+ it != hmi_requests_.end(); ++it) {
+ if (!it->complete) {
+ all_complete = false;
+ break;
+ }
+ if (hmi_apis::Common_Result::SUCCESS != it->status) {
+ if (mobile_api::Result::SUCCESS == status) {
+ status = static_cast<mobile_apis::Result::eType>(it->status);
+ } else if (status
+ != static_cast<mobile_apis::Result::eType>(it->status)) {
+ status = mobile_api::Result::eType::GENERIC_ERROR;
+ } LOG4CXX_TRACE(logger_, "Status from HMI: " << it->status <<
+ ", so response status become " << status);
+ } else {
+ any_arg_success = true;
+ }
+ }
+ if (all_complete) {
+ smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
+ if (any_arg_success) {
+ for (HmiRequests::const_iterator it = hmi_requests_.begin();
+ it != hmi_requests_.end(); ++it) {
+ response_params[it->str] = it->value;
+ }
+ }
+ LOG4CXX_INFO(logger_, "All HMI requests are complete");
+ SendResponse(any_arg_success, status, NULL, &response_params);
+ }
+#endif // #ifdef QT_HMI
+}
+
+bool UnsubscribeVehicleDataRequest::IsAnythingAlreadyUnsubscribed() {
+ LOG4CXX_INFO(logger_, "UnsubscribeVehicleDataRequest::Run");
+
+ const VehicleData& vehicle_data = MessageHelper::vehicle_data();
+ VehicleData::const_iterator it = vehicle_data.begin();
+
+ for (; vehicle_data.end() != it; ++it) {
+ if (true == (*message_)[strings::msg_params].keyExists(it->first)) {
+
+ if ((*message_)[strings::msg_params][it->first]
+ [strings::result_code].asInt() ==
+ hmi_apis::Common_VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+
+} // namespace commands
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc
new file mode 100644
index 000000000..60f7077da
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc
@@ -0,0 +1,66 @@
+/*
+
+ 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/unsubscribe_vehicle_data_response.h"
+
+namespace application_manager {
+namespace commands {
+
+UnsubscribeVehicleDataResponse::UnsubscribeVehicleDataResponse(
+ const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+UnsubscribeVehicleDataResponse::~UnsubscribeVehicleDataResponse() {
+}
+
+void UnsubscribeVehicleDataResponse::Run() {
+ LOG4CXX_INFO(logger_, "UnsubscribeVehicleDataResponse::Run");
+
+ namespace smart_objects = NsSmartDeviceLink::NsSmartObjects;
+
+ // check if response false
+ if (true == (*message_)[strings::msg_params].keyExists(strings::success)) {
+ if ((*message_)[strings::msg_params][strings::success].asBool() == false) {
+ LOG4CXX_ERROR(logger_, "Success = false");
+ SendResponse(false);
+ return;
+ }
+ }
+
+ // TODO(DK): Some logic
+ SendResponse(true);
+}
+
+} // namespace commands
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc
new file mode 100644
index 000000000..f2077ab41
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc
@@ -0,0 +1,172 @@
+/*
+
+ 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 <string>
+#include "application_manager/commands/mobile/update_turn_list_request.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
+#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+UpdateTurnListRequest::UpdateTurnListRequest(const MessageSharedPtr& message)
+ : CommandRequestImpl(message),
+ result_(mobile_apis::Result::INVALID_ENUM) {
+}
+
+UpdateTurnListRequest::~UpdateTurnListRequest() {
+}
+
+void UpdateTurnListRequest::Run() {
+ LOG4CXX_INFO(logger_, "UpdateTurnListRequest::Run");
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ (*message_)[strings::params][strings::connection_key].asUInt());
+
+ if (!app) {
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ LOG4CXX_ERROR(logger_, "Application is not registered");
+ return;
+ }
+
+ mobile_apis::Result::eType processing_result =
+ MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app);
+
+ if (mobile_apis::Result::SUCCESS != processing_result) {
+ if (mobile_apis::Result::INVALID_DATA == processing_result) {
+ LOG4CXX_ERROR(logger_, "INVALID_DATA!");
+ SendResponse(false, processing_result);
+ return;
+ }
+ if (mobile_apis::Result::UNSUPPORTED_RESOURCE == processing_result) {
+ LOG4CXX_ERROR(logger_, "UNSUPPORTED_RESOURCE!");
+ result_ = processing_result;
+ }
+ }
+
+ mobile_apis::Result::eType verification_result =
+ MessageHelper::VerifyImageFiles((*message_)[strings::msg_params], app);
+
+ if (mobile_apis::Result::SUCCESS != verification_result) {
+ LOG4CXX_ERROR_EXT(
+ logger_,
+ "MessageHelper::VerifyImageFiles return " << verification_result);
+ SendResponse(false, verification_result);
+ return;
+ }
+
+ if (!CheckTurnListArray()) {
+ LOG4CXX_ERROR(logger_, "INVALID_DATA!");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+
+
+ smart_objects::SmartObject msg_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ msg_params = (*message_)[strings::msg_params];
+ for (uint32_t i = 0; i < msg_params[strings::turn_list].length(); ++i) {
+ if (msg_params[strings::turn_list][i].keyExists(hmi_request::navi_text)) {
+ std::string navigation_text =
+ msg_params[strings::turn_list][i][hmi_request::navi_text].asString();
+ msg_params[strings::turn_list][i].erase(hmi_request::navi_text);
+ msg_params[strings::turn_list]
+ [i][hmi_request::navi_text][hmi_request::field_name] =
+ static_cast<int>(hmi_apis::Common_TextFieldName::turnText);
+ msg_params[strings::turn_list]
+ [i][hmi_request::navi_text][hmi_request::field_text] =
+ navigation_text;
+ }
+ }
+
+ msg_params[strings::app_id] = app->app_id();
+
+
+ SendHMIRequest(hmi_apis::FunctionID::Navigation_UpdateTurnList, &msg_params,
+ true);
+}
+
+void UpdateTurnListRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "UpdateTurnListRequest::on_event");
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::Navigation_UpdateTurnList: {
+ LOG4CXX_INFO(logger_, "Received Navigation_UpdateTurnList event");
+
+ 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 (mobile_apis::Result::INVALID_ENUM != result_) {
+ result_code = result_;
+ }
+
+ SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_,"Received unknown event" << event.id());
+ break;
+ }
+ }
+}
+
+bool UpdateTurnListRequest::CheckTurnListArray() {
+ if (!(*message_)[strings::msg_params].keyExists(strings::turn_list)) {
+ return false;
+ }
+
+ int32_t length = (*message_)[strings::msg_params][strings::turn_list].length();
+ if (0 == length) {
+ return false;
+ }
+ for (int32_t i = 0; i < length; ++i) {
+ if (!((*message_)[strings::msg_params][strings::turn_list][i].
+ keyExists(hmi_request::navi_text)) &&
+ !((*message_)[strings::msg_params][strings::turn_list][i].
+ keyExists(strings::turn_icon))) {
+ return false;
+ }
+ }
+ return true;
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/SDL_Core/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc b/SDL_Core/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc
new file mode 100644
index 000000000..ec1e0bce8
--- /dev/null
+++ b/SDL_Core/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc
@@ -0,0 +1,57 @@
+/*
+
+ 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/update_turn_list_response.h"
+#include "application_manager/application_manager_impl.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+UpdateTurnListResponse::UpdateTurnListResponse(const MessageSharedPtr& message)
+ : CommandResponseImpl(message) {
+}
+
+UpdateTurnListResponse::~UpdateTurnListResponse() {
+}
+
+void UpdateTurnListResponse::Run() {
+ LOG4CXX_INFO(logger_, "UpdateTurnListResponse::Run");
+
+ ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager