summaryrefslogtreecommitdiff
path: root/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi')
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls.cc230
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_request.cc156
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_response.cc (renamed from src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls_response.cc)13
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc1
17 files changed, 177 insertions, 237 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc
index 3dbdf528a5..baff925a4e 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc
@@ -31,6 +31,7 @@
*/
#include "sdl_rpc_plugin/commands/hmi/get_system_info_response.h"
#include "application_manager/message_helper.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls.cc
deleted file mode 100644
index 54a9633a37..0000000000
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls.cc
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright (c) 2018, 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 "sdl_rpc_plugin/commands/hmi/get_urls.h"
-#include "application_manager/application_manager.h"
-#include "application_manager/message.h"
-#include "application_manager/policies/policy_handler.h"
-#include "application_manager/rpc_service.h"
-#include "utils/helpers.h"
-
-namespace sdl_rpc_plugin {
-using namespace application_manager;
-namespace commands {
-
-GetUrls::GetUrls(const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
- : RequestFromHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {}
-
-GetUrls::~GetUrls() {}
-
-void GetUrls::Run() {
- LOG4CXX_AUTO_TRACE(logger_);
- namespace Common_Result = hmi_apis::Common_Result;
- using policy::EndpointUrls;
-
- if (!policy_handler_.PolicyEnabled()) {
- SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE);
- return;
- }
-
- const uint32_t service_to_check =
- (*message_)[strings::msg_params][hmi_request::service].asUInt();
-
- EndpointUrls endpoints;
- policy_handler_.GetUpdateUrls(service_to_check, endpoints);
-
- if (endpoints.empty()) {
- LOG4CXX_ERROR(logger_, "No URLs for service " << service_to_check);
- SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE);
- return;
- }
-
-#ifdef PROPRIETARY_MODE
- const uint32_t policy_service = 7u;
-
- if (policy_service == service_to_check) {
- ProcessPolicyServiceURLs(endpoints);
- return;
- }
-#endif // PROPRIETARY_MODE
-
- ProcessServiceURLs(endpoints);
-}
-
-void GetUrls::ProcessServiceURLs(const policy::EndpointUrls& endpoints) {
- namespace Common_Result = hmi_apis::Common_Result;
- using smart_objects::SmartObject;
-
- (*message_)[strings::msg_params].erase(hmi_request::service);
- SmartObject& urls = (*message_)[strings::msg_params][hmi_response::urls];
-
- size_t index = 0;
- for (size_t e = 0; e < endpoints.size(); ++e) {
- ApplicationSharedPtr app =
- application_manager_.application_by_policy_id(endpoints[e].app_id);
-
-#ifndef PROPRIETARY_MODE
- bool registered_not_default = false;
- if (policy::kDefaultId != endpoints[e].app_id) {
- if (!app) {
- LOG4CXX_ERROR(logger_,
- "Can't find application with policy id "
- << endpoints[e].app_id
- << " URLs adding for this application is skipped.");
- continue;
- }
- registered_not_default = true;
- }
-#endif // EXTERNAL_PROPRIETARY_MODE || HTTP
- for (size_t u = 0; u < endpoints[e].url.size(); ++u, ++index) {
- const std::string& app_url = endpoints[e].url[u];
- SmartObject& service_info = urls[index];
-
- service_info[strings::url] = app_url;
-#ifndef PROPRIETARY_MODE
- if (registered_not_default) {
- service_info[strings::app_id] = app->hmi_app_id();
- }
-#else // EXTERNAL_PROPRIETARY_MODE || HTTP
- service_info[hmi_response::policy_app_id] = endpoints[e].app_id;
-#endif
- }
- }
- SendResponseToHMI(Common_Result::SUCCESS);
-}
-
-void GetUrls::SendResponseToHMI(hmi_apis::Common_Result::eType result) {
- (*message_)[strings::params][strings::message_type] = MessageType::kResponse;
- (*message_)[strings::params][hmi_response::code] = result;
- rpc_service_.ManageHMICommand(message_);
-}
-
-#ifdef PROPRIETARY_MODE
-struct PolicyAppIdComparator {
- PolicyAppIdComparator(const std::string& policy_app_id)
- : policy_app_id_(policy_app_id) {}
-
- bool operator()(const policy::EndpointData& data) {
- return data.app_id == policy_app_id_;
- }
- std::string policy_app_id_;
-};
-
-void FillSODefaultUrls(smart_objects::SmartObject& urls,
- const policy::EndpointUrls& endpoints) {
- using smart_objects::SmartObject;
- PolicyAppIdComparator comparator(policy::kDefaultId);
- policy::EndpointUrls::const_iterator it =
- std::find_if(endpoints.begin(), endpoints.end(), comparator);
- if (it == endpoints.end()) {
- return;
- }
- SmartObject service_info = SmartObject(smart_objects::SmartType_Map);
- for (size_t i = 0; i < (*it).url.size(); ++i) {
- service_info[strings::url] = (*it).url[i];
- urls[i] = service_info;
- }
-}
-
-void GetUrls::ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints) {
- LOG4CXX_AUTO_TRACE(logger_);
- using namespace smart_objects;
- using namespace application_manager;
- using namespace strings;
- using namespace hmi_apis;
-
- const uint32_t app_id_to_send_to = policy_handler_.GetAppIdForSending();
-
- if (!app_id_to_send_to) {
- LOG4CXX_ERROR(logger_,
- "There are no available applications for processing.");
- SmartObject urls(SmartType_Array);
- FillSODefaultUrls(urls, endpoints);
- if (!urls.empty()) {
- (*message_)[msg_params][hmi_response::urls] = urls;
- }
- (*message_).erase(hmi_request::service);
- SendResponseToHMI(Common_Result::SUCCESS);
- return;
- }
-
- ApplicationSharedPtr app =
- application_manager_.application(app_id_to_send_to);
-
- if (app.use_count() == 0) {
- LOG4CXX_WARN(logger_,
- "There is no registered application with "
- "connection key '"
- << app_id_to_send_to << "'");
- SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE);
- return;
- }
-
- SmartObject& object = *message_;
- object[msg_params].erase(hmi_request::service);
- object[msg_params][hmi_response::urls] = SmartObject(SmartType_Array);
- SmartObject& urls = object[msg_params][hmi_response::urls];
- const std::string mobile_app_id = app->policy_app_id();
-
- size_t index = 0;
- for (size_t i = 0; i < endpoints.size(); ++i) {
- using namespace helpers;
-
- const bool to_add = Compare<std::string, EQ, ONE>(
- endpoints[i].app_id, mobile_app_id, policy::kDefaultId);
- const bool is_default = policy::kDefaultId == endpoints[i].app_id;
-
- if (to_add) {
- for (size_t k = 0; k < endpoints[i].url.size(); ++k) {
- if (!is_default) {
- urls[index][strings::app_id] = app_id_to_send_to;
- }
- urls[index][strings::url] = endpoints[i].url[k];
- ++index;
- }
- }
- }
- SendResponseToHMI(Common_Result::SUCCESS);
- return;
-}
-#endif // PROPRIETARY_MODE
-
-} // namespace commands
-} // namespace sdl_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc
index 9ddd822b1c..129ba8c9ba 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc
@@ -34,6 +34,7 @@
#include <algorithm>
#include "application_manager/application_manager.h"
#include "application_manager/message_helper.h"
+#include "application_manager/policies/policy_handler_interface.h"
#include "encryption/hashing.h"
#include "interfaces/HMI_API.h"
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc
index a29b9721e9..a743c58672 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc
@@ -35,6 +35,7 @@
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
+#include "application_manager/policies/policy_handler_interface.h"
#include "interfaces/HMI_API.h"
#include "interfaces/MOBILE_API.h"
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc
index 9c2c68989f..1e8da19c0a 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc
@@ -32,6 +32,7 @@
#include "sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h"
#include "application_manager/application_manager.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc
index 67352fbc4a..a0e75371b5 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc
@@ -32,6 +32,7 @@
#include "sdl_rpc_plugin/commands/hmi/on_policy_update.h"
#include "application_manager/application_manager.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc
index 4a8c8df0ee..b2c9151b40 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc
@@ -33,6 +33,7 @@
#include "sdl_rpc_plugin/commands/hmi/on_received_policy_update.h"
#include <string>
#include "application_manager/application_manager.h"
+#include "application_manager/policies/policy_handler_interface.h"
#include "utils/file_system.h"
namespace sdl_rpc_plugin {
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc
index 6a5ee4fce4..9b8523e882 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc
@@ -32,6 +32,7 @@
#include "sdl_rpc_plugin/commands/hmi/on_system_error_notification.h"
#include "application_manager/application_manager.h"
+#include "application_manager/policies/policy_handler_interface.h"
#include "interfaces/HMI_API.h"
namespace sdl_rpc_plugin {
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc
index b7ba6951fb..171c144055 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc
@@ -33,6 +33,7 @@
#include "sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h"
#include "application_manager/application_manager.h"
#include "application_manager/message_helper.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc
index 19b4047b1b..c4678f69e0 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc
@@ -65,7 +65,7 @@ void OnVRCommandNotification::Run() {
(*message_)[strings::msg_params][strings::cmd_id].asUInt();
uint32_t max_cmd_id = application_manager_.get_settings().max_cmd_id();
- // Check if this is one of standart VR commands (i.e. "Help")
+ // Check if this is one of standard VR commands (i.e. "Help")
if (cmd_id > max_cmd_id + 1) {
LOG4CXX_INFO(logger_, "Switched App");
const uint32_t app_id = cmd_id - max_cmd_id;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc
index 30184be7a1..13690809bb 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc
@@ -32,6 +32,7 @@
#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h"
#include "application_manager/message_helper.h"
+#include "application_manager/policies/policy_handler_interface.h"
#include "application_manager/state_controller.h"
namespace sdl_rpc_plugin {
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc
index 095ffbd9c7..c8266e0f39 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc
@@ -32,6 +32,7 @@
#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h"
#include "application_manager/application_manager.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_request.cc
new file mode 100644
index 0000000000..2607754228
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_request.cc
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2019, 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 "sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_request.h"
+#include "application_manager/application_manager.h"
+#include "application_manager/policies/policy_handler_interface.h"
+
+namespace sdl_rpc_plugin {
+using namespace application_manager;
+
+namespace commands {
+
+SDLGetPolicyConfigurationDataRequest::SDLGetPolicyConfigurationDataRequest(
+ const application_manager::commands::MessageSharedPtr& message,
+ ApplicationManager& application_manager,
+ rpc_service::RPCService& rpc_service,
+ HMICapabilities& hmi_capabilities,
+ policy::PolicyHandlerInterface& policy_handle)
+ : RequestFromHMI(message,
+ application_manager,
+ rpc_service,
+ hmi_capabilities,
+ policy_handle) {}
+
+SDLGetPolicyConfigurationDataRequest::~SDLGetPolicyConfigurationDataRequest() {}
+
+void SDLGetPolicyConfigurationDataRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ smart_objects::SmartObject response_value(
+ smart_objects::SmartType::SmartType_Array);
+
+ hmi_apis::Common_Result::eType result_code =
+ PrepareResponseParams(response_value);
+
+ if (hmi_apis::Common_Result::SUCCESS != result_code) {
+ LOG4CXX_ERROR(logger_, "Unable to PrepareResponseParams");
+ SendErrorResponse(
+ correlation_id(),
+ hmi_apis::FunctionID::SDL_GetPolicyConfigurationData,
+ result_code,
+ "",
+ application_manager::commands::Command::SOURCE_SDL_TO_HMI);
+ return;
+ }
+
+ smart_objects::SmartObject response_msg_params(
+ smart_objects::SmartType::SmartType_Map);
+ response_msg_params[strings::value] = response_value;
+ SendResponse(true,
+ correlation_id(),
+ hmi_apis::FunctionID::SDL_GetPolicyConfigurationData,
+ result_code,
+ &response_msg_params,
+ application_manager::commands::Command::SOURCE_SDL_TO_HMI);
+}
+
+hmi_apis::Common_Result::eType
+SDLGetPolicyConfigurationDataRequest::PrepareResponseParams(
+ smart_objects::SmartObject& response_out) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const auto policy_type =
+ (*message_)[strings::msg_params][strings::policy_type].asString();
+
+ const auto property =
+ (*message_)[strings::msg_params][strings::property].asString();
+
+ auto policy_table_data = policy_handler_.GetPolicyTableData();
+ if (!policy_table_data.isMember(policy_type)) {
+ LOG4CXX_ERROR(
+ logger_,
+ "policy_type " << policy_type << " doesn't exist in policy table.");
+ return hmi_apis::Common_Result::DATA_NOT_AVAILABLE;
+ }
+
+ auto& policy_section_table_data = policy_table_data[policy_type];
+ if (!policy_section_table_data.isMember(property)) {
+ LOG4CXX_ERROR(
+ logger_,
+ "property " << property << " doesn't exist in " << policy_type);
+ return hmi_apis::Common_Result::DATA_NOT_AVAILABLE;
+ }
+
+ auto& property_table_data = policy_section_table_data[property];
+ response_out = GetValueParam(property_table_data);
+
+ return hmi_apis::Common_Result::SUCCESS;
+}
+
+void clear_new_line_symbol(std::string& str_to_clear) {
+ str_to_clear.erase(
+ std::remove_if(str_to_clear.begin(),
+ str_to_clear.end(),
+ [](char character) { return '\n' == character; }),
+ str_to_clear.end());
+}
+
+smart_objects::SmartObject SDLGetPolicyConfigurationDataRequest::GetValueParam(
+ const Json::Value& policy_property) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ smart_objects::SmartObject value(smart_objects::SmartType_Array);
+
+ auto put_element_in_value_array = [&value](const Json::Value& element,
+ const int32_t index) {
+ Json::FastWriter writer;
+ std::string str;
+ if (element.type() == Json::objectValue) {
+ str = writer.write(element);
+ clear_new_line_symbol(str);
+ } else {
+ str = element.asString();
+ }
+ value[index] = str;
+ };
+
+ if (policy_property.type() == Json::arrayValue) {
+ for (Json::ArrayIndex i = 0; i < policy_property.size(); i++) {
+ put_element_in_value_array(policy_property[i], i);
+ }
+ return value;
+ }
+ put_element_in_value_array(policy_property, 0);
+ return value;
+}
+
+} // namespace commands
+} // namespace sdl_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_response.cc
index 77d90ec8bb..21b7dea41c 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_response.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Ford Motor Company
+ * Copyright (c) 2019, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,14 +30,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "sdl_rpc_plugin/commands/hmi/get_urls_response.h"
+#include "sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_response.h"
#include "application_manager/rpc_service.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
+
namespace commands {
-GetUrlsResponse::GetUrlsResponse(
+SDLGetPolicyConfigurationDataResponse::SDLGetPolicyConfigurationDataResponse(
const application_manager::commands::MessageSharedPtr& message,
ApplicationManager& application_manager,
rpc_service::RPCService& rpc_service,
@@ -49,13 +50,13 @@ GetUrlsResponse::GetUrlsResponse(
hmi_capabilities,
policy_handle) {}
-GetUrlsResponse::~GetUrlsResponse() {}
+SDLGetPolicyConfigurationDataResponse::
+ ~SDLGetPolicyConfigurationDataResponse() {}
-void GetUrlsResponse::Run() {
+void SDLGetPolicyConfigurationDataResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
(*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_;
(*message_)[strings::params][strings::protocol_version] = protocol_version_;
-
rpc_service_.SendMessageToHMI(message_);
}
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc
index 7200f6918c..b494be56e8 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc
@@ -32,6 +32,7 @@
#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h"
#include "application_manager/application_manager.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc
index 28167df047..38a63611fa 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc
@@ -32,6 +32,7 @@
#include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h"
#include "application_manager/message_helper.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc
index 96d454d4ee..a52f03b998 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc
@@ -32,6 +32,7 @@
*/
#include "sdl_rpc_plugin/commands/hmi/update_sdl_request.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;