summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndriy Byzhynar <AByzhynar@luxoft.com>2017-10-06 14:23:40 +0300
committerAndriy Byzhynar <AByzhynar@luxoft.com>2018-01-26 11:38:09 +0200
commit311f3959c94f9f1b9d50aad0fd1b8f181bc154e8 (patch)
tree0d67f8cc5c1bdadd06a03590736183d7b5b44dea
parent42e4e458ce202b815be641ef89b176c3b2e11eaa (diff)
downloadsdl_core-311f3959c94f9f1b9d50aad0fd1b8f181bc154e8.tar.gz
Fixed info string generation in case of specific parameter
'deliveryMode' usage when it is disallowed by Policies
-rw-r--r--src/components/application_manager/include/application_manager/commands/command_request_impl.h12
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/send_location_request.h7
-rw-r--r--src/components/application_manager/src/commands/command_request_impl.cc67
-rw-r--r--src/components/application_manager/src/commands/mobile/send_location_request.cc9
4 files changed, 72 insertions, 23 deletions
diff --git a/src/components/application_manager/include/application_manager/commands/command_request_impl.h b/src/components/application_manager/include/application_manager/commands/command_request_impl.h
index 74a884a223..7edfdaec76 100644
--- a/src/components/application_manager/include/application_manager/commands/command_request_impl.h
+++ b/src/components/application_manager/include/application_manager/commands/command_request_impl.h
@@ -42,6 +42,8 @@
namespace application_manager {
namespace commands {
+typedef std::map<std::string, std::string> CustomInfo;
+
struct ResponseInfo {
DEPRECATED ResponseInfo(hmi_apis::Common_Result::eType result,
HmiInterfaces::InterfaceID interface);
@@ -345,12 +347,12 @@ class CommandRequestImpl : public CommandImpl,
DISALLOW_COPY_AND_ASSIGN(CommandRequestImpl);
/**
- * @brief Adds param to disallowed parameters enumeration
- * @param info string with disallowed params enumeration
- * @param param disallowed param
+ * @brief Returns map of parameters and their custom info strings
+ * specified especially for these parameters
+ * Can be overloaded in children classes
+ * @return empty map of parameters and their info strings
*/
- void AddDissalowedParameterToInfoString(std::string& info,
- const std::string& param) const;
+ virtual CustomInfo CustomInfoMap() const;
/**
* @brief Adds disallowed parameters to response info
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/send_location_request.h b/src/components/application_manager/include/application_manager/commands/mobile/send_location_request.h
index 063c8064ea..e917af9c5f 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/send_location_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/send_location_request.h
@@ -71,6 +71,13 @@ class SendLocationRequest : public CommandRequestImpl {
private:
/**
+ * @brief Returns map of parameters and their custom info strings
+ * specified especially for these parameters
+ * @return map of parameters and their info strings
+ */
+ CustomInfo CustomInfoMap() const OVERRIDE;
+
+ /**
* @brief CheckFieldsCompatibility checks if fields are compatible with each
* other.
* @return true if compatible, otherwise return false
diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc
index 7b7452dc77..7e5ed1feaa 100644
--- a/src/components/application_manager/src/commands/command_request_impl.cc
+++ b/src/components/application_manager/src/commands/command_request_impl.cc
@@ -766,38 +766,69 @@ void CommandRequestImpl::RemoveDisallowedParameters() {
}
}
-void CommandRequestImpl::AddDissalowedParameterToInfoString(
- std::string& info, const std::string& param) const {
- // prepare disallowed params enumeration for response info string
- if (info.empty()) {
- info = "\'" + param + "\'";
+void AddDissalowedParameterToInfoString(const std::string& param,
+ std::string& info_out) {
+ // Prepare disallowed params enumeration for response info string
+ if (info_out.empty()) {
+ info_out = "\'" + param + "\'";
} else {
- info = info + "," + " " + "\'" + param + "\'";
+ info_out = info_out + "," + " " + "\'" + param + "\'";
}
}
+CustomInfo CommandRequestImpl::CustomInfoMap() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ return std::map<std::string, std::string>();
+}
+
void CommandRequestImpl::AddDisallowedParametersToInfo(
smart_objects::SmartObject& response) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const CustomInfo& custom_info_map = CustomInfoMap();
+
+ CustomInfo::const_iterator custom_param_it = custom_info_map.begin();
+ const RPCParams& disallowed_params =
+ removed_parameters_permissions_.disallowed_params;
+ const RPCParams& undefined_params =
+ removed_parameters_permissions_.undefined_params;
+
std::string info;
+ for (; custom_param_it != custom_info_map.end(); ++custom_param_it) {
+ const bool is_in_disallowed =
+ disallowed_params.find(custom_param_it->first) !=
+ disallowed_params.end();
+ const bool is_in_undefined =
+ undefined_params.find(custom_param_it->first) != undefined_params.end();
+ if (is_in_disallowed || is_in_undefined) {
+ info += custom_param_it->second;
+ }
+ }
- RPCParams::const_iterator it =
- removed_parameters_permissions_.disallowed_params.begin();
- for (; it != removed_parameters_permissions_.disallowed_params.end(); ++it) {
- AddDissalowedParameterToInfoString(info, (*it));
+ uint32_t added_params_counter = 0;
+ RPCParams::const_iterator params_it = disallowed_params.begin();
+ for (; params_it != disallowed_params.end(); ++params_it) {
+ if (custom_info_map.find(*params_it) == custom_info_map.end()) {
+ LOG4CXX_INFO(logger_, "Adding param to info : " << *params_it);
+ AddDissalowedParameterToInfoString((*params_it), info);
+ ++added_params_counter;
+ }
}
- it = removed_parameters_permissions_.undefined_params.begin();
- for (; it != removed_parameters_permissions_.undefined_params.end(); ++it) {
- AddDissalowedParameterToInfoString(info, (*it));
+ params_it = undefined_params.begin();
+ for (; params_it != undefined_params.end(); ++params_it) {
+ if (custom_info_map.find(*params_it) == custom_info_map.end()) {
+ LOG4CXX_INFO(logger_, "Adding param to info : " << *params_it);
+ AddDissalowedParameterToInfoString((*params_it), info);
+ ++added_params_counter;
+ }
}
- if (!info.empty()) {
- const uint32_t params_count =
- removed_parameters_permissions_.disallowed_params.size() +
- removed_parameters_permissions_.undefined_params.size();
- info += params_count > 1 ? " parameters are " : " parameter is ";
+ if (added_params_counter != 0) {
+ info += added_params_counter > 1 ? " parameters are " : " parameter is ";
info += "disallowed by Policies";
+ }
+ if (!info.empty()) {
if (!response[strings::msg_params][strings::info].asString().empty()) {
// If we already have info add info about disallowed params to it
response[strings::msg_params][strings::info] =
diff --git a/src/components/application_manager/src/commands/mobile/send_location_request.cc b/src/components/application_manager/src/commands/mobile/send_location_request.cc
index 6573806c02..f8aea5d2f6 100644
--- a/src/components/application_manager/src/commands/mobile/send_location_request.cc
+++ b/src/components/application_manager/src/commands/mobile/send_location_request.cc
@@ -163,6 +163,7 @@ void SendLocationRequest::on_event(const event_engine::Event& event) {
message[strings::params][hmi_response::code].asInt());
std::string response_info;
GetInfo(message, response_info);
+ LOG4CXX_INFO(logger_, "Response info : " << response_info);
const bool result = PrepareResultForMobileResponse(
result_code, HmiInterfaces::HMI_INTERFACE_Navigation);
SendResponse(result,
@@ -206,6 +207,14 @@ void insert_if_contains(
}
}
+CustomInfo SendLocationRequest::CustomInfoMap() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::map<std::string, std::string> custom_info_map;
+ custom_info_map[strings::delivery_mode] =
+ "default value of delivery mode will be used";
+ return custom_info_map;
+}
+
bool SendLocationRequest::IsWhiteSpaceExist() {
LOG4CXX_AUTO_TRACE(logger_);
std::vector<utils::custom_string::CustomString> fields_to_check;