summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src/commands/mobile/send_location_request.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/src/commands/mobile/send_location_request.cc')
-rw-r--r--src/components/application_manager/src/commands/mobile/send_location_request.cc66
1 files changed, 62 insertions, 4 deletions
diff --git a/src/components/application_manager/src/commands/mobile/send_location_request.cc b/src/components/application_manager/src/commands/mobile/send_location_request.cc
index b5c2e8a9a5..b77b4afd0f 100644
--- a/src/components/application_manager/src/commands/mobile/send_location_request.cc
+++ b/src/components/application_manager/src/commands/mobile/send_location_request.cc
@@ -46,17 +46,39 @@ SendLocationRequest::~SendLocationRequest() {
}
void SendLocationRequest::Run() {
- LOG4CXX_INFO(logger_, "SendLocationRequest::Run");
+ using namespace hmi_apis;
+ LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance()
->application(connection_key());
if (!app) {
- LOG4CXX_ERROR_EXT(
- logger_, "An application " << app->name() << " is not registered.");
+ LOG4CXX_ERROR_EXT(logger_,
+ "An application with connection key " << connection_key()
+ << " is not registered.");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
+ const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params];
+
+ std::list<Common_TextFieldName::eType> fields_to_check;
+ if (msg_params.keyExists(strings::location_name)) {
+ fields_to_check.push_back(Common_TextFieldName::locationName);
+ }
+ if (msg_params.keyExists(strings::location_description)) {
+ fields_to_check.push_back(Common_TextFieldName::locationDescription);
+ }
+ if (msg_params.keyExists(strings::address_lines)) {
+ fields_to_check.push_back(Common_TextFieldName::addressLines);
+ }
+ if (msg_params.keyExists(strings::phone_number)) {
+ fields_to_check.push_back(Common_TextFieldName::phoneNumber);
+ }
+
+ if (!CheckHMICapabilities(fields_to_check)) {
+ SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE);
+ return;
+ }
if (IsWhiteSpaceExist()) {
LOG4CXX_ERROR(logger_, "Strings contain invalid characters");
@@ -90,7 +112,10 @@ void SendLocationRequest::on_event(const event_engine::Event& event) {
mobile_apis::Result::eType result_code = GetMobileResultCode(
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asUInt()));
- bool result = mobile_apis::Result::SUCCESS == result_code;
+ bool result =
+ mobile_apis::Result::SUCCESS == result_code ||
+ mobile_apis::Result::WARNINGS == result_code ||
+ mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code ;
SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
break;
}
@@ -161,6 +186,39 @@ bool SendLocationRequest::IsWhiteSpaceExist() {
return false;
}
+bool SendLocationRequest::CheckHMICapabilities(std::list<hmi_apis::Common_TextFieldName::eType>& fields_names) {
+ using namespace smart_objects;
+ using namespace hmi_apis;
+
+ ApplicationManagerImpl* instance = ApplicationManagerImpl::instance();
+ const HMICapabilities& hmi_capabilities = instance->hmi_capabilities();
+ if (!hmi_capabilities.is_ui_cooperating()) {
+ LOG4CXX_ERROR_EXT(logger_, "UI is not supported.");
+ return false;
+ }
+ const size_t size_before = fields_names.size();
+ if (hmi_capabilities.display_capabilities()) {
+ const SmartObject disp_cap = (*hmi_capabilities.display_capabilities());
+ const SmartObject& text_fields = disp_cap.getElement(hmi_response::text_fields);
+ const size_t len = text_fields.length();
+ for (size_t i = 0; i < len; ++i) {
+ const SmartObject& text_field = text_fields[i];
+ const Common_TextFieldName::eType filed_name =
+ static_cast<Common_TextFieldName::eType>(text_field.getElement(strings::name).asInt());
+ const std::list<Common_TextFieldName::eType>::iterator it =
+ std::find(fields_names.begin(), fields_names.end(), filed_name);
+ if (it != fields_names.end()) {
+ fields_names.erase(it);
+ }
+ }
+ }
+ if (fields_names.size() == size_before) {
+ LOG4CXX_ERROR_EXT(logger_, "Some fields are not supported by capabilities");
+ return false;
+ }
+ return true;
+}
+
} // namespace commands
} // namespace application_manager