summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/src/commands/mobile/register_app_interface_request.cc')
-rw-r--r--src/components/application_manager/src/commands/mobile/register_app_interface_request.cc184
1 files changed, 52 insertions, 132 deletions
diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
index f62e0d4b8..0c4070611 100644
--- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
+++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
@@ -1,6 +1,6 @@
-/*
+/*
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2015, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -116,6 +116,18 @@ struct CheckMissedTypes {
const policy::StringArray& policy_app_types_;
std::string& log_;
};
+
+struct IsSameNickname {
+ IsSameNickname(const std::string& app_id):
+ app_id_(app_id) {
+ }
+ bool operator()(const policy::StringArray::value_type nickname) const {
+ return !strcasecmp(app_id_.c_str(), nickname.c_str());
+ }
+
+private:
+ const std::string& app_id_;
+};
}
namespace application_manager {
@@ -124,14 +136,15 @@ namespace commands {
RegisterAppInterfaceRequest::RegisterAppInterfaceRequest(
const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
+ : CommandRequestImpl(message),
+ result_checking_app_hmi_type_(mobile_apis::Result::INVALID_ENUM) {
}
RegisterAppInterfaceRequest::~RegisterAppInterfaceRequest() {
}
bool RegisterAppInterfaceRequest::Init() {
- LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::Init");
+ LOG4CXX_AUTO_TRACE(logger_);
return true;
}
@@ -139,8 +152,9 @@ void RegisterAppInterfaceRequest::Run() {
LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::Run " << connection_key());
// Fix problem with SDL and HMI HTML. This problem is not actual for HMI PASA.
- // Flag conditional compilation "CUSTOMER_PASA" is used in order to exclude hit code
+ // Flag conditional compilation specific to customer is used in order to exclude hit code
// to RTC
+ // FIXME(EZamakhov): on shutdown - get freez
if (true == profile::Profile::instance()->launch_hmi()) {
// wait till HMI started
while (!ApplicationManagerImpl::instance()->IsHMICooperating()) {
@@ -189,13 +203,6 @@ void RegisterAppInterfaceRequest::Run() {
return;
}
- mobile_apis::Result::eType restriction_result = CheckRestrictions();
- if (mobile_apis::Result::SUCCESS != restriction_result) {
- LOG4CXX_ERROR_EXT(logger_, "Param names restrictions check failed.");
- SendResponse(false, restriction_result);
- return;
- }
-
if (IsWhiteSpaceExist()) {
LOG4CXX_INFO(logger_,
"Incoming register app interface has contains \t\n \\t \\n");
@@ -254,7 +261,7 @@ void RegisterAppInterfaceRequest::Run() {
if (mobile_apis::AppHMIType::NAVIGATION ==
static_cast<mobile_apis::AppHMIType::eType>(
app_type.getElement(i).asUInt())) {
- app->set_allowed_support_navigation(true);
+ app->set_is_navi(true);
}
if (mobile_apis::AppHMIType::COMMUNICATION ==
static_cast<mobile_apis::AppHMIType::eType>(
@@ -281,38 +288,12 @@ void RegisterAppInterfaceRequest::Run() {
device_info);
SendRegisterAppInterfaceResponseToMobile();
-
- MessageHelper::SendLockScreenIconUrlNotification(
- (*message_)[strings::params][strings::connection_key].asInt());
-
- policy::PolicyHandler::instance()->PTExchangeAtRegistration(mobile_app_id);
- }
-}
-
-void RegisterAppInterfaceRequest::on_event(const event_engine::Event& event) {
- LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::on_event");
- switch (event.id()) {
- case hmi_apis::FunctionID::TTS_Speak: {
- const smart_objects::SmartObject& message = event.smart_object();
-
- mobile_apis::Result::eType tts_result =
- static_cast<mobile_apis::Result::eType>(
- message[strings::params][hmi_response::code].asInt());
-
- SendRegisterAppInterfaceResponseToMobile(tts_result);
- break;
- }
- default: {
- LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
- break;
- }
}
}
void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
mobile_apis::Result::eType result) {
- smart_objects::SmartObject* params = new smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
ApplicationManagerImpl* app_manager = ApplicationManagerImpl::instance();
const HMICapabilities& hmi_capabilities = app_manager->hmi_capabilities();
@@ -320,14 +301,12 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
ApplicationSharedPtr application =
ApplicationManagerImpl::instance()->application(key);
- if (!application.valid()) {
+ if (!application) {
LOG4CXX_ERROR(logger_, "There is no application for such connection key" <<
key);
return;
}
- smart_objects::SmartObject& response_params = *params;
-
response_params[strings::sync_msg_version][strings::major_version] =
APIVersion::kAPIV3;
response_params[strings::sync_msg_version][strings::minor_version] =
@@ -467,17 +446,17 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
}
ResumeCtrl& resumer = ApplicationManagerImpl::instance()->resume_controller();
- uint32_t hash_id = 0;
+ std::string hash_id = "";
- const char* add_info = "";
- const bool resumption = (*message_)[strings::msg_params].keyExists(strings::hash_id);
+ std::string add_info("");
+ bool resumption = (*message_)[strings::msg_params].keyExists(strings::hash_id);
bool need_restore_vr = resumption;
if (resumption) {
- hash_id = (*message_)[strings::msg_params][strings::hash_id].asUInt();
+ hash_id = (*message_)[strings::msg_params][strings::hash_id].asString();
if (!resumer.CheckApplicationHash(application, hash_id)) {
- LOG4CXX_WARN(logger_, "Hash does not matches");
+ LOG4CXX_WARN(logger_, "Hash does not match");
result = mobile_apis::Result::RESUME_FAILED;
- add_info = "Hash does not matches";
+ add_info = "Hash does not match";
need_restore_vr = false;
} else if (!resumer.CheckPersistenceFilesForResumption(application)) {
LOG4CXX_WARN(logger_, "Persistent data is missed");
@@ -488,8 +467,16 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
add_info = " Resume Succeed";
}
}
+ if ((mobile_apis::Result::SUCCESS == result) &&
+ (mobile_apis::Result::INVALID_ENUM != result_checking_app_hmi_type_)) {
+ add_info += response_info_;
+ result = result_checking_app_hmi_type_;
+ }
- SendResponse(true, result, add_info, params);
+ // in case application exist in resumption we need to send resumeVrgrammars
+ if (false == resumption) {
+ resumption = resumer.IsApplicationSaved(application->mobile_app_id());
+ }
MessageHelper::SendOnAppRegisteredNotificationToHMI(*(application.get()),
resumption,
@@ -497,6 +484,7 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
MessageHelper::SendChangeRegistrationRequestToHMI(application);
+ SendResponse(true, result, add_info.c_str(), &response_params);
if (result != mobile_apis::Result::RESUME_FAILED) {
resumer.StartResumption(application, hash_id);
} else {
@@ -506,17 +494,17 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
mobile_apis::Result::eType
RegisterAppInterfaceRequest::CheckCoincidence() {
- LOG4CXX_TRACE_ENTER(logger_);
+ LOG4CXX_AUTO_TRACE(logger_);
const smart_objects::SmartObject& msg_params =
(*message_)[strings::msg_params];
ApplicationManagerImpl::ApplicationListAccessor accessor;
- const std::set<ApplicationSharedPtr> applications = accessor.applications();
- std::set<ApplicationSharedPtr>::const_iterator it = applications.begin();
+ ApplicationManagerImpl::ApplictionSetConstIt it =
+ accessor.begin();
const std::string app_name = msg_params[strings::app_name].asString();
- for (; applications.end() != it; ++it) {
+ for (; accessor.end() != it; ++it) {
// name check
const std::string& cur_name = (*it)->name();
@@ -577,9 +565,10 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() {
}
if (!app_nicknames.empty()) {
- policy::StringArray::const_iterator it = std::find(
- app_nicknames.begin(), app_nicknames.end(),
+ IsSameNickname compare(
message[strings::msg_params][strings::app_name].asString());
+ policy::StringArray::const_iterator it = std::find_if(
+ app_nicknames.begin(), app_nicknames.end(), compare);
if (app_nicknames.end() == it) {
LOG4CXX_WARN(logger_,
"Application name was not found in nicknames list.");
@@ -608,7 +597,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() {
if (!log.empty()) {
response_info_ = "Following AppHMITypes are not present in policy "
"table:" + log;
- result = mobile_apis::Result::WARNINGS;
+ result_checking_app_hmi_type_ = mobile_apis::Result::WARNINGS;
}
}
// Replace AppHMITypes in request with values allowed by policy table
@@ -661,91 +650,22 @@ void RegisterAppInterfaceRequest::FillDeviceInfo(
}
}
-mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckRestrictions() const {
-
- LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::CheckRestrictions");
-
- const smart_objects::SmartObject& msg_params =
- (*message_)[strings::msg_params];
-
- const std::string& app_name = msg_params[strings::app_name].asString();
-
- if (ClearParamName(app_name).empty()) {
- printf("Application name is empty.\n");
- return mobile_apis::Result::INVALID_DATA;
- }
-
- if ((app_name[0] == '\n') ||
- ((app_name[0] == '\\') && (app_name[1] == 'n'))) {
-
- printf("Application name has invalid characters.");
- return mobile_apis::Result::INVALID_DATA;
- }
-
- if (msg_params.keyExists(strings::tts_name)) {
-
- const smart_objects::SmartArray* tts =
- msg_params[strings::tts_name].asArray();
-
- smart_objects::SmartArray::const_iterator it = tts->begin();
- smart_objects::SmartArray::const_iterator it_end = tts->end();
-
- for (; it != it_end; ++it) {
-
- const std::string& tts_name = (*it)[strings::text].asString();
-
- if (ClearParamName(tts_name).empty()) {
- printf("TTS value is empty.");
- return mobile_apis::Result::INVALID_DATA;
- }
-
- if ((tts_name[0] == '\n') ||
- ((tts_name[0] == '\\') && (tts_name[1] == 'n'))) {
-
- printf("TTS value(s) has invalid characters.");
- return mobile_apis::Result::INVALID_DATA;
- }
- }
- }
-
- return mobile_apis::Result::SUCCESS;
-}
-
-std::string
-RegisterAppInterfaceRequest::ClearParamName(std::string param_name) const {
-
- // Expecting for chars different from newlines and spaces in the appName
- //
- // There is an agreement, that "\n" is not allowed symbols, so we have to
- // check for this case also
-
- std::string newline = "\\n";
- while (std::string::npos != param_name.find(newline)) {
- param_name.erase(param_name.find(newline), newline.length());
- }
-
- std::string::iterator param_name_new_end =
- std::remove_if(param_name.begin(), param_name.end(), ::isspace);
-
- return std::string(param_name.begin(), param_name_new_end);
-}
-
bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() {
LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::"
"IsApplicationWithSameAppIdRegistered");
const std::string mobile_app_id = (*message_)[strings::msg_params]
- [strings::app_id].asString();
+ [strings::app_id].asString();
ApplicationManagerImpl::ApplicationListAccessor accessor;
- const std::set<ApplicationSharedPtr> applications = accessor.applications();
+ const ApplicationManagerImpl::ApplictionSet applications = accessor.applications();
- std::set<ApplicationSharedPtr>::const_iterator it = applications.begin();
- std::set<ApplicationSharedPtr>::const_iterator it_end = applications.end();
+ ApplicationManagerImpl::ApplictionSetConstIt it = applications.begin();
+ ApplicationManagerImpl::ApplictionSetConstIt it_end = applications.end();
for (; it != it_end; ++it) {
- if (mobile_app_id == (*it)->mobile_app_id()->asString()) {
+ if (!strcasecmp(mobile_app_id.c_str(),(*it)->mobile_app_id().c_str())) {
return true;
}
}
@@ -754,7 +674,7 @@ bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() {
}
bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() {
- LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::IsWhiteSpaceExist");
+ LOG4CXX_AUTO_TRACE(logger_);
const char* str = NULL;
str = (*message_)[strings::msg_params][strings::app_name].asCharArray();