diff options
Diffstat (limited to 'src/components/application_manager/src/commands/command_impl.cc')
-rw-r--r-- | src/components/application_manager/src/commands/command_impl.cc | 67 |
1 files changed, 49 insertions, 18 deletions
diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc index 0a3e65a790..b928184148 100644 --- a/src/components/application_manager/src/commands/command_impl.cc +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -94,25 +94,30 @@ void CommandImpl::SetAllowedToTerminate(const bool allowed) { allowed_to_terminate_ = allowed; } -void CommandImpl::ReplaceMobileByHMIAppId( +bool CommandImpl::ReplaceMobileWithHMIAppId( NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { + LOG4CXX_AUTO_TRACE(logger_); if (message.keyExists(strings::app_id)) { ApplicationSharedPtr application = application_manager_.application(message[strings::app_id].asUInt()); - if (application.valid()) { - LOG4CXX_DEBUG(logger_, - "ReplaceMobileByHMIAppId from " - << message[strings::app_id].asInt() << " to " - << application->hmi_app_id()); - message[strings::app_id] = application->hmi_app_id(); + if (!application) { + LOG4CXX_ERROR(logger_, "Substitution mobile --> HMI id is failed."); + return false; } + LOG4CXX_DEBUG(logger_, + "ReplaceMobileWithHMIAppId from " + << message[strings::app_id].asInt() << " to " + << application->hmi_app_id()); + message[strings::app_id] = application->hmi_app_id(); } else { switch (message.getType()) { case smart_objects::SmartType::SmartType_Array: { smart_objects::SmartArray* message_array = message.asArray(); smart_objects::SmartArray::iterator it = message_array->begin(); for (; it != message_array->end(); ++it) { - ReplaceMobileByHMIAppId(*it); + if (!ReplaceMobileWithHMIAppId(*it)) { + break; + } } break; } @@ -121,36 +126,51 @@ void CommandImpl::ReplaceMobileByHMIAppId( std::set<std::string>::const_iterator key = keys.begin(); for (; key != keys.end(); ++key) { std::string k = *key; - ReplaceMobileByHMIAppId(message[*key]); + if (!ReplaceMobileWithHMIAppId(message[*key])) { + break; + } } break; } default: { break; } } } + + return true; +} + +DEPRECATED void CommandImpl::ReplaceMobileByHMIAppId( + NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { + if (!ReplaceMobileWithHMIAppId(message)) { + LOG4CXX_ERROR(logger_, "Substitution mobile --> HMI id is failed."); + } } -void CommandImpl::ReplaceHMIByMobileAppId( +bool CommandImpl::ReplaceHMIWithMobileAppId( NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { if (message.keyExists(strings::app_id)) { ApplicationSharedPtr application = application_manager_.application_by_hmi_app( message[strings::app_id].asUInt()); - if (application.valid()) { - LOG4CXX_DEBUG(logger_, - "ReplaceHMIByMobileAppId from " - << message[strings::app_id].asInt() << " to " - << application->app_id()); - message[strings::app_id] = application->app_id(); + if (!application) { + LOG4CXX_ERROR(logger_, "Substitution HMI --> mobile id is failed."); + return false; } + LOG4CXX_DEBUG(logger_, + "ReplaceHMIWithMobileAppId from " + << message[strings::app_id].asInt() << " to " + << application->app_id()); + message[strings::app_id] = application->app_id(); } else { switch (message.getType()) { case smart_objects::SmartType::SmartType_Array: { smart_objects::SmartArray* message_array = message.asArray(); smart_objects::SmartArray::iterator it = message_array->begin(); for (; it != message_array->end(); ++it) { - ReplaceHMIByMobileAppId(*it); + if (!ReplaceHMIWithMobileAppId(*it)) { + break; + } } break; } @@ -158,13 +178,24 @@ void CommandImpl::ReplaceHMIByMobileAppId( std::set<std::string> keys = message.enumerate(); std::set<std::string>::const_iterator key = keys.begin(); for (; key != keys.end(); ++key) { - ReplaceHMIByMobileAppId(message[*key]); + if (!ReplaceHMIWithMobileAppId(message[*key])) { + break; + } } break; } default: { break; } } } + + return true; +} + +DEPRECATED void CommandImpl::ReplaceHMIByMobileAppId( + NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { + if (!ReplaceHMIWithMobileAppId(message)) { + LOG4CXX_ERROR(logger_, "Substitution HMI --> mobile id is failed."); + } } } // namespace commands |