diff options
author | Justin Dickow <jjdickow@gmail.com> | 2014-10-20 17:44:41 -0400 |
---|---|---|
committer | Justin Dickow <jjdickow@gmail.com> | 2014-10-20 17:44:41 -0400 |
commit | 34e7256493ff0e6594029b9857d7e2aa31f5dbeb (patch) | |
tree | 367306b507c52d3af211533810adbc22004e0192 /src/components/application_manager/src/commands | |
parent | 2eef966e9b5fd4d94dd98820095eb765e200c64b (diff) | |
download | sdl_core-34e7256493ff0e6594029b9857d7e2aa31f5dbeb.tar.gz |
SDL 3.8!
Signed-off-by: Justin Dickow <jjdickow@gmail.com>
Diffstat (limited to 'src/components/application_manager/src/commands')
315 files changed, 27242 insertions, 0 deletions
diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc new file mode 100644 index 0000000000..af666b22c4 --- /dev/null +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -0,0 +1,80 @@ +/** + Copyright (c) 2014, 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 "application_manager/commands/command_impl.h" +#include "config_profile/profile.h" + +namespace application_manager { +namespace commands { + +CREATE_LOGGERPTR_LOCAL(CommandImpl::logger_, "Commands") + +const int32_t CommandImpl::hmi_protocol_type_ = 1; +const int32_t CommandImpl::mobile_protocol_type_ = 0; +const int32_t CommandImpl::protocol_version_ = 3; + +CommandImpl::CommandImpl(const MessageSharedPtr& message) + : message_(message), + default_timeout_(profile::Profile::instance()->default_timeout()) { +} + +CommandImpl::~CommandImpl() { + CleanUp(); +} + +bool CommandImpl::CheckPermissions(){ + return true; +} + +bool CommandImpl::Init() { + return true; +} + +bool CommandImpl::CleanUp() { + return true; +} + +void CommandImpl::Run() { +} + +uint32_t CommandImpl::default_timeout() const { + return default_timeout_; +} + + +uint32_t CommandImpl::correlation_id() const { + return (*message_)[strings::params][strings::correlation_id].asUInt(); +} + + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/command_notification_impl.cc b/src/components/application_manager/src/commands/command_notification_impl.cc new file mode 100644 index 0000000000..c99f2d9086 --- /dev/null +++ b/src/components/application_manager/src/commands/command_notification_impl.cc @@ -0,0 +1,74 @@ +/* + Copyright (c) 2013, 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 "application_manager/commands/command_notification_impl.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/message_helper.h" + +namespace application_manager { + +namespace commands { + +CommandNotificationImpl::CommandNotificationImpl( + const MessageSharedPtr& message) + : CommandImpl(message) { +} + +CommandNotificationImpl::~CommandNotificationImpl() { +} + +bool CommandNotificationImpl::Init() { + return true; +} + +bool CommandNotificationImpl::CleanUp() { + return true; +} + +void CommandNotificationImpl::Run() { +} + +void CommandNotificationImpl::SendNotification() { + (*message_)[strings::params][strings::protocol_type] = mobile_protocol_type_; + (*message_)[strings::params][strings::protocol_version] = protocol_version_; + (*message_)[strings::params][strings::message_type] = + static_cast<int32_t>(application_manager::MessageType::kNotification); + + LOG4CXX_INFO(logger_, "SendNotification"); + MessageHelper::PrintSmartObject(*message_); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc new file mode 100644 index 0000000000..5f8757754f --- /dev/null +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -0,0 +1,548 @@ +/* + Copyright (c) 2013, 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 <algorithm> +#include <string> +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/message_helper.h" +#include "smart_objects/smart_object.h" + +namespace application_manager { + +namespace commands { + +struct DisallowedParamsInserter { + DisallowedParamsInserter(smart_objects::SmartObject& response, + mobile_apis::VehicleDataResultCode::eType code) + : response_(response), + code_(code) { + } + + bool operator()(const std::string& param) { + const VehicleData& vehicle_data = + application_manager::MessageHelper::vehicle_data(); + VehicleData::const_iterator it = vehicle_data.find(param); + if (vehicle_data.end() != it) { + smart_objects::SmartObject* disallowed_param = + new smart_objects::SmartObject(smart_objects::SmartType_Map); + (*disallowed_param)[strings::data_type] = (*it).second; + (*disallowed_param)[strings::result_code] = code_; + response_[strings::msg_params][param.c_str()] = *disallowed_param; + return true; + } + return false; + } +private: + smart_objects::SmartObject& response_; + mobile_apis::VehicleDataResultCode::eType code_; +}; + +CommandRequestImpl::CommandRequestImpl(const MessageSharedPtr& message) + : CommandImpl(message), + current_state_(kAwaitingHMIResponse) { +} + +CommandRequestImpl::~CommandRequestImpl() { +} + +bool CommandRequestImpl::Init() { + return true; +} + +bool CommandRequestImpl::CheckPermissions() { + return CheckAllowedParameters(); +} + +bool CommandRequestImpl::CleanUp() { + return true; +} + +void CommandRequestImpl::Run() { +} + +void CommandRequestImpl::onTimeOut() { + LOG4CXX_INFO(logger_, "CommandRequestImpl::onTimeOut"); + + unsubscribe_from_all_events(); + { + sync_primitives::AutoLock auto_lock(state_lock_); + if (kCompleted == current_state_) { + // don't send timeout if request completed + return; + } + + current_state_ = kTimedOut; + } + + smart_objects::SmartObject* response = + MessageHelper::CreateNegativeResponse(connection_key(), function_id(), + correlation_id(), mobile_api::Result::GENERIC_ERROR); + + ApplicationManagerImpl::instance()->ManageMobileCommand(response); +} + +void CommandRequestImpl::on_event(const event_engine::Event& event) { +} + +void CommandRequestImpl::SendResponse( + const bool success, const mobile_apis::Result::eType& result_code, + const char* info, const NsSmart::SmartObject* response_params) { + + { + sync_primitives::AutoLock auto_lock(state_lock_); + if (kTimedOut == current_state_) { + // don't send response if request timeout expired + return; + } + + current_state_ = kCompleted; + } + + NsSmartDeviceLink::NsSmartObjects::SmartObject* result = + new NsSmartDeviceLink::NsSmartObjects::SmartObject; + if (!result) { + LOG4CXX_ERROR(logger_, "Memory allocation failed."); + return; + } + NsSmartDeviceLink::NsSmartObjects::SmartObject& response = *result; + + response[strings::params][strings::message_type] = MessageType::kResponse; + response[strings::params][strings::correlation_id] = correlation_id(); + response[strings::params][strings::protocol_type] = + CommandImpl::mobile_protocol_type_; + response[strings::params][strings::protocol_version] = + CommandImpl::protocol_version_; + response[strings::params][strings::connection_key] = connection_key(); + response[strings::params][strings::function_id] = function_id(); + + if (response_params) { + response[strings::msg_params] = *response_params; + } + + if (info) { + response[strings::msg_params][strings::info] = std::string(info); + } + + // Add disallowed parameters and info from request back to response with appropriate + // reasons (VehicleData result codes) + if (result_code != mobile_apis::Result::APPLICATION_NOT_REGISTERED) { + const mobile_apis::FunctionID::eType& id = + static_cast<mobile_apis::FunctionID::eType>(function_id()); + if ((id == mobile_apis::FunctionID::SubscribeVehicleDataID) || + (id == mobile_apis::FunctionID::UnsubscribeVehicleDataID)) { + AddDisallowedParameters(response); + AddDisallowedParametersToInfo(response); + } else if (id == mobile_apis::FunctionID::GetVehicleDataID) { + AddDisallowedParametersToInfo(response); + } + } + + response[strings::msg_params][strings::success] = success; + response[strings::msg_params][strings::result_code] = result_code; + + ApplicationManagerImpl::instance()->ManageMobileCommand(result); +} + +bool CommandRequestImpl::CheckSyntax(std::string str, bool allow_empty_line) { + if (std::string::npos != str.find_first_of("\t\n")) { + LOG4CXX_ERROR(logger_, "CheckSyntax failed! :" << str); + return false; + } + if (std::string::npos != str.find("\\n") || + std::string::npos != str.find("\\t")) { + LOG4CXX_ERROR(logger_, "CheckSyntax failed! :" << str); + return false; + } + if (!allow_empty_line) { + if ((std::string::npos == str.find_first_not_of(' '))) { + return false; + } + } + return true; +} + +void CommandRequestImpl::SendHMIRequest( + const hmi_apis::FunctionID::eType& function_id, + const NsSmart::SmartObject* msg_params, bool use_events) { + + NsSmartDeviceLink::NsSmartObjects::SmartObject* result = + new NsSmartDeviceLink::NsSmartObjects::SmartObject; + if (!result) { + LOG4CXX_ERROR(logger_, "Memory allocation failed."); + return; + } + + const uint32_t hmi_correlation_id = + ApplicationManagerImpl::instance()->GetNextHMICorrelationID(); + if (use_events) { + LOG4CXX_WARN(logger_, "subscribe_on_event " << function_id << " " << hmi_correlation_id); + subscribe_on_event(function_id, hmi_correlation_id); + } + + NsSmartDeviceLink::NsSmartObjects::SmartObject& request = *result; + request[strings::params][strings::message_type] = MessageType::kRequest; + request[strings::params][strings::function_id] = function_id; + request[strings::params][strings::correlation_id] = hmi_correlation_id; + request[strings::params][strings::protocol_version] = + CommandImpl::protocol_version_; + request[strings::params][strings::protocol_type] = + CommandImpl::hmi_protocol_type_; + + if (msg_params) { + request[strings::msg_params] = *msg_params; + } + + if (!ApplicationManagerImpl::instance()->ManageHMICommand(result)) { + LOG4CXX_ERROR(logger_, "Unable to send request"); + SendResponse(false, mobile_apis::Result::OUT_OF_MEMORY); + } +} + +void CommandRequestImpl::CreateHMINotification( + const hmi_apis::FunctionID::eType& function_id, + const NsSmart::SmartObject& msg_params) const { + + NsSmartDeviceLink::NsSmartObjects::SmartObject* result = + new NsSmartDeviceLink::NsSmartObjects::SmartObject; + if (!result) { + LOG4CXX_ERROR(logger_, "Memory allocation failed."); + return; + } + NsSmartDeviceLink::NsSmartObjects::SmartObject& notify = *result; + + notify[strings::params][strings::message_type] = + static_cast<int32_t>(application_manager::MessageType::kNotification); + notify[strings::params][strings::function_id] = function_id; + notify[strings::msg_params] = msg_params; + + if (!ApplicationManagerImpl::instance()->ManageHMICommand(result)) { + LOG4CXX_ERROR(logger_, "Unable to send HMI notification"); + } +} + +mobile_apis::Result::eType CommandRequestImpl::GetMobileResultCode( + const hmi_apis::Common_Result::eType& hmi_code) const { + + mobile_apis::Result::eType mobile_result = mobile_apis::Result::GENERIC_ERROR; + switch (hmi_code) { + case hmi_apis::Common_Result::SUCCESS: { + mobile_result = mobile_apis::Result::SUCCESS; + break; + } + case hmi_apis::Common_Result::UNSUPPORTED_REQUEST: { + mobile_result = mobile_apis::Result::UNSUPPORTED_REQUEST; + break; + } + case hmi_apis::Common_Result::UNSUPPORTED_RESOURCE: { + mobile_result = mobile_apis::Result::UNSUPPORTED_RESOURCE; + break; + } + case hmi_apis::Common_Result::DISALLOWED: { + mobile_result = mobile_apis::Result::DISALLOWED; + break; + } + case hmi_apis::Common_Result::REJECTED: { + mobile_result = mobile_apis::Result::REJECTED; + break; + } + case hmi_apis::Common_Result::ABORTED: { + mobile_result = mobile_apis::Result::ABORTED; + break; + } + case hmi_apis::Common_Result::IGNORED: { + mobile_result = mobile_apis::Result::IGNORED; + break; + } + case hmi_apis::Common_Result::RETRY: { + mobile_result = mobile_apis::Result::RETRY; + break; + } + case hmi_apis::Common_Result::IN_USE: { + mobile_result = mobile_apis::Result::IN_USE; + break; + } + case hmi_apis::Common_Result::DATA_NOT_AVAILABLE: { + mobile_result = mobile_apis::Result::VEHICLE_DATA_NOT_AVAILABLE; + break; + } + case hmi_apis::Common_Result::TIMED_OUT: { + mobile_result = mobile_apis::Result::TIMED_OUT; + break; + } + case hmi_apis::Common_Result::INVALID_DATA: { + mobile_result = mobile_apis::Result::INVALID_DATA; + break; + } + case hmi_apis::Common_Result::CHAR_LIMIT_EXCEEDED: { + mobile_result = mobile_apis::Result::CHAR_LIMIT_EXCEEDED; + break; + } + case hmi_apis::Common_Result::INVALID_ID: { + mobile_result = mobile_apis::Result::INVALID_ID; + break; + } + case hmi_apis::Common_Result::DUPLICATE_NAME: { + mobile_result = mobile_apis::Result::DUPLICATE_NAME; + break; + } + case hmi_apis::Common_Result::APPLICATION_NOT_REGISTERED: { + mobile_result = mobile_apis::Result::APPLICATION_NOT_REGISTERED; + break; + } + case hmi_apis::Common_Result::WRONG_LANGUAGE: { + mobile_result = mobile_apis::Result::WRONG_LANGUAGE; + break; + } + case hmi_apis::Common_Result::OUT_OF_MEMORY: { + mobile_result = mobile_apis::Result::OUT_OF_MEMORY; + break; + } + case hmi_apis::Common_Result::TOO_MANY_PENDING_REQUESTS: { + mobile_result = mobile_apis::Result::TOO_MANY_PENDING_REQUESTS; + break; + } + case hmi_apis::Common_Result::NO_APPS_REGISTERED: { + mobile_result = mobile_apis::Result::APPLICATION_NOT_REGISTERED; + break; + } + case hmi_apis::Common_Result::NO_DEVICES_CONNECTED: { + mobile_result = mobile_apis::Result::APPLICATION_NOT_REGISTERED; + break; + } + case hmi_apis::Common_Result::WARNINGS: { + mobile_result = mobile_apis::Result::WARNINGS; + break; + } + case hmi_apis::Common_Result::GENERIC_ERROR: { + mobile_result = mobile_apis::Result::GENERIC_ERROR; + break; + } + case hmi_apis::Common_Result::USER_DISALLOWED: { + mobile_result = mobile_apis::Result::USER_DISALLOWED; + break; + } + default: { + LOG4CXX_ERROR(logger_, "Unknown HMI result code " << hmi_code); + break; + } + } + + return mobile_result; +} + +bool CommandRequestImpl::CheckAllowedParameters() { + LOG4CXX_INFO(logger_, "CheckAllowedParameters"); + + // RegisterAppInterface should always be allowed + if (mobile_apis::FunctionID::RegisterAppInterfaceID == + static_cast<mobile_apis::FunctionID::eType>(function_id())) { + return true; + } + + typedef std::set<application_manager::ApplicationSharedPtr> ApplicationList; + ApplicationManagerImpl::ApplicationListAccessor accessor; + ApplicationList app_list = accessor.applications(); + ApplicationList::const_iterator it_app_list = app_list.begin(); + ApplicationList::const_iterator it_app_list_end = app_list.end(); + for (; it_app_list != it_app_list_end; ++it_app_list) { + if (connection_key() == (*it_app_list).get()->app_id()) { + + RPCParams params; + + const smart_objects::SmartObject& s_map = (*message_)[strings::msg_params]; + if (smart_objects::SmartType_Map == s_map.getType()) { + smart_objects::SmartMap::iterator iter = s_map.map_begin(); + smart_objects::SmartMap::iterator iter_end = s_map.map_end(); + + for (; iter != iter_end; ++iter) { + params.push_back(iter->first); + } + } + + CommandParametersPermissions params_permissions; + mobile_apis::Result::eType check_result = + application_manager::ApplicationManagerImpl::instance()-> + CheckPolicyPermissions( + (*it_app_list).get()->mobile_app_id()->asString(), + (*it_app_list).get()->hmi_level(), + static_cast<mobile_api::FunctionID::eType>(function_id()), + params, + ¶ms_permissions); + + // Check, if RPC is allowed by policy + if (mobile_apis::Result::SUCCESS != check_result) { + smart_objects::SmartObject* response = + MessageHelper::CreateBlockedByPoliciesResponse( + static_cast<mobile_api::FunctionID::eType>(function_id()), + check_result, correlation_id(), (*it_app_list)->app_id()); + + ApplicationManagerImpl::instance()->SendMessageToMobile(response); + return false; + } + + // If no parameters specified in policy table, no restriction will be + // applied for parameters + if (params_permissions.allowed_params.empty() && + params_permissions.disallowed_params.empty() && + params_permissions.undefined_params.empty()) { + return true; + } + + RemoveDisallowedParameters(params_permissions); + } + } + return true; +} + +void CommandRequestImpl::RemoveDisallowedParameters( + const CommandParametersPermissions& params_permissions) { + LOG4CXX_INFO(logger_, "RemoveDisallowedParameters"); + + smart_objects::SmartObject& params = (*message_)[strings::msg_params]; + + // Remove from request all disallowed parameters + std::vector<std::string>::const_iterator it_disallowed = + params_permissions.disallowed_params.begin(); + std::vector<std::string>::const_iterator it_disallowed_end = + params_permissions.disallowed_params.end(); + for (;it_disallowed != it_disallowed_end; ++it_disallowed) { + if (params.keyExists(*it_disallowed)) { + params.erase(*it_disallowed); + parameters_permissions_.disallowed_params.push_back( + *it_disallowed); + LOG4CXX_INFO(logger_, "Following parameter is disallowed by user: " + << *it_disallowed); + } + } + + // Remove from request all undefined yet parameters + std::vector<std::string>::const_iterator it_undefined = + params_permissions.undefined_params.begin(); + std::vector<std::string>::const_iterator it_undefined_end = + params_permissions.undefined_params.end(); + for (;it_undefined != it_undefined_end; ++it_undefined) { + if (params.keyExists(*it_undefined)) { + params.erase(*it_undefined); + parameters_permissions_.undefined_params.push_back( + *it_undefined); + LOG4CXX_INFO(logger_, "Following parameter is disallowed by policy: " + << *it_undefined); + } + } + + // Remove from request all parameters missed in allowed + const VehicleData& vehicle_data = + application_manager::MessageHelper::vehicle_data(); + + VehicleData::const_iterator it_vehicle_data = vehicle_data.begin(); + VehicleData::const_iterator it_vehicle_data_end = vehicle_data.end(); + for (;it_vehicle_data != it_vehicle_data_end; ++it_vehicle_data) { + const std::string key = it_vehicle_data->first; + if (params.keyExists(key) && + params_permissions.allowed_params.end() == + std::find(params_permissions.allowed_params.begin(), + params_permissions.allowed_params.end(), + key)) { + params.erase(key); + parameters_permissions_.undefined_params.push_back(key); + LOG4CXX_INFO(logger_, + "Following parameter is not found among allowed parameters '" + << key + << "' and will be treated as disallowed."); + } + } +} + +void CommandRequestImpl::AddDissalowedParameterToInfoString( + std::string& info, const std::string& param) const { + // prepare disallowed params enumeration for response info string + if (info.empty()) { + info = "\'" + param + "\'"; + } else { + info = info + "," + " " + "\'" + param + "\'"; + } +} + +void CommandRequestImpl::AddDisallowedParametersToInfo( + smart_objects::SmartObject& response) const { + std::string info; + + std::vector<std::string>::const_iterator it = + parameters_permissions_.disallowed_params.begin(); + for (; it != parameters_permissions_.disallowed_params.end(); ++it) { + AddDissalowedParameterToInfoString(info, (*it)); + } + + it = parameters_permissions_.undefined_params.begin(); + for (; it != parameters_permissions_.undefined_params.end(); ++it) { + AddDissalowedParameterToInfoString(info, (*it)); + } + + if (!info.empty()) { + info += " disallowed by policies."; + + 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] = + response[strings::msg_params][strings::info].asString() + " " + info; + } else { + response[strings::msg_params][strings::info] = info; + } + } +} + +void CommandRequestImpl::AddDisallowedParameters( + smart_objects::SmartObject& response) { + DisallowedParamsInserter disallowed_inserter( + response, + mobile_apis::VehicleDataResultCode::VDRC_USER_DISALLOWED); + std::for_each(parameters_permissions_.disallowed_params.begin(), + parameters_permissions_.disallowed_params.end(), + disallowed_inserter); + + DisallowedParamsInserter undefined_inserter( + response, + mobile_apis::VehicleDataResultCode::VDRC_DISALLOWED); + std::for_each(parameters_permissions_.undefined_params.begin(), + parameters_permissions_.undefined_params.end(), + undefined_inserter); +} + +bool CommandRequestImpl::HasDisallowedParams() const { + return ((!parameters_permissions_.disallowed_params.empty()) || + (!parameters_permissions_.undefined_params.empty())); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/command_response_impl.cc b/src/components/application_manager/src/commands/command_response_impl.cc new file mode 100644 index 0000000000..d7bd9133bf --- /dev/null +++ b/src/components/application_manager/src/commands/command_response_impl.cc @@ -0,0 +1,88 @@ +/* + Copyright (c) 2013, 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 "application_manager/commands/command_response_impl.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +CommandResponseImpl::CommandResponseImpl(const MessageSharedPtr& message) + : CommandImpl(message) { +} + +CommandResponseImpl::~CommandResponseImpl() { +} + +bool CommandResponseImpl::Init() { + return true; +} + +bool CommandResponseImpl::CleanUp() { + return true; +} + +void CommandResponseImpl::Run() { +} + +void CommandResponseImpl::SendResponse( + bool success, const mobile_apis::Result::eType& result_code, bool final_message) { + LOG4CXX_INFO(logger_, "Trying to send response"); + + (*message_)[strings::params][strings::protocol_type] = mobile_protocol_type_; + (*message_)[strings::params][strings::protocol_version] = protocol_version_; + (*message_)[strings::msg_params][strings::success] = success; + + if (!(*message_)[strings::msg_params].keyExists(strings::result_code)) { + if (mobile_apis::Result::INVALID_ENUM != result_code) { + (*message_)[strings::msg_params][strings::result_code] = result_code; + } else if ((*message_)[strings::params].keyExists(hmi_response::code)) { + (*message_)[strings::msg_params][strings::result_code] = + (*message_)[strings::params][hmi_response::code]; + } else { + if (success) { + (*message_)[strings::msg_params][strings::result_code] = + mobile_apis::Result::SUCCESS; + } else { + (*message_)[strings::msg_params][strings::result_code] = + mobile_apis::Result::INVALID_ENUM; + } + } + } + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_, final_message); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/activate_app_request.cc b/src/components/application_manager/src/commands/hmi/activate_app_request.cc new file mode 100644 index 0000000000..a1b17f5229 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/activate_app_request.cc @@ -0,0 +1,101 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/activate_app_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/message_helper.h" + +namespace application_manager { + + namespace commands { + + ActivateAppRequest::ActivateAppRequest( + const MessageSharedPtr& message): RequestToHMI(message) { + } + + + ActivateAppRequest::~ActivateAppRequest() { + LOG4CXX_TRACE(logger_, "~ActivateAppRequest"); + } + + void ActivateAppRequest::Run() { + LOG4CXX_TRACE(logger_, "enter " << correlation_id()); + uint32_t app_id = RequestToHMI::application_id(); + ApplicationManagerImpl::instance()->set_application_id(correlation_id(), app_id); +#ifdef ENABLE_LOG + mobile_apis::HMILevel::eType requested_hmi_level = static_cast<mobile_apis::HMILevel::eType>( + (*message_)[strings::msg_params][strings::activate_app_hmi_level].asInt()); + LOG4CXX_TRACE(logger_, "requested_hmi_level = " << requested_hmi_level); +#endif + SendRequest(); + subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp, + correlation_id()); + LOG4CXX_TRACE(logger_, "exit"); + } + + + void ActivateAppRequest::on_event(const event_engine::Event& event) { + LOG4CXX_TRACE_ENTER(logger_); + const smart_objects::SmartObject* response = &(event.smart_object()); + const hmi_apis::Common_Result::eType code = + static_cast<hmi_apis::Common_Result::eType>( + (*response)[strings::params][hmi_response::code].asInt()); + if (hmi_apis::Common_Result::SUCCESS != code) { + LOG4CXX_ERROR(logger_, "Error ActivateApp result code " << code); + return; + } + int32_t correlation_id = RequestToHMI::correlation_id(); + // Mobile id is converted to HMI id for HMI requests + const uint32_t hmi_app_id = ApplicationManagerImpl::instance()-> + application_id(correlation_id); + mobile_apis::HMILevel::eType requested_hmi_level = static_cast<mobile_apis::HMILevel::eType>( + (*message_)[strings::msg_params][strings::activate_app_hmi_level].asInt()); + if (0 == hmi_app_id) { + LOG4CXX_ERROR(logger_, "Error hmi_app_id = "<< hmi_app_id); + return; + } + + ApplicationSharedPtr application = ApplicationManagerImpl::instance()-> + application_by_hmi_app(hmi_app_id); + if (!application.valid()) { + LOG4CXX_ERROR(logger_, "Application can't be activated."); + return; + } + if (mobile_apis::HMILevel::HMI_FULL == requested_hmi_level) { + ApplicationManagerImpl::instance()->ActivateApplication(application); + MessageHelper::SendHMIStatusNotification(*(application.get())); + } + } + } // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/activate_app_response.cc b/src/components/application_manager/src/commands/hmi/activate_app_response.cc new file mode 100644 index 0000000000..aba5886097 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/activate_app_response.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/activate_app_response.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/message_helper.h" + +namespace application_manager { + +namespace commands { + +ActivateAppResponse::ActivateAppResponse( + const MessageSharedPtr& message): ResponseFromHMI(message) { +} + +ActivateAppResponse::~ActivateAppResponse() { +} + +void ActivateAppResponse::Run() { + LOG4CXX_TRACE(logger_, "enter"); + event_engine::Event event(hmi_apis::FunctionID::BasicCommunication_ActivateApp); + event.set_smart_object(*message_); + event.raise(); + LOG4CXX_TRACE(logger_, "exit"); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/add_statistics_info_notification.cc b/src/components/application_manager/src/commands/hmi/add_statistics_info_notification.cc new file mode 100644 index 0000000000..c11621045e --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/add_statistics_info_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2014, 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 "application_manager/commands/hmi/add_statistics_info_notification.h" +#include "application_manager/policies/policy_handler.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +AddStatisticsInfoNotification::AddStatisticsInfoNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +AddStatisticsInfoNotification::~AddStatisticsInfoNotification() { +} + +void AddStatisticsInfoNotification::Run() { + LOG4CXX_INFO(logger_, "AddStatisticsInfoNotification::Run"); + + int type = (*message_)[strings::msg_params][hmi_notification::statistic_type] + .asInt(); + + policy::PolicyHandler::instance()->AddStatisticsInfo(type); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/allow_all_apps_request.cc b/src/components/application_manager/src/commands/hmi/allow_all_apps_request.cc new file mode 100644 index 0000000000..6ac42c7a00 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/allow_all_apps_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/allow_all_apps_request.h" + +namespace application_manager { + +namespace commands { + +AllowAllAppsRequest::AllowAllAppsRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +AllowAllAppsRequest::~AllowAllAppsRequest() { +} + +void AllowAllAppsRequest::Run() { + LOG4CXX_INFO(logger_, "AllowAllAppsRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/allow_all_apps_response.cc b/src/components/application_manager/src/commands/hmi/allow_all_apps_response.cc new file mode 100644 index 0000000000..69c52a3269 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/allow_all_apps_response.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/allow_all_apps_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +AllowAllAppsResponse::AllowAllAppsResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +AllowAllAppsResponse::~AllowAllAppsResponse() { +} + +void AllowAllAppsResponse::Run() { + LOG4CXX_INFO(logger_, "AllowAllAppsResponse::Run"); + + ApplicationManagerImpl::instance()->set_all_apps_allowed( + (*message_)[strings::msg_params][hmi_response::allowed].asBool()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/allow_app_request.cc b/src/components/application_manager/src/commands/hmi/allow_app_request.cc new file mode 100644 index 0000000000..302a8c6766 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/allow_app_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/allow_app_request.h" + +namespace application_manager { + +namespace commands { + +AllowAppRequest::AllowAppRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +AllowAppRequest::~AllowAppRequest() { +} + +void AllowAppRequest::Run() { + LOG4CXX_INFO(logger_, "AllowAppRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/allow_app_response.cc b/src/components/application_manager/src/commands/hmi/allow_app_response.cc new file mode 100644 index 0000000000..035e41438d --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/allow_app_response.cc @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/allow_app_response.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" + +namespace application_manager { + +namespace commands { + +AllowAppResponse::AllowAppResponse( + const MessageSharedPtr& message): ResponseFromHMI(message) { +} + +AllowAppResponse::~AllowAppResponse() { +} + +void AllowAppResponse::Run() { + LOG4CXX_INFO(logger_, "AllowAppResponse::Run"); + + uint32_t connection_key = + (*message_)[strings::params][strings::connection_key].asInt(); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()-> + application(connection_key); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + app->set_app_allowed((*message_)[strings::msg_params][hmi_response::allowed].asBool()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/basic_communication_system_request.cc b/src/components/application_manager/src/commands/hmi/basic_communication_system_request.cc new file mode 100644 index 0000000000..0d2bcca4f4 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/basic_communication_system_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/basic_communication_system_request.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +BasicCommunicationSystemRequest::BasicCommunicationSystemRequest( + const MessageSharedPtr& message): RequestToHMI(message) { +} + +BasicCommunicationSystemRequest::~BasicCommunicationSystemRequest() { +} + +void BasicCommunicationSystemRequest::Run() { + LOG4CXX_INFO(logger_, "BasicCommunicationSystemRequest::Run"); + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/basic_communication_system_response.cc b/src/components/application_manager/src/commands/hmi/basic_communication_system_response.cc new file mode 100644 index 0000000000..dd9f657adc --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/basic_communication_system_response.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/basic_communication_system_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +BasicCommunicationSystemResponse::BasicCommunicationSystemResponse( + const MessageSharedPtr& message): ResponseFromHMI(message) { +} + +BasicCommunicationSystemResponse::~BasicCommunicationSystemResponse() { +} + +void BasicCommunicationSystemResponse::Run() { + LOG4CXX_INFO(logger_, "BasicCommunicationSystemResponse::Run"); + event_engine::Event event(hmi_apis::FunctionID::BasicCommunication_SystemRequest); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/button_get_capabilities_request.cc b/src/components/application_manager/src/commands/hmi/button_get_capabilities_request.cc new file mode 100644 index 0000000000..e00b3fdc5a --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/button_get_capabilities_request.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/button_get_capabilities_request.h" +#include "utils/logger.h" + +namespace application_manager { + +namespace commands { + +ButtonGetCapabilitiesRequest::ButtonGetCapabilitiesRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +ButtonGetCapabilitiesRequest::~ButtonGetCapabilitiesRequest() { +} + +void ButtonGetCapabilitiesRequest::Run() { + LOG4CXX_INFO(logger_, "ButtonGetCapabilitiesRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/button_get_capabilities_response.cc b/src/components/application_manager/src/commands/hmi/button_get_capabilities_response.cc new file mode 100644 index 0000000000..0b67234743 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/button_get_capabilities_response.cc @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/button_get_capabilities_response.h" +#include "application_manager/application_manager_impl.h" +#include "utils/logger.h" + +namespace application_manager { + +namespace commands { + +ButtonGetCapabilitiesResponse::ButtonGetCapabilitiesResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +ButtonGetCapabilitiesResponse::~ButtonGetCapabilitiesResponse() { +} + +void ButtonGetCapabilitiesResponse::Run() { + LOG4CXX_INFO(logger_, "ButtonGetCapabilitiesResponse::Run"); + + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + + hmi_capabilities.set_button_capabilities( + (*message_)[strings::msg_params][hmi_response::capabilities]); + + hmi_capabilities.set_preset_bank_capabilities( + (*message_)[strings::msg_params][hmi_response::preset_bank_capabilities]); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/close_popup_request.cc b/src/components/application_manager/src/commands/hmi/close_popup_request.cc new file mode 100644 index 0000000000..3cc5818688 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/close_popup_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/close_popup_request.h" + +namespace application_manager { + +namespace commands { + +ClosePopupRequest::ClosePopupRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +ClosePopupRequest::~ClosePopupRequest() { +} + +void ClosePopupRequest::Run() { + LOG4CXX_INFO(logger_, "ClosePopupRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/close_popup_response.cc b/src/components/application_manager/src/commands/hmi/close_popup_response.cc new file mode 100644 index 0000000000..fa98be5e02 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/close_popup_response.cc @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/close_popup_response.h" + +namespace application_manager { + +namespace commands { + +ClosePopupResponse::ClosePopupResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +ClosePopupResponse::~ClosePopupResponse() { +} + +void ClosePopupResponse::Run() { + LOG4CXX_INFO(logger_, "ClosePopupResponse::Run"); + + // TODO(VS): Process response from HMI +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/get_system_info_request.cc b/src/components/application_manager/src/commands/hmi/get_system_info_request.cc new file mode 100644 index 0000000000..53a084d23e --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/get_system_info_request.cc @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2014, 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 "application_manager/commands/hmi/get_system_info_request.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +GetSystemInfoRequest::GetSystemInfoRequest( + const MessageSharedPtr& message): RequestToHMI(message) { +} + +GetSystemInfoRequest::~GetSystemInfoRequest() { +} + +void GetSystemInfoRequest::Run() { + LOG4CXX_INFO(logger_, "GetSystemInfoRequest::Run"); + uint32_t correlation_id = RequestToHMI::correlation_id(); + uint32_t app_id = RequestToHMI::application_id(); + ApplicationManagerImpl::instance()->set_application_id(correlation_id, app_id); + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + + diff --git a/src/components/application_manager/src/commands/hmi/get_system_info_response.cc b/src/components/application_manager/src/commands/hmi/get_system_info_response.cc new file mode 100644 index 0000000000..090b04c3e3 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/get_system_info_response.cc @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/get_system_info_response.h" +#include "application_manager/policies/policy_handler.h" +#include "application_manager/message_helper.h" + +namespace application_manager { + +namespace commands { + +GetSystemInfoResponse::GetSystemInfoResponse( + const MessageSharedPtr& message): ResponseFromHMI(message) { +} + +GetSystemInfoResponse::~GetSystemInfoResponse() { +} + +void GetSystemInfoResponse::Run() { + LOG4CXX_INFO(logger_, "GetSystemInfoResponse::Run"); + const hmi_apis::Common_Result::eType code = + static_cast<hmi_apis::Common_Result::eType>( + (*message_)[strings::params][hmi_response::code].asInt()); + + if (hmi_apis::Common_Result::SUCCESS != code) { + LOG4CXX_WARN(logger_, "GetSystemError returns an error code " << code); + return; + } + const std::string ccpu_version = + (*message_)[strings::msg_params]["ccpu_version"].asString(); + const std::string wers_country_code = + (*message_)[strings::msg_params]["wersCountryCode"].asString(); + uint32_t lang_code = (*message_)[strings::msg_params]["language"].asUInt(); + const std::string language = + application_manager::MessageHelper::CommonLanguageToString( + static_cast<hmi_apis::Common_Language::eType>(lang_code)); + + policy::PolicyHandler::instance()->OnGetSystemInfo(ccpu_version, + wers_country_code, + language); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/get_urls.cc b/src/components/application_manager/src/commands/hmi/get_urls.cc new file mode 100644 index 0000000000..b3d0f60610 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/get_urls.cc @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/get_urls.h" +#include "application_manager/message.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/policies/policy_handler.h" + +namespace application_manager { +namespace commands { + +GetUrls::GetUrls(const MessageSharedPtr& message) + : RequestFromHMI(message) { +} + +GetUrls::~GetUrls() { +} + +void GetUrls::Run() { + LOG4CXX_INFO(logger_, "GetUrls::Run"); + smart_objects::SmartObject& object = *message_; + object[strings::params][strings::message_type] = MessageType::kResponse; + if (policy::PolicyHandler::instance()->PolicyEnabled()) { + policy::EndpointUrls endpoints = + policy::PolicyHandler::instance()->GetUpdateUrls( + object[strings::msg_params][hmi_request::service].asInt()); + object[strings::msg_params].erase(hmi_request::service); + object[strings::msg_params][hmi_response::urls] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + for (size_t i = 0; i < endpoints.size(); ++i) { + std::string url = endpoints[i].url.empty() ? "" : endpoints[i].url[0]; + object[strings::msg_params][hmi_response::urls][i][strings::url] = url; + if (policy::kDefaultId != endpoints[i].app_id) { + object[strings::msg_params][hmi_response::urls][i][hmi_response::policy_app_id] = + endpoints[i].app_id; + } + } + object[strings::params][hmi_response::code] = hmi_apis::Common_Result::SUCCESS; + } else { + object[strings::params][hmi_response::code] = hmi_apis::Common_Result::DATA_NOT_AVAILABLE; + } + ApplicationManagerImpl::instance()->ManageHMICommand(message_); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/get_urls_response.cc b/src/components/application_manager/src/commands/hmi/get_urls_response.cc new file mode 100644 index 0000000000..f8086affe3 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/get_urls_response.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/get_urls_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { +namespace commands { + +GetUrlsResponse::GetUrlsResponse( + const MessageSharedPtr& message): ResponseToHMI(message) { +} + +GetUrlsResponse::~GetUrlsResponse() { +} + +void GetUrlsResponse::Run() { + LOG4CXX_INFO(logger_, "GetUrlsResponse::Run"); + (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; + (*message_)[strings::params][strings::protocol_version] = protocol_version_; + + ApplicationManagerImpl::instance()->SendMessageToHMI(message_); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/mixing_audio_supported_request.cc b/src/components/application_manager/src/commands/hmi/mixing_audio_supported_request.cc new file mode 100644 index 0000000000..9ab4bf5dbb --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/mixing_audio_supported_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/mixing_audio_supported_request.h" + +namespace application_manager { + +namespace commands { + +MixingAudioSupportedRequest::MixingAudioSupportedRequest( + const MessageSharedPtr& message) : RequestToHMI(message) { +} + +MixingAudioSupportedRequest::~MixingAudioSupportedRequest() { +} + +void MixingAudioSupportedRequest::Run() { + LOG4CXX_INFO(logger_, "MixingAudioSupportedRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/mixing_audio_supported_response.cc b/src/components/application_manager/src/commands/hmi/mixing_audio_supported_response.cc new file mode 100644 index 0000000000..4a4fc276de --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/mixing_audio_supported_response.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/mixing_audio_supported_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +MixingAudioSupportedResponse::MixingAudioSupportedResponse( + const MessageSharedPtr& message) : ResponseFromHMI(message) { +} + +MixingAudioSupportedResponse::~MixingAudioSupportedResponse() { +} + +void MixingAudioSupportedResponse::Run() { + LOG4CXX_INFO(logger_, "MixingAudioSupportedResponse::Run"); + + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + hmi_capabilities.set_attenuated_supported((*message_) + [strings::msg_params][hmi_response::attenuated_supported].asBool()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/navi_alert_maneuver_request.cc b/src/components/application_manager/src/commands/hmi/navi_alert_maneuver_request.cc new file mode 100644 index 0000000000..7128231b11 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_alert_maneuver_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/navi_alert_maneuver_request.h" + +namespace application_manager { + +namespace commands { + +NaviAlertManeuverRequest::NaviAlertManeuverRequest( + const MessageSharedPtr& message) : RequestToHMI(message) { +} + +NaviAlertManeuverRequest::~NaviAlertManeuverRequest() { +} + +void NaviAlertManeuverRequest::Run() { + LOG4CXX_INFO(logger_, "NaviAlertManeuverRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/navi_alert_maneuver_response.cc b/src/components/application_manager/src/commands/hmi/navi_alert_maneuver_response.cc new file mode 100644 index 0000000000..823c96211e --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_alert_maneuver_response.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/navi_alert_maneuver_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +NaviAlertManeuverResponse::NaviAlertManeuverResponse( + const MessageSharedPtr& message) : ResponseFromHMI(message) { +} + +NaviAlertManeuverResponse::~NaviAlertManeuverResponse() { +} + +void NaviAlertManeuverResponse::Run() { + LOG4CXX_INFO(logger_, "NaviAlertManeuverResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::Navigation_AlertManeuver); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc new file mode 100644 index 0000000000..3c7a7d3ab5 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/navi_audio_start_stream_request.h" + +namespace application_manager { + +namespace commands { + +AudioStartStreamRequest::AudioStartStreamRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +AudioStartStreamRequest::~AudioStartStreamRequest() { +} + +void AudioStartStreamRequest::Run() { + LOG4CXX_INFO(logger_, "AudioStartStreamRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + + diff --git a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_response.cc b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_response.cc new file mode 100644 index 0000000000..e4cc8f4cc6 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_response.cc @@ -0,0 +1,72 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/navi_audio_start_stream_response.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" + +namespace application_manager { + +namespace commands { + +AudioStartStreamResponse::AudioStartStreamResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +AudioStartStreamResponse::~AudioStartStreamResponse() { +} + +void AudioStartStreamResponse::Run() { + LOG4CXX_INFO(logger_, "AudioStartStreamResponse::Run"); + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->active_application(); + + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "NaviStartStreamResponse no active app!"); + return; + } + + const hmi_apis::Common_Result::eType code = + static_cast<hmi_apis::Common_Result::eType>( + (*message_)[strings::params][hmi_response::code].asInt()); + + if (hmi_apis::Common_Result::SUCCESS == code) { + LOG4CXX_INFO(logger_, "AudioStartStreamResponse SUCCESS"); + app->set_hmi_supports_navi_audio_streaming(true); + } else { + LOG4CXX_INFO(logger_, "AudioStartStreamResponse NOT SUCCESS"); + app->set_hmi_supports_navi_audio_streaming(false); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_request.cc new file mode 100644 index 0000000000..4052769d53 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_request.cc @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/navi_audio_stop_stream_request.h" + +namespace application_manager { + +namespace commands { + +AudioStopStreamRequest::AudioStopStreamRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +AudioStopStreamRequest::~AudioStopStreamRequest() { +} + +void AudioStopStreamRequest::Run() { + LOG4CXX_INFO(logger_, "AudioStopStreamRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_response.cc b/src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_response.cc new file mode 100644 index 0000000000..81a6c62e8d --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_response.cc @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/navi_audio_stop_stream_response.h" + +namespace application_manager { + +namespace commands { + +AudioStopStreamResponse::AudioStopStreamResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +AudioStopStreamResponse::~AudioStopStreamResponse() { +} + +void AudioStopStreamResponse::Run() { + LOG4CXX_INFO(logger_, "AudioStopStreamResponse::Run"); + +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/navi_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/navi_is_ready_request.cc new file mode 100644 index 0000000000..b7a1799427 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_is_ready_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/navi_is_ready_request.h" + +namespace application_manager { + +namespace commands { + +NaviIsReadyRequest::NaviIsReadyRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +NaviIsReadyRequest::~NaviIsReadyRequest() { +} + +void NaviIsReadyRequest::Run() { + LOG4CXX_INFO(logger_, "NaviIsReadyRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/navi_is_ready_response.cc b/src/components/application_manager/src/commands/hmi/navi_is_ready_response.cc new file mode 100644 index 0000000000..8aef42b40d --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_is_ready_response.cc @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/navi_is_ready_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +NaviIsReadyResponse::NaviIsReadyResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +NaviIsReadyResponse::~NaviIsReadyResponse() { +} + +void NaviIsReadyResponse::Run() { + LOG4CXX_INFO(logger_, "NaviIsReadyResponse::Run"); + smart_objects::SmartObject& object = *message_; + + bool is_available = false; + if (object[strings::msg_params].keyExists(strings::available)) { + is_available = object[strings::msg_params][strings::available].asBool(); + } + + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + + hmi_capabilities.set_is_navi_cooperating(is_available); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/navi_send_location_request.cc b/src/components/application_manager/src/commands/hmi/navi_send_location_request.cc new file mode 100644 index 0000000000..f396a24323 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_send_location_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/navi_send_location_request.h" + +namespace application_manager { + +namespace commands { + +NaviSendLocationRequest::NaviSendLocationRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +NaviSendLocationRequest::~NaviSendLocationRequest() { +} + +void NaviSendLocationRequest::Run() { + LOG4CXX_INFO(logger_, "NaviSendLocationRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/navi_send_location_response.cc b/src/components/application_manager/src/commands/hmi/navi_send_location_response.cc new file mode 100644 index 0000000000..944ced170c --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_send_location_response.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/navi_send_location_response.h" +#include "application_manager/event_engine/event.h" + +namespace application_manager { + +namespace commands { + +NaviSendLocationResponse::NaviSendLocationResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +NaviSendLocationResponse::~NaviSendLocationResponse() { +} + +void NaviSendLocationResponse::Run() { + LOG4CXX_INFO(logger_, "NaviSendLocationResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::Navigation_SendLocation); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/navi_show_constant_tbt_request.cc b/src/components/application_manager/src/commands/hmi/navi_show_constant_tbt_request.cc new file mode 100644 index 0000000000..9103e1f6c4 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_show_constant_tbt_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/navi_show_constant_tbt_request.h" + +namespace application_manager { + +namespace commands { + +NaviShowConstantTBTRequest::NaviShowConstantTBTRequest( + const MessageSharedPtr& message) : RequestToHMI(message) { +} + +NaviShowConstantTBTRequest::~NaviShowConstantTBTRequest() { +} + +void NaviShowConstantTBTRequest::Run() { + LOG4CXX_INFO(logger_, "NaviShowConstantTBTRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/navi_show_constant_tbt_response.cc b/src/components/application_manager/src/commands/hmi/navi_show_constant_tbt_response.cc new file mode 100644 index 0000000000..03c70dd81b --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_show_constant_tbt_response.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/navi_show_constant_tbt_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +NaviShowConstantTBTResponse::NaviShowConstantTBTResponse( + const MessageSharedPtr& message) : ResponseFromHMI(message) { +} + +NaviShowConstantTBTResponse::~NaviShowConstantTBTResponse() { +} + +void NaviShowConstantTBTResponse::Run() { + LOG4CXX_INFO(logger_, "NaviShowConstantTBTResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::Navigation_ShowConstantTBT); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc new file mode 100644 index 0000000000..cb9dbd61e3 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/navi_start_stream_request.h" + +namespace application_manager { + +namespace commands { + +NaviStartStreamRequest::NaviStartStreamRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +NaviStartStreamRequest::~NaviStartStreamRequest() { +} + +void NaviStartStreamRequest::Run() { + LOG4CXX_INFO(logger_, "NaviStartStreamRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + + diff --git a/src/components/application_manager/src/commands/hmi/navi_start_stream_response.cc b/src/components/application_manager/src/commands/hmi/navi_start_stream_response.cc new file mode 100644 index 0000000000..79d51dcb66 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_start_stream_response.cc @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/navi_start_stream_response.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" + +namespace application_manager { + +namespace commands { + +NaviStartStreamResponse::NaviStartStreamResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +NaviStartStreamResponse::~NaviStartStreamResponse() { +} + +void NaviStartStreamResponse::Run() { + LOG4CXX_INFO(logger_, "NaviStartStreamResponse::Run"); + + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->active_application(); + + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "NaviStartStreamResponse no active app!"); + return; + } + + const hmi_apis::Common_Result::eType code = + static_cast<hmi_apis::Common_Result::eType>( + (*message_)[strings::params][hmi_response::code].asInt()); + + if (hmi_apis::Common_Result::SUCCESS == code) { + LOG4CXX_INFO(logger_, "NaviStartStreamResponse SUCCESS"); + app->set_hmi_supports_navi_video_streaming(true); + } else { + LOG4CXX_INFO(logger_, "NaviStartStreamResponse NOT SUCCESS"); + app->set_hmi_supports_navi_video_streaming(false); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/navi_stop_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_stop_stream_request.cc new file mode 100644 index 0000000000..2f1e14a122 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_stop_stream_request.cc @@ -0,0 +1,23 @@ +#include "application_manager/commands/hmi/navi_stop_stream_request.h" + +namespace application_manager { + +namespace commands { + +NaviStopStreamRequest::NaviStopStreamRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +NaviStopStreamRequest::~NaviStopStreamRequest() { +} + +void NaviStopStreamRequest::Run() { + LOG4CXX_INFO(logger_, "NaviStopStreamRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/navi_stop_stream_response.cc b/src/components/application_manager/src/commands/hmi/navi_stop_stream_response.cc new file mode 100644 index 0000000000..c368940d5b --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_stop_stream_response.cc @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/navi_stop_stream_response.h" + +namespace application_manager { + +namespace commands { + +NaviStopStreamResponse::NaviStopStreamResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +NaviStopStreamResponse::~NaviStopStreamResponse() { +} + +void NaviStopStreamResponse::Run() { + LOG4CXX_INFO(logger_, "NaviStopStreamResponse::Run"); + +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/navi_update_turn_list_request.cc b/src/components/application_manager/src/commands/hmi/navi_update_turn_list_request.cc new file mode 100644 index 0000000000..d0df9ec867 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_update_turn_list_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/navi_update_turn_list_request.h" + +namespace application_manager { + +namespace commands { + +NaviUpdateTurnListRequest::NaviUpdateTurnListRequest( + const MessageSharedPtr& message) : RequestToHMI(message) { +} + +NaviUpdateTurnListRequest::~NaviUpdateTurnListRequest() { +} + +void NaviUpdateTurnListRequest::Run() { + LOG4CXX_INFO(logger_, "NaviUpdateTurnListRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/navi_update_turn_list_response.cc b/src/components/application_manager/src/commands/hmi/navi_update_turn_list_response.cc new file mode 100644 index 0000000000..d93b67bb52 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/navi_update_turn_list_response.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/navi_update_turn_list_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +NaviUpdateTurnListResponse::NaviUpdateTurnListResponse( + const MessageSharedPtr& message) : ResponseFromHMI(message) { +} + +NaviUpdateTurnListResponse::~NaviUpdateTurnListResponse() { +} + +void NaviUpdateTurnListResponse::Run() { + LOG4CXX_INFO(logger_, "NaviUpdateTurnListResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::Navigation_UpdateTurnList); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc b/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc new file mode 100644 index 0000000000..2b7ec13c43 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc @@ -0,0 +1,103 @@ +/* + Copyright (c) 2013, 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 "application_manager/commands/hmi/notification_from_hmi.h" +#include "application_manager/application_manager_impl.h" +#include "smart_objects/smart_object.h" + +namespace application_manager { + +namespace commands { + +NotificationFromHMI::NotificationFromHMI(const MessageSharedPtr& message) + : CommandImpl(message) { + + // Replace HMI app id with Mobile connection id + ApplicationManagerImpl::instance()->ReplaceHMIByMobileAppId(*(message.get())); +} + +NotificationFromHMI::~NotificationFromHMI() { +} + +bool NotificationFromHMI::Init() { + return true; +} + +bool NotificationFromHMI::CleanUp() { + return true; +} + +void NotificationFromHMI::Run() { +} + +void NotificationFromHMI::SendNotificationToMobile( + const MessageSharedPtr& message) { + ApplicationManagerImpl::instance()->ManageMobileCommand(message); +} + +void NotificationFromHMI::CreateHMIRequest( + const hmi_apis::FunctionID::eType& function_id, + const NsSmartObj::SmartObject& msg_params) const { + + NsSmartDeviceLink::NsSmartObjects::SmartObject* result = + new NsSmartDeviceLink::NsSmartObjects::SmartObject; + if (!result) { + LOG4CXX_ERROR(logger_, "Memory allocation failed."); + return; + } + + // get hmi correlation id for chaining further request from this object + const uint32_t hmi_correlation_id_ = ApplicationManagerImpl::instance() + ->GetNextHMICorrelationID(); + + NsSmartDeviceLink::NsSmartObjects::SmartObject& request = *result; + request[strings::params][strings::message_type] = + static_cast<int32_t>(application_manager::MessageType::kRequest); + request[strings::params][strings::function_id] = + static_cast<int32_t>(function_id); + request[strings::params][strings::correlation_id] = hmi_correlation_id_; + request[strings::params][strings::protocol_version] = + CommandImpl::protocol_version_; + request[strings::params][strings::protocol_type] = + CommandImpl::hmi_protocol_type_; + + request[strings::msg_params] = msg_params; + + if (!ApplicationManagerImpl::instance()->ManageHMICommand(result)) { + LOG4CXX_ERROR(logger_, "Unable to send request"); + return; + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc b/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc new file mode 100644 index 0000000000..e4f8920ec9 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc @@ -0,0 +1,69 @@ +/* + Copyright (c) 2013, 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 "application_manager/commands/hmi/notification_to_hmi.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +NotificationToHMI::NotificationToHMI(const MessageSharedPtr& message) + : CommandImpl(message) { + + // Replace Mobile connection id with HMI app id + ApplicationManagerImpl::instance()->ReplaceMobileByHMIAppId(*(message.get())); +} + +NotificationToHMI::~NotificationToHMI() { +} + +bool NotificationToHMI::Init() { + return true; +} + +bool NotificationToHMI::CleanUp() { + return true; +} + +void NotificationToHMI::Run() { +} + +void NotificationToHMI::SendNotification() { + (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; + (*message_)[strings::params][strings::protocol_version] = protocol_version_; + ApplicationManagerImpl::instance()->SendMessageToHMI(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/on_allow_sdl_functionality_notification.cc b/src/components/application_manager/src/commands/hmi/on_allow_sdl_functionality_notification.cc new file mode 100644 index 0000000000..020428d6c0 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_allow_sdl_functionality_notification.cc @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_allow_sdl_functionality_notification.h" +#include "application_manager/policies/policy_handler.h" + +namespace application_manager { + +namespace commands { + +OnAllowSDLFunctionalityNotification::OnAllowSDLFunctionalityNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnAllowSDLFunctionalityNotification::~OnAllowSDLFunctionalityNotification() { +} + +void OnAllowSDLFunctionalityNotification::Run() { + LOG4CXX_INFO(logger_, "OnAllowSDLFunctionalityNotification::Run"); + uint32_t device_id = 0; + if ((*message_)[strings::msg_params].keyExists("device")) { + device_id = (*message_)[strings::msg_params]["device"]["id"].asUInt(); + } + policy::PolicyHandler::instance()->OnAllowSDLFunctionalityNotification( + (*message_)[strings::msg_params][hmi_response::allowed].asBool(), + device_id); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_app_activated_notification.cc b/src/components/application_manager/src/commands/hmi/on_app_activated_notification.cc new file mode 100644 index 0000000000..8152244a9c --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_app_activated_notification.cc @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_app_activated_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +OnAppActivatedNotification::OnAppActivatedNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnAppActivatedNotification::~OnAppActivatedNotification() { +} + +void OnAppActivatedNotification::Run() { + LOG4CXX_INFO(logger_, "OnAppActivatedNotification::Run"); + uint32_t app_id = ((*message_)[strings::msg_params][strings::app_id]).asUInt(); + MessageHelper::SendActivateAppToHMI(app_id); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_app_deactivated_notification.cc b/src/components/application_manager/src/commands/hmi/on_app_deactivated_notification.cc new file mode 100644 index 0000000000..152546b24b --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_app_deactivated_notification.cc @@ -0,0 +1,140 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_app_deactivated_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "config_profile/profile.h" + +namespace application_manager { + +namespace commands { + +OnAppDeactivatedNotification::OnAppDeactivatedNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnAppDeactivatedNotification::~OnAppDeactivatedNotification() { +} + +void OnAppDeactivatedNotification::Run() { + LOG4CXX_INFO(logger_, "OnAppDeactivatedNotification::Run"); + uint32_t app_id = (*message_)[strings::msg_params][strings::app_id].asUInt(); + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->application(app_id); + if (!app.valid()) { + LOG4CXX_ERROR(logger_, "Application not found, id="<<app_id); + return; + } + + if (!(((hmi_apis::Common_DeactivateReason::AUDIO == + (*message_)[strings::msg_params][hmi_request::reason].asInt()) || + (hmi_apis::Common_DeactivateReason::PHONECALL == + (*message_)[strings::msg_params][hmi_request::reason].asInt())) && + (app->hmi_level() == mobile_api::HMILevel::eType::HMI_LIMITED))) { + app = ApplicationManagerImpl::instance()->active_application(); + if (!app.valid()) { + LOG4CXX_ERROR_EXT(logger_, "OnAppDeactivatedNotification no active app!"); + return; + } + if (app_id != app->app_id()) { + LOG4CXX_ERROR_EXT(logger_, "Wrong application id!"); + return; + } + } + + if (mobile_api::HMILevel::eType::HMI_NONE == app->hmi_level()) { + return; + } + + switch ((*message_)[strings::msg_params][hmi_request::reason].asInt()) { + case hmi_apis::Common_DeactivateReason::AUDIO: { + if (app->is_media_application()) { + if (profile::Profile::instance()->is_mixing_audio_supported() && + (ApplicationManagerImpl::instance()->vr_session_started() || + app->tts_speak_state())) { + app->set_audio_streaming_state(mobile_api::AudioStreamingState::ATTENUATED); + } else { + app->set_audio_streaming_state(mobile_api::AudioStreamingState::NOT_AUDIBLE); + } + } + // switch HMI level for all applications in FULL or LIMITED + ApplicationManagerImpl::ApplicationListAccessor accessor; + ApplicationManagerImpl::TAppList applications = + accessor.applications(); + ApplicationManagerImpl::TAppListIt it = + applications.begin(); + for (; applications.end() != it; ++it) { + ApplicationSharedPtr app = *it; + if (app.valid()) { + if (mobile_apis::HMILevel::eType::HMI_FULL == app->hmi_level() || + mobile_apis::HMILevel::eType::HMI_LIMITED == app->hmi_level()) { + app->set_hmi_level(mobile_api::HMILevel::HMI_BACKGROUND); + MessageHelper::SendHMIStatusNotification(*app); + } + } + } + break; + } + case hmi_apis::Common_DeactivateReason::PHONECALL: { + app->set_audio_streaming_state(mobile_api::AudioStreamingState::NOT_AUDIBLE); + app->set_hmi_level(mobile_api::HMILevel::HMI_BACKGROUND); + break; + } + case hmi_apis::Common_DeactivateReason::NAVIGATIONMAP: + case hmi_apis::Common_DeactivateReason::PHONEMENU: + case hmi_apis::Common_DeactivateReason::SYNCSETTINGS: + case hmi_apis::Common_DeactivateReason::GENERAL: { + if (app->is_media_application()) { + if (mobile_api::HMILevel::HMI_FULL == app->hmi_level()) { + app->set_hmi_level(mobile_api::HMILevel::HMI_LIMITED); + } + } else { + app->set_hmi_level(mobile_api::HMILevel::HMI_BACKGROUND); + } + break; + } + default: { + LOG4CXX_ERROR_EXT(logger_, "Unknown reason of app deactivation"); + return; + } + } + + MessageHelper::SendHMIStatusNotification(*app); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_app_permission_changed_notification.cc b/src/components/application_manager/src/commands/hmi/on_app_permission_changed_notification.cc new file mode 100644 index 0000000000..26d580e83a --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_app_permission_changed_notification.cc @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_app_permission_changed_notification.h" + +namespace application_manager { + +namespace commands { + +OnAppPermissionChangedNotification::OnAppPermissionChangedNotification( + const MessageSharedPtr& message) + : NotificationToHMI(message) { +} + +OnAppPermissionChangedNotification::~OnAppPermissionChangedNotification() { +} + +void OnAppPermissionChangedNotification::Run() { + LOG4CXX_INFO(logger_, "OnAppPermissionChangedNotification::Run"); + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/on_app_permission_consent_notification.cc b/src/components/application_manager/src/commands/hmi/on_app_permission_consent_notification.cc new file mode 100644 index 0000000000..951a2ebdf1 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_app_permission_consent_notification.cc @@ -0,0 +1,92 @@ + +/** + * Copyright (c) 2014, 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 "application_manager/commands/hmi/on_app_permission_consent_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler.h" + +namespace application_manager { + +namespace commands { + +OnAppPermissionConsentNotification::OnAppPermissionConsentNotification(const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnAppPermissionConsentNotification::~OnAppPermissionConsentNotification() { +} + +void OnAppPermissionConsentNotification::Run() { + LOG4CXX_INFO(logger_, "OnAppPermissionConsentNotification::Run"); + smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; + + uint32_t connection_key = 0; + + policy::PermissionConsent permission_consent; + + // If user defined group permissions for specific app + if (msg_params.keyExists(strings::app_id)) { + connection_key = msg_params[strings::app_id].asUInt(); + } + + if (msg_params.keyExists("consentedFunctions")) { + smart_objects::SmartArray* user_consent = + msg_params["consentedFunctions"].asArray(); + + smart_objects::SmartArray::const_iterator it = user_consent->begin(); + smart_objects::SmartArray::const_iterator it_end = user_consent->end(); + for (; it != it_end; ++it) { + policy::FunctionalGroupPermission permissions; + permissions.group_id = (*it)["id"].asInt(); + permissions.group_alias = (*it)["name"].asString(); + if ((*it).keyExists("allowed")) { + permissions.state = (*it)["allowed"].asBool() ? policy::kGroupAllowed : + policy::kGroupDisallowed; + } else { + permissions.state = policy::kGroupUndefined; + } + + permission_consent.group_permissions.push_back(permissions); + } + + permission_consent.consent_source = msg_params["source"].asString(); + + policy::PolicyHandler::instance()->OnAppPermissionConsent(connection_key, + permission_consent); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/on_app_registered_notification.cc b/src/components/application_manager/src/commands/hmi/on_app_registered_notification.cc new file mode 100644 index 0000000000..26bc396db6 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_app_registered_notification.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_app_registered_notification.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +OnAppRegisteredNotification::OnAppRegisteredNotification( + const MessageSharedPtr& message) : NotificationToHMI(message) { +} + +OnAppRegisteredNotification::~OnAppRegisteredNotification() { +} + +void OnAppRegisteredNotification::Run() { + LOG4CXX_INFO(logger_, "OnAppRegisteredNotification::Run"); + + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_app_unregistered_notification.cc b/src/components/application_manager/src/commands/hmi/on_app_unregistered_notification.cc new file mode 100644 index 0000000000..2bedcb0631 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_app_unregistered_notification.cc @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_app_unregistered_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/event_engine/event.h" + +namespace application_manager { + +namespace commands { + +OnAppUnregisteredNotification::OnAppUnregisteredNotification( + const MessageSharedPtr& message) : NotificationToHMI(message) { +} + +OnAppUnregisteredNotification::~OnAppUnregisteredNotification() { +} + +void OnAppUnregisteredNotification::Run() { + LOG4CXX_INFO(logger_, "OnAppUnregisteredNotification::Run"); + + //sending event for delete VRCommand on PerformInteraction + event_engine::Event event(hmi_apis::FunctionID::BasicCommunication_OnAppUnregistered); + event.set_smart_object(*message_); + event.raise(); + + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_button_event_notification.cc b/src/components/application_manager/src/commands/hmi/on_button_event_notification.cc new file mode 100644 index 0000000000..23aceaa7d6 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_button_event_notification.cc @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_button_event_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "utils/logger.h" + +namespace application_manager { + +namespace commands { + +namespace hmi { + +OnButtonEventNotification::OnButtonEventNotification( + const MessageSharedPtr& message) : NotificationFromHMI(message) { +} + +void OnButtonEventNotification::Run() { + LOG4CXX_INFO(logger_, "OnButtonEventNotification::Run"); + + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::OnButtonEventID); + + SendNotificationToMobile(message_); +} + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_button_press_notification.cc b/src/components/application_manager/src/commands/hmi/on_button_press_notification.cc new file mode 100644 index 0000000000..83bcbd7efa --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_button_press_notification.cc @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_button_press_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "utils/logger.h" +#include "application_manager/event_engine/event.h" + +namespace application_manager { + +namespace commands { + +namespace hmi { + +OnButtonPressNotification::OnButtonPressNotification( + const MessageSharedPtr& message) : NotificationFromHMI(message) { +} + +void OnButtonPressNotification::Run() { + LOG4CXX_INFO(logger_, "OnButtonPressNotification::Run"); + event_engine::Event event(hmi_apis::FunctionID::Buttons_OnButtonPress); + event.set_smart_object(*message_); + event.raise(); + (*message_)[strings::params][strings::function_id] = + static_cast<int>(mobile_apis::FunctionID::eType::OnButtonPressID); + SendNotificationToMobile(message_); +} + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_device_chosen_notification.cc b/src/components/application_manager/src/commands/hmi/on_device_chosen_notification.cc new file mode 100644 index 0000000000..537c246f42 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_device_chosen_notification.cc @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_device_chosen_notification.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +OnDeviceChosenNotification::OnDeviceChosenNotification( + const MessageSharedPtr& message) : NotificationFromHMI(message) { +} + +OnDeviceChosenNotification::~OnDeviceChosenNotification() { +} + +void OnDeviceChosenNotification::Run() { + LOG4CXX_INFO(logger_, "OnDeviceChosenNotification::Run"); + + if ((*message_)[strings::msg_params].keyExists(strings::device_info)) { + ApplicationManagerImpl::instance()->ConnectToDevice( + (*message_)[strings::msg_params][strings::device_info][strings::id] + .asInt()); + } +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc b/src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc new file mode 100644 index 0000000000..8af2571b55 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc @@ -0,0 +1,70 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_device_state_changed_notification.h" +#include "application_manager/policies/policy_handler.h" +#include "application_manager/message_helper.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +OnDeviceStateChangedNotification::OnDeviceStateChangedNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnDeviceStateChangedNotification::~OnDeviceStateChangedNotification() { +} + +void OnDeviceStateChangedNotification::Run() { + LOG4CXX_INFO(logger_, "OnDeviceStateChangedNotification::Run"); + + if ((*message_)[strings::msg_params]["deviceState"] + == hmi_apis::Common_DeviceState::UNPAIRED) { + std::string device_id = (*message_)[strings::msg_params]["deviceInternalId"] + .asString(); + if (device_id.empty()) { + if ((*message_)[strings::msg_params].keyExists("deviceId")) { + device_id = MessageHelper::GetDeviceMacAddressForHandle( + (*message_)[strings::msg_params]["deviceId"]["id"].asInt()); + } + } + policy::PolicyHandler::instance()->RemoveDevice(device_id); + } +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_driver_distraction_notification.cc b/src/components/application_manager/src/commands/hmi/on_driver_distraction_notification.cc new file mode 100644 index 0000000000..d5a8edc48d --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_driver_distraction_notification.cc @@ -0,0 +1,98 @@ +/** + * Copyright (c) 2013, 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 <set> +#include "application_manager/commands/hmi/on_driver_distraction_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +namespace hmi { + +OnDriverDistractionNotification::OnDriverDistractionNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnDriverDistractionNotification::~OnDriverDistractionNotification() { +} + +void OnDriverDistractionNotification::Run() { + LOG4CXX_INFO(logger_, "OnDriverDistractionNotification::Run"); + + const hmi_apis::Common_DriverDistractionState::eType state = + static_cast<hmi_apis::Common_DriverDistractionState::eType>( + (*message_)[strings::msg_params][hmi_notification::state] + .asInt()); + ApplicationManagerImpl::instance()->set_driver_distraction(state); + + MessageSharedPtr on_driver_distraction = + new smart_objects::SmartObject(); + + if (false == on_driver_distraction.valid()) { + LOG4CXX_ERROR_EXT(logger_, "NULL pointer"); + return; + } + + (*on_driver_distraction)[strings::params][strings::function_id] = + mobile_api::FunctionID::OnDriverDistractionID; + + (*on_driver_distraction)[strings::msg_params][mobile_notification::state] = + state; + + ApplicationManagerImpl::ApplicationListAccessor accessor; + const std::set<ApplicationSharedPtr> applications = accessor.applications(); + + std::set<ApplicationSharedPtr>::const_iterator it = applications.begin(); + for (; applications.end() != it; ++it) { + ApplicationSharedPtr app = *it; + if (app.valid()) { + if (mobile_apis::HMILevel::eType::HMI_NONE != app->hmi_level()) { + (*on_driver_distraction)[strings::params] + [strings::connection_key] = app->app_id(); + SendNotificationToMobile(on_driver_distraction); + } + } + } +} + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc b/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc new file mode 100644 index 0000000000..3d027ff1c6 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2014, 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 "application_manager/commands/hmi/on_exit_all_applications_notification.h" +#include "application_manager/application_manager_impl.h" +#include "interfaces/HMI_API.h" +#include "utils/signals.h" + +namespace application_manager { + +namespace commands { + +OnExitAllApplicationsNotification::OnExitAllApplicationsNotification( + const MessageSharedPtr& message) : NotificationFromHMI(message) { +} + +OnExitAllApplicationsNotification::~OnExitAllApplicationsNotification() { +} + +void OnExitAllApplicationsNotification::Run() { + LOG4CXX_INFO(logger_, "OnExitAllApplicationsNotification::Run"); + + const hmi_apis::Common_ApplicationsCloseReason::eType reason = + static_cast<hmi_apis::Common_ApplicationsCloseReason::eType>( + (*message_)[strings::msg_params][hmi_request::reason].asInt()); + + mobile_api::AppInterfaceUnregisteredReason::eType mob_reason = + mobile_api::AppInterfaceUnregisteredReason::INVALID_ENUM; + + ApplicationManagerImpl* app_manager = ApplicationManagerImpl::instance(); + + switch (reason) { + case hmi_apis::Common_ApplicationsCloseReason::IGNITION_OFF: { + mob_reason = mobile_api::AppInterfaceUnregisteredReason::IGNITION_OFF; + break; + } + case hmi_apis::Common_ApplicationsCloseReason::MASTER_RESET: { + mob_reason = mobile_api::AppInterfaceUnregisteredReason::MASTER_RESET; + break; + } + case hmi_apis::Common_ApplicationsCloseReason::FACTORY_DEFAULTS: { + mob_reason = mobile_api::AppInterfaceUnregisteredReason::FACTORY_DEFAULTS; + break; + } + case hmi_apis::Common_ApplicationsCloseReason::SUSPEND: { + app_manager->HeadUnitSuspend(); + SendOnSDLPersistenceComplete(); + return; + } + default : { + LOG4CXX_ERROR(logger_, "Unknown Application close reason" << reason); + return; + } + } + + app_manager->SetUnregisterAllApplicationsReason(mob_reason); + + if (mobile_api::AppInterfaceUnregisteredReason::MASTER_RESET == mob_reason || + mobile_api::AppInterfaceUnregisteredReason::FACTORY_DEFAULTS == mob_reason) { + app_manager->HeadUnitReset(mob_reason); + } + + threads::Thread::InterruptMainThread(); +} + +void OnExitAllApplicationsNotification::SendOnSDLPersistenceComplete() { + LOG4CXX_INFO(logger_, "" + "OnExitAllApplicationsNotification::SendOnSDLPersistenceComplete"); + + smart_objects::SmartObject* message = + new smart_objects::SmartObject(smart_objects::SmartType_Map); + (*message)[strings::params][strings::function_id] = + hmi_apis::FunctionID::BasicCommunication_OnSDLPersistenceComplete; + (*message)[strings::params][strings::message_type] = MessageType::kNotification; + (*message)[strings::params][strings::correlation_id] = + ApplicationManagerImpl::instance()->GetNextHMICorrelationID(); + + ApplicationManagerImpl::instance()->ManageHMICommand(message); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc b/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc new file mode 100644 index 0000000000..f4aed61392 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_exit_application_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +OnExitApplicationNotification::OnExitApplicationNotification( + const MessageSharedPtr& message) : NotificationFromHMI(message) { +} + +OnExitApplicationNotification::~OnExitApplicationNotification() { +} + +void OnExitApplicationNotification::Run() { + LOG4CXX_INFO(logger_, "OnExitApplicationNotification::Run"); + + ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance(); + ApplicationSharedPtr app_impl = app_mgr->application( + (*message_)[strings::msg_params][strings::app_id].asUInt()); + if (!(app_impl.valid())) { + LOG4CXX_ERROR(logger_, "Application does not exist"); + return; + } + hmi_apis::Common_ApplicationToNONEReason::eType reason; + reason = static_cast<hmi_apis::Common_ApplicationToNONEReason::eType> + ((*message_)[strings::msg_params][strings::reason].asInt()); + switch (reason) { + case hmi_apis::Common_ApplicationToNONEReason::USER_EXIT : { + break; + } + default : { + LOG4CXX_WARN(logger_, "Unhandled reason"); + break; + } + } + app_impl->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); + app_impl->set_audio_streaming_state(mobile_apis::AudioStreamingState::NOT_AUDIBLE); + app_impl->set_system_context(mobile_api::SystemContext::SYSCTXT_MAIN); + MessageHelper::SendHMIStatusNotification(*app_impl); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/on_file_removed_notification.cc b/src/components/application_manager/src/commands/hmi/on_file_removed_notification.cc new file mode 100644 index 0000000000..f1a590ee04 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_file_removed_notification.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_file_removed_notification.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +OnFileRemovedNotification::OnFileRemovedNotification( + const MessageSharedPtr& message) : NotificationToHMI(message) { +} + +OnFileRemovedNotification::~OnFileRemovedNotification() { +} + +void OnFileRemovedNotification::Run() { + LOG4CXX_INFO(logger_, "OnFileRemovedNotification::Run"); + + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_find_applications.cc b/src/components/application_manager/src/commands/hmi/on_find_applications.cc new file mode 100644 index 0000000000..bc32ab1cf0 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_find_applications.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_find_applications.h" + +namespace application_manager { + +namespace commands { + +OnFindApplications::OnFindApplications(const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnFindApplications::~OnFindApplications() { +} + +void OnFindApplications::Run() { + LOG4CXX_INFO(logger_, "OnFindApplications::Run"); + + // TODO(PV): add UpdateAppsOnDevice to ApplicationManager +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_ignition_cycle_over_notification.cc b/src/components/application_manager/src/commands/hmi/on_ignition_cycle_over_notification.cc new file mode 100644 index 0000000000..523013734f --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_ignition_cycle_over_notification.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_ignition_cycle_over_notification.h" +#include "application_manager/policies/policy_handler.h" + +namespace application_manager { + +namespace commands { + +OnIgnitionCycleOverNotification::OnIgnitionCycleOverNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnIgnitionCycleOverNotification::~OnIgnitionCycleOverNotification() { +} + +void OnIgnitionCycleOverNotification::Run() { + LOG4CXX_INFO(logger_, "OnIgnitionCycleOverNotification::Run"); + policy::PolicyHandler::instance()->OnIgnitionCycleOver(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_navi_tbt_client_state_notification.cc b/src/components/application_manager/src/commands/hmi/on_navi_tbt_client_state_notification.cc new file mode 100644 index 0000000000..a68ae90796 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_navi_tbt_client_state_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_navi_tbt_client_state_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnNaviTBTClientStateNotification::OnNaviTBTClientStateNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnNaviTBTClientStateNotification::~OnNaviTBTClientStateNotification() { +} + +void OnNaviTBTClientStateNotification::Run() { + LOG4CXX_INFO(logger_, "OnNaviTBTClientStateNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::OnTBTClientStateID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_play_tone_notification.cc b/src/components/application_manager/src/commands/hmi/on_play_tone_notification.cc new file mode 100644 index 0000000000..e05b38d456 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_play_tone_notification.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_play_tone_notification.h" + +namespace application_manager { + +namespace commands { + +OnPlayToneNotification::OnPlayToneNotification(const MessageSharedPtr& message) + : NotificationToHMI(message) { +} + +OnPlayToneNotification::~OnPlayToneNotification() { +} + +void OnPlayToneNotification::Run() { + LOG4CXX_INFO(logger_, "OnPlayToneNotification::Run"); + + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_policy_update.cc b/src/components/application_manager/src/commands/hmi/on_policy_update.cc new file mode 100644 index 0000000000..b3f5803d44 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_policy_update.cc @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2014, 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 "application_manager/commands/hmi/on_policy_update.h" +#include "application_manager/policies/policy_handler.h" + +namespace application_manager { +namespace commands { + +OnPolicyUpdate::OnPolicyUpdate(const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnPolicyUpdate::~OnPolicyUpdate() { +} + +void OnPolicyUpdate::Run() { + LOG4CXX_INFO(logger_, "OnPolicyUpdate::Run"); + policy::PolicyHandler::instance()->OnPTExchangeNeeded(); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/on_put_file_notification.cc b/src/components/application_manager/src/commands/hmi/on_put_file_notification.cc new file mode 100644 index 0000000000..2fecbec9c7 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_put_file_notification.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_put_file_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnPutFileNotification::OnPutFileNotification( + const MessageSharedPtr& message) + : NotificationToHMI(message) { +} + +OnPutFileNotification::~OnPutFileNotification() { +} + +void OnPutFileNotification::Run() { + LOG4CXX_INFO(logger_, "OnPutFileNotification::Run"); + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_ready_notification.cc b/src/components/application_manager/src/commands/hmi/on_ready_notification.cc new file mode 100644 index 0000000000..783aa4af40 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_ready_notification.cc @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_ready_notification.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +OnReadyNotification::OnReadyNotification(const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnReadyNotification::~OnReadyNotification() { +} + +void OnReadyNotification::Run() { + LOG4CXX_INFO(logger_, "OnReadyNotification::Run"); + + ApplicationManagerImpl::instance()->OnHMIStartedCooperation(); + event_engine::Event event(hmi_apis::FunctionID::BasicCommunication_OnReady); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc b/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc new file mode 100644 index 0000000000..1e517f35de --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2014, 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 <string> +#include "application_manager/commands/hmi/on_received_policy_update.h" +#include "application_manager/policies/policy_handler.h" +#include "utils/file_system.h" + +namespace application_manager { + +namespace commands { + +OnReceivedPolicyUpdate::OnReceivedPolicyUpdate(const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnReceivedPolicyUpdate::~OnReceivedPolicyUpdate() { +} + +void OnReceivedPolicyUpdate::Run() { + LOG4CXX_INFO(logger_, "OnReceivedPolicyUpdate::Run"); + const std::string& file_path = + (*message_)[strings::msg_params][hmi_notification::policyfile].asString(); + policy::BinaryMessage file_content; + if (!file_system::ReadBinaryFile(file_path, file_content)) { + LOG4CXX_ERROR(logger_, "Failed to read Update file."); + return; + } + policy::PolicyHandler::instance()->ReceiveMessageFromSDK(file_path, file_content); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/on_record_start_notification.cc b/src/components/application_manager/src/commands/hmi/on_record_start_notification.cc new file mode 100644 index 0000000000..e0dae8f045 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_record_start_notification.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_record_start_notification.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +OnRecordStartdNotification::OnRecordStartdNotification( + const MessageSharedPtr& message) : NotificationToHMI(message) { +} + +OnRecordStartdNotification::~OnRecordStartdNotification() { +} + +void OnRecordStartdNotification::Run() { + LOG4CXX_INFO(logger_, "OnRecordStartdNotification::Run"); + + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_resume_audio_source_notification.cc b/src/components/application_manager/src/commands/hmi/on_resume_audio_source_notification.cc new file mode 100644 index 0000000000..70868b826f --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_resume_audio_source_notification.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2014, 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 "application_manager/commands/hmi/on_resume_audio_source_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnResumeAudioSourceNotification::OnResumeAudioSourceNotification( + const MessageSharedPtr& message) + : NotificationToHMI(message) { +} + +OnResumeAudioSourceNotification::~OnResumeAudioSourceNotification() { +} + +void OnResumeAudioSourceNotification::Run() { + LOG4CXX_INFO(logger_, "OnResumeAudioSourceNotification::Run"); + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_sdl_close_notification.cc b/src/components/application_manager/src/commands/hmi/on_sdl_close_notification.cc new file mode 100644 index 0000000000..70240b4bf6 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_sdl_close_notification.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_sdl_close_notification.h" + +namespace application_manager { + +namespace commands { + +OnSDLCloseNotification::OnSDLCloseNotification( + const MessageSharedPtr& message) : NotificationToHMI(message) { +} + +OnSDLCloseNotification::~OnSDLCloseNotification() { +} + +void OnSDLCloseNotification::Run() { + LOG4CXX_INFO(logger_, "OnSdlCloseNotification::Run"); + + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_sdl_consent_needed_notification.cc b/src/components/application_manager/src/commands/hmi/on_sdl_consent_needed_notification.cc new file mode 100644 index 0000000000..1fda4986e4 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_sdl_consent_needed_notification.cc @@ -0,0 +1,56 @@ + +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_sdl_consent_needed_notification.h" + +namespace application_manager { + +namespace commands { + +OnSDLConsentNeededNotification::OnSDLConsentNeededNotification( + const MessageSharedPtr& message) + : NotificationToHMI(message) { +} + +OnSDLConsentNeededNotification::~OnSDLConsentNeededNotification() { +} + +void OnSDLConsentNeededNotification::Run() { + LOG4CXX_INFO(logger_, "OnSDLConsentNeededNotification::Run"); + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_sdl_persistence_complete_notification.cc b/src/components/application_manager/src/commands/hmi/on_sdl_persistence_complete_notification.cc new file mode 100644 index 0000000000..d71413ef85 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_sdl_persistence_complete_notification.cc @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_sdl_persistence_complete_notification.h" + +namespace application_manager { + +namespace commands { + +OnSDLPersistenceCompleteNotification::OnSDLPersistenceCompleteNotification( + const MessageSharedPtr& message) + : NotificationToHMI(message) { +} + +OnSDLPersistenceCompleteNotification::~OnSDLPersistenceCompleteNotification() { +} + +void OnSDLPersistenceCompleteNotification::Run() { + LOG4CXX_INFO(logger_, "OnSDLpersistenceCompleteNotification::Run"); + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/on_start_device_discovery.cc b/src/components/application_manager/src/commands/hmi/on_start_device_discovery.cc new file mode 100644 index 0000000000..fc5ffed42c --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_start_device_discovery.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_start_device_discovery.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +OnStartDeviceDiscovery::OnStartDeviceDiscovery(const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnStartDeviceDiscovery::~OnStartDeviceDiscovery() { +} + +void OnStartDeviceDiscovery::Run() { + LOG4CXX_INFO(logger_, "OnStartDeviceDiscovery::Run"); + + ApplicationManagerImpl::instance()->StartDevicesDiscovery(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_status_update_notification.cc b/src/components/application_manager/src/commands/hmi/on_status_update_notification.cc new file mode 100644 index 0000000000..6e4e65987e --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_status_update_notification.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_status_update_notification.h" + +namespace application_manager { + +namespace commands { + +OnStatusUpdateNotification::OnStatusUpdateNotification( + const MessageSharedPtr& message) + : NotificationToHMI(message) { +} + +OnStatusUpdateNotification::~OnStatusUpdateNotification() { +} + +void OnStatusUpdateNotification::Run() { + LOG4CXX_INFO(logger_, "OnGetStatusUpdateNotification::Run"); + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_system_context_notification.cc b/src/components/application_manager/src/commands/hmi/on_system_context_notification.cc new file mode 100644 index 0000000000..5a5c12b907 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_system_context_notification.cc @@ -0,0 +1,87 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_system_context_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" + +namespace application_manager { +namespace commands { + +OnSystemContextNotification::OnSystemContextNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnSystemContextNotification::~OnSystemContextNotification() { +} + +void OnSystemContextNotification::Run() { + LOG4CXX_INFO(logger_, "OnSystemContextNotification::Run"); + + mobile_api::SystemContext::eType system_context = + static_cast<mobile_api::SystemContext::eType>( + (*message_)[strings::msg_params][hmi_notification::system_context].asInt()); + + ApplicationSharedPtr app; + + if ((mobile_api::SystemContext::SYSCTXT_VRSESSION == system_context) || + (mobile_api::SystemContext::SYSCTXT_MENU == system_context) || + (mobile_api::SystemContext::SYSCTXT_HMI_OBSCURED == system_context)) { + app = ApplicationManagerImpl::instance()->active_application(); + } else if ((mobile_api::SystemContext::SYSCTXT_ALERT == system_context) || + (mobile_api::SystemContext::SYSCTXT_MAIN == system_context)) { + if ((*message_)[strings::msg_params].keyExists(strings::app_id)) { + app = ApplicationManagerImpl::instance()-> + application((*message_)[strings::msg_params][strings::app_id].asUInt()); + } + } + + if (app.valid() && (system_context != app->system_context()) && + (system_context != mobile_api::SystemContext::INVALID_ENUM)) { + SendSystemContextNotification(app, system_context); + } else { + LOG4CXX_ERROR(logger_, "Ignored wrong SystemContext notification!"); + } +} + +void OnSystemContextNotification::SendSystemContextNotification(ApplicationSharedPtr app, + mobile_api::SystemContext::eType system_context) { + app->set_system_context(system_context); + MessageHelper::SendHMIStatusNotification(*app); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_system_error_notification.cc b/src/components/application_manager/src/commands/hmi/on_system_error_notification.cc new file mode 100644 index 0000000000..bac3d37359 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_system_error_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2014, 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 "application_manager/commands/hmi/on_system_error_notification.h" +#include "application_manager/policies/policy_handler.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +OnSystemErrorNotification::OnSystemErrorNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnSystemErrorNotification::~OnSystemErrorNotification() { +} + +void OnSystemErrorNotification::Run() { + LOG4CXX_INFO(logger_, "OnSystemErrorNotification::Run"); + + int code = (*message_)[strings::msg_params][hmi_notification::error] + .asInt(); + + policy::PolicyHandler::instance()->OnSystemError(code); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_system_info_changed_notification.cc b/src/components/application_manager/src/commands/hmi/on_system_info_changed_notification.cc new file mode 100644 index 0000000000..ec8460d581 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_system_info_changed_notification.cc @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_system_info_changed_notification.h" +#include "application_manager/policies/policy_handler.h" +#include "application_manager/message_helper.h" + +namespace application_manager { + +namespace commands { + +OnSystemInfoChangedNotification::OnSystemInfoChangedNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnSystemInfoChangedNotification::~OnSystemInfoChangedNotification() { +} + +void OnSystemInfoChangedNotification::Run() { + LOG4CXX_INFO(logger_, "OnSystemInfoChangedNotification::Run"); + uint32_t lang_code = + (*message_)[strings::msg_params][strings::language].asUInt(); + const std::string language = + application_manager::MessageHelper::CommonLanguageToString( + static_cast<hmi_apis::Common_Language::eType>(lang_code)); + + policy::PolicyHandler::instance()->OnSystemInfoChanged(language); +} + +} // namespace commands + +} // namespace application_manager + + diff --git a/src/components/application_manager/src/commands/hmi/on_system_request_notification.cc b/src/components/application_manager/src/commands/hmi/on_system_request_notification.cc new file mode 100644 index 0000000000..e3d0ea511d --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_system_request_notification.cc @@ -0,0 +1,96 @@ +/** + * Copyright (c) 2013, 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 "application_manager/application_impl.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/commands/hmi/on_system_request_notification.h" +#include "application_manager/policies/policy_handler.h" +#include "interfaces/MOBILE_API.h" +#include "utils/macro.h" + +using policy::PolicyHandler; + +namespace application_manager { + +namespace commands { + +OnSystemRequestNotification::OnSystemRequestNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnSystemRequestNotification::~OnSystemRequestNotification() { +} + +void OnSystemRequestNotification::Run() { + LOG4CXX_INFO(logger_, "OnSystemRequestNotification::Run"); + + smart_objects::SmartObject& params = (*message_)[strings::params]; + smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; + + params[strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnSystemRequestID); + + std::string app_id = msg_params[strings::app_id].asString(); + + if (strings::default_app_id == app_id) { + PolicyHandler* policy_handler = PolicyHandler::instance(); + uint32_t selected_app_id = policy_handler->GetAppIdForSending(); + if (0 == selected_app_id) { + LOG4CXX_WARN(logger_, + "Can't select application to forward OnSystemRequestNotification"); + return; + } + ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance(); + ApplicationSharedPtr selected_app = app_mgr->application(selected_app_id); + if (!selected_app.valid()) { + LOG4CXX_ERROR(logger_, "PolicyHandler selected invalid app_id"); + return; + } + params[strings::connection_key] = selected_app_id; + } else { + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->application_by_policy_id(app_id); + if (!app.valid()) { + LOG4CXX_WARN(logger_, "Application with such id is not yet registered."); + return; + } + params[strings::connection_key] = app->app_id(); + } + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_tts_language_change_notification.cc b/src/components/application_manager/src/commands/hmi/on_tts_language_change_notification.cc new file mode 100644 index 0000000000..60c0dca10a --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_tts_language_change_notification.cc @@ -0,0 +1,96 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_tts_language_change_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnTTSLanguageChangeNotification::OnTTSLanguageChangeNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnTTSLanguageChangeNotification::~OnTTSLanguageChangeNotification() { +} + +void OnTTSLanguageChangeNotification::Run() { + LOG4CXX_INFO(logger_, "OnTTSLanguageChangeNotification::Run"); + + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + + hmi_capabilities.set_active_tts_language( + static_cast<hmi_apis::Common_Language::eType>( + (*message_)[strings::msg_params][strings::language].asInt())); + + /* need to clarify, because unchanged VR + cause WRONG_LANGUAGE on Register */ + hmi_capabilities.set_active_vr_language( + static_cast<hmi_apis::Common_Language::eType>( + (*message_)[strings::msg_params][strings::language].asInt())); + + (*message_)[strings::msg_params][strings::hmi_display_language] = + hmi_capabilities.active_ui_language(); + + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID); + + ApplicationManagerImpl::ApplicationListAccessor accessor; + const std::set<ApplicationSharedPtr> applications = accessor.applications(); + + std::set<ApplicationSharedPtr>::iterator it = applications.begin(); + for (;applications.end() != it; ++it) { + ApplicationSharedPtr app = (*it); + (*message_)[strings::params][strings::connection_key] = app->app_id(); + SendNotificationToMobile(message_); + + if (static_cast<int>(app->language()) + != (*message_)[strings::msg_params][strings::language].asInt()) { + MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( + app->app_id(), + mobile_api::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE); + ApplicationManagerImpl::instance()->UnregisterApplication( + app->app_id(), mobile_apis::Result::SUCCESS, false); + } + } +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_tts_reset_timeout_notification.cc b/src/components/application_manager/src/commands/hmi/on_tts_reset_timeout_notification.cc new file mode 100644 index 0000000000..047a5d985d --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_tts_reset_timeout_notification.cc @@ -0,0 +1,31 @@ +#include "application_manager/commands/hmi/on_tts_reset_timeout_notification.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +namespace hmi { + +OnTTSResetTimeoutNotification::OnTTSResetTimeoutNotification( + const MessageSharedPtr& message) : NotificationFromHMI(message) { +} + +OnTTSResetTimeoutNotification::~OnTTSResetTimeoutNotification() { +} + +void OnTTSResetTimeoutNotification::Run() { + LOG4CXX_INFO(logger_, "OnTTSResetTimeoutNotification::Run"); + + event_engine::Event event(hmi_apis::FunctionID::TTS_OnResetTimeout); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_tts_started_notification.cc b/src/components/application_manager/src/commands/hmi/on_tts_started_notification.cc new file mode 100644 index 0000000000..519fc290d9 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_tts_started_notification.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_tts_started_notification.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +OnTTSStartedNotification::OnTTSStartedNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnTTSStartedNotification::~OnTTSStartedNotification() { +} + +void OnTTSStartedNotification::Run() { + LOG4CXX_INFO(logger_, "OnTTSStartedNotification::Run"); + + ApplicationManagerImpl::instance()->Mute(kTTSSessionChanging); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_tts_stopped_notification.cc b/src/components/application_manager/src/commands/hmi/on_tts_stopped_notification.cc new file mode 100644 index 0000000000..b3e3683f32 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_tts_stopped_notification.cc @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_tts_stopped_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/event_engine/event.h" + +namespace application_manager { + +namespace commands { + +OnTTSStoppedNotification::OnTTSStoppedNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnTTSStoppedNotification::~OnTTSStoppedNotification() { +} + +void OnTTSStoppedNotification::Run() { + LOG4CXX_INFO(logger_, "OnTTSStoppedNotification::Run"); + + event_engine::Event event(hmi_apis::FunctionID::TTS_Stopped); + event.set_smart_object(*message_); + event.raise(); + ApplicationManagerImpl::instance()->Unmute(kTTSSessionChanging); + +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_ui_command_notification.cc b/src/components/application_manager/src/commands/hmi/on_ui_command_notification.cc new file mode 100644 index 0000000000..4ed5839e5f --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_ui_command_notification.cc @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_ui_command_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnUICommandNotification::OnUICommandNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnUICommandNotification::~OnUICommandNotification() { +} + +void OnUICommandNotification::Run() { + LOG4CXX_INFO(logger_, "OnUICommandNotification::Run"); + + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnCommandID); + + (*message_)[strings::msg_params][strings::trigger_source] = + static_cast<int32_t>(mobile_apis::TriggerSource::TS_MENU); + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_ui_keyboard_input_notification.cc b/src/components/application_manager/src/commands/hmi/on_ui_keyboard_input_notification.cc new file mode 100644 index 0000000000..45ff7425b7 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_ui_keyboard_input_notification.cc @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_ui_keyboard_input_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +namespace hmi { + +OnUIKeyBoardInputNotification::OnUIKeyBoardInputNotification( + const MessageSharedPtr& message) : NotificationFromHMI(message) { +} + +OnUIKeyBoardInputNotification::~OnUIKeyBoardInputNotification() { +} + +void OnUIKeyBoardInputNotification::Run() { + LOG4CXX_INFO(logger_, "OnUIKeyBoardInputNotification::Run"); + + //prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + mobile_apis::FunctionID::OnKeyboardInputID; + SendNotificationToMobile(message_); +} + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_ui_language_change_notification.cc b/src/components/application_manager/src/commands/hmi/on_ui_language_change_notification.cc new file mode 100644 index 0000000000..5756f50eb5 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_ui_language_change_notification.cc @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_ui_language_change_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnUILanguageChangeNotification::OnUILanguageChangeNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnUILanguageChangeNotification::~OnUILanguageChangeNotification() { +} + +void OnUILanguageChangeNotification::Run() { + LOG4CXX_INFO(logger_, "OnUILanguageChangeNotification::Run"); + + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + + hmi_capabilities.set_active_ui_language( + static_cast<hmi_apis::Common_Language::eType>( + (*message_)[strings::msg_params][strings::language].asInt())); + + (*message_)[strings::msg_params][strings::hmi_display_language] = + (*message_)[strings::msg_params][strings::language]; + + (*message_)[strings::msg_params][strings::language] = + hmi_capabilities.active_vr_language(); + + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID); + + ApplicationManagerImpl::ApplicationListAccessor accessor; + const std::set<ApplicationSharedPtr> applications = accessor.applications(); + + std::set<ApplicationSharedPtr>::iterator it = applications.begin(); + for (;applications.end() != it; ++it) { + ApplicationSharedPtr app = *it; + (*message_)[strings::params][strings::connection_key] = app->app_id(); + SendNotificationToMobile(message_); + + if (app->ui_language() != (*message_)[strings::msg_params] + [strings::hmi_display_language].asInt()) { + + MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( + app->app_id(), + mobile_api::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE); + ApplicationManagerImpl::instance()->UnregisterApplication( + app->app_id(), mobile_apis::Result::SUCCESS, false); + } + } +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_ui_reset_timeout_notification.cc b/src/components/application_manager/src/commands/hmi/on_ui_reset_timeout_notification.cc new file mode 100644 index 0000000000..357bfc4cb3 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_ui_reset_timeout_notification.cc @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_ui_reset_timeout_notification.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +namespace hmi { + +OnUIResetTimeoutNotification::OnUIResetTimeoutNotification( + const MessageSharedPtr& message) : NotificationFromHMI(message) { +} + +OnUIResetTimeoutNotification::~OnUIResetTimeoutNotification() { +} + +void OnUIResetTimeoutNotification::Run() { + LOG4CXX_INFO(logger_, "OnUIResetTimeoutNotification::Run"); + + event_engine::Event event(hmi_apis::FunctionID::UI_OnResetTimeout); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_ui_touch_event_notification.cc b/src/components/application_manager/src/commands/hmi/on_ui_touch_event_notification.cc new file mode 100644 index 0000000000..7868e81193 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_ui_touch_event_notification.cc @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_ui_touch_event_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +namespace hmi { + +OnUITouchEventNotification::OnUITouchEventNotification( + const MessageSharedPtr& message) : NotificationFromHMI(message) { +} + +OnUITouchEventNotification::~OnUITouchEventNotification() { +} + +void OnUITouchEventNotification::Run() { + LOG4CXX_INFO(logger_, "OnUITouchEventNotification::Run"); + + //prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + mobile_apis::FunctionID::OnTouchEventID; + SendNotificationToMobile(message_); +} + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_update_device_list.cc b/src/components/application_manager/src/commands/hmi/on_update_device_list.cc new file mode 100644 index 0000000000..a5b84748ef --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_update_device_list.cc @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_update_device_list.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +OnUpdateDeviceList::OnUpdateDeviceList(const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnUpdateDeviceList::~OnUpdateDeviceList() { +} + +void OnUpdateDeviceList::Run() { + LOG4CXX_INFO(logger_, "OnUpdateDeviceList::Run"); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_acc_pedal_position_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_acc_pedal_position_notification.cc new file mode 100644 index 0000000000..be0c4ebb60 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_acc_pedal_position_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_acc_pedal_position_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIAccPedalPositionNotification::OnVIAccPedalPositionNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIAccPedalPositionNotification::~OnVIAccPedalPositionNotification() { +} + +void OnVIAccPedalPositionNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIAccPedalPositionNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_belt_status_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_belt_status_notification.cc new file mode 100644 index 0000000000..688a5c1fb1 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_belt_status_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_belt_status_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIBeltStatusNotification::OnVIBeltStatusNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIBeltStatusNotification::~OnVIBeltStatusNotification() { +} + +void OnVIBeltStatusNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIBeltStatusNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_body_information_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_body_information_notification.cc new file mode 100644 index 0000000000..e80a2edcf3 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_body_information_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_body_information_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIBodyInformationNotification::OnVIBodyInformationNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIBodyInformationNotification::~OnVIBodyInformationNotification() { +} + +void OnVIBodyInformationNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIBodyInformationNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_device_status_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_device_status_notification.cc new file mode 100644 index 0000000000..4669398da1 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_device_status_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_device_status_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIDeviceStatusNotification::OnVIDeviceStatusNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIDeviceStatusNotification::~OnVIDeviceStatusNotification() { +} + +void OnVIDeviceStatusNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIDeviceStatusNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_driver_braking_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_driver_braking_notification.cc new file mode 100644 index 0000000000..8b61d0af21 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_driver_braking_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_driver_braking_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIDriverBrakingNotification::OnVIDriverBrakingNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIDriverBrakingNotification::~OnVIDriverBrakingNotification() { +} + +void OnVIDriverBrakingNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIDriverBrakingNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_engine_torque_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_engine_torque_notification.cc new file mode 100644 index 0000000000..1b0989b1ec --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_engine_torque_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_engine_torque_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIEngineTorqueNotification::OnVIEngineTorqueNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIEngineTorqueNotification::~OnVIEngineTorqueNotification() { +} + +void OnVIEngineTorqueNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIEngineTorqueNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_external_temperature_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_external_temperature_notification.cc new file mode 100644 index 0000000000..f7a9213598 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_external_temperature_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_external_temperature_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIExternalTemperatureNotification::OnVIExternalTemperatureNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIExternalTemperatureNotification::~OnVIExternalTemperatureNotification() { +} + +void OnVIExternalTemperatureNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIExternalTemperatureNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_fuel_level_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_fuel_level_notification.cc new file mode 100644 index 0000000000..97d797b630 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_fuel_level_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_fuel_level_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIFuelLevelNotification::OnVIFuelLevelNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIFuelLevelNotification::~OnVIFuelLevelNotification() { +} + +void OnVIFuelLevelNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIFuelLevelNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_fuel_level_state_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_fuel_level_state_notification.cc new file mode 100644 index 0000000000..0024f17a80 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_fuel_level_state_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_fuel_level_state_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIFuelLevelStateNotification::OnVIFuelLevelStateNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIFuelLevelStateNotification::~OnVIFuelLevelStateNotification() { +} + +void OnVIFuelLevelStateNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIFuelLevelStateNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_gps_data_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_gps_data_notification.cc new file mode 100644 index 0000000000..5b7ec72977 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_gps_data_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_gps_data_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIGpsDataNotification::OnVIGpsDataNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIGpsDataNotification::~OnVIGpsDataNotification() { +} + +void OnVIGpsDataNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIGpsDataNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_head_lamp_status_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_head_lamp_status_notification.cc new file mode 100644 index 0000000000..355c00f0c9 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_head_lamp_status_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_head_lamp_status_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIHeadLampStatusNotification::OnVIHeadLampStatusNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIHeadLampStatusNotification::~OnVIHeadLampStatusNotification() { +} + +void OnVIHeadLampStatusNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIHeadLampStatusNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_instant_fuel_consumption_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_instant_fuel_consumption_notification.cc new file mode 100644 index 0000000000..17240bce6c --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_instant_fuel_consumption_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_instant_fuel_consumption_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIInstantFuelConsumptionNotification::OnVIInstantFuelConsumptionNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIInstantFuelConsumptionNotification::~OnVIInstantFuelConsumptionNotification() { +} + +void OnVIInstantFuelConsumptionNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIInstantFuelConsumptionNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_my_key_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_my_key_notification.cc new file mode 100644 index 0000000000..1caaecb442 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_my_key_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_my_key_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIMyKeyNotification::OnVIMyKeyNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIMyKeyNotification::~OnVIMyKeyNotification() { +} + +void OnVIMyKeyNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIMyKeyNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_odometer_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_odometer_notification.cc new file mode 100644 index 0000000000..02127a1389 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_odometer_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_odometer_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIOdometerNotification::OnVIOdometerNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIOdometerNotification::~OnVIOdometerNotification() { +} + +void OnVIOdometerNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIOdometerNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_prndl_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_prndl_notification.cc new file mode 100644 index 0000000000..4692191cb3 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_prndl_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_prndl_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIPrndlNotification::OnVIPrndlNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIPrndlNotification::~OnVIPrndlNotification() { +} + +void OnVIPrndlNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIPrndlNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_rpm_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_rpm_notification.cc new file mode 100644 index 0000000000..b16421903a --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_rpm_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_rpm_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIRpmNotification::OnVIRpmNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIRpmNotification::~OnVIRpmNotification() { +} + +void OnVIRpmNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIRpmNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_speed_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_speed_notification.cc new file mode 100644 index 0000000000..6bc1e8b2cf --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_speed_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_speed_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVISpeedNotification::OnVISpeedNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVISpeedNotification::~OnVISpeedNotification() { +} + +void OnVISpeedNotification::Run() { + LOG4CXX_INFO(logger_, "OnVISpeedNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_steering_wheel_angle_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_steering_wheel_angle_notification.cc new file mode 100644 index 0000000000..853b4eeea3 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_steering_wheel_angle_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_steering_wheel_angle_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVISteeringWheelAngleNotification::OnVISteeringWheelAngleNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVISteeringWheelAngleNotification::~OnVISteeringWheelAngleNotification() { +} + +void OnVISteeringWheelAngleNotification::Run() { + LOG4CXX_INFO(logger_, "OnVISteeringWheelAngleNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_tire_pressure_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_tire_pressure_notification.cc new file mode 100644 index 0000000000..01ac7e9f8c --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_tire_pressure_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_tire_pressure_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVITirePressureNotification::OnVITirePressureNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVITirePressureNotification::~OnVITirePressureNotification() { +} + +void OnVITirePressureNotification::Run() { + LOG4CXX_INFO(logger_, "OnVITirePressureNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc new file mode 100644 index 0000000000..eda88ef602 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_vehicle_data_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIVehicleDataNotification::OnVIVehicleDataNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIVehicleDataNotification::~OnVIVehicleDataNotification() { +} + +void OnVIVehicleDataNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIVehicleDataNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_vin_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_vin_notification.cc new file mode 100644 index 0000000000..546dc0d3cf --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_vin_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_vin_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIVinNotification::OnVIVinNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIVinNotification::~OnVIVinNotification() { +} + +void OnVIVinNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIVinNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vi_wiper_status_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_wiper_status_notification.cc new file mode 100644 index 0000000000..101427df0a --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vi_wiper_status_notification.cc @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vi_wiper_status_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVIWiperStatusNotification::OnVIWiperStatusNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVIWiperStatusNotification::~OnVIWiperStatusNotification() { +} + +void OnVIWiperStatusNotification::Run() { + LOG4CXX_INFO(logger_, "OnVIWiperStatusNotification::Run"); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vr_command_notification.cc b/src/components/application_manager/src/commands/hmi/on_vr_command_notification.cc new file mode 100644 index 0000000000..99842b8524 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vr_command_notification.cc @@ -0,0 +1,101 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vr_command_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/message_helper.h" +#include "config_profile/profile.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" +#include "application_manager/event_engine/event.h" + +namespace application_manager { + +namespace commands { + +OnVRCommandNotification::OnVRCommandNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVRCommandNotification::~OnVRCommandNotification() { +} + +void OnVRCommandNotification::Run() { + LOG4CXX_INFO(logger_, "OnVRCommandNotification::Run"); + + ApplicationSharedPtr active_app = ApplicationManagerImpl::instance() + ->active_application(); + const uint32_t cmd_id = (*message_)[strings::msg_params][strings::cmd_id] + .asUInt(); + uint32_t max_cmd_id = profile::Profile::instance()->max_cmd_id(); + + // Check if this is one of standart VR commands (i.e. "Help") + if (cmd_id > max_cmd_id + 1) { + LOG4CXX_INFO(logger_, "Switched App"); + MessageHelper::SendActivateAppToHMI(cmd_id - max_cmd_id); + return; + } + + // Check if this is "Help" + if (cmd_id == max_cmd_id + 1) { + return; + } + const uint32_t app_id = (*message_)[strings::msg_params][strings::app_id] + .asUInt(); + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + /* check if perform interaction is active + * if it is active we should sent to HMI DeleteCommand request + * and PerformInterActionResponse to mobile + */ + if (0 != app->is_perform_interaction_active()) { + event_engine::Event event(hmi_apis::FunctionID::VR_OnCommand); + event.set_smart_object(*message_); + event.raise(); + } else { + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnCommandID); + + (*message_)[strings::msg_params][strings::trigger_source] = + static_cast<int32_t>(mobile_apis::TriggerSource::TS_VR); + SendNotificationToMobile(message_); + } +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vr_language_change_notification.cc b/src/components/application_manager/src/commands/hmi/on_vr_language_change_notification.cc new file mode 100644 index 0000000000..92e7cb7b23 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vr_language_change_notification.cc @@ -0,0 +1,91 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vr_language_change_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVRLanguageChangeNotification::OnVRLanguageChangeNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVRLanguageChangeNotification::~OnVRLanguageChangeNotification() { +} + +void OnVRLanguageChangeNotification::Run() { + LOG4CXX_INFO(logger_, "OnVRLanguageChangeNotification::Run"); + + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + + hmi_capabilities.set_active_vr_language( + static_cast<hmi_apis::Common_Language::eType>( + (*message_)[strings::msg_params][strings::language].asInt())); + + (*message_)[strings::msg_params][strings::hmi_display_language] = + hmi_capabilities.active_ui_language(); + + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID); + + ApplicationManagerImpl::ApplicationListAccessor accessor; + const std::set<ApplicationSharedPtr> applications = accessor.applications(); + + std::set<ApplicationSharedPtr>::iterator it = applications.begin(); + for (;applications.end() != it; ++it) { + ApplicationSharedPtr app = (*it); + (*message_)[strings::params][strings::connection_key] = app->app_id(); + SendNotificationToMobile(message_); + if (static_cast<int32_t>(app->language()) + != (*message_)[strings::msg_params][strings::language].asInt()) { + app->set_hmi_level(mobile_api::HMILevel::HMI_NONE); + + MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( + app->app_id(), + mobile_api::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE); + ApplicationManagerImpl::instance()->UnregisterApplication( + app->app_id(), mobile_apis::Result::SUCCESS, false); + } + } +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vr_started_notification.cc b/src/components/application_manager/src/commands/hmi/on_vr_started_notification.cc new file mode 100644 index 0000000000..72f6767e8c --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vr_started_notification.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vr_started_notification.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +OnVRStartedNotification::OnVRStartedNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVRStartedNotification::~OnVRStartedNotification() { +} + +void OnVRStartedNotification::Run() { + LOG4CXX_INFO(logger_, "OnVRStartedNotification::Run"); + + ApplicationManagerImpl::instance()->set_vr_session_started(true); + ApplicationManagerImpl::instance()->Mute(kVRSessionChanging); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_vr_stopped_notification.cc b/src/components/application_manager/src/commands/hmi/on_vr_stopped_notification.cc new file mode 100644 index 0000000000..46274a3b2e --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_vr_stopped_notification.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/on_vr_stopped_notification.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +OnVRStoppedNotification::OnVRStoppedNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnVRStoppedNotification::~OnVRStoppedNotification() { +} + +void OnVRStoppedNotification::Run() { + LOG4CXX_INFO(logger_, "OnVRStoppedNotification::Run"); + + ApplicationManagerImpl::instance()->set_vr_session_started(false); + ApplicationManagerImpl::instance()->Unmute(kVRSessionChanging); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/request_from_hmi.cc b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc new file mode 100644 index 0000000000..7b7f740904 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc @@ -0,0 +1,63 @@ +/* + Copyright (c) 2013, 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 "application_manager/commands/hmi/request_from_hmi.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +RequestFromHMI::RequestFromHMI(const MessageSharedPtr& message) + : CommandImpl(message) { + + // Replace HMI app id with Mobile connection id + ApplicationManagerImpl::instance()->ReplaceHMIByMobileAppId(*(message.get())); +} + +RequestFromHMI::~RequestFromHMI() { +} + +bool RequestFromHMI::Init() { + return true; +} + +bool RequestFromHMI::CleanUp() { + return true; +} + +void RequestFromHMI::Run() { +} + +} // namespace commands +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc new file mode 100644 index 0000000000..242118a417 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc @@ -0,0 +1,70 @@ +/** + Copyright (c) 2014, 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 "application_manager/commands/hmi/request_to_hmi.h" +#include "application_manager/application_manager_impl.h" +#include "config_profile/profile.h" + +namespace application_manager { + +namespace commands { + +RequestToHMI::RequestToHMI(const MessageSharedPtr& message) + : CommandImpl(message) { + // Replace Mobile connection id with HMI app id + ApplicationManagerImpl::instance()->ReplaceMobileByHMIAppId(*(message.get())); +} + +RequestToHMI::~RequestToHMI() { +} + +bool RequestToHMI::Init() { + return true; +} + +bool RequestToHMI::CleanUp() { + return true; +} + +void RequestToHMI::Run() { +} + +void RequestToHMI::SendRequest() { + (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; + (*message_)[strings::params][strings::protocol_version] = protocol_version_; + + ApplicationManagerImpl::instance()->SendMessageToHMI(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/response_from_hmi.cc b/src/components/application_manager/src/commands/hmi/response_from_hmi.cc new file mode 100644 index 0000000000..42bebb847d --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/response_from_hmi.cc @@ -0,0 +1,108 @@ +/* + Copyright (c) 2013, 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 "application_manager/commands/hmi/response_from_hmi.h" +#include "application_manager/application_manager_impl.h" +#include "smart_objects/smart_object.h" + +namespace application_manager { + +namespace commands { + +ResponseFromHMI::ResponseFromHMI(const MessageSharedPtr& message) + : CommandImpl(message) { + //If it is error response, shift info + if ((*message)[strings::params].keyExists(hmi_response::message)) { + (*message)[strings::msg_params][strings::info] = + (*message)[strings::params][hmi_response::message]; + } + + // Replace HMI app id with Mobile connection id + ApplicationManagerImpl::instance()->ReplaceHMIByMobileAppId(*(message.get())); +} + +ResponseFromHMI::~ResponseFromHMI() { +} + +bool ResponseFromHMI::Init() { + return true; +} + +bool ResponseFromHMI::CleanUp() { + return true; +} + +void ResponseFromHMI::Run() { +} + +void ResponseFromHMI::SendResponseToMobile(const MessageSharedPtr& message) { + (*message)[strings::params][strings::message_type] = MessageType::kResponse; + + ApplicationManagerImpl::instance()->ManageMobileCommand(message); +} + +void ResponseFromHMI::CreateHMIRequest( + const hmi_apis::FunctionID::eType& function_id, + const NsSmart::SmartObject& msg_params) const { + + NsSmartDeviceLink::NsSmartObjects::SmartObject* result = + new NsSmartDeviceLink::NsSmartObjects::SmartObject; + + if (!result) { + LOG4CXX_ERROR(logger_, "Memory allocation failed."); + return; + } + + // get hmi correlation id for chaining further request from this object + const uint32_t hmi_correlation_id_ = ApplicationManagerImpl::instance() + ->GetNextHMICorrelationID(); + + NsSmartDeviceLink::NsSmartObjects::SmartObject& request = *result; + request[strings::params][strings::message_type] = MessageType::kRequest; + request[strings::params][strings::function_id] = function_id; + request[strings::params][strings::correlation_id] = hmi_correlation_id_; + request[strings::params][strings::protocol_version] = + CommandImpl::protocol_version_; + request[strings::params][strings::protocol_type] = + CommandImpl::hmi_protocol_type_; + + request[strings::msg_params] = msg_params; + + if (!ApplicationManagerImpl::instance()->ManageHMICommand(result)) { + LOG4CXX_ERROR(logger_, "Unable to send request"); + return; + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/response_to_hmi.cc b/src/components/application_manager/src/commands/hmi/response_to_hmi.cc new file mode 100644 index 0000000000..d18987428e --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/response_to_hmi.cc @@ -0,0 +1,66 @@ +/* + Copyright (c) 2013, 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 "application_manager/commands/hmi/response_to_hmi.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +ResponseToHMI::ResponseToHMI(const MessageSharedPtr& message) + : CommandImpl(message) { + // Replace Mobile connection id with HMI app id + ApplicationManagerImpl::instance()->ReplaceMobileByHMIAppId(*(message.get())); +} + +ResponseToHMI::~ResponseToHMI() { +} + +bool ResponseToHMI::Init() { + return true; +} + +bool ResponseToHMI::CleanUp() { + return true; +} + +void ResponseToHMI::Run() { + (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; + (*message_)[strings::params][strings::protocol_version] = protocol_version_; + + ApplicationManagerImpl::instance()->SendMessageToHMI(message_); +} + +} // namespace commands +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc new file mode 100644 index 0000000000..72abf233ce --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/sdl_activate_app_request.h" +#include "application_manager/policies/policy_handler.h" + +namespace application_manager { + +namespace commands { + +SDLActivateAppRequest::SDLActivateAppRequest(const MessageSharedPtr& message) + : RequestFromHMI(message) { +} + +SDLActivateAppRequest::~SDLActivateAppRequest() { +} + +void SDLActivateAppRequest::Run() { + LOG4CXX_INFO(logger_, "SDLActivateAppRequest::Run"); + policy::PolicyHandler::instance()->OnActivateApp( + (*message_)[strings::msg_params][strings::app_id].asUInt(), + (*message_)[strings::params][strings::correlation_id].asInt()); +} + +} // namespace commands +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/sdl_activate_app_response.cc b/src/components/application_manager/src/commands/hmi/sdl_activate_app_response.cc new file mode 100644 index 0000000000..46eb402f41 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/sdl_activate_app_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/sdl_activate_app_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +SDLActivateAppResponse::SDLActivateAppResponse( + const MessageSharedPtr& message): ResponseToHMI(message) { +} + +SDLActivateAppResponse::~SDLActivateAppResponse() { +} + +void SDLActivateAppResponse::Run() { + LOG4CXX_INFO(logger_, "SDLActivateAppResponse::Run"); + (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; + (*message_)[strings::params][strings::protocol_version] = protocol_version_; + + ApplicationManagerImpl::instance()->SendMessageToHMI(message_); +} + +} // namespace commands +} // namespace application_manager + + diff --git a/src/components/application_manager/src/commands/hmi/sdl_get_list_of_permissions_request.cc b/src/components/application_manager/src/commands/hmi/sdl_get_list_of_permissions_request.cc new file mode 100644 index 0000000000..7eb5a268ac --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/sdl_get_list_of_permissions_request.cc @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/sdl_get_list_of_permissions_request.h" +#include "application_manager/policies/policy_handler.h" + +namespace application_manager { + +namespace commands { + +SDLGetListOfPermissionsRequest::SDLGetListOfPermissionsRequest( + const MessageSharedPtr& message) + : RequestFromHMI(message) { +} + +SDLGetListOfPermissionsRequest::~SDLGetListOfPermissionsRequest() { +} + +void SDLGetListOfPermissionsRequest::Run() { + LOG4CXX_INFO(logger_, "SDLGetListOfPermissionsRequest::Run"); + uint32_t connection_key = 0; + if ((*message_)[strings::msg_params].keyExists(strings::app_id)) { + connection_key = (*message_)[strings::msg_params][strings::app_id].asUInt(); + } + policy::PolicyHandler::instance()->OnGetListOfPermissions( + connection_key, + (*message_)[strings::params][strings::correlation_id].asUInt()); +} + +} // namespace commands +} // namespace application_manager + + diff --git a/src/components/application_manager/src/commands/hmi/sdl_get_list_of_permissions_response.cc b/src/components/application_manager/src/commands/hmi/sdl_get_list_of_permissions_response.cc new file mode 100644 index 0000000000..da474cb128 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/sdl_get_list_of_permissions_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/sdl_get_list_of_permissions_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +SDLGetListOfPermissionsResponse::SDLGetListOfPermissionsResponse( + const MessageSharedPtr& message): ResponseToHMI(message) { +} + +SDLGetListOfPermissionsResponse::~SDLGetListOfPermissionsResponse() { +} + +void SDLGetListOfPermissionsResponse::Run() { + LOG4CXX_INFO(logger_, "SDLGetListOfPermissionsResponse::Run"); + (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; + (*message_)[strings::params][strings::protocol_version] = protocol_version_; + + ApplicationManagerImpl::instance()->SendMessageToHMI(message_); +} + +} // namespace commands +} // namespace application_manager + + diff --git a/src/components/application_manager/src/commands/hmi/sdl_get_status_update_request.cc b/src/components/application_manager/src/commands/hmi/sdl_get_status_update_request.cc new file mode 100644 index 0000000000..cc5fbc63ae --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/sdl_get_status_update_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/sdl_get_status_update_request.h" +#include "application_manager/policies/policy_handler.h" + +namespace application_manager { + +namespace commands { + +SDLGetStatusUpdateRequest::SDLGetStatusUpdateRequest(const MessageSharedPtr& message) + : RequestFromHMI(message) { +} + +SDLGetStatusUpdateRequest::~SDLGetStatusUpdateRequest() { +} + +void SDLGetStatusUpdateRequest::Run() { + LOG4CXX_INFO(logger_, "SDLGetStatusUpdateRequest::Run"); + policy::PolicyHandler::instance()->OnGetStatusUpdate( + (*message_)[strings::params][strings::correlation_id].asUInt()); +} + +} // namespace commands +} // namespace application_manager + + diff --git a/src/components/application_manager/src/commands/hmi/sdl_get_status_update_response.cc b/src/components/application_manager/src/commands/hmi/sdl_get_status_update_response.cc new file mode 100644 index 0000000000..08d8d315a5 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/sdl_get_status_update_response.cc @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/sdl_get_status_update_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +SDLGetStatusUpdateResponse::SDLGetStatusUpdateResponse( + const MessageSharedPtr& message): ResponseToHMI(message) { +} + +SDLGetStatusUpdateResponse::~SDLGetStatusUpdateResponse() { +} + +void SDLGetStatusUpdateResponse::Run() { + LOG4CXX_INFO(logger_, "SDLGetStatusUpdateResponse::Run"); + (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; + (*message_)[strings::params][strings::protocol_version] = protocol_version_; + + ApplicationManagerImpl::instance()->SendMessageToHMI(message_); +} + +} // namespace commands +} // namespace application_manager + + + diff --git a/src/components/application_manager/src/commands/hmi/sdl_get_user_friendly_message_request.cc b/src/components/application_manager/src/commands/hmi/sdl_get_user_friendly_message_request.cc new file mode 100644 index 0000000000..047d6bf846 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/sdl_get_user_friendly_message_request.cc @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/sdl_get_user_friendly_message_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler.h" + +namespace application_manager { + +namespace commands { + +SDLGetUserFriendlyMessageRequest::SDLGetUserFriendlyMessageRequest( + const MessageSharedPtr& message) + : RequestFromHMI(message) { +} + +SDLGetUserFriendlyMessageRequest::~SDLGetUserFriendlyMessageRequest() { +} + +void SDLGetUserFriendlyMessageRequest::Run() { + LOG4CXX_INFO(logger_, "SDLGetUserFriendlyMessageRequest::Run"); + const std::string messageCodes = "messageCodes"; + if (!(*message_)[strings::msg_params].keyExists(messageCodes)) { + LOG4CXX_WARN(logger_, + "Mandatory parameter '"+messageCodes+"'' is missing"); + return; + } + smart_objects::SmartArray* msg = + (*message_)[strings::msg_params][messageCodes].asArray(); + + std::vector<std::string> msg_codes; + + smart_objects::SmartArray::const_iterator it = msg->begin(); + smart_objects::SmartArray::const_iterator it_end = msg->end(); + for (; it != it_end; ++it) { + msg_codes.push_back((*it).asString()); + } + + std::string required_language; + if ((*message_)[strings::msg_params].keyExists(strings::language)) { + uint32_t lang_code = (*message_)[strings::msg_params][strings::language] + .asUInt(); + required_language = + application_manager::MessageHelper::CommonLanguageToString( + static_cast<hmi_apis::Common_Language::eType>(lang_code)); + } else { + hmi_apis::Common_Language::eType ui_language = + application_manager::ApplicationManagerImpl::instance() + ->hmi_capabilities().active_ui_language(); + + required_language = + application_manager::MessageHelper::CommonLanguageToString(ui_language); + } + + policy::PolicyHandler::instance()->OnGetUserFriendlyMessage( + msg_codes, required_language, + (*message_)[strings::params][strings::correlation_id].asInt()); +} + +} // namespace commands +} // namespace application_manager + + diff --git a/src/components/application_manager/src/commands/hmi/sdl_get_user_friendly_message_response.cc b/src/components/application_manager/src/commands/hmi/sdl_get_user_friendly_message_response.cc new file mode 100644 index 0000000000..c849204cc3 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/sdl_get_user_friendly_message_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/sdl_get_user_friendly_message_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +SDLGetUserFriendlyMessageResponse::SDLGetUserFriendlyMessageResponse( + const MessageSharedPtr& message): ResponseToHMI(message) { +} + +SDLGetUserFriendlyMessageResponse::~SDLGetUserFriendlyMessageResponse() { +} + +void SDLGetUserFriendlyMessageResponse::Run() { + LOG4CXX_INFO(logger_, "SDLGetUserFriendlyMessageResponse::Run"); + (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; + (*message_)[strings::params][strings::protocol_version] = protocol_version_; + + ApplicationManagerImpl::instance()->SendMessageToHMI(message_); +} + +} // namespace commands +} // namespace application_manager + + diff --git a/src/components/application_manager/src/commands/hmi/sdl_policy_update.cc b/src/components/application_manager/src/commands/hmi/sdl_policy_update.cc new file mode 100644 index 0000000000..4779e106c5 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/sdl_policy_update.cc @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/sdl_policy_update.h" + +namespace application_manager { + +namespace commands { + +SDLPolicyUpdate::SDLPolicyUpdate( + const MessageSharedPtr& message): RequestToHMI(message) { +} + +SDLPolicyUpdate::~SDLPolicyUpdate() { +} + +void SDLPolicyUpdate::Run() { + LOG4CXX_INFO(logger_, "SDLPolicyUpdate::Run"); + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/sdl_policy_update_response.cc b/src/components/application_manager/src/commands/hmi/sdl_policy_update_response.cc new file mode 100644 index 0000000000..a3db3a9047 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/sdl_policy_update_response.cc @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/sdl_policy_update_response.h" + +namespace application_manager { + +namespace commands { +SDLPolicyUpdateResponse::SDLPolicyUpdateResponse( + const MessageSharedPtr& message): ResponseFromHMI(message) { +} + +SDLPolicyUpdateResponse::~SDLPolicyUpdateResponse() { +} + +void SDLPolicyUpdateResponse::Run() { + LOG4CXX_INFO(logger_, "SDLPolicyUpdateResponse::Run"); + // TODO(PV): add some logic here +} +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/tts_change_registration_request.cc b/src/components/application_manager/src/commands/hmi/tts_change_registration_request.cc new file mode 100644 index 0000000000..638503d162 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/tts_change_registration_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/tts_change_registration_request.h" + +namespace application_manager { + +namespace commands { + +TTSChangeRegistrationRequest::TTSChangeRegistrationRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +TTSChangeRegistrationRequest::~TTSChangeRegistrationRequest() { +} + +void TTSChangeRegistrationRequest::Run() { + LOG4CXX_INFO(logger_, "TTSChangeRegistrationRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/tts_change_registration_response.cc b/src/components/application_manager/src/commands/hmi/tts_change_registration_response.cc new file mode 100644 index 0000000000..67e48b4ed5 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/tts_change_registration_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/tts_change_registration_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +TTSChangeRegistratioResponse::TTSChangeRegistratioResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +TTSChangeRegistratioResponse::~TTSChangeRegistratioResponse() { +} + +void TTSChangeRegistratioResponse::Run() { + LOG4CXX_INFO(logger_, "TTSChangeRegistratioResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::TTS_ChangeRegistration); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/tts_get_capabilities_request.cc b/src/components/application_manager/src/commands/hmi/tts_get_capabilities_request.cc new file mode 100644 index 0000000000..59cf50b38d --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/tts_get_capabilities_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/tts_get_capabilities_request.h" + +namespace application_manager { + +namespace commands { + +TTSGetCapabilitiesRequest::TTSGetCapabilitiesRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +TTSGetCapabilitiesRequest::~TTSGetCapabilitiesRequest() { +} + +void TTSGetCapabilitiesRequest::Run() { + LOG4CXX_INFO(logger_, "TTSGetCapabilitiesRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/tts_get_capabilities_response.cc b/src/components/application_manager/src/commands/hmi/tts_get_capabilities_response.cc new file mode 100644 index 0000000000..f7309822d8 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/tts_get_capabilities_response.cc @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/tts_get_capabilities_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +TTSGetCapabilitiesResponse::TTSGetCapabilitiesResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +TTSGetCapabilitiesResponse::~TTSGetCapabilitiesResponse() { +} + +void TTSGetCapabilitiesResponse::Run() { + LOG4CXX_INFO(logger_, "TTSGetCapabilitiesResponse::Run"); + + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + if ((*message_)[strings::msg_params].keyExists(hmi_response::speech_capabilities)) { + hmi_capabilities.set_speech_capabilities( + (*message_)[strings::msg_params][hmi_response::speech_capabilities]); + } + if ((*message_)[strings::msg_params].keyExists( + hmi_response::prerecorded_speech_capabilities)) { + hmi_capabilities.set_prerecorded_speech( + (*message_)[strings::msg_params] + [hmi_response::prerecorded_speech_capabilities]); + } + +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/tts_get_language_request.cc b/src/components/application_manager/src/commands/hmi/tts_get_language_request.cc new file mode 100644 index 0000000000..9f2fe7134a --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/tts_get_language_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/tts_get_language_request.h" + +namespace application_manager { + +namespace commands { + +TTSGetLanguageRequest::TTSGetLanguageRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +TTSGetLanguageRequest::~TTSGetLanguageRequest() { +} + +void TTSGetLanguageRequest::Run() { + LOG4CXX_INFO(logger_, "TTSGetLanguageRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/tts_get_language_response.cc b/src/components/application_manager/src/commands/hmi/tts_get_language_response.cc new file mode 100644 index 0000000000..e26fa87739 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/tts_get_language_response.cc @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/tts_get_language_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +TTSGetLanguageResponse::TTSGetLanguageResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +TTSGetLanguageResponse::~TTSGetLanguageResponse() { +} + +void TTSGetLanguageResponse::Run() { + LOG4CXX_INFO(logger_, "TTSGetLanguageResponse::Run"); + + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + + hmi_capabilities.set_active_tts_language( + static_cast<hmi_apis::Common_Language::eType>( + (*message_)[strings::msg_params][hmi_response::language].asInt())); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/tts_get_supported_languages_request.cc b/src/components/application_manager/src/commands/hmi/tts_get_supported_languages_request.cc new file mode 100644 index 0000000000..08c1d82448 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/tts_get_supported_languages_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/tts_get_supported_languages_request.h" + +namespace application_manager { + +namespace commands { + +TTSGetSupportedLanguagesRequest::TTSGetSupportedLanguagesRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +TTSGetSupportedLanguagesRequest::~TTSGetSupportedLanguagesRequest() { +} + +void TTSGetSupportedLanguagesRequest::Run() { + LOG4CXX_INFO(logger_, "TTSGetSupportedLanguagesRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/tts_get_supported_languages_response.cc b/src/components/application_manager/src/commands/hmi/tts_get_supported_languages_response.cc new file mode 100644 index 0000000000..aa041f66b3 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/tts_get_supported_languages_response.cc @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/tts_get_supported_languages_response.h" +#include "application_manager/application_manager_impl.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +TTSGetSupportedLanguagesResponse::TTSGetSupportedLanguagesResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +TTSGetSupportedLanguagesResponse::~TTSGetSupportedLanguagesResponse() { +} + +void TTSGetSupportedLanguagesResponse::Run() { + LOG4CXX_INFO(logger_, "TTSGetSupportedLanguagesResponse::Run"); + + const hmi_apis::Common_Result::eType code = + static_cast<hmi_apis::Common_Result::eType>( + (*message_)[strings::params][hmi_response::code].asInt()); + + if (hmi_apis::Common_Result::SUCCESS == code) { + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + + hmi_capabilities.set_tts_supported_languages( + (*message_)[strings::msg_params][hmi_response::languages]); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/tts_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/tts_is_ready_request.cc new file mode 100644 index 0000000000..7733de4887 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/tts_is_ready_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/tts_is_ready_request.h" + +namespace application_manager { + +namespace commands { + +TTSIsReadyRequest::TTSIsReadyRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +TTSIsReadyRequest::~TTSIsReadyRequest() { +} + +void TTSIsReadyRequest::Run() { + LOG4CXX_INFO(logger_, "TTSIsReadyRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/tts_is_ready_response.cc b/src/components/application_manager/src/commands/hmi/tts_is_ready_response.cc new file mode 100644 index 0000000000..fb3cb4858f --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/tts_is_ready_response.cc @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/tts_is_ready_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +TTSIsReadyResponse::TTSIsReadyResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +TTSIsReadyResponse::~TTSIsReadyResponse() { +} + +void TTSIsReadyResponse::Run() { + LOG4CXX_INFO(logger_, "TTSIsReadyResponse::Run"); + smart_objects::SmartObject& object = *message_; + + bool is_available = false; + if (object[strings::msg_params].keyExists(strings::available)) { + is_available = object[strings::msg_params][strings::available].asBool(); + } + + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + hmi_capabilities.set_is_tts_cooperating(is_available); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/tts_set_global_properties_request.cc b/src/components/application_manager/src/commands/hmi/tts_set_global_properties_request.cc new file mode 100644 index 0000000000..04f1380d91 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/tts_set_global_properties_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/tts_set_global_properties_request.h" + +namespace application_manager { + +namespace commands { + +TTSSetGlobalPropertiesRequest::TTSSetGlobalPropertiesRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +TTSSetGlobalPropertiesRequest::~TTSSetGlobalPropertiesRequest() { +} + +void TTSSetGlobalPropertiesRequest::Run() { + LOG4CXX_INFO(logger_, "TTSSetGlobalPropertiesRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/tts_set_global_properties_response.cc b/src/components/application_manager/src/commands/hmi/tts_set_global_properties_response.cc new file mode 100644 index 0000000000..c90655186f --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/tts_set_global_properties_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/tts_set_global_properties_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +TTSSetGlobalPropertiesResponse::TTSSetGlobalPropertiesResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +TTSSetGlobalPropertiesResponse::~TTSSetGlobalPropertiesResponse() { +} + +void TTSSetGlobalPropertiesResponse::Run() { + LOG4CXX_INFO(logger_, "TTSSetGlobalPropertiesResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/tts_speak_request.cc b/src/components/application_manager/src/commands/hmi/tts_speak_request.cc new file mode 100644 index 0000000000..9b4bd68585 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/tts_speak_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/tts_speak_request.h" + +namespace application_manager { + +namespace commands { + +TTSSpeakRequest::TTSSpeakRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +TTSSpeakRequest::~TTSSpeakRequest() { +} + +void TTSSpeakRequest::Run() { + LOG4CXX_INFO(logger_, "TTSSpeakRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/tts_speak_response.cc b/src/components/application_manager/src/commands/hmi/tts_speak_response.cc new file mode 100644 index 0000000000..9b9e43dbe8 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/tts_speak_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/tts_speak_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +TTSSpeakResponse::TTSSpeakResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +TTSSpeakResponse::~TTSSpeakResponse() { +} + +void TTSSpeakResponse::Run() { + LOG4CXX_INFO(logger_, "TTSSpeakResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::TTS_Speak); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/tts_stop_speaking_request.cc b/src/components/application_manager/src/commands/hmi/tts_stop_speaking_request.cc new file mode 100644 index 0000000000..107cb7933b --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/tts_stop_speaking_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/tts_stop_speaking_request.h" + +namespace application_manager { + +namespace commands { + +TTSStopSpeakingRequest::TTSStopSpeakingRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +TTSStopSpeakingRequest::~TTSStopSpeakingRequest() { +} + +void TTSStopSpeakingRequest::Run() { + LOG4CXX_INFO(logger_, "TTSStopSpeakingRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/tts_stop_speaking_response.cc b/src/components/application_manager/src/commands/hmi/tts_stop_speaking_response.cc new file mode 100644 index 0000000000..9bd4f89660 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/tts_stop_speaking_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/tts_stop_speaking_response.h" + +#include "application_manager/event_engine/event.h" + +namespace application_manager { + +namespace commands { + +TTSStopSpeakingResponse::TTSStopSpeakingResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +TTSStopSpeakingResponse::~TTSStopSpeakingResponse() { +} + +void TTSStopSpeakingResponse::Run() { + LOG4CXX_INFO(logger_, "TTSStopSpeakingResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::TTS_StopSpeaking); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_add_command_request.cc b/src/components/application_manager/src/commands/hmi/ui_add_command_request.cc new file mode 100644 index 0000000000..9aa5d2e2d3 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_add_command_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_add_command_request.h" + +namespace application_manager { + +namespace commands { + +UIAddCommandRequest::UIAddCommandRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UIAddCommandRequest::~UIAddCommandRequest() { +} + +void UIAddCommandRequest::Run() { + LOG4CXX_INFO(logger_, "UIAddCommandRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_add_command_response.cc b/src/components/application_manager/src/commands/hmi/ui_add_command_response.cc new file mode 100644 index 0000000000..21b34e0637 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_add_command_response.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_add_command_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +UIAddCommandResponse::UIAddCommandResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UIAddCommandResponse::~UIAddCommandResponse() { +} + +void UIAddCommandResponse::Run() { + LOG4CXX_INFO(logger_, "UIAddCommandResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::UI_AddCommand); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_add_submenu_request.cc b/src/components/application_manager/src/commands/hmi/ui_add_submenu_request.cc new file mode 100644 index 0000000000..7a9c5c6fed --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_add_submenu_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_add_submenu_request.h" + +namespace application_manager { + +namespace commands { + +UIAddSubmenuRequest::UIAddSubmenuRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UIAddSubmenuRequest::~UIAddSubmenuRequest() { +} + +void UIAddSubmenuRequest::Run() { + LOG4CXX_INFO(logger_, "UIAddCommandRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_add_submenu_response.cc b/src/components/application_manager/src/commands/hmi/ui_add_submenu_response.cc new file mode 100644 index 0000000000..af88de2b48 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_add_submenu_response.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_add_submenu_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +UIAddSubmenuResponse::UIAddSubmenuResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UIAddSubmenuResponse::~UIAddSubmenuResponse() { +} + +void UIAddSubmenuResponse::Run() { + LOG4CXX_INFO(logger_, "UIAddSubmenuResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::UI_AddSubMenu); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_alert_request.cc b/src/components/application_manager/src/commands/hmi/ui_alert_request.cc new file mode 100644 index 0000000000..f8c9ed5708 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_alert_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_alert_request.h" + +namespace application_manager { + +namespace commands { + +UIAlertRequest::UIAlertRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UIAlertRequest::~UIAlertRequest() { +} + +void UIAlertRequest::Run() { + LOG4CXX_INFO(logger_, "UIAlertRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_alert_response.cc b/src/components/application_manager/src/commands/hmi/ui_alert_response.cc new file mode 100644 index 0000000000..289b90d290 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_alert_response.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_alert_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +UIAlertResponse::UIAlertResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UIAlertResponse::~UIAlertResponse() { +} + +void UIAlertResponse::Run() { + LOG4CXX_INFO(logger_, "UIAlertResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::UI_Alert); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_change_registration_request.cc b/src/components/application_manager/src/commands/hmi/ui_change_registration_request.cc new file mode 100644 index 0000000000..fbba2b4023 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_change_registration_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_change_registration_request.h" + +namespace application_manager { + +namespace commands { + +UIChangeRegistrationRequest::UIChangeRegistrationRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UIChangeRegistrationRequest::~UIChangeRegistrationRequest() { +} + +void UIChangeRegistrationRequest::Run() { + LOG4CXX_INFO(logger_, "UIChangeRegistrationRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_change_registration_response.cc b/src/components/application_manager/src/commands/hmi/ui_change_registration_response.cc new file mode 100644 index 0000000000..16447077dd --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_change_registration_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_change_registration_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +UIChangeRegistratioResponse::UIChangeRegistratioResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UIChangeRegistratioResponse::~UIChangeRegistratioResponse() { +} + +void UIChangeRegistratioResponse::Run() { + LOG4CXX_INFO(logger_, "UIChangeRegistratioResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::UI_ChangeRegistration); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_delete_command_request.cc b/src/components/application_manager/src/commands/hmi/ui_delete_command_request.cc new file mode 100644 index 0000000000..23fb4c67f5 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_delete_command_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_delete_command_request.h" + +namespace application_manager { + +namespace commands { + +UIDeleteCommandRequest::UIDeleteCommandRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UIDeleteCommandRequest::~UIDeleteCommandRequest() { +} + +void UIDeleteCommandRequest::Run() { + LOG4CXX_INFO(logger_, "UIDeleteCommandRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_delete_command_response.cc b/src/components/application_manager/src/commands/hmi/ui_delete_command_response.cc new file mode 100644 index 0000000000..0ac32877c4 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_delete_command_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_delete_command_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +UIDeleteCommandResponse::UIDeleteCommandResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UIDeleteCommandResponse::~UIDeleteCommandResponse() { +} + +void UIDeleteCommandResponse::Run() { + LOG4CXX_INFO(logger_, "UIDeleteCommandResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::UI_DeleteCommand); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_delete_submenu_request.cc b/src/components/application_manager/src/commands/hmi/ui_delete_submenu_request.cc new file mode 100644 index 0000000000..41f356b981 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_delete_submenu_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_delete_submenu_request.h" + +namespace application_manager { + +namespace commands { + +UIDeleteSubmenuRequest::UIDeleteSubmenuRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UIDeleteSubmenuRequest::~UIDeleteSubmenuRequest() { +} + +void UIDeleteSubmenuRequest::Run() { + LOG4CXX_INFO(logger_, "UIDeleteSubmenuRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_delete_submenu_response.cc b/src/components/application_manager/src/commands/hmi/ui_delete_submenu_response.cc new file mode 100644 index 0000000000..5a3359b722 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_delete_submenu_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_delete_submenu_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +UIDeleteSubmenuResponse::UIDeleteSubmenuResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UIDeleteSubmenuResponse::~UIDeleteSubmenuResponse() { +} + +void UIDeleteSubmenuResponse::Run() { + LOG4CXX_INFO(logger_, "UIDeleteSubmenuResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::UI_DeleteSubMenu); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_end_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/hmi/ui_end_audio_pass_thru_request.cc new file mode 100644 index 0000000000..4c93f9235b --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_end_audio_pass_thru_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_end_audio_pass_thru_request.h" + +namespace application_manager { + +namespace commands { + +UIEndAudioPassThruRequest::UIEndAudioPassThruRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UIEndAudioPassThruRequest::~UIEndAudioPassThruRequest() { +} + +void UIEndAudioPassThruRequest::Run() { + LOG4CXX_INFO(logger_, "UIEndAudioPassThruRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_end_audio_pass_thru_response.cc b/src/components/application_manager/src/commands/hmi/ui_end_audio_pass_thru_response.cc new file mode 100644 index 0000000000..e560ae293a --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_end_audio_pass_thru_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_end_audio_pass_thru_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +UIEndAudioPassThruResponse::UIEndAudioPassThruResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UIEndAudioPassThruResponse::~UIEndAudioPassThruResponse() { +} + +void UIEndAudioPassThruResponse::Run() { + LOG4CXX_INFO(logger_, "UIEndAudioPassThruResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::UI_EndAudioPassThru); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_get_capabilities_request.cc b/src/components/application_manager/src/commands/hmi/ui_get_capabilities_request.cc new file mode 100644 index 0000000000..b9f1b6917c --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_get_capabilities_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_get_capabilities_request.h" + +namespace application_manager { + +namespace commands { + +UIGetCapabilitiesRequest::UIGetCapabilitiesRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UIGetCapabilitiesRequest::~UIGetCapabilitiesRequest() { +} + +void UIGetCapabilitiesRequest::Run() { + LOG4CXX_INFO(logger_, "UIGetCapabilitiesRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_get_capabilities_response.cc b/src/components/application_manager/src/commands/hmi/ui_get_capabilities_response.cc new file mode 100644 index 0000000000..0663bf033e --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_get_capabilities_response.cc @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_get_capabilities_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +UIGetCapabilitiesResponse::UIGetCapabilitiesResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UIGetCapabilitiesResponse::~UIGetCapabilitiesResponse() { +} + +void UIGetCapabilitiesResponse::Run() { + LOG4CXX_INFO(logger_, "UIGetCapabilitiesResponse::Run"); + + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + + hmi_capabilities.set_display_capabilities( + (*message_)[strings::msg_params][hmi_response::display_capabilities]); + + hmi_capabilities.set_hmi_zone_capabilities( + (*message_)[strings::msg_params][hmi_response::hmi_zone_capabilities]); + + if ((*message_)[strings::msg_params].keyExists( + hmi_response::soft_button_capabilities)) { + hmi_capabilities.set_soft_button_capabilities( + (*message_)[strings::msg_params][hmi_response::soft_button_capabilities]); + } + + if ((*message_)[strings::msg_params].keyExists( + strings::audio_pass_thru_capabilities)) { + + hmi_capabilities.set_audio_pass_thru_capabilities( + (*message_)[strings::msg_params][strings::audio_pass_thru_capabilities]); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_get_language_request.cc b/src/components/application_manager/src/commands/hmi/ui_get_language_request.cc new file mode 100644 index 0000000000..ffca242d43 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_get_language_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_get_language_request.h" + +namespace application_manager { + +namespace commands { + +UIGetLanguageRequest::UIGetLanguageRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UIGetLanguageRequest::~UIGetLanguageRequest() { +} + +void UIGetLanguageRequest::Run() { + LOG4CXX_INFO(logger_, "UIGetLanguageRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_get_language_response.cc b/src/components/application_manager/src/commands/hmi/ui_get_language_response.cc new file mode 100644 index 0000000000..20435d788b --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_get_language_response.cc @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_get_language_response.h" +#include "application_manager/application_manager_impl.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +UIGetLanguageResponse::UIGetLanguageResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UIGetLanguageResponse::~UIGetLanguageResponse() { +} + +void UIGetLanguageResponse::Run() { + LOG4CXX_INFO(logger_, "UIGetLanguageResponse::Run"); + + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + + hmi_capabilities.set_active_ui_language( + static_cast<hmi_apis::Common_Language::eType>( + (*message_)[strings::msg_params][hmi_response::language].asInt())); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_get_supported_languages_request.cc b/src/components/application_manager/src/commands/hmi/ui_get_supported_languages_request.cc new file mode 100644 index 0000000000..455486ef6c --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_get_supported_languages_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_get_supported_languages_request.h" + +namespace application_manager { + +namespace commands { + +UIGetSupportedLanguagesRequest::UIGetSupportedLanguagesRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UIGetSupportedLanguagesRequest::~UIGetSupportedLanguagesRequest() { +} + +void UIGetSupportedLanguagesRequest::Run() { + LOG4CXX_INFO(logger_, "UIGetSupportedLanguagesRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_get_supported_languages_response.cc b/src/components/application_manager/src/commands/hmi/ui_get_supported_languages_response.cc new file mode 100644 index 0000000000..8492cfca5b --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_get_supported_languages_response.cc @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_get_supported_languages_response.h" +#include "application_manager/application_manager_impl.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +UIGetSupportedLanguagesResponse::UIGetSupportedLanguagesResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UIGetSupportedLanguagesResponse::~UIGetSupportedLanguagesResponse() { +} + +void UIGetSupportedLanguagesResponse::Run() { + LOG4CXX_INFO(logger_, "UIGetSupportedLanguagesResponse::Run"); + + const hmi_apis::Common_Result::eType code = + static_cast<hmi_apis::Common_Result::eType>( + (*message_)[strings::params][hmi_response::code].asInt()); + + if (hmi_apis::Common_Result::SUCCESS == code) { + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + + hmi_capabilities.set_ui_supported_languages( + (*message_)[strings::msg_params][hmi_response::languages]); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/ui_is_ready_request.cc new file mode 100644 index 0000000000..50d0ddd95a --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_is_ready_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_is_ready_request.h" + +namespace application_manager { + +namespace commands { + +UIIsReadyRequest::UIIsReadyRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UIIsReadyRequest::~UIIsReadyRequest() { +} + +void UIIsReadyRequest::Run() { + LOG4CXX_INFO(logger_, "UIIsReadyRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_is_ready_response.cc b/src/components/application_manager/src/commands/hmi/ui_is_ready_response.cc new file mode 100644 index 0000000000..97d11b6022 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_is_ready_response.cc @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_is_ready_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +UIIsReadyResponse::UIIsReadyResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UIIsReadyResponse::~UIIsReadyResponse() { +} + +void UIIsReadyResponse::Run() { + LOG4CXX_INFO(logger_, "UIIsReadyResponse::Run"); + smart_objects::SmartObject& object = *message_; + + bool is_available = false; + if (object[strings::msg_params].keyExists(strings::available)) { + is_available = object[strings::msg_params][strings::available].asBool(); + } + + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + + hmi_capabilities.set_is_ui_cooperating(is_available); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_perform_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/hmi/ui_perform_audio_pass_thru_request.cc new file mode 100644 index 0000000000..cf77703a9b --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_perform_audio_pass_thru_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_perform_audio_pass_thru_request.h" + +namespace application_manager { + +namespace commands { + +UIPerformAudioPassThruRequest::UIPerformAudioPassThruRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UIPerformAudioPassThruRequest::~UIPerformAudioPassThruRequest() { +} + +void UIPerformAudioPassThruRequest::Run() { + LOG4CXX_INFO(logger_, "UIPerformAudioPassThruRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_perform_audio_pass_thru_response.cc b/src/components/application_manager/src/commands/hmi/ui_perform_audio_pass_thru_response.cc new file mode 100644 index 0000000000..36d4c507b5 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_perform_audio_pass_thru_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_perform_audio_pass_thru_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +UIPerformAudioPassThruResponse::UIPerformAudioPassThruResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UIPerformAudioPassThruResponse::~UIPerformAudioPassThruResponse() { +} + +void UIPerformAudioPassThruResponse::Run() { + LOG4CXX_INFO(logger_, "UIPerformAudioPassThruResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::UI_PerformAudioPassThru); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_perform_interaction_request.cc b/src/components/application_manager/src/commands/hmi/ui_perform_interaction_request.cc new file mode 100644 index 0000000000..09f98ec036 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_perform_interaction_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_perform_interaction_request.h" + +namespace application_manager { + +namespace commands { + +UIPerformInteractionRequest::UIPerformInteractionRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UIPerformInteractionRequest::~UIPerformInteractionRequest() { +} + +void UIPerformInteractionRequest::Run() { + LOG4CXX_INFO(logger_, "UIPerformInteractionRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_perform_interaction_response.cc b/src/components/application_manager/src/commands/hmi/ui_perform_interaction_response.cc new file mode 100644 index 0000000000..2f5f6ead57 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_perform_interaction_response.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_perform_interaction_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +UIPerformInteractionResponse::UIPerformInteractionResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UIPerformInteractionResponse::~UIPerformInteractionResponse() { +} + +void UIPerformInteractionResponse::Run() { + LOG4CXX_INFO(logger_, "UIPerformInteractionResponse::Run"); + event_engine::Event event(hmi_apis::FunctionID::UI_PerformInteraction); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_scrollable_message_request.cc b/src/components/application_manager/src/commands/hmi/ui_scrollable_message_request.cc new file mode 100644 index 0000000000..ac34dd236f --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_scrollable_message_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_scrollable_message_request.h" + +namespace application_manager { + +namespace commands { + +UIScrollableMessageRequest::UIScrollableMessageRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UIScrollableMessageRequest::~UIScrollableMessageRequest() { +} + +void UIScrollableMessageRequest::Run() { + LOG4CXX_INFO(logger_, "UIScrollableMessageRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_scrollable_message_response.cc b/src/components/application_manager/src/commands/hmi/ui_scrollable_message_response.cc new file mode 100644 index 0000000000..182d512c8c --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_scrollable_message_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_scrollable_message_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +UIScrollableMessageResponse::UIScrollableMessageResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UIScrollableMessageResponse::~UIScrollableMessageResponse() { +} + +void UIScrollableMessageResponse::Run() { + LOG4CXX_INFO(logger_, "UIScrollableMessageResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::UI_ScrollableMessage); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_set_display_layout_request.cc b/src/components/application_manager/src/commands/hmi/ui_set_display_layout_request.cc new file mode 100644 index 0000000000..3dea853486 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_set_display_layout_request.cc @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_set_display_layout_request.h" + +namespace application_manager { + +namespace commands { + +UiSetDisplayLayoutRequest::UiSetDisplayLayoutRequest( + const MessageSharedPtr& message): RequestToHMI(message) { +} + +UiSetDisplayLayoutRequest::~UiSetDisplayLayoutRequest() { +} + +void UiSetDisplayLayoutRequest::Run() { + LOG4CXX_INFO(logger_, "UiSetDisplayLayoutRequest::Run"); + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_set_display_layout_response.cc b/src/components/application_manager/src/commands/hmi/ui_set_display_layout_response.cc new file mode 100644 index 0000000000..f381a4db28 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_set_display_layout_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_set_display_layout_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +UiSetDisplayLayoutResponse::UiSetDisplayLayoutResponse( + const MessageSharedPtr& message): ResponseFromHMI(message) { +} + +UiSetDisplayLayoutResponse::~UiSetDisplayLayoutResponse() { +} + +void UiSetDisplayLayoutResponse::Run() { + LOG4CXX_INFO(logger_, "UiSetDisplayLayoutResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::UI_SetDisplayLayout); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_set_global_properties_request.cc b/src/components/application_manager/src/commands/hmi/ui_set_global_properties_request.cc new file mode 100644 index 0000000000..e538866c1b --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_set_global_properties_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_set_global_properties_request.h" + +namespace application_manager { + +namespace commands { + +UISetGlobalPropertiesRequest::UISetGlobalPropertiesRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UISetGlobalPropertiesRequest::~UISetGlobalPropertiesRequest() { +} + +void UISetGlobalPropertiesRequest::Run() { + LOG4CXX_INFO(logger_, "UISetGlobalPropertiesRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_set_global_properties_response.cc b/src/components/application_manager/src/commands/hmi/ui_set_global_properties_response.cc new file mode 100644 index 0000000000..67023533c9 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_set_global_properties_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_set_global_properties_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +UISetGlobalPropertiesResponse::UISetGlobalPropertiesResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UISetGlobalPropertiesResponse::~UISetGlobalPropertiesResponse() { +} + +void UISetGlobalPropertiesResponse::Run() { + LOG4CXX_INFO(logger_, "UISetGlobalPropertiesResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::UI_SetGlobalProperties); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_set_icon_request.cc b/src/components/application_manager/src/commands/hmi/ui_set_icon_request.cc new file mode 100644 index 0000000000..b587a3028e --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_set_icon_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_set_icon_request.h" + +namespace application_manager { + +namespace commands { + +UISetIconRequest::UISetIconRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UISetIconRequest::~UISetIconRequest() { +} + +void UISetIconRequest::Run() { + LOG4CXX_INFO(logger_, "UISetIconRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_set_icon_response.cc b/src/components/application_manager/src/commands/hmi/ui_set_icon_response.cc new file mode 100644 index 0000000000..f4565baaf1 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_set_icon_response.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_set_icon_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +UISetIconResponse::UISetIconResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UISetIconResponse::~UISetIconResponse() { +} + +void UISetIconResponse::Run() { + LOG4CXX_INFO(logger_, "UISetIconResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::UI_SetAppIcon); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_set_media_clock_timer_request.cc b/src/components/application_manager/src/commands/hmi/ui_set_media_clock_timer_request.cc new file mode 100644 index 0000000000..1eb218013b --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_set_media_clock_timer_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_set_media_clock_timer_request.h" + +namespace application_manager { + +namespace commands { + +UISetMediaClockTimerRequest::UISetMediaClockTimerRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UISetMediaClockTimerRequest::~UISetMediaClockTimerRequest() { +} + +void UISetMediaClockTimerRequest::Run() { + LOG4CXX_INFO(logger_, "UISetMediaClockTimerRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_set_media_clock_timer_response.cc b/src/components/application_manager/src/commands/hmi/ui_set_media_clock_timer_response.cc new file mode 100644 index 0000000000..ee67862a1a --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_set_media_clock_timer_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_set_media_clock_timer_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +UISetMediaClockTimerResponse::UISetMediaClockTimerResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UISetMediaClockTimerResponse::~UISetMediaClockTimerResponse() { +} + +void UISetMediaClockTimerResponse::Run() { + LOG4CXX_INFO(logger_, "UISetMediaClockTimerResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::UI_SetMediaClockTimer); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_show_request.cc b/src/components/application_manager/src/commands/hmi/ui_show_request.cc new file mode 100644 index 0000000000..841c8a62fa --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_show_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_show_request.h" + +namespace application_manager { + +namespace commands { + +UIShowRequest::UIShowRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UIShowRequest::~UIShowRequest() { +} + +void UIShowRequest::Run() { + LOG4CXX_INFO(logger_, "UIShowRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_show_response.cc b/src/components/application_manager/src/commands/hmi/ui_show_response.cc new file mode 100644 index 0000000000..c95cbbd2ba --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_show_response.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_show_response.h" +#include "application_manager/event_engine/event.h" + +namespace application_manager { + +namespace commands { + +UIShowResponse::UIShowResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UIShowResponse::~UIShowResponse() { +} + +void UIShowResponse::Run() { + LOG4CXX_INFO(logger_, "UIShowResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::UI_Show); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/ui_slider_request.cc b/src/components/application_manager/src/commands/hmi/ui_slider_request.cc new file mode 100644 index 0000000000..fc7203c0ea --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_slider_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_slider_request.h" + +namespace application_manager { + +namespace commands { + +UISliderRequest::UISliderRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UISliderRequest::~UISliderRequest() { +} + +void UISliderRequest::Run() { + LOG4CXX_INFO(logger_, "UISliderRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/ui_slider_response.cc b/src/components/application_manager/src/commands/hmi/ui_slider_response.cc new file mode 100644 index 0000000000..8d2522e224 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/ui_slider_response.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/ui_slider_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +UISliderResponse::UISliderResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UISliderResponse::~UISliderResponse() { +} + +void UISliderResponse::Run() { + LOG4CXX_INFO(logger_, "UISliderResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::UI_Slider); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/update_app_list_request.cc b/src/components/application_manager/src/commands/hmi/update_app_list_request.cc new file mode 100644 index 0000000000..955f4b19c6 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/update_app_list_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/update_app_list_request.h" + +namespace application_manager { + +namespace commands { + +UpdateAppListRequest::UpdateAppListRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UpdateAppListRequest::~UpdateAppListRequest() { +} + +void UpdateAppListRequest::Run() { + LOG4CXX_INFO(logger_, "UpdateAppListRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + + diff --git a/src/components/application_manager/src/commands/hmi/update_app_list_response.cc b/src/components/application_manager/src/commands/hmi/update_app_list_response.cc new file mode 100644 index 0000000000..d5db0b4ea8 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/update_app_list_response.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/update_app_list_response.h" + +namespace application_manager { + +namespace commands { + +UpdateAppListResponse::UpdateAppListResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UpdateAppListResponse::~UpdateAppListResponse() { +} + +void UpdateAppListResponse::Run() { + LOG4CXX_INFO(logger_, "UpdateAppListResponse::Run"); + + // TODO(PV): add check +} + +} // namespace commands + +} // namespace application_manager + + diff --git a/src/components/application_manager/src/commands/hmi/update_device_list_request.cc b/src/components/application_manager/src/commands/hmi/update_device_list_request.cc new file mode 100644 index 0000000000..1f632378b4 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/update_device_list_request.cc @@ -0,0 +1,96 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/update_device_list_request.h" +#include "application_manager/application_manager_impl.h" +#include "config_profile/profile.h" +#include "interfaces/HMI_API.h" + +#include <unistd.h> + +namespace application_manager { + +namespace commands { + +UpdateDeviceListRequest::UpdateDeviceListRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UpdateDeviceListRequest::~UpdateDeviceListRequest() { +} + +void UpdateDeviceListRequest::Run() { + LOG4CXX_INFO(logger_, "UpdateDeviceListRequest::Run"); + sync_primitives::AutoLock auto_lock(wait_hmi_lock); + // 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 to RTC + if (true == profile::Profile::instance()->launch_hmi()) { + if (!ApplicationManagerImpl::instance()->IsHMICooperating()) { + LOG4CXX_INFO(logger_, "MY Wait for HMI Cooperation"); + subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_OnReady); + termination_condition_.Wait(auto_lock); + LOG4CXX_INFO(logger_, "MY HMI Cooperation OK"); + } + } + + SendRequest(); +} + +void UpdateDeviceListRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "UpdateDeviceListRequest::on_event"); + sync_primitives::AutoLock auto_lock(wait_hmi_lock); + switch (event.id()) { + case hmi_apis::FunctionID::BasicCommunication_OnReady : { + LOG4CXX_INFO(logger_, "received OnReady"); + unsubscribe_from_event(hmi_apis::FunctionID::BasicCommunication_OnReady); + termination_condition_.Broadcast(); + break; + }; + default : { + LOG4CXX_ERROR(logger_, "Unknown event "); + break; + }; + } +} + +bool UpdateDeviceListRequest::CleanUp() { + sync_primitives::AutoLock auto_lock(wait_hmi_lock); + termination_condition_.Broadcast(); + return true; +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/update_device_list_response.cc b/src/components/application_manager/src/commands/hmi/update_device_list_response.cc new file mode 100644 index 0000000000..85ef57404c --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/update_device_list_response.cc @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/update_device_list_response.h" + +namespace application_manager { + +namespace commands { + +UpdateDeviceListResponse::UpdateDeviceListResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +UpdateDeviceListResponse::~UpdateDeviceListResponse() { +} + +void UpdateDeviceListResponse::Run() { + LOG4CXX_INFO(logger_, "UpdateDeviceListResponse::Run"); + + // TODO(PV): add check for correctness. +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/update_sdl_request.cc b/src/components/application_manager/src/commands/hmi/update_sdl_request.cc new file mode 100644 index 0000000000..7d47f84ce3 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/update_sdl_request.cc @@ -0,0 +1,58 @@ + +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/update_sdl_request.h" +#include "application_manager/policies/policy_handler.h" + +namespace application_manager { + +namespace commands { + +UpdateSDLRequest::UpdateSDLRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +UpdateSDLRequest::~UpdateSDLRequest() { +} + +void UpdateSDLRequest::Run() { + LOG4CXX_INFO(logger_, "UpdateSDLRequest::Run"); + + policy::PolicyHandler::instance()->PTExchangeAtUserRequest( + (*message_)[strings::params][strings::correlation_id].asInt()); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/update_sdl_response.cc b/src/components/application_manager/src/commands/hmi/update_sdl_response.cc new file mode 100644 index 0000000000..d2be2c655c --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/update_sdl_response.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/update_sdl_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +UpdateSDLResponse::UpdateSDLResponse( + const MessageSharedPtr& message): ResponseFromHMI(message) { +} + +UpdateSDLResponse::~UpdateSDLResponse() { +} + +void UpdateSDLResponse::Run() { + LOG4CXX_INFO(logger_, "UpdateSDLResponse::Run"); + (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; + (*message_)[strings::params][strings::protocol_version] = protocol_version_; + + ApplicationManagerImpl::instance()->SendMessageToHMI(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/vi_diagnostic_message_request.cc b/src/components/application_manager/src/commands/hmi/vi_diagnostic_message_request.cc new file mode 100644 index 0000000000..45d44e4475 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vi_diagnostic_message_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vi_diagnostic_message_request.h" + +namespace application_manager { + +namespace commands { + +VIDiagnosticMessageRequest::VIDiagnosticMessageRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +VIDiagnosticMessageRequest::~VIDiagnosticMessageRequest() { +} + +void VIDiagnosticMessageRequest::Run() { + LOG4CXX_INFO(logger_, "VIDiagnosticMessageRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/vi_diagnostic_message_response.cc b/src/components/application_manager/src/commands/hmi/vi_diagnostic_message_response.cc new file mode 100644 index 0000000000..d83869b279 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vi_diagnostic_message_response.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vi_diagnostic_message_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +VIDiagnosticMessageResponse::VIDiagnosticMessageResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +VIDiagnosticMessageResponse::~VIDiagnosticMessageResponse() { +} + +void VIDiagnosticMessageResponse::Run() { + LOG4CXX_INFO(logger_, "VIDiagnosticMessageResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/vi_get_dtcs_request.cc b/src/components/application_manager/src/commands/hmi/vi_get_dtcs_request.cc new file mode 100644 index 0000000000..5289816fb5 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vi_get_dtcs_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vi_get_dtcs_request.h" + +namespace application_manager { + +namespace commands { + +VIGetDTCsRequest::VIGetDTCsRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +VIGetDTCsRequest::~VIGetDTCsRequest() { +} + +void VIGetDTCsRequest::Run() { + LOG4CXX_INFO(logger_, "VIGetDTCsRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/vi_get_dtcs_response.cc b/src/components/application_manager/src/commands/hmi/vi_get_dtcs_response.cc new file mode 100644 index 0000000000..0cacc51d6c --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vi_get_dtcs_response.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vi_get_dtcs_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +VIGetDTCsResponse::VIGetDTCsResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +VIGetDTCsResponse::~VIGetDTCsResponse() { +} + +void VIGetDTCsResponse::Run() { + LOG4CXX_INFO(logger_, "VIGetDTCsResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::VehicleInfo_GetDTCs); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/vi_get_vehicle_data_request.cc b/src/components/application_manager/src/commands/hmi/vi_get_vehicle_data_request.cc new file mode 100644 index 0000000000..40b2ca9fed --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vi_get_vehicle_data_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vi_get_vehicle_data_request.h" + +namespace application_manager { + +namespace commands { + +VIGetVehicleDataRequest::VIGetVehicleDataRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +VIGetVehicleDataRequest::~VIGetVehicleDataRequest() { +} + +void VIGetVehicleDataRequest::Run() { + LOG4CXX_INFO(logger_, "VIGetVehicleDataRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/vi_get_vehicle_data_response.cc b/src/components/application_manager/src/commands/hmi/vi_get_vehicle_data_response.cc new file mode 100644 index 0000000000..73444a19bd --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vi_get_vehicle_data_response.cc @@ -0,0 +1,95 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vi_get_vehicle_data_response.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/policies/policy_handler.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +VIGetVehicleDataResponse::VIGetVehicleDataResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +VIGetVehicleDataResponse::~VIGetVehicleDataResponse() { +} + +void VIGetVehicleDataResponse::Run() { + LOG4CXX_INFO(logger_, "VIGetVehicleDataResponse::Run"); + smart_objects::SmartObject* result_so = new smart_objects::SmartObject( + smart_objects::SmartType_Map); + if (!result_so) { + // TODO(PV): add response with out of memory. + LOG4CXX_ERROR(logger_, + "Failed to create new Smart Object on get vehicle response."); + return; + } + + event_engine::Event event(hmi_apis::FunctionID::VehicleInfo_GetVehicleData); + + smart_objects::SmartObject& result = *result_so; + + if ((*message_)[strings::params][strings::message_type] + == static_cast<int32_t>(hmi_apis::messageType::error_response)) { + if ((*message_)[strings::params].keyExists(strings::data)) { + result[strings::msg_params] = (*message_)[strings::params][strings::data]; + result[strings::params][hmi_response::code] = + (*message_)[strings::params][hmi_response::code]; + result[strings::params][strings::correlation_id] = + (*message_)[strings::params][strings::correlation_id]; + result[strings::params][strings::error_msg] = + (*message_)[strings::params][strings::error_msg]; + result[strings::params][strings::message_type] = + (*message_)[strings::params][strings::message_type]; + result[strings::params][strings::protocol_type] = + (*message_)[strings::params][strings::protocol_type]; + result[strings::params][strings::protocol_version] = + (*message_)[strings::params][strings::protocol_version]; + } + + + event.set_smart_object(*result_so); + } else { + event.set_smart_object(*message_); + policy::PolicyHandler::instance()->OnVehicleDataUpdated(*message_); + } + + + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/vi_get_vehicle_type_request.cc b/src/components/application_manager/src/commands/hmi/vi_get_vehicle_type_request.cc new file mode 100644 index 0000000000..4c46de950e --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vi_get_vehicle_type_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vi_get_vehicle_type_request.h" + +namespace application_manager { + +namespace commands { + +VIGetVehicleTypeRequest::VIGetVehicleTypeRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +VIGetVehicleTypeRequest::~VIGetVehicleTypeRequest() { +} + +void VIGetVehicleTypeRequest::Run() { + LOG4CXX_INFO(logger_, "VIGetVehicleTypeRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/vi_get_vehicle_type_response.cc b/src/components/application_manager/src/commands/hmi/vi_get_vehicle_type_response.cc new file mode 100644 index 0000000000..18c0136d12 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vi_get_vehicle_type_response.cc @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vi_get_vehicle_type_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +VIGetVehicleTypeResponse::VIGetVehicleTypeResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +VIGetVehicleTypeResponse::~VIGetVehicleTypeResponse() { +} + +void VIGetVehicleTypeResponse::Run() { + LOG4CXX_INFO(logger_, "VIGetVehicleTypeResponse::Run"); + + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + + hmi_capabilities.set_vehicle_type( + (*message_)[strings::msg_params][hmi_response::vehicle_type]); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/vi_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/vi_is_ready_request.cc new file mode 100644 index 0000000000..074d6f6022 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vi_is_ready_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vi_is_ready_request.h" + +namespace application_manager { + +namespace commands { + +VIIsReadyRequest::VIIsReadyRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +VIIsReadyRequest::~VIIsReadyRequest() { +} + +void VIIsReadyRequest::Run() { + LOG4CXX_INFO(logger_, "VIIsReadyRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/vi_is_ready_response.cc b/src/components/application_manager/src/commands/hmi/vi_is_ready_response.cc new file mode 100644 index 0000000000..e7c9c180c2 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vi_is_ready_response.cc @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vi_is_ready_response.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/policies/policy_handler.h" + +namespace application_manager { + +namespace commands { + +VIIsReadyResponse::VIIsReadyResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +VIIsReadyResponse::~VIIsReadyResponse() { +} + +void VIIsReadyResponse::Run() { + LOG4CXX_INFO(logger_, "VIIsReadyResponse::Run"); + smart_objects::SmartObject& object = *message_; + + bool is_available = false; + if (object[strings::msg_params].keyExists(strings::available)) { + is_available = object[strings::msg_params][strings::available].asBool(); + } + + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + hmi_capabilities.set_is_ivi_cooperating(is_available); + + policy::PolicyHandler::instance()->OnVIIsReady(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/vi_read_did_request.cc b/src/components/application_manager/src/commands/hmi/vi_read_did_request.cc new file mode 100644 index 0000000000..1485b471c4 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vi_read_did_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vi_read_did_request.h" + +namespace application_manager { + +namespace commands { + +VIReadDIDRequest::VIReadDIDRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +VIReadDIDRequest::~VIReadDIDRequest() { +} + +void VIReadDIDRequest::Run() { + LOG4CXX_INFO(logger_, "VIReadDIDRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/vi_read_did_response.cc b/src/components/application_manager/src/commands/hmi/vi_read_did_response.cc new file mode 100644 index 0000000000..ddd9f3c540 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vi_read_did_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vi_read_did_response.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/application_manager_impl.h" + + +namespace application_manager { + +namespace commands { + +VIReadDIDResponse::VIReadDIDResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +VIReadDIDResponse::~VIReadDIDResponse() { +} + +void VIReadDIDResponse::Run() { + LOG4CXX_INFO(logger_, "VIReadDIDResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::VehicleInfo_ReadDID); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/vi_subscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/hmi/vi_subscribe_vehicle_data_request.cc new file mode 100644 index 0000000000..38950a2a2b --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vi_subscribe_vehicle_data_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vi_subscribe_vehicle_data_request.h" + +namespace application_manager { + +namespace commands { + +VISubscribeVehicleDataRequest::VISubscribeVehicleDataRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +VISubscribeVehicleDataRequest::~VISubscribeVehicleDataRequest() { +} + +void VISubscribeVehicleDataRequest::Run() { + LOG4CXX_INFO(logger_, "VISubscribeVehicleDataRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/vi_subscribe_vehicle_data_response.cc b/src/components/application_manager/src/commands/hmi/vi_subscribe_vehicle_data_response.cc new file mode 100644 index 0000000000..bd67294fbb --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vi_subscribe_vehicle_data_response.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vi_subscribe_vehicle_data_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { +namespace commands { + +VISubscribeVehicleDataResponse::VISubscribeVehicleDataResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +VISubscribeVehicleDataResponse::~VISubscribeVehicleDataResponse() { +} + +void VISubscribeVehicleDataResponse::Run() { + LOG4CXX_INFO(logger_, "VISubscribeVehicleDataResponse::Run"); + event_engine::Event event( + hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData + ); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/vi_unsubscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/hmi/vi_unsubscribe_vehicle_data_request.cc new file mode 100644 index 0000000000..0af87c2a2e --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vi_unsubscribe_vehicle_data_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vi_unsubscribe_vehicle_data_request.h" + +namespace application_manager { + +namespace commands { + +VIUnsubscribeVehicleDataRequest::VIUnsubscribeVehicleDataRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +VIUnsubscribeVehicleDataRequest::~VIUnsubscribeVehicleDataRequest() { +} + +void VIUnsubscribeVehicleDataRequest::Run() { + LOG4CXX_INFO(logger_, "VIUnsubscribeVehicleDataRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/vi_unsubscribe_vehicle_data_response.cc b/src/components/application_manager/src/commands/hmi/vi_unsubscribe_vehicle_data_response.cc new file mode 100644 index 0000000000..22231b4a61 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vi_unsubscribe_vehicle_data_response.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vi_unsubscribe_vehicle_data_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { +namespace commands { + +VIUnsubscribeVehicleDataResponse::VIUnsubscribeVehicleDataResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +VIUnsubscribeVehicleDataResponse::~VIUnsubscribeVehicleDataResponse() { +} + +void VIUnsubscribeVehicleDataResponse::Run() { + LOG4CXX_INFO(logger_, "VIUnsubscribeVehicleDataResponse::Run"); + event_engine::Event event( + hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData + ); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/vr_add_command_request.cc b/src/components/application_manager/src/commands/hmi/vr_add_command_request.cc new file mode 100644 index 0000000000..a74ece95da --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vr_add_command_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vr_add_command_request.h" + +namespace application_manager { + +namespace commands { + +VRAddCommandRequest::VRAddCommandRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +VRAddCommandRequest::~VRAddCommandRequest() { +} + +void VRAddCommandRequest::Run() { + LOG4CXX_INFO(logger_, "VRAddCommandRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/vr_add_command_response.cc b/src/components/application_manager/src/commands/hmi/vr_add_command_response.cc new file mode 100644 index 0000000000..513ccdace2 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vr_add_command_response.cc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vr_add_command_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +VRAddCommandResponse::VRAddCommandResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +VRAddCommandResponse::~VRAddCommandResponse() { +} + +void VRAddCommandResponse::Run() { + LOG4CXX_INFO(logger_, "VRAddCommandResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::VR_AddCommand); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/vr_change_registration_request.cc b/src/components/application_manager/src/commands/hmi/vr_change_registration_request.cc new file mode 100644 index 0000000000..bd7c1e7841 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vr_change_registration_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vr_change_registration_request.h" + +namespace application_manager { + +namespace commands { + +VRChangeRegistrationRequest::VRChangeRegistrationRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +VRChangeRegistrationRequest::~VRChangeRegistrationRequest() { +} + +void VRChangeRegistrationRequest::Run() { + LOG4CXX_INFO(logger_, "VRChangeRegistrationRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/vr_change_registration_response.cc b/src/components/application_manager/src/commands/hmi/vr_change_registration_response.cc new file mode 100644 index 0000000000..92a36d23f6 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vr_change_registration_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vr_change_registration_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +VRChangeRegistrationResponse::VRChangeRegistrationResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +VRChangeRegistrationResponse::~VRChangeRegistrationResponse() { +} + +void VRChangeRegistrationResponse::Run() { + LOG4CXX_INFO(logger_, "VRChangeRegistratioResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::VR_ChangeRegistration); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/vr_delete_command_request.cc b/src/components/application_manager/src/commands/hmi/vr_delete_command_request.cc new file mode 100644 index 0000000000..0241be6308 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vr_delete_command_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vr_delete_command_request.h" + +namespace application_manager { + +namespace commands { + +VRDeleteCommandRequest::VRDeleteCommandRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +VRDeleteCommandRequest::~VRDeleteCommandRequest() { +} + +void VRDeleteCommandRequest::Run() { + LOG4CXX_INFO(logger_, "VRDeleteCommandRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/vr_delete_command_response.cc b/src/components/application_manager/src/commands/hmi/vr_delete_command_response.cc new file mode 100644 index 0000000000..c5a13126b0 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vr_delete_command_response.cc @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vr_delete_command_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +VRDeleteCommandResponse::VRDeleteCommandResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +VRDeleteCommandResponse::~VRDeleteCommandResponse() { +} + +void VRDeleteCommandResponse::Run() { + LOG4CXX_INFO(logger_, "VRDeleteCommandResponse::Run"); + + event_engine::Event event(hmi_apis::FunctionID::VR_DeleteCommand); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/vr_get_capabilities_request.cc b/src/components/application_manager/src/commands/hmi/vr_get_capabilities_request.cc new file mode 100644 index 0000000000..8b1d4ae0b4 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vr_get_capabilities_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vr_get_capabilities_request.h" + +namespace application_manager { + +namespace commands { + +VRGetCapabilitiesRequest::VRGetCapabilitiesRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +VRGetCapabilitiesRequest::~VRGetCapabilitiesRequest() { +} + +void VRGetCapabilitiesRequest::Run() { + LOG4CXX_INFO(logger_, "VRGetCapabilitiesRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/vr_get_capabilities_response.cc b/src/components/application_manager/src/commands/hmi/vr_get_capabilities_response.cc new file mode 100644 index 0000000000..de6fdd7a93 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vr_get_capabilities_response.cc @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vr_get_capabilities_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +VRGetCapabilitiesResponse::VRGetCapabilitiesResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +VRGetCapabilitiesResponse::~VRGetCapabilitiesResponse() { +} + +void VRGetCapabilitiesResponse::Run() { + LOG4CXX_INFO(logger_, "VRGetCapabilitiesResponse::Run"); + + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + + hmi_capabilities.set_vr_capabilities( + (*message_)[strings::msg_params][strings::vr_capabilities]); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/vr_get_language_request.cc b/src/components/application_manager/src/commands/hmi/vr_get_language_request.cc new file mode 100644 index 0000000000..9f4aeb9797 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vr_get_language_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vr_get_language_request.h" + +namespace application_manager { + +namespace commands { + +VRGetLanguageRequest::VRGetLanguageRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +VRGetLanguageRequest::~VRGetLanguageRequest() { +} + +void VRGetLanguageRequest::Run() { + LOG4CXX_INFO(logger_, "VRGetLanguageRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/vr_get_language_response.cc b/src/components/application_manager/src/commands/hmi/vr_get_language_response.cc new file mode 100644 index 0000000000..acbd24fbbf --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vr_get_language_response.cc @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vr_get_language_response.h" +#include "application_manager/application_manager_impl.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +VRGetLanguageResponse::VRGetLanguageResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +VRGetLanguageResponse::~VRGetLanguageResponse() { +} + +void VRGetLanguageResponse::Run() { + LOG4CXX_INFO(logger_, "VRGetLanguageResponse::Run"); + + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + hmi_capabilities.set_active_vr_language( + static_cast<hmi_apis::Common_Language::eType>( + (*message_)[strings::msg_params][hmi_response::language].asInt())); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/vr_get_supported_languages_request.cc b/src/components/application_manager/src/commands/hmi/vr_get_supported_languages_request.cc new file mode 100644 index 0000000000..e43d88430d --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vr_get_supported_languages_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vr_get_supported_languages_request.h" + +namespace application_manager { + +namespace commands { + +VRGetSupportedLanguagesRequest::VRGetSupportedLanguagesRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +VRGetSupportedLanguagesRequest::~VRGetSupportedLanguagesRequest() { +} + +void VRGetSupportedLanguagesRequest::Run() { + LOG4CXX_INFO(logger_, "VRGetSupportedLanguagesRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/vr_get_supported_languages_response.cc b/src/components/application_manager/src/commands/hmi/vr_get_supported_languages_response.cc new file mode 100644 index 0000000000..d2cc148a09 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vr_get_supported_languages_response.cc @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vr_get_supported_languages_response.h" +#include "application_manager/application_manager_impl.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +VRGetSupportedLanguagesResponse::VRGetSupportedLanguagesResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +VRGetSupportedLanguagesResponse::~VRGetSupportedLanguagesResponse() { +} + +void VRGetSupportedLanguagesResponse::Run() { + LOG4CXX_INFO(logger_, "VRGetSupportedLanguagesResponse::Run"); + + const hmi_apis::Common_Result::eType code = + static_cast<hmi_apis::Common_Result::eType>( + (*message_)[strings::params][hmi_response::code].asInt()); + + if (hmi_apis::Common_Result::SUCCESS == code) { + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + hmi_capabilities.set_vr_supported_languages( + (*message_)[strings::msg_params][hmi_response::languages]); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/vr_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/vr_is_ready_request.cc new file mode 100644 index 0000000000..944cfcbb3c --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vr_is_ready_request.cc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vr_is_ready_request.h" + +namespace application_manager { + +namespace commands { + +VRIsReadyRequest::VRIsReadyRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +VRIsReadyRequest::~VRIsReadyRequest() { +} + +void VRIsReadyRequest::Run() { + LOG4CXX_INFO(logger_, "VRIsReadyRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/vr_is_ready_response.cc b/src/components/application_manager/src/commands/hmi/vr_is_ready_response.cc new file mode 100644 index 0000000000..8cf5e66ee7 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vr_is_ready_response.cc @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vr_is_ready_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +VRIsReadyResponse::VRIsReadyResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +VRIsReadyResponse::~VRIsReadyResponse() { +} + +void VRIsReadyResponse::Run() { + LOG4CXX_INFO(logger_, "VRIsReadyResponse::Run"); + smart_objects::SmartObject& object = *message_; + + bool is_available = false; + if (object[strings::msg_params].keyExists(strings::available)) { + is_available = object[strings::msg_params][strings::available].asBool(); + } + + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + hmi_capabilities.set_is_vr_cooperating(is_available); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/vr_perform_interaction_request.cc b/src/components/application_manager/src/commands/hmi/vr_perform_interaction_request.cc new file mode 100644 index 0000000000..6de32dc5b5 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vr_perform_interaction_request.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vr_perform_interaction_request.h" + +namespace application_manager { + +namespace commands { + +VRPerformInteractionRequest::VRPerformInteractionRequest( + const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +VRPerformInteractionRequest::~VRPerformInteractionRequest() { +} + +void VRPerformInteractionRequest::Run() { + LOG4CXX_INFO(logger_, "VRPerformInteractionRequest::Run"); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/vr_perform_interaction_response.cc b/src/components/application_manager/src/commands/hmi/vr_perform_interaction_response.cc new file mode 100644 index 0000000000..fea09b9f29 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vr_perform_interaction_response.cc @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, 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 "application_manager/commands/hmi/vr_perform_interaction_response.h" +#include "application_manager/event_engine/event.h" + +namespace application_manager { + +namespace commands { + +VRPerformInteractionResponse::VRPerformInteractionResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +VRPerformInteractionResponse::~VRPerformInteractionResponse() { +} + +void VRPerformInteractionResponse::Run() { + LOG4CXX_INFO(logger_, "VRPerformInteractionResponse::Run"); + event_engine::Event event(hmi_apis::FunctionID::VR_PerformInteraction); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/add_command_request.cc b/src/components/application_manager/src/commands/mobile/add_command_request.cc new file mode 100644 index 0000000000..35cc619895 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/add_command_request.cc @@ -0,0 +1,414 @@ +/* + + Copyright (c) 2013, 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 <string> +#include "application_manager/commands/mobile/add_command_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application.h" +#include "application_manager/message_helper.h" +#include "utils/file_system.h" + +namespace application_manager { + +namespace commands { + +AddCommandRequest::AddCommandRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message), + send_ui_(false), + send_vr_(false), + is_ui_received_(false), + is_vr_received_(false), + ui_result_(hmi_apis::Common_Result::INVALID_ENUM), + vr_result_(hmi_apis::Common_Result::INVALID_ENUM) { +} + +AddCommandRequest::~AddCommandRequest() { +} + +void AddCommandRequest::onTimeOut() { + LOG4CXX_INFO(logger_, "AddCommandRequest::onTimeOut"); + RemoveCommand(); + CommandRequestImpl::onTimeOut(); +} + +void AddCommandRequest::Run() { + LOG4CXX_INFO(logger_, "AddCommandRequest::Run"); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + (*message_)[strings::params][strings::connection_key].asUInt()); + + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "No application associated with session key"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if ((*message_)[strings::msg_params].keyExists(strings::cmd_icon)) { + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyImage((*message_)[strings::msg_params] + [strings::cmd_icon], app); + + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR_EXT( + logger_, + "MessageHelper::VerifyImage return " << verification_result); + SendResponse(false, verification_result); + return; + } + } + + if (!((*message_)[strings::msg_params].keyExists(strings::cmd_id))) { + LOG4CXX_ERROR_EXT(logger_, "INVALID_DATA"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if (app->FindCommand( + (*message_)[strings::msg_params][strings::cmd_id].asUInt())) { + LOG4CXX_ERROR_EXT(logger_, "INVALID_ID"); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + + bool data_exist = false; + + if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) { + if (!CheckCommandName(app)) { + SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); + return; + } + if (((*message_)[strings::msg_params][strings::menu_params].keyExists( + hmi_request::parent_id)) && (0 != (*message_)[strings::msg_params] + [strings::menu_params][hmi_request::parent_id].asUInt())) { + if (!CheckCommandParentId(app)) { + SendResponse(false, mobile_apis::Result::INVALID_ID, + "Parent ID doesn't exist"); + return; + } + } + data_exist = true; + } + + if (((*message_)[strings::msg_params].keyExists(strings::vr_commands)) + && ((*message_)[strings::msg_params] + [strings::vr_commands].length() > 0)) { + + if (!CheckCommandVRSynonym(app)) { + SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); + return; + } + + data_exist = true; + } + + if (!data_exist) { + LOG4CXX_ERROR_EXT(logger_, "INVALID_DATA"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, + "Incoming add command has contains \t\n \\t \\n"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + app->AddCommand((*message_)[strings::msg_params] + [strings::cmd_id].asUInt(), + (*message_)[strings::msg_params]); + + smart_objects::SmartObject ui_msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) { + ui_msg_params[strings::cmd_id] = + (*message_)[strings::msg_params][strings::cmd_id]; + ui_msg_params[strings::menu_params] = + (*message_)[strings::msg_params][strings::menu_params]; + + ui_msg_params[strings::app_id] = app->app_id(); + + if ( ((*message_)[strings::msg_params].keyExists(strings::cmd_icon)) + && ((*message_)[strings::msg_params][strings::cmd_icon].keyExists(strings::value)) + && (0 < (*message_)[strings::msg_params][strings::cmd_icon] + [strings::value].length())) { + ui_msg_params[strings::cmd_icon] = + (*message_)[strings::msg_params][strings::cmd_icon]; + } + + send_ui_ = true; + } + + smart_objects::SmartObject vr_msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + if ((*message_)[strings::msg_params].keyExists(strings::vr_commands)) { + vr_msg_params[strings::cmd_id] = + (*message_)[strings::msg_params][strings::cmd_id]; + vr_msg_params[strings::vr_commands] = + (*message_)[strings::msg_params][strings::vr_commands]; + vr_msg_params[strings::app_id] = app->app_id(); + + vr_msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; + vr_msg_params[strings::grammar_id] = app->get_grammar_id(); + + send_vr_ = true; + } + + if (send_ui_) { + SendHMIRequest(hmi_apis::FunctionID::UI_AddCommand, &ui_msg_params, true); + } + + if (send_vr_) { + SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &vr_msg_params, true); + } +} + +bool AddCommandRequest::CheckCommandName(ApplicationConstSharedPtr app) { + if (!app) { + return false; + } + + const CommandsMap& commands = app->commands_map(); + CommandsMap::const_iterator i = commands.begin(); + uint32_t saved_parent_id = 0; + uint32_t parent_id = 0; + if ((*message_)[strings::msg_params] + [strings::menu_params].keyExists(hmi_request::parent_id)) { + parent_id = (*message_)[strings::msg_params] + [strings::menu_params][hmi_request::parent_id].asUInt(); + } + + for (; commands.end() != i; ++i) { + + if (!(*i->second).keyExists(strings::menu_params)) { + continue; + } + + saved_parent_id = 0; + if ((*i->second)[strings::menu_params].keyExists(hmi_request::parent_id)) { + saved_parent_id = (*i->second)[strings::menu_params][hmi_request::parent_id].asUInt(); + } + if (((*i->second)[strings::menu_params][strings::menu_name].asString() + == (*message_)[strings::msg_params][strings::menu_params] + [strings::menu_name].asString()) && + (saved_parent_id == parent_id)) { + LOG4CXX_INFO(logger_, "AddCommandRequest::CheckCommandName received" + " command name already exist in same level menu"); + return false; + } + } + return true; +} + +bool AddCommandRequest::CheckCommandVRSynonym(ApplicationConstSharedPtr app) { + if (!app) { + return false; + } + + const CommandsMap& commands = app->commands_map(); + CommandsMap::const_iterator it = commands.begin(); + + for (; commands.end() != it; ++it) { + + if(!(*it->second).keyExists(strings::vr_commands)) { + continue; + } + + for (size_t i = 0; i < (*it->second)[strings::vr_commands].length(); ++i) { + for (size_t j = 0; + j < (*message_)[strings::msg_params][strings::vr_commands].length(); + ++j) { + std::string vr_cmd_i = + (*it->second)[strings::vr_commands][i].asString(); + std::string vr_cmd_j = + (*message_)[strings::msg_params] + [strings::vr_commands][j].asString(); + + if (0 == strcasecmp(vr_cmd_i.c_str(), vr_cmd_j.c_str())) { + LOG4CXX_INFO(logger_, "AddCommandRequest::CheckCommandVRSynonym" + " received command vr synonym already exist"); + return false; + } + } + } + } + return true; +} + +bool AddCommandRequest::CheckCommandParentId(ApplicationConstSharedPtr app) { + if (!app) { + return false; + } + + const int32_t parent_id = + (*message_)[strings::msg_params][strings::menu_params] + [hmi_request::parent_id].asInt(); + smart_objects::SmartObject* parent = app->FindSubMenu(parent_id); + + if (!parent) { + LOG4CXX_INFO(logger_, "AddCommandRequest::CheckCommandParentId received" + " submenu doesn't exist"); + return false; + } + return true; +} + +void AddCommandRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "AddCommandRequest::on_event"); + + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_AddCommand: { + LOG4CXX_INFO(logger_, "Received UI_AddCommand event"); + is_ui_received_ = true; + ui_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + if (hmi_apis::Common_Result::SUCCESS != ui_result_) { + (*message_)[strings::msg_params].erase(strings::menu_params); + } + break; + } + case hmi_apis::FunctionID::VR_AddCommand: { + LOG4CXX_INFO(logger_, "Received VR_AddCommand event"); + is_vr_received_ = true; + vr_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + if (hmi_apis::Common_Result::SUCCESS != vr_result_) { + (*message_)[strings::msg_params].erase(strings::vr_commands); + } + break; + } + default: { + LOG4CXX_ERROR(logger_,"Received unknown event" << event.id()); + return; + } + } + + if (!IsPendingResponseExist()) { + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + if (hmi_apis::Common_Result::REJECTED == ui_result_) { + RemoveCommand(); + } + + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; + + bool result = ((hmi_apis::Common_Result::SUCCESS == ui_result_) && + (hmi_apis::Common_Result::SUCCESS == vr_result_)) || + ((hmi_apis::Common_Result::SUCCESS == ui_result_) && + (hmi_apis::Common_Result::INVALID_ENUM == vr_result_ || + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == vr_result_)) || + ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_ || + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_ ) && + (hmi_apis::Common_Result::SUCCESS == vr_result_)); + + if (!result && (hmi_apis::Common_Result::REJECTED == ui_result_)) { + result_code = static_cast<mobile_apis::Result::eType>(ui_result_); + } else { + result_code = static_cast<mobile_apis::Result::eType>( + std::max(ui_result_, vr_result_)); + } + + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + if (true == result) { + application->UpdateHash(); + } + } +} + +bool AddCommandRequest::IsPendingResponseExist() { + return send_ui_ != is_ui_received_ || send_vr_ != is_vr_received_; +} + +bool AddCommandRequest::IsWhiteSpaceExist() { + LOG4CXX_INFO(logger_, "AddCommandRequest::IsWhiteSpaceExist"); + const char* str = NULL; + + if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) { + str = (*message_)[strings::msg_params][strings::menu_params] + [strings::menu_name].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid menu name syntax check failed."); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::vr_commands)) { + const size_t len = + (*message_)[strings::msg_params][strings::vr_commands].length(); + + for (size_t i = 0; i < len; ++i) { + str = (*message_)[strings::msg_params] + [strings::vr_commands][i].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid vr_commands syntax check failed"); + return true; + } + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::cmd_icon)) { + str = (*message_)[strings::msg_params] + [strings::cmd_icon][strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid cmd_icon value syntax check failed"); + return true; + } + } + return false; +} + +void AddCommandRequest::RemoveCommand() { + LOG4CXX_INFO(logger_, "AddCommandRequest::RemoveCommand"); + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + connection_key()); + if (!app.valid()) { + LOG4CXX_ERROR(logger_, "No application associated with session key"); + return; + } + app->RemoveCommand((*message_)[strings::msg_params] + [strings::cmd_id].asUInt()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/add_command_response.cc b/src/components/application_manager/src/commands/mobile/add_command_response.cc new file mode 100644 index 0000000000..0c135af076 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/add_command_response.cc @@ -0,0 +1,56 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/add_command_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +AddCommandResponse::AddCommandResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +AddCommandResponse::~AddCommandResponse() { +} + +void AddCommandResponse::Run() { + LOG4CXX_INFO(logger_, "AddCommandResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc b/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc new file mode 100644 index 0000000000..ce6fa3fc51 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc @@ -0,0 +1,146 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/add_sub_menu_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application.h" + +namespace application_manager { + +namespace commands { + +AddSubMenuRequest::AddSubMenuRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +AddSubMenuRequest::~AddSubMenuRequest() { +} + +void AddSubMenuRequest::Run() { + LOG4CXX_INFO(logger_, "AddSubMenuRequest::Run"); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + (*message_)[strings::params][strings::connection_key].asUInt()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (app->FindSubMenu( + (*message_)[strings::msg_params][strings::menu_id].asInt())) { + LOG4CXX_ERROR(logger_, "INVALID_ID"); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + + if (app->IsSubMenuNameAlreadyExist( + (*message_)[strings::msg_params][strings::menu_name].asString())) { + LOG4CXX_ERROR(logger_, "DUPLICATE_NAME"); + SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); + return; + } + + if (!CheckSubMenuName()) { + LOG4CXX_ERROR(logger_, "SubMenuName is not valid"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + msg_params[strings::menu_id] = + (*message_)[strings::msg_params][strings::menu_id]; + if ((*message_)[strings::msg_params].keyExists(strings::position)) { + msg_params[strings::menu_params][strings::position] = + (*message_)[strings::msg_params][strings::position]; + } + msg_params[strings::menu_params][strings::menu_name] = + (*message_)[strings::msg_params][strings::menu_name]; + msg_params[strings::app_id] = app->app_id(); + + SendHMIRequest(hmi_apis::FunctionID::UI_AddSubMenu, &msg_params, true); +} + +void AddSubMenuRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "AddSubMenuRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_AddSubMenu: { + mobile_apis::Result::eType result_code = + static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + bool result = mobile_apis::Result::SUCCESS == result_code; + + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + if (result) { + application->AddSubMenu((*message_)[strings::msg_params] + [strings::menu_id].asInt(), + (*message_)[strings::msg_params]); + } + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + application->UpdateHash(); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +bool AddSubMenuRequest::CheckSubMenuName() { + const char* str = NULL; + + str = (*message_)[strings::msg_params][strings::menu_name].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_INFO(logger_, "Invalid subMenu name."); + return false; + } + return true; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc b/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc new file mode 100644 index 0000000000..bcd7df2888 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc @@ -0,0 +1,57 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/add_sub_menu_response.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" + +namespace application_manager { + +namespace commands { + +AddSubMenuResponse::AddSubMenuResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +AddSubMenuResponse::~AddSubMenuResponse() { +} + +void AddSubMenuResponse::Run() { + LOG4CXX_INFO(logger_, "AddSubMenuResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc new file mode 100644 index 0000000000..abb5bc7f3c --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc @@ -0,0 +1,232 @@ +/* + + Copyright (c) 2013, 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 <string.h> +#include "application_manager/commands/mobile/alert_maneuver_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" + +namespace application_manager { + +namespace commands { + +AlertManeuverRequest::AlertManeuverRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message), + tts_speak_result_code_(mobile_apis::Result::INVALID_ENUM), + navi_alert_maneuver_result_code_(mobile_apis::Result::INVALID_ENUM) { + subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout); +} + +AlertManeuverRequest::~AlertManeuverRequest() { +} + +void AlertManeuverRequest::Run() { + LOG4CXX_INFO(logger_, "AlertManeuverRequest::Run"); + + if ((!(*message_)[strings::msg_params].keyExists(strings::soft_buttons)) && + (!(*message_)[strings::msg_params].keyExists(strings::tts_chunks))) { + LOG4CXX_ERROR(logger_, "AlertManeuverRequest::Request without parameters!"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + (*message_)[strings::params][strings::connection_key].asUInt()); + + if (NULL == app.get()) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, + "Incoming alert maneuver has contains \\t\\n \\\\t \\\\n" + "text contains only whitespace in ttsChunks"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + //ProcessSoftButtons checks strings on the contents incorrect character + + mobile_apis::Result::eType processing_result = + MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app); + + if (mobile_apis::Result::SUCCESS != processing_result) { + LOG4CXX_ERROR(logger_, "Wrong soft buttons parameters!"); + SendResponse(false, processing_result); + return; + } + + // Checking parameters and how many HMI requests should be sent + bool tts_is_ok = false; + + // check TTSChunk parameter + if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) { + if (0 < (*message_)[strings::msg_params][strings::tts_chunks].length()) { + pending_requests_.Add(hmi_apis::FunctionID::TTS_Speak); + tts_is_ok = true; + } + } + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + msg_params[hmi_request::soft_buttons] = + (*message_)[strings::msg_params][strings::soft_buttons]; + MessageHelper::SubscribeApplicationToSoftButton((*message_)[strings::msg_params], + app, function_id()); + } + + pending_requests_.Add(hmi_apis::FunctionID::Navigation_AlertManeuver); + SendHMIRequest(hmi_apis::FunctionID::Navigation_AlertManeuver, + &msg_params, true); + + if (tts_is_ok) { + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + msg_params[hmi_request::tts_chunks] = + (*message_)[strings::msg_params][strings::tts_chunks]; + + msg_params[strings::app_id] = app->app_id(); + SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, &msg_params, true); + } +} + +void AlertManeuverRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "AlertManeuverRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; + hmi_apis::FunctionID::eType event_id = event.id(); + switch (event_id) { + case hmi_apis::FunctionID::Navigation_AlertManeuver: { + LOG4CXX_INFO(logger_, "Received Navigation_AlertManeuver event"); + + pending_requests_.Remove(event_id); + + navi_alert_maneuver_result_code_ = + static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + break; + } + case hmi_apis::FunctionID::TTS_Speak: { + LOG4CXX_INFO(logger_, "Received TTS_Speak event"); + + pending_requests_.Remove(event_id); + + tts_speak_result_code_ = + static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + break; + } + case hmi_apis::FunctionID::TTS_OnResetTimeout: { + LOG4CXX_INFO(logger_, "Received TTS_OnResetTimeout event"); + + ApplicationManagerImpl::instance()->updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + break; + } + default: { + LOG4CXX_ERROR(logger_,"Received unknown event" << event.id()); + SendResponse(false, result_code, "Received unknown event"); + return; + } + } + + if (pending_requests_.IsFinal(event_id)) { + + bool result = ((hmi_apis::Common_Result::SUCCESS == + static_cast<hmi_apis::Common_Result::eType>(tts_speak_result_code_) || + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == + static_cast<hmi_apis::Common_Result::eType>(tts_speak_result_code_) || + (hmi_apis::Common_Result::INVALID_ENUM == + static_cast<hmi_apis::Common_Result::eType>(tts_speak_result_code_))) && + (hmi_apis::Common_Result::SUCCESS == + static_cast<hmi_apis::Common_Result::eType>(navi_alert_maneuver_result_code_))) || + (hmi_apis::Common_Result::SUCCESS == static_cast<hmi_apis::Common_Result::eType>( + tts_speak_result_code_) && hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == + static_cast<hmi_apis::Common_Result::eType>(navi_alert_maneuver_result_code_)); + + mobile_apis::Result::eType result_code = + static_cast<mobile_apis::Result::eType>(std::max(tts_speak_result_code_, + navi_alert_maneuver_result_code_)); + + const char* return_info = NULL; + + if (result && hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == + static_cast<hmi_apis::Common_Result::eType>(tts_speak_result_code_)) { + result_code = mobile_apis::Result::WARNINGS; + return_info = + std::string("Unsupported phoneme type sent in a prompt").c_str(); + } + + SendResponse(result, result_code, return_info, + &(message[strings::msg_params])); + } else { + LOG4CXX_INFO(logger_, + "There are some pending responses from HMI." + "AlertManeuverRequest still waiting."); + } +} + +bool AlertManeuverRequest::IsWhiteSpaceExist() { + LOG4CXX_INFO(logger_, "AlertManeuverRequest::IsWhiteSpaceExist"); + const char* str = NULL; + + if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) { + const smart_objects::SmartArray* tc_array = + (*message_)[strings::msg_params][strings::tts_chunks].asArray(); + + smart_objects::SmartArray::const_iterator it_tc = tc_array->begin(); + smart_objects::SmartArray::const_iterator it_tc_end = tc_array->end(); + + for (; it_tc != it_tc_end; ++it_tc) { + str = (*it_tc)[strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid tts_chunks syntax check failed"); + return true; + } + } + } + return false; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc b/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc new file mode 100644 index 0000000000..99fcde69a8 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc @@ -0,0 +1,57 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/alert_maneuver_response.h" +#include "application_manager/application_manager_impl.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +AlertManeuverResponse::AlertManeuverResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +AlertManeuverResponse::~AlertManeuverResponse() { +} + +void AlertManeuverResponse::Run() { + LOG4CXX_INFO(logger_, "AlertManeuverResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/alert_request.cc b/src/components/application_manager/src/commands/mobile/alert_request.cc new file mode 100644 index 0000000000..c08b7c32d7 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/alert_request.cc @@ -0,0 +1,415 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/alert_request.h" + +#include <string.h> + +#include "application_manager/message_helper.h" +#include "application_manager/application_impl.h" +#include "application_manager/application_manager_impl.h" + + +namespace application_manager { + +namespace commands { + +namespace smart_objects = NsSmartDeviceLink::NsSmartObjects; + +AlertRequest::AlertRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message), + awaiting_ui_alert_response_(false), + awaiting_tts_speak_response_(false), + awaiting_tts_stop_speaking_response_(false), + response_success_(false), + flag_other_component_sent_(false), + response_result_(mobile_apis::Result::INVALID_ENUM), + tts_speak_response_(mobile_apis::Result::INVALID_ENUM) { + subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); + subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout); +} + +AlertRequest::~AlertRequest() { +} + +bool AlertRequest::Init() { + /* Timeout in milliseconds. + If omitted a standard value of 10000 milliseconds is used.*/ + if ((*message_)[strings::msg_params].keyExists(strings::duration)) { + default_timeout_ = + (*message_)[strings::msg_params][strings::duration].asUInt(); + } else { + const int32_t def_value = 5000; + default_timeout_ = def_value; + } + + // If soft buttons are present, SDL will not use initiate timeout tracking for response. + if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + LOG4CXX_INFO(logger_, "Request contains soft buttons - request timeout " + "will be set to 0."); + default_timeout_ = 0; + } + + return true; +} + +void AlertRequest::Run() { + LOG4CXX_INFO(logger_, "AlertRequest::Run"); + + uint32_t app_id = (*message_)[strings::params][strings::connection_key] + .asInt(); + + if (!Validate(app_id)) { + // Invalid command, abort execution + return; + } + + if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) { + if (0 < (*message_)[strings::msg_params][strings::tts_chunks].length()) { + awaiting_tts_speak_response_ = true; + } + } + SendAlertRequest(app_id); + SendPlayToneNotification(app_id); + if (awaiting_tts_speak_response_) { + SendSpeakRequest(app_id); + } +} + +void AlertRequest::onTimeOut() { + if (false == (*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + CommandRequestImpl::onTimeOut(); + return; + } + LOG4CXX_INFO(logger_, "default timeout ignored. " + "AlertRequest with soft buttons wait timeout on HMI side"); +} + +void AlertRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "AlertRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::TTS_OnResetTimeout: + case hmi_apis::FunctionID::UI_OnResetTimeout: { + LOG4CXX_INFO(logger_, "Received UI_OnResetTimeout event " + " or TTS_OnResetTimeout event" + << awaiting_tts_speak_response_ << " " + << awaiting_tts_stop_speaking_response_ << " " + << awaiting_ui_alert_response_); + ApplicationManagerImpl::instance()->updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + break; + } + case hmi_apis::FunctionID::UI_Alert: { + LOG4CXX_INFO(logger_, "Received UI_Alert event"); + // Unsubscribe from event to avoid unwanted messages + unsubscribe_from_event(hmi_apis::FunctionID::UI_Alert); + awaiting_ui_alert_response_ = false; + + if (awaiting_tts_speak_response_) { + awaiting_tts_stop_speaking_response_ = true; + SendHMIRequest(hmi_apis::FunctionID::TTS_StopSpeaking, NULL, true); + } + + mobile_apis::Result::eType result_code = + static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + // Mobile Alert request is successful when UI_Alert is successful + response_success_ = (mobile_apis::Result::SUCCESS == result_code || + mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code); + response_result_ = result_code; + response_params_ = message[strings::msg_params]; + break; + } + case hmi_apis::FunctionID::TTS_Speak: { + LOG4CXX_INFO(logger_, "Received TTS_Speak event"); + // Unsubscribe from event to avoid unwanted messages + unsubscribe_from_event(hmi_apis::FunctionID::TTS_Speak); + awaiting_tts_speak_response_ = false; + tts_speak_response_ = static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + break; + } + case hmi_apis::FunctionID::TTS_StopSpeaking: { + LOG4CXX_INFO(logger_, "Received TTS_StopSpeaking event"); + // Unsubscribe from event to avoid unwanted messages + unsubscribe_from_event(hmi_apis::FunctionID::TTS_StopSpeaking); + awaiting_tts_stop_speaking_response_ = false; + break; + } + default: { + LOG4CXX_ERROR(logger_,"Received unknown event" << event.id()); + return; + } + } + if (!HasHmiResponsesToWait()) { + std::string response_info(""); + if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == tts_speak_response_) && + (!flag_other_component_sent_)) { + response_success_ = false; + response_result_ = mobile_apis::Result::WARNINGS; + response_info = "Unsupported phoneme type sent in a prompt"; + } else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == + tts_speak_response_) && (mobile_apis::Result::UNSUPPORTED_RESOURCE == + response_result_)) { + response_result_ = mobile_apis::Result::WARNINGS; + response_info = "Unsupported phoneme type sent in a prompt and " + "unsupported image sent in soft buttons"; + } else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == + tts_speak_response_) && (mobile_apis::Result::SUCCESS == + response_result_)) { + response_result_ = mobile_apis::Result::WARNINGS; + response_info = "Unsupported phoneme type sent in a prompt"; + } else if ((mobile_apis::Result::SUCCESS == tts_speak_response_) && + ((mobile_apis::Result::INVALID_ENUM == response_result_) && + (!flag_other_component_sent_))) { + response_result_ = mobile_apis::Result::SUCCESS; + response_success_ = true; + } + + // If timeout is not set, watchdog will not track request timeout and + // HMI is responsible for response returning. In this case, if ABORTED will + // be rerurned from HMI, success should be sent to mobile. + if (mobile_apis::Result::ABORTED == response_result_ && + 0 == default_timeout_) { + response_success_ = true; + } + + if (mobile_apis::Result::ABORTED == tts_speak_response_ && + (!flag_other_component_sent_)) { + response_success_ = false; + response_result_ = tts_speak_response_; + } + + SendResponse(response_success_, response_result_, + response_info.empty() ? NULL : response_info.c_str(), + &response_params_); + } +} + +bool AlertRequest::Validate(uint32_t app_id) { + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); + + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "No application associated with session key"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return false; + } + + if (mobile_apis::HMILevel::HMI_BACKGROUND == app->hmi_level() && + app->IsCommandLimitsExceeded( + static_cast<mobile_apis::FunctionID::eType>(function_id()), + application_manager::TLimitSource::POLICY_TABLE)) { + LOG4CXX_ERROR(logger_, "Alert frequency is too high."); + SendResponse(false, mobile_apis::Result::REJECTED); + return false; + } + + if (!CheckStringsOfAlertRequest()) { + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return false; + } + + //ProcessSoftButtons checks strings on the contents incorrect character + + mobile_apis::Result::eType processing_result = + MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app); + + if (mobile_apis::Result::SUCCESS != processing_result) { + LOG4CXX_ERROR(logger_, "INVALID_DATA!"); + SendResponse(false, processing_result); + return false; + } + + // check if mandatory params(alertText1 and TTSChunk) specified + if ((!(*message_)[strings::msg_params].keyExists(strings::alert_text1)) + && (!(*message_)[strings::msg_params].keyExists(strings::alert_text2)) + && (!(*message_)[strings::msg_params].keyExists(strings::tts_chunks) + && (1 > (*message_)[strings::msg_params] + [strings::tts_chunks].length()))) { + LOG4CXX_ERROR_EXT(logger_, "Mandatory parameters are missing"); + SendResponse(false, mobile_apis::Result::INVALID_DATA, + "Mandatory parameters are missing"); + return false; + } + + return true; +} + +void AlertRequest::SendAlertRequest(int32_t app_id) { + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + msg_params[hmi_request::alert_strings] = smart_objects::SmartObject( + smart_objects::SmartType_Array); + + int32_t index = 0; + if ((*message_)[strings::msg_params].keyExists(strings::alert_text1)) { + msg_params[hmi_request::alert_strings][index][hmi_request::field_name] = + hmi_apis::Common_TextFieldName::alertText1; + msg_params[hmi_request::alert_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::alert_text1]; + index++; + } + if ((*message_)[strings::msg_params].keyExists(strings::alert_text2)) { + msg_params[hmi_request::alert_strings][index][hmi_request::field_name] = + hmi_apis::Common_TextFieldName::alertText2; + msg_params[hmi_request::alert_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::alert_text2]; + index++; + } + if ((*message_)[strings::msg_params].keyExists(strings::alert_text3)) { + msg_params[hmi_request::alert_strings][index][hmi_request::field_name] = + hmi_apis::Common_TextFieldName::alertText3; + msg_params[hmi_request::alert_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::alert_text3]; + } + + // softButtons + if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + msg_params[hmi_request::soft_buttons] = + (*message_)[strings::msg_params][strings::soft_buttons]; + MessageHelper::SubscribeApplicationToSoftButton( + (*message_)[strings::msg_params], app, function_id()); + } + // app_id + msg_params[strings::app_id] = app_id; + msg_params[strings::duration] = default_timeout_; + + // NAVI platform progressIndicator + if ((*message_)[strings::msg_params].keyExists(strings::progress_indicator)) { + msg_params[strings::progress_indicator] = + (*message_)[strings::msg_params][strings::progress_indicator]; + } + + // PASA Alert type + msg_params[strings::alert_type] = hmi_apis::Common_AlertType::UI; + if (awaiting_tts_speak_response_) { + msg_params[strings::alert_type] = hmi_apis::Common_AlertType::BOTH; + } + + // check out if there are alert strings or soft buttons + if (msg_params[hmi_request::alert_strings].length() > 0 || + msg_params.keyExists(hmi_request::soft_buttons)) { + + awaiting_ui_alert_response_ = true; + flag_other_component_sent_ = true; + SendHMIRequest(hmi_apis::FunctionID::UI_Alert, &msg_params, true); + } +} + +void AlertRequest::SendSpeakRequest(int32_t app_id) { + + // crate HMI speak request + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + msg_params[hmi_request::tts_chunks] = smart_objects::SmartObject( + smart_objects::SmartType_Array); + msg_params[hmi_request::tts_chunks] = + (*message_)[strings::msg_params][strings::tts_chunks]; + msg_params[strings::app_id] = app_id; + msg_params[hmi_request::speak_type] = + hmi_apis::Common_SpeakType::ALERT; + SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, &msg_params, true); +} + +void AlertRequest::SendPlayToneNotification(int32_t app_id) { + LOG4CXX_INFO(logger_, "AlertRequest::SendPlayToneNotification"); + + // check playtone parameter + if ((*message_)[strings::msg_params].keyExists(strings::play_tone)) { + if ((*message_)[strings::msg_params][strings::play_tone].asBool()) { + // crate HMI basic communication playtone request + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + CreateHMINotification(hmi_apis::FunctionID::BasicCommunication_PlayTone, + msg_params); + } + } +} + +bool AlertRequest::CheckStringsOfAlertRequest() { + LOG4CXX_INFO(logger_, "AlertRequest::CheckStringsOfAlertRequest"); + const char* str = NULL; + + if ((*message_)[strings::msg_params].keyExists(strings::alert_text1)) { + str = (*message_)[strings::msg_params][strings::alert_text1].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid alert_text_1 syntax check failed"); + return false; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::alert_text2)) { + str = (*message_)[strings::msg_params][strings::alert_text2].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid alert_text_2 syntax check failed"); + return false; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::alert_text3)) { + str = (*message_)[strings::msg_params][strings::alert_text3].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid alert_text_3 syntax check failed"); + return false; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) { + smart_objects::SmartObject& tts_chunks_array = + (*message_)[strings::msg_params][strings::tts_chunks]; + for (size_t i = 0; i < tts_chunks_array.length(); ++i) { + str = tts_chunks_array[i][strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid tts_chunks text syntax check failed"); + return false; + } + } + } + return true; +} + +bool AlertRequest::HasHmiResponsesToWait() { + return awaiting_ui_alert_response_ || awaiting_tts_speak_response_ + || awaiting_tts_stop_speaking_response_; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/alert_response.cc b/src/components/application_manager/src/commands/mobile/alert_response.cc new file mode 100644 index 0000000000..5b8cd6557b --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/alert_response.cc @@ -0,0 +1,59 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/alert_response.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +AlertResponse::AlertResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +AlertResponse::~AlertResponse() { +} + +void AlertResponse::Run() { + LOG4CXX_INFO(logger_, "AlertResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/change_registration_request.cc b/src/components/application_manager/src/commands/mobile/change_registration_request.cc new file mode 100644 index 0000000000..9780aad7bb --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/change_registration_request.cc @@ -0,0 +1,433 @@ +/* + + Copyright (c) 2013, 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 <string.h> +#include <algorithm> +#include "application_manager/commands/mobile/change_registration_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +ChangeRegistrationRequest::ChangeRegistrationRequest( + const MessageSharedPtr& message) + : CommandRequestImpl(message), + ui_result_(hmi_apis::Common_Result::INVALID_ENUM), + vr_result_(hmi_apis::Common_Result::INVALID_ENUM), + tts_result_(hmi_apis::Common_Result::INVALID_ENUM) { +} + +ChangeRegistrationRequest::~ChangeRegistrationRequest() { +} + +void ChangeRegistrationRequest::Run() { + LOG4CXX_INFO(logger_, "ChangeRegistrationRequest::Run"); + + ApplicationManagerImpl* instance = ApplicationManagerImpl::instance(); + const HMICapabilities& hmi_capabilities = instance->hmi_capabilities(); + + ApplicationSharedPtr app = instance->application(connection_key()); + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_INFO(logger_, + "Incoming request contains \t\n \\t \\n or whitespace"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if (mobile_apis::Result::SUCCESS != CheckCoincidence()) { + SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); + return; + } + + if (!hmi_capabilities.is_ui_cooperating()) { + ui_result_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + } + + if (!hmi_capabilities.is_vr_cooperating()) { + vr_result_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + } + + if (!hmi_capabilities.is_tts_cooperating()) { + tts_result_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + } + + const int32_t hmi_language = + (*message_)[strings::msg_params][strings::hmi_display_language].asInt(); + + const int32_t language = + (*message_)[strings::msg_params][strings::language].asInt(); + + if (false == + (IsLanguageSupportedByUI(hmi_language) && + IsLanguageSupportedByVR(language) && + IsLanguageSupportedByTTS(language))) { + LOG4CXX_ERROR(logger_, "Language is not supported"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + pending_requests_.Add(hmi_apis::FunctionID::UI_ChangeRegistration); + pending_requests_.Add(hmi_apis::FunctionID::VR_ChangeRegistration); + pending_requests_.Add(hmi_apis::FunctionID::TTS_ChangeRegistration); + + // UI processing + smart_objects::SmartObject ui_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + ui_params[strings::language] = hmi_language; + ui_params[strings::app_id] = app->app_id(); + if ((*message_)[strings::msg_params].keyExists(strings::app_name)) { + ui_params[strings::app_name] = + (*message_)[strings::msg_params][strings::app_name]; + app->set_name((*message_)[strings::msg_params][strings::app_name].asString()); + } + if ((*message_)[strings::msg_params].keyExists( + strings::ngn_media_screen_app_name)) { + ui_params[strings::ngn_media_screen_app_name] = + (*message_)[strings::msg_params][strings::ngn_media_screen_app_name]; + app->set_ngn_media_screen_name((*message_)[strings::msg_params] + [strings::ngn_media_screen_app_name]); + } + + SendHMIRequest(hmi_apis::FunctionID::UI_ChangeRegistration, + &ui_params, true); + + // VR processing + smart_objects::SmartObject vr_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + vr_params[strings::language] = + (*message_)[strings::msg_params][strings::language]; + + vr_params[strings::app_id] = app->app_id(); + if ((*message_)[strings::msg_params].keyExists(strings::vr_synonyms)) { + vr_params[strings::vr_synonyms] = (*message_)[strings::msg_params] + [strings::vr_synonyms]; + app -> set_vr_synonyms((*message_)[strings::msg_params][strings::vr_synonyms]); + } + SendHMIRequest(hmi_apis::FunctionID::VR_ChangeRegistration, + &vr_params, true); + + // TTS processing + smart_objects::SmartObject tts_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + tts_params[strings::language] = + (*message_)[strings::msg_params][strings::language]; + + tts_params[strings::app_id] = app->app_id(); + if ((*message_)[strings::msg_params].keyExists(strings::tts_name)) { + tts_params[strings::tts_name] = (*message_)[strings::msg_params] + [strings::tts_name]; + app->set_tts_name((*message_)[strings::msg_params][strings::tts_name]); + } + + SendHMIRequest(hmi_apis::FunctionID::TTS_ChangeRegistration, + &tts_params, true); +} + +bool ChangeRegistrationRequest::WasAnySuccess( + const hmi_apis::Common_Result::eType ui, + const hmi_apis::Common_Result::eType vr, + const hmi_apis::Common_Result::eType tts) { + + return + hmi_apis::Common_Result::SUCCESS == ui || + hmi_apis::Common_Result::SUCCESS == vr || + hmi_apis::Common_Result::SUCCESS == tts; +} + +void ChangeRegistrationRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "ChangeRegistrationRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + hmi_apis::FunctionID::eType event_id = event.id(); + + switch (event_id) { + case hmi_apis::FunctionID::UI_ChangeRegistration: { + LOG4CXX_INFO(logger_, "Received UI_ChangeRegistration event"); + pending_requests_.Remove(event_id); + ui_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + break; + } + case hmi_apis::FunctionID::VR_ChangeRegistration: { + LOG4CXX_INFO(logger_, "Received VR_ChangeRegistration event"); + pending_requests_.Remove(event_id); + vr_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + break; + } + case hmi_apis::FunctionID::TTS_ChangeRegistration: { + LOG4CXX_INFO(logger_, "Received TTS_ChangeRegistration event"); + pending_requests_.Remove(event_id); + tts_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event_id); + return; + } + } + + if (pending_requests_.IsFinal(event_id)) { + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + if (hmi_apis::Common_Result::SUCCESS == ui_result_) { + application->set_ui_language(static_cast<mobile_api::Language::eType>( + (*message_)[strings::msg_params][strings::hmi_display_language].asInt())); + } + + if (hmi_apis::Common_Result::SUCCESS == vr_result_ + || hmi_apis::Common_Result::SUCCESS == tts_result_) { + application->set_language(static_cast<mobile_api::Language::eType>( + (*message_)[strings::msg_params][strings::language].asInt())); + } + + int32_t greates_result_code = std::max(std::max(ui_result_, vr_result_), + tts_result_); + + (*message_)[strings::params][strings::function_id] = + mobile_apis::FunctionID::eType::ChangeRegistrationID; + + SendResponse(WasAnySuccess(ui_result_, vr_result_, tts_result_), + static_cast<mobile_apis::Result::eType>(greates_result_code), + NULL, &(message[strings::msg_params])); + } else { + LOG4CXX_INFO(logger_, + "There are some pending responses from HMI." + "ChangeRegistrationRequest still waiting."); + } +} + +bool ChangeRegistrationRequest::IsLanguageSupportedByUI( + const int32_t& hmi_display_lang) { + + const HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + const smart_objects::SmartObject* ui_languages = + hmi_capabilities.ui_supported_languages(); + + if (!ui_languages) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return false; + } + + for (size_t i = 0; i < ui_languages->length(); ++i) { + if (hmi_display_lang == ui_languages->getElement(i).asInt()) { + return true; + } + } + + LOG4CXX_ERROR(logger_, "Language isn't supported by UI"); + + return false; +} + +bool ChangeRegistrationRequest::IsLanguageSupportedByVR( + const int32_t& hmi_display_lang) { + const HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + const smart_objects::SmartObject* vr_languages = + hmi_capabilities.vr_supported_languages(); + + if (!vr_languages) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return false; + } + + for (size_t i = 0; i < vr_languages->length(); ++i) { + if (hmi_display_lang == vr_languages->getElement(i).asInt()) { + return true; + } + } + + LOG4CXX_ERROR(logger_, "Language isn't supported by VR"); + + return false; +} + +bool ChangeRegistrationRequest::IsLanguageSupportedByTTS( + const int32_t& hmi_display_lang) { + const HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + const smart_objects::SmartObject* tts_languages = + hmi_capabilities.tts_supported_languages(); + + if (!tts_languages) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return false; + } + + for (size_t i = 0; i < tts_languages->length(); ++i) { + if (hmi_display_lang == tts_languages->getElement(i).asInt()) { + return true; + break; + } + } + + LOG4CXX_ERROR(logger_, "Language isn't supported by TTS"); + return false; +} + +bool ChangeRegistrationRequest::IsWhiteSpaceExist() { + const char* str = NULL; + + if ((*message_)[strings::msg_params].keyExists(strings::app_name)) { + str = (*message_)[strings::msg_params][strings::app_name].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid app_name syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::tts_name)) { + const smart_objects::SmartArray* tn_array = + (*message_)[strings::msg_params][strings::tts_name].asArray(); + + smart_objects::SmartArray::const_iterator it_tn = tn_array->begin(); + smart_objects::SmartArray::const_iterator it_tn_end = tn_array->end(); + + for (; it_tn != it_tn_end; ++it_tn) { + str = (*it_tn)[strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid tts_name syntax check failed"); + return true; + } + } + } + + if ((*message_)[strings::msg_params]. + keyExists(strings::ngn_media_screen_app_name)) { + str = (*message_)[strings::msg_params] + [strings::ngn_media_screen_app_name].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid ngn_media_screen_app_name syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::vr_synonyms)) { + const smart_objects::SmartArray* vs_array = + (*message_)[strings::msg_params][strings::vr_synonyms].asArray(); + + smart_objects::SmartArray::const_iterator it_vs = vs_array->begin(); + smart_objects::SmartArray::const_iterator it_vs_end = vs_array->end(); + + for (; it_vs != it_vs_end; ++it_vs) { + str = (*it_vs).asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid vr_synonyms syntax check failed"); + return true; + } + } + } + return false; +} + +mobile_apis::Result::eType ChangeRegistrationRequest::CheckCoincidence() { + LOG4CXX_INFO(logger_, "ChangeRegistrationRequest::CheckCoincidence"); + + 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(); + std::string app_name; + uint32_t app_id = connection_key(); + if (msg_params.keyExists(strings::app_name)) { + app_name = msg_params[strings::app_name].asString(); + } + + for (; applications.end() != it; ++it) { + if (app_id == (*it)->app_id()) { + continue; + } + + const std::string& cur_name = (*it)->name(); + if (msg_params.keyExists(strings::app_name)) { + if (!strcasecmp(app_name.c_str(), cur_name.c_str())) { + LOG4CXX_ERROR(logger_, "Application name is known already."); + return mobile_apis::Result::DUPLICATE_NAME; + } + + const smart_objects::SmartObject* vr = (*it)->vr_synonyms(); + const std::vector<smart_objects::SmartObject>* curr_vr = NULL; + if (NULL != vr) { + curr_vr = vr->asArray(); + CoincidencePredicateVR v(app_name); + + if (0 != std::count_if(curr_vr->begin(), curr_vr->end(), v)) { + LOG4CXX_ERROR(logger_, "Application name is known already."); + return mobile_apis::Result::DUPLICATE_NAME; + } + } + } + + // vr check + if (msg_params.keyExists(strings::vr_synonyms)) { + const std::vector<smart_objects::SmartObject>* new_vr = + msg_params[strings::vr_synonyms].asArray(); + + CoincidencePredicateVR v(cur_name); + if (0 != std::count_if(new_vr->begin(), new_vr->end(), v)) { + LOG4CXX_ERROR(logger_, "vr_synonyms duplicated with app_name ."); + return mobile_apis::Result::DUPLICATE_NAME; + } + } // end vr check + } // application for end + return mobile_apis::Result::SUCCESS; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/change_registration_response.cc b/src/components/application_manager/src/commands/mobile/change_registration_response.cc new file mode 100644 index 0000000000..13c926ec82 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/change_registration_response.cc @@ -0,0 +1,57 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/change_registration_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +ChangeRegistrationResponse::ChangeRegistrationResponse( + const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +ChangeRegistrationResponse::~ChangeRegistrationResponse() { +} + +void ChangeRegistrationResponse::Run() { + LOG4CXX_INFO(logger_, "ChangeRegistrationResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc new file mode 100644 index 0000000000..583f0a0460 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc @@ -0,0 +1,343 @@ +/* + + Copyright (c) 2013, 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 <string.h> +#include <string> +#include <algorithm> +#include <vector> +#include "application_manager/commands/mobile/create_interaction_choice_set_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" + +namespace application_manager { + +namespace commands { + +CreateInteractionChoiceSetRequest::CreateInteractionChoiceSetRequest( + const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +CreateInteractionChoiceSetRequest::~CreateInteractionChoiceSetRequest() { +} + +void CreateInteractionChoiceSetRequest::Run() { + LOG4CXX_INFO(logger_, "CreateInteractionChoiceSetRequest::Run"); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + (*message_)[strings::params][strings::connection_key].asUInt()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + for (uint32_t i = 0; + i < (*message_)[strings::msg_params][strings::choice_set].length(); + ++i) { + mobile_apis::Result::eType verification_result_image = + mobile_apis::Result::SUCCESS; + mobile_apis::Result::eType verification_result_secondary_image = + mobile_apis::Result::SUCCESS; + if ((*message_)[strings::msg_params] + [strings::choice_set][i].keyExists(strings::image)) { + verification_result_image = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::choice_set] + [i][strings::image], app); + } + if ((*message_)[strings::msg_params] + [strings::choice_set][i].keyExists(strings::secondary_image)) { + verification_result_secondary_image = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::choice_set] + [i][strings::secondary_image], app); + } + if (verification_result_image == mobile_apis::Result::INVALID_DATA || + verification_result_secondary_image == mobile_apis::Result::INVALID_DATA) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } + + const int32_t choice_set_id = (*message_)[strings::msg_params] + [strings::interaction_choice_set_id].asInt(); + + if (app->FindChoiceSet(choice_set_id)) { + LOG4CXX_ERROR(logger_, "Invalid ID"); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + + mobile_apis::Result::eType result = CheckChoiceSet(app); + if (mobile_apis::Result::SUCCESS != result) { + SendResponse(false, result); + return; + } + uint32_t grammar_id = ApplicationManagerImpl::instance()->GenerateGrammarID(); + (*message_)[strings::msg_params][strings::grammar_id] = grammar_id; + app->AddChoiceSet(choice_set_id, (*message_)[strings::msg_params]); + SendVRAddCommandRequest(app); + SendResponse(true, mobile_apis::Result::SUCCESS); + app->UpdateHash(); +} + +mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( + ApplicationConstSharedPtr app) { + LOG4CXX_INFO(logger_, "CreateInteractionChoiceSetRequest::CheckChoiceSet"); + + const smart_objects::SmartArray* new_choice_set_array = + (*message_)[strings::msg_params][strings::choice_set].asArray(); + + smart_objects::SmartArray::const_iterator it_array = + new_choice_set_array->begin(); + + smart_objects::SmartArray::const_iterator it_array_end = + new_choice_set_array->end(); + + // Self check of new choice set for params coincidence + for (; it_array != it_array_end; ++it_array) { + const smart_objects::SmartArray* vr_array = + (*it_array)[strings::vr_commands].asArray(); + + CoincidencePredicateChoiceID c((*it_array)[strings::choice_id].asInt()); + if (1 != std::count_if( + new_choice_set_array->begin(), + new_choice_set_array->end(), + c)) { + + LOG4CXX_ERROR(logger_, "Incoming choice set has duplicate IDs."); + return mobile_apis::Result::INVALID_ID; + } + + // Check new choice set params along with already registered choice sets + const ChoiceSetMap& app_choice_set_map = app->choice_set_map(); + ChoiceSetMap::const_iterator it = app_choice_set_map.begin(); + ChoiceSetMap::const_iterator itEnd = app_choice_set_map.end(); + for (; it != itEnd; ++it) { + const smart_objects::SmartObject* app_choice_set = it->second; + if (NULL != app_choice_set) { + + const smart_objects::SmartArray* curr_choice_set = + (*app_choice_set)[strings::choice_set].asArray(); + + if (0 != std::count_if( + curr_choice_set->begin(), + curr_choice_set->end(), + c)) { + LOG4CXX_ERROR(logger_, "Incoming choice ID already exists."); + return mobile_apis::Result::INVALID_ID; + } + } + } + + CoincidencePredicateMenuName m((*it_array)[strings::menu_name].asString()); + if (1 != std::count_if( + new_choice_set_array->begin(), + new_choice_set_array->end(), + m)) { + + LOG4CXX_ERROR(logger_, "Incoming choice set has duplicate menu names."); + return mobile_apis::Result::DUPLICATE_NAME; + } + + // Check coincidence inside the current choice + + smart_objects::SmartArray::const_iterator it_vr = vr_array->begin(); + smart_objects::SmartArray::const_iterator it_vr_end = vr_array->end(); + + for (; it_vr != it_vr_end; ++it_vr) { + CoincidencePredicateVRCommands v((*it_vr)); + if (1 != std::count_if(vr_array->begin(), vr_array->end(), v)) { + + LOG4CXX_ERROR(logger_, + "Incoming choice set has duplicate VR command(s)"); + + return mobile_apis::Result::DUPLICATE_NAME; + } + } + + // Check along with VR commands in other choices in the new set + smart_objects::SmartArray::const_iterator it_same_array = + new_choice_set_array->begin(); + + smart_objects::SmartArray::const_iterator it_same_array_end = + new_choice_set_array->end(); + + for (; it_same_array != it_same_array_end; ++it_same_array) { + + // Skip check for itself + if ((*it_array)[strings::choice_id] == + (*it_same_array)[strings::choice_id]) { + + continue; + } + + if (compareSynonyms((*it_array), (*it_same_array))) { + + LOG4CXX_ERROR(logger_, + "Incoming choice set has duplicate VR command(s)."); + + return mobile_apis::Result::DUPLICATE_NAME; + } + } + + if (IsWhiteSpaceExist((*it_array))) { + LOG4CXX_ERROR(logger_, + "Incoming choice set has contains \t\n \\t \\n"); + return mobile_apis::Result::INVALID_DATA; + } + } + + return mobile_apis::Result::SUCCESS; +} + +bool CreateInteractionChoiceSetRequest::compareSynonyms( + const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice1, + const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice2) { + + smart_objects::SmartArray* vr_cmds_1 = + choice1[strings::vr_commands].asArray(); + DCHECK(vr_cmds_1 != NULL); + smart_objects::SmartArray* vr_cmds_2 = + choice2[strings::vr_commands].asArray(); + DCHECK(vr_cmds_2 != NULL); + + smart_objects::SmartArray::iterator it; + it = std::find_first_of(vr_cmds_1->begin(), vr_cmds_1->end(), + vr_cmds_2->begin(), vr_cmds_2->end(), + CreateInteractionChoiceSetRequest::compareStr); + + + if (it != vr_cmds_1->end()) { + LOG4CXX_INFO(logger_, "Incoming choice set has duplicated VR synonyms " + << it->asString()); + return true; + } + + return false; +} + +bool CreateInteractionChoiceSetRequest::compareStr( + const NsSmartDeviceLink::NsSmartObjects::SmartObject& str1, + const NsSmartDeviceLink::NsSmartObjects::SmartObject& str2) { + + return 0 == strcasecmp(str1.asCharArray(), str2.asCharArray()); +} + +bool CreateInteractionChoiceSetRequest::IsWhiteSpaceExist( + const smart_objects::SmartObject& choice_set) { + LOG4CXX_INFO(logger_, "CreateInteractionChoiceSetRequest::IsWhiteSpaceExist"); + const char* str = NULL; + + str = choice_set[strings::menu_name].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid menu_name syntax check failed"); + return true; + } + + if (choice_set.keyExists(strings::secondary_text)) { + str = choice_set[strings::secondary_text].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid secondary_text syntax check failed"); + return true; + } + } + + if (choice_set.keyExists(strings::tertiary_text)) { + str = choice_set[strings::tertiary_text].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid tertiary_text syntax check failed"); + return true; + } + } + + if (choice_set.keyExists(strings::vr_commands)) { + const size_t len = + choice_set[strings::vr_commands].length(); + + for (size_t i = 0; i < len; ++i) { + str = choice_set[strings::vr_commands][i].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid vr_commands syntax check failed"); + return true; + } + } + } + + if (choice_set.keyExists(strings::image)) { + str = choice_set[strings::image][strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid image value syntax check failed"); + return true; + } + } + + if (choice_set.keyExists(strings::secondary_image)) { + str = choice_set[strings::secondary_image][strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid secondary_image value syntax check failed"); + return true; + } + } + return false; +} + +void CreateInteractionChoiceSetRequest::SendVRAddCommandRequest( + application_manager::ApplicationSharedPtr const app) { + + smart_objects::SmartObject* choice_set = &(*message_)[strings::msg_params]; + + for (size_t j = 0; j < (*choice_set)[strings::choice_set].length(); ++j) { + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + msg_params[strings::app_id] = app->app_id(); + msg_params[strings::cmd_id] = + (*choice_set)[strings::choice_set][j][strings::choice_id]; + msg_params[strings::vr_commands] = smart_objects::SmartObject( + smart_objects::SmartType_Array); + msg_params[strings::vr_commands] = + (*choice_set)[strings::choice_set][j][strings::vr_commands]; + + msg_params[strings::type] = hmi_apis::Common_VRCommandType::Choice; + msg_params[strings::grammar_id] = (*choice_set)[strings::grammar_id]; + + SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &msg_params); + } + +} + + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_response.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_response.cc new file mode 100644 index 0000000000..8d6ea1b348 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_response.cc @@ -0,0 +1,68 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/create_interaction_choice_set_response.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +CreateInteractionChoiceSetResponse::CreateInteractionChoiceSetResponse( + const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +CreateInteractionChoiceSetResponse::~CreateInteractionChoiceSetResponse() { +} + +void CreateInteractionChoiceSetResponse::Run() { + LOG4CXX_INFO(logger_, "CreateInteractionChoiceSetResponse::Run"); + + // check if response false + if (true == (*message_)[strings::msg_params].keyExists(strings::success)) { + if ((*message_)[strings::msg_params][strings::success].asBool() == false) { + LOG4CXX_ERROR(logger_, "Success = false"); + SendResponse(false); + return; + } + } + + SendResponse(true); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/delete_command_request.cc b/src/components/application_manager/src/commands/mobile/delete_command_request.cc new file mode 100644 index 0000000000..3c3ee88203 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/delete_command_request.cc @@ -0,0 +1,183 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/delete_command_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +DeleteCommandRequest::DeleteCommandRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message), + is_ui_send_(false), + is_vr_send_(false), + is_ui_received_(false), + is_vr_received_(false), + ui_result_(hmi_apis::Common_Result::INVALID_ENUM), + vr_result_(hmi_apis::Common_Result::INVALID_ENUM) { +} + +DeleteCommandRequest::~DeleteCommandRequest() { +} + +void DeleteCommandRequest::Run() { + LOG4CXX_INFO(logger_, "DeleteCommandRequest::Run"); + + ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application( + (*message_)[strings::params][strings::connection_key].asUInt()); + + if (!application) { + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + LOG4CXX_ERROR(logger_, "Application is not registered"); + return; + } + + smart_objects::SmartObject* command = application->FindCommand( + (*message_)[strings::msg_params][strings::cmd_id].asInt()); + + if (!command) { + SendResponse(false, mobile_apis::Result::INVALID_ID); + LOG4CXX_ERROR(logger_, "Invalid ID"); + return; + } + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + msg_params[strings::cmd_id] = + (*message_)[strings::msg_params][strings::cmd_id]; + msg_params[strings::app_id] = application->app_id(); + + // we should specify amount of required responses in the 1st request + uint32_t chaining_counter = 0; + if ((*command).keyExists(strings::menu_params)) { + ++chaining_counter; + } + + if ((*command).keyExists(strings::vr_commands)) { + ++chaining_counter; + } + + if ((*command).keyExists(strings::menu_params)) { + is_ui_send_ = true; + + SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params, true); + } + // check vr params + if ((*command).keyExists(strings::vr_commands)) { + is_vr_send_ = true; + + // VR params + msg_params[strings::grammar_id] = application->get_grammar_id(); + msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; + SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params, true); + } +} + +void DeleteCommandRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "DeleteCommandRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_DeleteCommand: { + LOG4CXX_INFO(logger_, "Received UI_DeleteCommand event"); + is_ui_received_ = true; + ui_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + break; + } + case hmi_apis::FunctionID::VR_DeleteCommand: { + LOG4CXX_INFO(logger_, "Received VR_DeleteCommand event"); + is_vr_received_ = true; + vr_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + break; + } + default: { + LOG4CXX_ERROR(logger_,"Received unknown event" << event.id()); + return; + } + } + + if (!IsPendingResponseExist()) { + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + smart_objects::SmartObject* command = application->FindCommand( + (*message_)[strings::msg_params][strings::cmd_id].asInt()); + + if (command) { + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; + + bool result = ((hmi_apis::Common_Result::SUCCESS == ui_result_) && + (hmi_apis::Common_Result::SUCCESS == vr_result_)) || + ((hmi_apis::Common_Result::SUCCESS == ui_result_) && + (hmi_apis::Common_Result::INVALID_ENUM == vr_result_)) || + ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_) && + (hmi_apis::Common_Result::SUCCESS == vr_result_)); + + if (result) { + application->RemoveCommand( + (*message_)[strings::msg_params][strings::cmd_id].asInt()); + } + + if (!result && (hmi_apis::Common_Result::REJECTED == ui_result_)) { + result_code = static_cast<mobile_apis::Result::eType>(vr_result_); + } else { + result_code = static_cast<mobile_apis::Result::eType>( + std::max(ui_result_, vr_result_)); + } + + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + } + } +} + +bool DeleteCommandRequest::IsPendingResponseExist() { + return is_ui_send_ != is_ui_received_ || is_vr_send_ != is_vr_received_; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/delete_command_response.cc b/src/components/application_manager/src/commands/mobile/delete_command_response.cc new file mode 100644 index 0000000000..812e587430 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/delete_command_response.cc @@ -0,0 +1,56 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/delete_command_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +DeleteCommandResponse::DeleteCommandResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +DeleteCommandResponse::~DeleteCommandResponse() { +} + +void DeleteCommandResponse::Run() { + LOG4CXX_INFO(logger_, "DeleteCommandResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/delete_file_request.cc b/src/components/application_manager/src/commands/mobile/delete_file_request.cc new file mode 100644 index 0000000000..ca5a4395fc --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/delete_file_request.cc @@ -0,0 +1,115 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/delete_file_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "config_profile/profile.h" +#include "utils/file_system.h" + +namespace application_manager { + +namespace commands { + +DeleteFileRequest::DeleteFileRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +DeleteFileRequest::~DeleteFileRequest() { +} + +void DeleteFileRequest::Run() { + LOG4CXX_INFO(logger_, "DeleteFileRequest::Run"); + + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!application) { + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + LOG4CXX_ERROR(logger_, "Application is not registered"); + return; + } + + if ((mobile_api::HMILevel::HMI_NONE == application->hmi_level()) && + (profile::Profile::instance()->delete_file_in_none() <= + application->delete_file_in_none_count())) { + // If application is in the HMI_NONE level the quantity of allowed + // DeleteFile request is limited by the configuration profile + LOG4CXX_ERROR(logger_, "Too many requests from the app with HMILevel HMI_NONE "); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + const std::string& sync_file_name = + (*message_)[strings::msg_params][strings::sync_file_name].asString(); + + std::string full_file_path = + profile::Profile::instance()->app_storage_folder() + "/"; + full_file_path += application->folder_name(); + full_file_path += "/"; + full_file_path += sync_file_name; + + if (file_system::FileExists(full_file_path)) { + if (file_system::DeleteFile(full_file_path)) { + const AppFile* file = application->GetFile(full_file_path); + if (file) { + SendFileRemovedNotification(file); + } + + application->DeleteFile(full_file_path); + application->increment_delete_file_in_none_count(); + SendResponse(true, mobile_apis::Result::SUCCESS); + } else { + SendResponse(false, mobile_apis::Result::GENERIC_ERROR); + } + } else { + SendResponse(false, mobile_apis::Result::INVALID_DATA); + } +} + +void DeleteFileRequest::SendFileRemovedNotification( + const AppFile* file) const { + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + msg_params[strings::app_id] = connection_key(); + msg_params[strings::file_name] = file->file_name; + msg_params[strings::file_type] = file->file_type; + + CreateHMINotification( + hmi_apis::FunctionID::BasicCommunication_OnFileRemoved, msg_params); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/delete_file_response.cc b/src/components/application_manager/src/commands/mobile/delete_file_response.cc new file mode 100644 index 0000000000..81470ccf6b --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/delete_file_response.cc @@ -0,0 +1,69 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/delete_file_response.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" + +namespace application_manager { + +namespace commands { + +DeleteFileResponse::DeleteFileResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +DeleteFileResponse::~DeleteFileResponse() { +} + +void DeleteFileResponse::Run() { + LOG4CXX_INFO(logger_, "DeleteFileResponse::Run"); + uint32_t app_id = (*message_)[strings::params][strings::connection_key] + .asUInt(); + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->application(app_id); + if (!app) { + LOG4CXX_ERROR(logger_, "Application not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + (*message_)[strings::msg_params][strings::space_available] = + static_cast<int32_t>( + ApplicationManagerImpl::instance()->GetAvailableSpaceForApp(app->name())); + SendResponse((*message_)[strings::msg_params][strings::success].asBool()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc new file mode 100644 index 0000000000..1fcd4b33d8 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc @@ -0,0 +1,138 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/delete_interaction_choice_set_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" +#include "application_manager/message_helper.h" +namespace application_manager { + +namespace commands { + +DeleteInteractionChoiceSetRequest::DeleteInteractionChoiceSetRequest( + const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +DeleteInteractionChoiceSetRequest::~DeleteInteractionChoiceSetRequest() { +} + +void DeleteInteractionChoiceSetRequest::Run() { + LOG4CXX_INFO(logger_, "DeleteInteractionChoiceSetRequest::Run"); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + (*message_)[strings::params][strings::connection_key].asUInt()); + + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "No application associated with session key"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + const int32_t choise_set_id = + (*message_)[strings::msg_params] + [strings::interaction_choice_set_id].asInt(); + + if (!app->FindChoiceSet(choise_set_id)) { + LOG4CXX_ERROR_EXT(logger_, "INVALID_ID"); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + + if (ChoiceSetInUse(app)) { + LOG4CXX_ERROR_EXT(logger_, "Choice set currently in use"); + SendResponse(false, mobile_apis::Result::IN_USE); + return; + } + SendVrDeleteCommand(app); + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + msg_params[strings::interaction_choice_set_id] = choise_set_id; + msg_params[strings::app_id] = app->app_id(); + + app->RemoveChoiceSet(choise_set_id); + + SendResponse(true, mobile_apis::Result::SUCCESS); + /*CreateHMIRequest(hmi_apis::FunctionID::UI_DeleteInteractionChoiceSet, + msg_params, true);*/ +} + +bool DeleteInteractionChoiceSetRequest::ChoiceSetInUse(ApplicationConstSharedPtr app) { + if (app->is_perform_interaction_active()) { + // retrieve stored choice sets for perform interaction + const PerformChoiceSetMap& choice_set_map = app + ->performinteraction_choice_set_map(); + + PerformChoiceSetMap::const_iterator it = choice_set_map.begin(); + for (; choice_set_map.end() != it; ++it) { + if (it->first + == (*message_)[strings::msg_params] + [strings::interaction_choice_set_id].asUInt()) { + LOG4CXX_ERROR_EXT(logger_, + "DeleteInteractionChoiceSetRequest::ChoiceSetInUse"); + return true; + } + } + } + return false; +} + +void DeleteInteractionChoiceSetRequest::SendVrDeleteCommand( + application_manager::ApplicationSharedPtr app) { + LOG4CXX_INFO(logger_, "PerformInteractionRequest::SendVrDeleteCommand"); + + smart_objects::SmartObject* choice_set = + app->FindChoiceSet((*message_)[strings::msg_params] + [strings::interaction_choice_set_id].asInt()); + + if (choice_set) { + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + msg_params[strings::app_id] = app->app_id(); + msg_params[strings::type] = hmi_apis::Common_VRCommandType::Choice; + msg_params[strings::grammar_id] = (*choice_set)[strings::grammar_id]; + choice_set = &((*choice_set)[strings::choice_set]); + for (uint32_t i = 0; i < (*choice_set).length() ; ++i) { + msg_params[strings::cmd_id] = (*choice_set)[i][strings::choice_id]; + SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params); + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_response.cc b/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_response.cc new file mode 100644 index 0000000000..d260add7cc --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_response.cc @@ -0,0 +1,77 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/delete_interaction_choice_set_response.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +DeleteInteractionChoiceSetResponse::DeleteInteractionChoiceSetResponse( + const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +DeleteInteractionChoiceSetResponse::~DeleteInteractionChoiceSetResponse() { +} + +void DeleteInteractionChoiceSetResponse::Run() { + LOG4CXX_INFO(logger_, "DeleteInteractionChoiceSetResponse::Run"); + + // check if response false + if (true == (*message_)[strings::msg_params].keyExists(strings::success)) { + if ((*message_)[strings::msg_params][strings::success].asBool() == false) { + LOG4CXX_ERROR(logger_, "Success = false"); + SendResponse(false); + return; + } + } + + const int32_t code = + (*message_)[strings::msg_params][strings::result_code].asInt(); + + if (hmi_apis::Common_Result::SUCCESS == code) { + SendResponse(true); + } else { + // TODO(DK): Some logic + SendResponse(false); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc b/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc new file mode 100644 index 0000000000..d91e742687 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc @@ -0,0 +1,179 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/delete_sub_menu_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +DeleteSubMenuRequest::DeleteSubMenuRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +DeleteSubMenuRequest::~DeleteSubMenuRequest() { +} + +void DeleteSubMenuRequest::Run() { + LOG4CXX_INFO(logger_, "DeleteSubMenuRequest::Run"); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + (*message_)[strings::params][strings::connection_key].asUInt()); + + if (!app) { + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + LOG4CXX_ERROR(logger_, "Application is not registered"); + return; + } + + if (!app->FindSubMenu( + (*message_)[strings::msg_params][strings::menu_id].asInt())) { + SendResponse(false, mobile_apis::Result::INVALID_ID); + LOG4CXX_ERROR(logger_, "Invalid ID"); + return; + } + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + msg_params[strings::menu_id] = + (*message_)[strings::msg_params][strings::menu_id]; + msg_params[strings::app_id] = app->app_id(); + + SendHMIRequest(hmi_apis::FunctionID::UI_DeleteSubMenu, &msg_params, true); +} + +void DeleteSubMenuRequest::DeleteSubMenuVRCommands(ApplicationConstSharedPtr app) { + LOG4CXX_INFO(logger_, "DeleteSubMenuRequest::DeleteSubMenuVRCommands"); + + const CommandsMap& commands = app->commands_map(); + CommandsMap::const_iterator it = commands.begin(); + + for (; commands.end() != it; ++it) { + + if (!(*it->second).keyExists(strings::vr_commands)) { + continue; + } + + if ((*message_)[strings::msg_params][strings::menu_id].asInt() + == (*it->second)[strings::menu_params] + [hmi_request::parent_id].asInt()) { + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + msg_params[strings::cmd_id] = (*it->second)[strings::cmd_id].asInt(); + msg_params[strings::app_id] = app->app_id(); + msg_params[strings::grammar_id] = app->get_grammar_id(); + msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; + + SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params); + } + } +} + +void DeleteSubMenuRequest::DeleteSubMenuUICommands(ApplicationSharedPtr const app) { + LOG4CXX_INFO(logger_, "DeleteSubMenuRequest::DeleteSubMenuUICommands"); + + const CommandsMap& commands = app->commands_map(); + CommandsMap::const_iterator it = commands.begin(); + + while (commands.end() != it) { + + if (!(*it->second).keyExists(strings::menu_params)) { + continue; + } + + if ((*message_)[strings::msg_params][strings::menu_id].asInt() + == (*it->second)[strings::menu_params] + [hmi_request::parent_id].asInt()) { + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + msg_params[strings::app_id] = app->app_id(); + msg_params[strings::cmd_id] = (*it->second)[strings::cmd_id].asInt(); + + app->RemoveCommand((*it->second)[strings::cmd_id].asInt()); + + it = commands.begin(); // Can not relay on + // iterators after erase was called + + SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params); + } else { + ++it; + } + } +} + +void DeleteSubMenuRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "DeleteSubMenuRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_DeleteSubMenu: { + mobile_apis::Result::eType result_code = + static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + bool result = mobile_apis::Result::SUCCESS == result_code; + + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + if (result) { + // delete sub menu items from SDL and HMI + DeleteSubMenuVRCommands(application); + DeleteSubMenuUICommands(application); + application->RemoveSubMenu( + (*message_)[strings::msg_params][strings::menu_id].asInt()); + } + + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc b/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc new file mode 100644 index 0000000000..0a25a11610 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc @@ -0,0 +1,57 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/delete_sub_menu_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +DeleteSubMenuResponse::DeleteSubMenuResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +DeleteSubMenuResponse::~DeleteSubMenuResponse() { +} + +void DeleteSubMenuResponse::Run() { + LOG4CXX_INFO(logger_, "DeleteSubMenuResponse::Run"); + + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc b/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc new file mode 100644 index 0000000000..75016c05fb --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc @@ -0,0 +1,94 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/diagnostic_message_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +DiagnosticMessageRequest::DiagnosticMessageRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +DiagnosticMessageRequest::~DiagnosticMessageRequest() { +} + +void DiagnosticMessageRequest::Run() { + LOG4CXX_INFO(logger_, "DiagnosticMessageRequest::Run"); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + connection_key()); + + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "An application is not registered."); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + // Add app_id for HMI request + (*message_)[strings::msg_params][strings::app_id] = app->app_id(); + + SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage, + &(*message_)[strings::msg_params], true); + +} + +void DiagnosticMessageRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "DiagnosticMessageRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage: { + mobile_apis::Result::eType result_code = + static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + bool result = mobile_apis::Result::SUCCESS == result_code; + + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc b/src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc new file mode 100644 index 0000000000..2a8b234fff --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc @@ -0,0 +1,56 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/diagnostic_message_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +DiagnosticMessageResponse::DiagnosticMessageResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +DiagnosticMessageResponse::~DiagnosticMessageResponse() { +} + +void DiagnosticMessageResponse::Run() { + LOG4CXX_INFO(logger_, "DiagnosticMessageResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/dial_number_request.cc b/src/components/application_manager/src/commands/mobile/dial_number_request.cc new file mode 100644 index 0000000000..140f43128d --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/dial_number_request.cc @@ -0,0 +1,57 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/dial_number_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" + +namespace application_manager { + +namespace commands { + +DialNumberRequest::DialNumberRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +DialNumberRequest::~DialNumberRequest() { +} + +void DialNumberRequest::Run() { + LOG4CXX_INFO(logger_, "DialNumberRequest::Run"); + + SendResponse(false, mobile_apis::Result::UNSUPPORTED_REQUEST); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc new file mode 100644 index 0000000000..eedc9f813e --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc @@ -0,0 +1,88 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/end_audio_pass_thru_request.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +EndAudioPassThruRequest::EndAudioPassThruRequest( + const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +EndAudioPassThruRequest::~EndAudioPassThruRequest() { +} + +void EndAudioPassThruRequest::Run() { + LOG4CXX_INFO(logger_, "EndAudioPassThruRequest::Run"); + + SendHMIRequest(hmi_apis::FunctionID::UI_EndAudioPassThru, NULL, true); +} + +void EndAudioPassThruRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "EndAudioPassThruRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_EndAudioPassThru: { + mobile_apis::Result::eType mobile_code = + GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asUInt())); + + bool result = mobile_apis::Result::SUCCESS == mobile_code; + + if (result) { + bool ended_successfully = + ApplicationManagerImpl::instance()->end_audio_pass_thru(); + if (ended_successfully) { + ApplicationManagerImpl::instance()->StopAudioPassThru( + connection_key()); + } + } + + SendResponse(result, mobile_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc new file mode 100644 index 0000000000..128d921f9f --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc @@ -0,0 +1,57 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/end_audio_pass_thru_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +EndAudioPassThruResponse::EndAudioPassThruResponse( + const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +EndAudioPassThruResponse::~EndAudioPassThruResponse() { +} + +void EndAudioPassThruResponse::Run() { + LOG4CXX_INFO(logger_, "EndAudioPassThruResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/generic_response.cc b/src/components/application_manager/src/commands/mobile/generic_response.cc new file mode 100644 index 0000000000..69c841b2f1 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/generic_response.cc @@ -0,0 +1,65 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/generic_response.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" + +namespace application_manager { + +namespace commands { + +void GenericResponse::Run() { + /*NsSmartDeviceLink::NsSmartObjects::SmartObject response; + + response[strings::params][strings::correlation_id] = + (*message_)[strings::params][strings::correlation_id]; + response[strings::params][strings::protocol_version] = + (*message_)[strings::params][strings::protocol_version]; + response[strings::params][strings::connection_key] = + (*message_)[strings::params][strings::connection_key]; + + response[strings::msg_params][strings::success] = false; + */ + + (*message_)[strings::params][strings::message_type] = MessageType::kResponse; + (*message_)[strings::msg_params][strings::success] = false; + (*message_)[strings::msg_params][strings::result_code] = + mobile_apis::Result::INVALID_DATA; + + SendResponse(false); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc b/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc new file mode 100644 index 0000000000..9a81f94db1 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc @@ -0,0 +1,108 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/get_dtcs_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +GetDTCsRequest::GetDTCsRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +GetDTCsRequest::~GetDTCsRequest() { +} + +void GetDTCsRequest::Run() { + LOG4CXX_INFO(logger_, "GetDTCsRequest::Run"); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + (*message_)[strings::params][strings::connection_key].asUInt()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (mobile_api::HMILevel::HMI_NONE == app->hmi_level()) { + LOG4CXX_ERROR(logger_, "App has not been activated"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + msg_params[strings::ecu_name] = + (*message_)[strings::msg_params][strings::ecu_name]; + + if ((*message_)[strings::msg_params].keyExists(strings::dtc_mask)) { + msg_params[strings::dtc_mask] = + (*message_)[strings::msg_params][strings::dtc_mask]; + } + + msg_params[strings::app_id] = app->app_id(); + + SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_GetDTCs, &msg_params, true); +} + +void GetDTCsRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "GetDTCsRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::VehicleInfo_GetDTCs: { + mobile_apis::Result::eType result_code = + static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + bool result = mobile_apis::Result::SUCCESS == result_code; + + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/get_dtcs_response.cc b/src/components/application_manager/src/commands/mobile/get_dtcs_response.cc new file mode 100644 index 0000000000..2ed7a92952 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/get_dtcs_response.cc @@ -0,0 +1,56 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/get_dtcs_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +GetDTCsResponse::GetDTCsResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +GetDTCsResponse::~GetDTCsResponse() { +} + +void GetDTCsResponse::Run() { + LOG4CXX_INFO(logger_, "GetDTCsResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc new file mode 100644 index 0000000000..a3d08a15ff --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc @@ -0,0 +1,302 @@ +/* + + Copyright (c) 2013, 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 <string> +#include "application_manager/commands/mobile/get_vehicle_data_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +namespace str = strings; + +#ifdef HMI_DBUS_API +GetVehicleDataRequest::GetVehicleDataRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +GetVehicleDataRequest::~GetVehicleDataRequest() { +} + +void GetVehicleDataRequest::Run() { + LOG4CXX_INFO(logger_, "GetVehicleDataRequest::Run"); + + int32_t app_id = (*message_)[strings::params][strings::connection_key].asUInt(); + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (mobile_api::HMILevel::HMI_NONE == app->hmi_level()) { + LOG4CXX_ERROR(logger_, "app in HMI level HMI_NONE"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + const VehicleData& vehicle_data = MessageHelper::vehicle_data(); + VehicleData::const_iterator it = vehicle_data.begin(); + + for (; vehicle_data.end() != it; ++it) { + if (true == (*message_)[str::msg_params].keyExists(it->first) + && true == (*message_)[str::msg_params][it->first].asBool()) { + SendRequestsToHmi(app->app_id()); + return; + } + } + + SendResponse(false, mobile_apis::Result::INVALID_DATA); +} + +namespace { + struct Subrequest { + hmi_apis::FunctionID::eType func_id; + const char* str; + }; + Subrequest subrequests[] = { + { hmi_apis::FunctionID::VehicleInfo_GetGpsData, str::gps}, + { hmi_apis::FunctionID::VehicleInfo_GetSpeed, str::speed}, + { hmi_apis::FunctionID::VehicleInfo_GetRpm, str::rpm}, + { hmi_apis::FunctionID::VehicleInfo_GetFuelLevel, str::fuel_level}, + { hmi_apis::FunctionID::VehicleInfo_GetFuelLevelState, str::fuel_level_state}, + { hmi_apis::FunctionID::VehicleInfo_GetInstantFuelConsumption, str::instant_fuel_consumption}, + { hmi_apis::FunctionID::VehicleInfo_GetExternalTemperature, str::external_temp}, + { hmi_apis::FunctionID::VehicleInfo_GetVin, str::vin}, + { hmi_apis::FunctionID::VehicleInfo_GetPrndl, str::prndl}, + { hmi_apis::FunctionID::VehicleInfo_GetTirePressure, str::tire_pressure}, + { hmi_apis::FunctionID::VehicleInfo_GetOdometer, str::odometer}, + { hmi_apis::FunctionID::VehicleInfo_GetBeltStatus, str::belt_status}, + { hmi_apis::FunctionID::VehicleInfo_GetBodyInformation, str::body_information}, + { hmi_apis::FunctionID::VehicleInfo_GetDeviceStatus, str::device_status}, + { hmi_apis::FunctionID::VehicleInfo_GetDriverBraking, str::driver_braking}, + { hmi_apis::FunctionID::VehicleInfo_GetWiperStatus, str::wiper_status}, + { hmi_apis::FunctionID::VehicleInfo_GetHeadLampStatus, str::head_lamp_status}, + { hmi_apis::FunctionID::VehicleInfo_GetEngineTorque, str::engine_torque}, + { hmi_apis::FunctionID::VehicleInfo_GetAccPedalPosition, str::acc_pedal_pos}, + { hmi_apis::FunctionID::VehicleInfo_GetSteeringWheelAngle, str::steering_wheel_angle}, + { hmi_apis::FunctionID::VehicleInfo_GetECallInfo, str::e_call_info}, + { hmi_apis::FunctionID::VehicleInfo_GetAirbagStatus, str::airbag_status}, + { hmi_apis::FunctionID::VehicleInfo_GetEmergencyEvent, str::emergency_event}, + { hmi_apis::FunctionID::VehicleInfo_GetClusterModeStatus, str::cluster_mode_status}, + { hmi_apis::FunctionID::VehicleInfo_GetMyKey, str::my_key}, + }; +} + +void GetVehicleDataRequest::SendRequestsToHmi(const int32_t app_id) { + smart_objects::SmartObject msg_params(smart_objects::SmartType_Map); + msg_params[strings::app_id] = app_id; + + for (size_t i = 0; i < sizeof(subrequests) / sizeof(subrequests[0]); ++i) { + const Subrequest& sr = subrequests[i]; + if (true == (*message_)[str::msg_params].keyExists(sr.str) + && true == (*message_)[str::msg_params][sr.str].asBool()) { + HmiRequest hmi_request; + hmi_request.str = sr.str; + hmi_request.func_id = sr.func_id; + hmi_request.complete = false; + hmi_requests_.push_back(hmi_request); + } + } + + LOG4CXX_INFO(logger_, + hmi_requests_.size() << " requests are going to be sent to HMI"); + + for (HmiRequests::const_iterator it = hmi_requests_.begin(); + it != hmi_requests_.end(); ++it) { + SendHMIRequest(it->func_id, &msg_params, true); + } +} + +void GetVehicleDataRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "GetVehicleDataRequest::on_event " << event.id()); + + const smart_objects::SmartObject& message = event.smart_object(); + + for (HmiRequests::iterator it = hmi_requests_.begin(); + it != hmi_requests_.end(); ++it) { + HmiRequest & hmi_request = *it; + if (hmi_request.func_id == event.id()) { + hmi_request.status = + static_cast<hmi_apis::Common_Result::eType>(message[strings::params][hmi_response::code] + .asInt()); + if (hmi_apis::Common_Result::SUCCESS == hmi_request.status) + hmi_request.value = message[str::msg_params][hmi_request.str]; + hmi_request.complete = true; + break; + } + } + + bool all_complete = true; + bool any_arg_success = false; + mobile_api::Result::eType status = mobile_api::Result::eType::SUCCESS; + for (HmiRequests::const_iterator it = hmi_requests_.begin(); + it != hmi_requests_.end(); ++it) { + if (!it->complete) { + all_complete = false; + break; + } + if (hmi_apis::Common_Result::SUCCESS != it->status) { + if (mobile_api::Result::SUCCESS == status) { + status = static_cast<mobile_apis::Result::eType>(it->status); + } else if (status + != static_cast<mobile_apis::Result::eType>(it->status)) { + status = mobile_api::Result::eType::GENERIC_ERROR; + } + LOG4CXX_TRACE(logger_, "Status from HMI: " << it->status << ", so response status become " << status); + } else { + any_arg_success = true; + } + } + + if (all_complete) { + smart_objects::SmartObject response_params(smart_objects::SmartType_Map); + if (any_arg_success) { + for (HmiRequests::const_iterator it = hmi_requests_.begin(); + it != hmi_requests_.end(); ++it) { + response_params[it->str] = it->value; + } + } + LOG4CXX_INFO( + logger_, "All HMI requests are complete"); + const char *info = NULL; + std::string error_message; + if (true == message[strings::params].keyExists(strings::error_msg)) { + error_message = message[strings::params][strings::error_msg].asString(); + info = error_message.c_str(); + } + SendResponse( any_arg_success, status, info, &response_params); + } +} +#else +GetVehicleDataRequest::GetVehicleDataRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +GetVehicleDataRequest::~GetVehicleDataRequest() { +} + +void GetVehicleDataRequest::Run() { + LOG4CXX_INFO(logger_, "GetVehicleDataRequest::Run"); + + int32_t app_id = (*message_)[strings::params][strings::connection_key].asUInt(); + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (mobile_api::HMILevel::HMI_NONE == app->hmi_level()) { + LOG4CXX_ERROR(logger_, "app in HMI level HMI_NONE."); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + if (app->IsCommandLimitsExceeded( + static_cast<mobile_apis::FunctionID::eType>(function_id()), + application_manager::TLimitSource::CONFIG_FILE)) { + LOG4CXX_ERROR(logger_, "GetVehicleData frequency is too high."); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + const VehicleData& vehicle_data = MessageHelper::vehicle_data(); + VehicleData::const_iterator it = vehicle_data.begin(); + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + msg_params[strings::app_id] = app->app_id(); + const uint32_t min_length_msg_params = 1; + for (; vehicle_data.end() != it; ++it) { + if (true == (*message_)[str::msg_params].keyExists(it->first) + && true == (*message_)[str::msg_params][it->first].asBool()) { + msg_params[it->first] = (*message_)[strings::msg_params][it->first]; + } + } + if (msg_params.length() > min_length_msg_params) { + SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_GetVehicleData, + &msg_params, true); + return; + } else if (HasDisallowedParams()) { + SendResponse(false, mobile_apis::Result::DISALLOWED); + } else { + SendResponse(false, mobile_apis::Result::INVALID_DATA); + } +} + +void GetVehicleDataRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "GetVehicleDataRequest::on_event"); + smart_objects::SmartObject message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::VehicleInfo_GetVehicleData: { + mobile_apis::Result::eType result_code = + static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + bool result = false; + if (mobile_apis::Result::SUCCESS == result_code || + (hmi_apis::Common_Result::DATA_NOT_AVAILABLE == + static_cast<hmi_apis::Common_Result::eType>(result_code) + && message[strings::msg_params].length() > 1)) { + result = true; + } + const char *info = NULL; + std::string error_message; + if (true == + message[strings::msg_params].keyExists(hmi_response::method)) { + message[strings::msg_params].erase(hmi_response::method); + } + if (true == message[strings::params].keyExists(strings::error_msg)) { + error_message = message[strings::params][strings::error_msg].asString(); + info = error_message.c_str(); + } + SendResponse(result, result_code, info, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +#endif // #ifdef HMI_DBUS_API + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc b/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc new file mode 100644 index 0000000000..d9087fdc61 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc @@ -0,0 +1,57 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/get_vehicle_data_response.h" +#include "application_manager/application_manager_impl.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +GetVehicleDataResponse::GetVehicleDataResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +GetVehicleDataResponse::~GetVehicleDataResponse() { +} + +void GetVehicleDataResponse::Run() { + LOG4CXX_INFO(logger_, "GetVehicleDataResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/list_files_request.cc b/src/components/application_manager/src/commands/mobile/list_files_request.cc new file mode 100644 index 0000000000..d0fa71d466 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/list_files_request.cc @@ -0,0 +1,97 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/list_files_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "config_profile/profile.h" +#include "application_manager/mobile_command_factory.h" +#include "utils/file_system.h" + +namespace application_manager { + +namespace commands { + +ListFilesRequest::ListFilesRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +ListFilesRequest::~ListFilesRequest() { +} + +void ListFilesRequest::Run() { + LOG4CXX_INFO(logger_, "ListFilesRequest::Run"); + + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!application) { + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + LOG4CXX_ERROR(logger_, "Application is not registered"); + return; + } + + if ((mobile_api::HMILevel::HMI_NONE == application->hmi_level()) && + (profile::Profile::instance()->list_files_in_none() <= + application->list_files_in_none_count())) { + // If application is in the HMI_NONE level the quantity of allowed + // DeleteFile request is limited by the configuration profile + LOG4CXX_ERROR(logger_, "Too many requests from the app with HMILevel HMI_NONE "); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + application->increment_list_files_in_none_count(); + + (*message_)[strings::msg_params][strings::space_available] = + static_cast<int32_t>(ApplicationManagerImpl::instance()-> + GetAvailableSpaceForApp(application->folder_name())); + int32_t i = 0; + const AppFilesMap& app_files = application->getAppFiles(); + for (AppFilesMap::const_iterator it = app_files.begin(); + it != app_files.end(); ++it) { + //In AppFile to application stored full path to file. In message required + //to write only name file. + //Plus one required for move to next letter after '/'. + (*message_)[strings::msg_params][strings::filenames][i++] = + it->first.substr(it->first.find_last_of('/') + 1); + } + (*message_)[strings::params][strings::message_type] = + application_manager::MessageType::kResponse; + SendResponse(true, mobile_apis::Result::SUCCESS, NULL, + &(*message_)[strings::msg_params]); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/list_files_response.cc b/src/components/application_manager/src/commands/mobile/list_files_response.cc new file mode 100644 index 0000000000..6ffbec1ac4 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/list_files_response.cc @@ -0,0 +1,57 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/list_files_response.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" + +namespace application_manager { + +namespace commands { + +ListFilesResponse::ListFilesResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +ListFilesResponse::~ListFilesResponse() { +} + +void ListFilesResponse::Run() { + LOG4CXX_INFO(logger_, "ListFilesResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc b/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc new file mode 100644 index 0000000000..ebd0d6aac1 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc @@ -0,0 +1,55 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/on_app_interface_unregistered_notification.h" +#include "application_manager/message.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { +namespace commands { + +OnAppInterfaceUnregisteredNotification::OnAppInterfaceUnregisteredNotification( + const MessageSharedPtr& message) + : CommandNotificationImpl(message) { +} + +OnAppInterfaceUnregisteredNotification::~OnAppInterfaceUnregisteredNotification() { +} + +void OnAppInterfaceUnregisteredNotification::Run() { + LOG4CXX_INFO(logger_, "OnAppInterfaceUnregisteredNotification::Run"); + + SendNotification(); +} +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc b/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc new file mode 100644 index 0000000000..2515f591b1 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc @@ -0,0 +1,53 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/on_audio_pass_thru_notification.h" + +namespace application_manager { +namespace commands { + +OnAudioPassThruNotification::OnAudioPassThruNotification( + const MessageSharedPtr& message) + : CommandNotificationImpl(message) { +} + +OnAudioPassThruNotification::~OnAudioPassThruNotification() { +} + +void OnAudioPassThruNotification::Run() { + LOG4CXX_INFO(logger_, "OnAudioPassThruNotification::Run"); + + SendNotification(); +} +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc b/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc new file mode 100644 index 0000000000..55b9b8818d --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc @@ -0,0 +1,163 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/on_button_event_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +namespace mobile { + +OnButtonEventNotification::OnButtonEventNotification( + const MessageSharedPtr& message) + : CommandNotificationImpl(message) { +} + +OnButtonEventNotification::~OnButtonEventNotification() { +} + +void OnButtonEventNotification::Run() { + LOG4CXX_INFO(logger_, "OnButtonEventNotification::Run"); + + const uint32_t btn_id = + static_cast<uint32_t>( + (*message_)[strings::msg_params][hmi_response::button_name].asInt()); + + // CUSTOM_BUTTON notification + if (static_cast<uint32_t>(mobile_apis::ButtonName::CUSTOM_BUTTON) == btn_id) { + // app_id is mandatory for CUSTOM_BUTTON notification + if (false == (*message_)[strings::msg_params].keyExists(strings::app_id)) { + LOG4CXX_ERROR_EXT(logger_, "CUSTOM_BUTTON OnButtonEvent without app_id."); + return; + } + + // custom_button_id is mandatory for CUSTOM_BUTTON notification + if (false == (*message_)[strings::msg_params].keyExists( + hmi_response::custom_button_id)) { + LOG4CXX_ERROR_EXT(logger_, + "CUSTOM_BUTTON OnButtonEvent without custom_button_id."); + return; + } + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + (*message_)[strings::msg_params][strings::app_id].asUInt()); + + if (false == app.valid()) { + LOG4CXX_ERROR_EXT(logger_, "Application doesn't exist."); + return; + } + + uint32_t custom_btn_id = 0; + custom_btn_id = (*message_)[strings::msg_params] + [hmi_response::custom_button_id].asUInt(); + + if (false == app->IsSubscribedToSoftButton(custom_btn_id)) { + LOG4CXX_ERROR_EXT(logger_, + "Application doesn't subscribed to this custom_button_id."); + return; + } + + SendButtonEvent(app); + return; + } + + const std::vector<ApplicationSharedPtr>& subscribedApps = + ApplicationManagerImpl::instance()->applications_by_button(btn_id); + + std::vector<ApplicationSharedPtr>::const_iterator it = subscribedApps.begin(); + for (; subscribedApps.end() != it; ++it) { + ApplicationSharedPtr subscribed_app = *it; + if (!subscribed_app) { + LOG4CXX_WARN_EXT(logger_, "Null pointer to subscribed app."); + continue; + } + + //Send ButtonEvent notification only in HMI_FULL or HMI_LIMITED mode + if ((mobile_api::HMILevel::HMI_FULL != subscribed_app->hmi_level()) && + (mobile_api::HMILevel::HMI_LIMITED != subscribed_app->hmi_level())) { + LOG4CXX_WARN_EXT(logger_, "OnButtonEvent in HMI_BACKGROUND or NONE"); + continue; + } + + //Send ButtonEvent notification for OK button only in HMI_FULL mode + if ((static_cast<uint32_t>(mobile_apis::ButtonName::OK) == btn_id) && + (mobile_api::HMILevel::HMI_FULL != subscribed_app->hmi_level())) { + continue; + } + + SendButtonEvent(subscribed_app); + } +} + +void OnButtonEventNotification::SendButtonEvent(ApplicationConstSharedPtr app) { + smart_objects::SmartObject* on_btn_event = new smart_objects::SmartObject(); + + if (!on_btn_event) { + LOG4CXX_ERROR_EXT(logger_, "OnButtonEvent NULL pointer"); + return; + } + + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "OnButtonEvent NULL pointer"); + return; + } + + (*on_btn_event)[strings::params][strings::connection_key] = app->app_id(); + + (*on_btn_event)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnButtonEventID); + + (*on_btn_event)[strings::msg_params][strings::button_name] = + (*message_)[strings::msg_params][hmi_response::button_name]; + (*on_btn_event)[strings::msg_params][strings::button_event_mode] = + (*message_)[strings::msg_params][hmi_response::button_mode]; + + if ((*message_)[strings::msg_params].keyExists( + hmi_response::custom_button_id)) { + (*on_btn_event)[strings::msg_params][strings::custom_button_id] = + (*message_)[strings::msg_params][strings::custom_button_id]; + } + + message_.reset(on_btn_event); + SendNotification(); +} + +} // namespace mobile + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc b/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc new file mode 100644 index 0000000000..cfafc7af1c --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc @@ -0,0 +1,163 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/on_button_press_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +namespace mobile { + +OnButtonPressNotification::OnButtonPressNotification( + const MessageSharedPtr& message) + : CommandNotificationImpl(message) { +} + +OnButtonPressNotification::~OnButtonPressNotification() { +} + +void OnButtonPressNotification::Run() { + LOG4CXX_INFO(logger_, "OnButtonPressNotification::Run"); + + const uint32_t btn_id = + static_cast<uint32_t>( + (*message_)[strings::msg_params][hmi_response::button_name].asInt()); + + // CUSTOM_BUTTON notification + if (static_cast<uint32_t>(mobile_apis::ButtonName::CUSTOM_BUTTON) == btn_id) { + // app_id is mandatory for CUSTOM_BUTTON notification + if (false == (*message_)[strings::msg_params].keyExists(strings::app_id)) { + LOG4CXX_ERROR_EXT(logger_, "CUSTOM_BUTTON OnButtonPress without app_id."); + return; + } + + // custom_button_id is mandatory for CUSTOM_BUTTON notification + if (false == (*message_)[strings::msg_params].keyExists( + hmi_response::custom_button_id)) { + LOG4CXX_ERROR_EXT(logger_, + "CUSTOM_BUTTON OnButtonPress without custom_button_id."); + return; + } + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + (*message_)[strings::msg_params][strings::app_id].asUInt()); + + if (false == app.valid()) { + LOG4CXX_ERROR_EXT(logger_, "Application doesn't exist."); + return; + } + + uint32_t custom_btn_id = 0; + custom_btn_id = (*message_)[strings::msg_params] + [hmi_response::custom_button_id].asUInt(); + + if (false == app->IsSubscribedToSoftButton(custom_btn_id)) { + LOG4CXX_ERROR_EXT(logger_, + "Application doesn't subscribed to this custom_button_id."); + return; + } + + SendButtonPress(app); + return; + } + + const std::vector<ApplicationSharedPtr>& subscribedApps = + ApplicationManagerImpl::instance()->applications_by_button(btn_id); + + std::vector<ApplicationSharedPtr>::const_iterator it = subscribedApps.begin(); + for (; subscribedApps.end() != it; ++it) { + ApplicationSharedPtr subscribed_app = *it; + if (!subscribed_app) { + LOG4CXX_WARN_EXT(logger_, "Null pointer to subscribed app."); + continue; + } + + //Send ButtonPress notification only in HMI_FULL or HMI_LIMITED mode + if ((mobile_api::HMILevel::HMI_FULL != subscribed_app->hmi_level()) && + (mobile_api::HMILevel::HMI_LIMITED != subscribed_app->hmi_level())) { + LOG4CXX_WARN_EXT(logger_, "OnButtonPress in HMI_BACKGROUND or NONE"); + continue; + } + + //Send ButtonPress notification for OK button only in HMI_FULL mode + if ((static_cast<uint32_t>(mobile_apis::ButtonName::OK) == btn_id) && + (mobile_api::HMILevel::HMI_FULL != subscribed_app->hmi_level())) { + continue; + } + + SendButtonPress(subscribed_app); + } +} + +void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) { + smart_objects::SmartObject* on_btn_press = new smart_objects::SmartObject(); + + if (!on_btn_press) { + LOG4CXX_ERROR_EXT(logger_, "OnButtonPress NULL pointer"); + return; + } + + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "OnButtonPress NULL pointer"); + return; + } + + (*on_btn_press)[strings::params][strings::connection_key] = app->app_id(); + + (*on_btn_press)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnButtonPressID); + + (*on_btn_press)[strings::msg_params][strings::button_name] = + (*message_)[strings::msg_params][hmi_response::button_name]; + (*on_btn_press)[strings::msg_params][strings::button_press_mode] = + (*message_)[strings::msg_params][hmi_response::button_mode]; + + if ((*message_)[strings::msg_params].keyExists( + hmi_response::custom_button_id)) { + (*on_btn_press)[strings::msg_params][strings::custom_button_id] = + (*message_)[strings::msg_params][strings::custom_button_id]; + } + + message_.reset(on_btn_press); + SendNotification(); +} + +} // namespace mobile + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_command_notification.cc b/src/components/application_manager/src/commands/mobile/on_command_notification.cc new file mode 100644 index 0000000000..8342d05a45 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/on_command_notification.cc @@ -0,0 +1,80 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/on_command_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" + +namespace application_manager { + +namespace commands { + +OnCommandNotification::OnCommandNotification(const MessageSharedPtr& message) + : CommandNotificationImpl(message) { +} + +OnCommandNotification::~OnCommandNotification() { +} + +void OnCommandNotification::Run() { + LOG4CXX_INFO(logger_, "OnCommandNotification::Run"); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + (*message_)[strings::msg_params][strings::app_id].asInt()); + + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "No application associated with session key"); + return; + } + + const uint32_t cmd_id = (*message_)[strings::msg_params][strings::cmd_id] + .asUInt(); + + if (!app->FindCommand(cmd_id)) { + LOG4CXX_ERROR_EXT(logger_, + " No applications found for the command " << cmd_id); + return; + } + + (*message_)[strings::params][strings::connection_key] = app->app_id(); + // remove app_id from notification + if ((*message_)[strings::msg_params].keyExists(strings::app_id)) { + (*message_)[strings::msg_params].erase(strings::app_id); + } + + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_driver_distraction_notification.cc b/src/components/application_manager/src/commands/mobile/on_driver_distraction_notification.cc new file mode 100644 index 0000000000..fc92c17e94 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/on_driver_distraction_notification.cc @@ -0,0 +1,63 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/on_driver_distraction_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +namespace mobile { + +OnDriverDistractionNotification::OnDriverDistractionNotification( + const MessageSharedPtr& message) + : CommandNotificationImpl(message) { +} + +OnDriverDistractionNotification::~OnDriverDistractionNotification() { +} + +void OnDriverDistractionNotification::Run() { + LOG4CXX_INFO(logger_, "OnDriverDistractionNotification::Run"); + + SendNotification(); +} + +} // namespace mobile + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc b/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc new file mode 100644 index 0000000000..b9ee1339bb --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc @@ -0,0 +1,75 @@ + +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/on_hash_change_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" +#include <string> +#include <sstream> + +namespace application_manager { + +namespace commands { + +namespace mobile { + +OnHashChangeNotification::OnHashChangeNotification( + const MessageSharedPtr& message) + : CommandNotificationImpl(message) { +} + +OnHashChangeNotification::~OnHashChangeNotification() { +} + +void OnHashChangeNotification::Run() { + LOG4CXX_INFO(logger_, "OnHashChangeNotification::Run"); + + (*message_)[strings::params][strings::message_type] = + static_cast<int32_t>(application_manager::MessageType::kNotification); + + int32_t app_id; + app_id = (*message_)[strings::params][strings::connection_key].asInt(); + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); + std::stringstream stream; + stream << app->curHash(); + (*message_)[strings::msg_params][strings::hash_id] = stream.str(); + SendNotification(); +} + +} //namespace mobile + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc b/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc new file mode 100644 index 0000000000..9c03c0f623 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc @@ -0,0 +1,87 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/on_hmi_status_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/message_helper.h" +#include "application_manager/message.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { +namespace commands { + +OnHMIStatusNotification::OnHMIStatusNotification( + const MessageSharedPtr& message) + : CommandNotificationImpl(message) { +} + +OnHMIStatusNotification::~OnHMIStatusNotification() { +} + +void OnHMIStatusNotification::Run() { + LOG4CXX_INFO(logger_, "OnHMIStatusNotification::Run"); + + (*message_)[strings::params][strings::message_type] = static_cast<int32_t> ( + application_manager::MessageType::kNotification); + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + (*message_)[strings::params][strings::connection_key].asUInt()); + if (!app.valid()) { + LOG4CXX_ERROR(logger_, "OnHMIStatusNotification application doesn't exist"); + return; + } + mobile_apis::HMILevel::eType hmi_level = + static_cast<mobile_apis::HMILevel::eType>( + (*message_)[strings::msg_params][strings::hmi_level].asInt()); + if ((mobile_apis::HMILevel::HMI_BACKGROUND == hmi_level) || + (mobile_apis::HMILevel::HMI_NONE == hmi_level)) { + if (!(app->tts_properties_in_none())) { + app->set_tts_properties_in_none(true); + LOG4CXX_INFO(logger_, "OnHMIStatusNotification::Send TTS GlobalProperties" + " with empty array to HMI"); + MessageHelper::SendTTSGlobalProperties(app, false); + } + } else if ((mobile_apis::HMILevel::HMI_FULL == hmi_level) || + (mobile_apis::HMILevel::HMI_LIMITED == hmi_level)) { + if (!(app->tts_properties_in_full())) { + app->set_tts_properties_in_full(true); + LOG4CXX_INFO(logger_, "OnHMIStatusNotification AddAppToTTSGlobalPropertiesList"); + ApplicationManagerImpl::instance()->AddAppToTTSGlobalPropertiesList( + app->app_id()); + } + } + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc b/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc new file mode 100644 index 0000000000..969885ab16 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc @@ -0,0 +1,73 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/on_keyboard_input_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +namespace mobile { + +OnKeyBoardInputNotification::OnKeyBoardInputNotification( + const MessageSharedPtr& message) + : CommandNotificationImpl(message) { +} + +OnKeyBoardInputNotification::~OnKeyBoardInputNotification() { +} + +void OnKeyBoardInputNotification::Run() { + LOG4CXX_INFO(logger_, "OnKeyBoardInputNotification::Run"); + + const std::vector<ApplicationSharedPtr>& applications = + ApplicationManagerImpl::instance()->applications_with_navi(); + + std::vector<ApplicationSharedPtr>::const_iterator it = applications.begin(); + for (; applications.end() != it; ++it) { + ApplicationSharedPtr app = *it; + if (mobile_apis::HMILevel::eType::HMI_NONE != app->hmi_level()) { + (*message_)[strings::params][strings::connection_key] = app->app_id(); + SendNotification(); + } + } +} + +} // namespace mobile + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_language_change_notification.cc b/src/components/application_manager/src/commands/mobile/on_language_change_notification.cc new file mode 100644 index 0000000000..f550df8748 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/on_language_change_notification.cc @@ -0,0 +1,56 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/on_language_change_notification.h" + +namespace application_manager { + +namespace commands { + +OnLanguageChangeNotification::OnLanguageChangeNotification( + const MessageSharedPtr& message) + : CommandNotificationImpl(message) { +} + +OnLanguageChangeNotification::~OnLanguageChangeNotification() { +} + +void OnLanguageChangeNotification::Run() { + LOG4CXX_INFO(logger_, "OnLanguageChangeNotification::Run"); + + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc b/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc new file mode 100644 index 0000000000..37c81085eb --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc @@ -0,0 +1,61 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/on_permissions_change_notification.h" +#include "application_manager/message.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnPermissionsChangeNotification::OnPermissionsChangeNotification( + const MessageSharedPtr& message) + : CommandNotificationImpl(message) { +} + +OnPermissionsChangeNotification::~OnPermissionsChangeNotification() { +} + +void OnPermissionsChangeNotification::Run() { + LOG4CXX_INFO(logger_, "OnPermissionsChangeNotification::Run"); + + (*message_)[strings::params][strings::message_type] = + static_cast<int32_t>(application_manager::MessageType::kNotification); + + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc new file mode 100644 index 0000000000..ebf98cd7e8 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc @@ -0,0 +1,80 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/on_system_request_notification.h" +#include "interfaces/MOBILE_API.h" +#include "utils/file_system.h" + +namespace application_manager { + +namespace commands { + +namespace mobile { + +OnSystemRequestNotification::OnSystemRequestNotification( + const MessageSharedPtr& message) + : CommandNotificationImpl(message) { +} + +OnSystemRequestNotification::~OnSystemRequestNotification() { +} + +void OnSystemRequestNotification::Run() { + LOG4CXX_INFO(logger_, "OnSystemRequestNotification::Run"); + + mobile_apis::RequestType::eType request_type = static_cast<mobile_apis::RequestType::eType> + ((*message_)[strings::msg_params][strings::request_type].asInt()); + + if (mobile_apis::RequestType::PROPRIETARY == request_type) { + std::string filename = (*message_)[strings::msg_params][strings::file_name].asString(); + + std::vector<uint8_t> binary_data; + file_system::ReadBinaryFile(filename, binary_data); + (*message_)[strings::params][strings::binary_data] = binary_data; + (*message_)[strings::msg_params][strings::file_type] = + mobile_apis::FileType::JSON; + } else if (mobile_apis::RequestType::HTTP == request_type) { + (*message_)[strings::msg_params][strings::file_type] = + mobile_apis::FileType::BINARY; + // TODO(PV): if needed for HTTP HMI case to be changed. + //(*message_)[strings::params][strings::binary_data] = binary_data; + } + + SendNotification(); +} + +} //namespace mobile + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_tbt_client_state_notification.cc b/src/components/application_manager/src/commands/mobile/on_tbt_client_state_notification.cc new file mode 100644 index 0000000000..05494c6144 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/on_tbt_client_state_notification.cc @@ -0,0 +1,72 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/on_tbt_client_state_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnTBTClientStateNotification::OnTBTClientStateNotification( + const MessageSharedPtr& message) + : CommandNotificationImpl(message) { +} + +OnTBTClientStateNotification::~OnTBTClientStateNotification() { +} + +void OnTBTClientStateNotification::Run() { + LOG4CXX_INFO(logger_, "OnTBTClientStateNotification::Run"); + + (*message_)[strings::params][strings::message_type] = + static_cast<int32_t>(application_manager::MessageType::kNotification); + + const std::vector<ApplicationSharedPtr>& applications = + ApplicationManagerImpl::instance()->applications_with_navi(); + + std::vector<ApplicationSharedPtr>::const_iterator it = applications.begin(); + for (; applications.end() != it; ++it) { + ApplicationSharedPtr app = *it; + if (mobile_apis::HMILevel::eType::HMI_NONE != app->hmi_level()) { + (*message_)[strings::params][strings::connection_key] = app->app_id(); + SendNotification(); + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc b/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc new file mode 100644 index 0000000000..250faa8f38 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc @@ -0,0 +1,72 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/on_touch_event_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" + +namespace application_manager { + +namespace commands { + +namespace mobile { + +OnTouchEventNotification::OnTouchEventNotification( + const MessageSharedPtr& message) + : CommandNotificationImpl(message) { +} + +OnTouchEventNotification::~OnTouchEventNotification() { +} + +void OnTouchEventNotification::Run() { + LOG4CXX_INFO(logger_, "OnTouchEventNotification::Run"); + + const std::vector<ApplicationSharedPtr>& applications = + ApplicationManagerImpl::instance()->applications_with_navi(); + + std::vector<ApplicationSharedPtr>::const_iterator it = applications.begin(); + for (; applications.end() != it; ++it) { + ApplicationSharedPtr app = *it; + if (mobile_apis::HMILevel::HMI_FULL == app->hmi_level()) { + (*message_)[strings::params][strings::connection_key] = app->app_id(); + SendNotification(); + } + } +} + +} // namespace mobile + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc b/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc new file mode 100644 index 0000000000..420c42f30c --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc @@ -0,0 +1,89 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/on_vehicle_data_notification.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnVehicleDataNotification::OnVehicleDataNotification( + const MessageSharedPtr& message) + : CommandNotificationImpl(message) { +} + +OnVehicleDataNotification::~OnVehicleDataNotification() { +} + +void OnVehicleDataNotification::Run() { + LOG4CXX_INFO(logger_, "OnVehicleDataNotification::Run"); + + const VehicleData& vehicle_data = MessageHelper::vehicle_data(); + VehicleData::const_iterator it = vehicle_data.begin(); + + for (; vehicle_data.end() != it; ++it) { + if (true == (*message_)[strings::msg_params].keyExists(it->first)) { + const std::vector<utils::SharedPtr<Application>>& applications = + ApplicationManagerImpl::instance()->IviInfoUpdated(it->second, + (*message_)[strings::msg_params][it->first].asInt()); + + std::vector<utils::SharedPtr<Application>>::const_iterator it = applications.begin(); + for (; applications.end() != it; ++it) { + utils::SharedPtr<Application> app = *it; + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "NULL pointer"); + continue; + } + + LOG4CXX_INFO( + logger_, + "Send OnVehicleData PRNDL notification to " << app->name() + << " application id " << app->app_id()); + + (*message_)[strings::params][strings::connection_key] = app->app_id(); + + SendNotification(); + } + + return; + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc new file mode 100644 index 0000000000..c5f269fc48 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc @@ -0,0 +1,316 @@ +/* + + Copyright (c) 2013, 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 <string.h> +#include "application_manager/commands/mobile/perform_audio_pass_thru_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" + +namespace application_manager { + +namespace commands { + +namespace str = strings; + +PerformAudioPassThruRequest::PerformAudioPassThruRequest( + const MessageSharedPtr& message) + : CommandRequestImpl(message), + is_active_tts_speak_(false), + result_tts_speak_(mobile_apis::Result::SUCCESS) { + subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout); +} + +PerformAudioPassThruRequest::~PerformAudioPassThruRequest() { +} + +void PerformAudioPassThruRequest::onTimeOut() { + LOG4CXX_INFO(logger_, "PerformAudioPassThruRequest::onTimeOut"); + + if (ApplicationManagerImpl::instance()->end_audio_pass_thru()) { + ApplicationManagerImpl::instance()->StopAudioPassThru(connection_key()); + } + + FinishTTSSpeak(); + + CommandRequestImpl::onTimeOut(); +} + +bool PerformAudioPassThruRequest::Init() { + default_timeout_ += (((*message_)[str::msg_params][str::max_duration].asInt())/1000); + return true; +} + +void PerformAudioPassThruRequest::Run() { + LOG4CXX_INFO(logger_, "PerformAudioPassThruRequest::Run"); + + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "APPLICATION_NOT_REGISTERED"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (mobile_api::HMILevel::HMI_NONE == app->hmi_level()) { + LOG4CXX_ERROR(logger_, "application isn't activated"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, + "Incoming perform audio pass thru has contains \\t\\n \\\\t \\\\n" + " text contains only whitespace in initialPrompt"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if ((*message_)[str::msg_params].keyExists(str::initial_prompt) && + (0 < (*message_)[str::msg_params][str::initial_prompt].length())) { + // In case TTS Speak, subscribe on notification + SendSpeakRequest(); + SendPerformAudioPassThruRequest(); + } else { + SendPerformAudioPassThruRequest(); + SendRecordStartNotification(); + StartMicrophoneRecording(); + } +} + +void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "PerformAudioPassThruRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_PerformAudioPassThru: { + + mobile_apis::Result::eType mobile_code = + GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asUInt())); + + // in case perform audio is started by other request skip stopping + if (mobile_apis::Result::REJECTED == mobile_code) { + LOG4CXX_ERROR(logger_, "Request was rejected"); + SendResponse(false, mobile_code, NULL, &(message[strings::msg_params])); + return; + } + + if (ApplicationManagerImpl::instance()->end_audio_pass_thru()) { + ApplicationManagerImpl::instance()->StopAudioPassThru(connection_key()); + } + + FinishTTSSpeak(); + + std::string return_info; + bool result = mobile_apis::Result::SUCCESS == mobile_code || + mobile_apis::Result::RETRY == mobile_code; + + if ((mobile_apis::Result::SUCCESS == mobile_code) && + (mobile_apis::Result::UNSUPPORTED_RESOURCE == result_tts_speak_)) { + mobile_code = mobile_apis::Result::WARNINGS; + return_info = "Unsupported phoneme type sent in a prompt"; + } + + SendResponse(result, mobile_code, return_info.c_str(), + &(message[strings::msg_params])); + break; + } + case hmi_apis::FunctionID::TTS_Speak: { + LOG4CXX_INFO(logger_, "Received TTS_Speak event"); + result_tts_speak_ = GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asUInt())); + is_active_tts_speak_ = false; + SendRecordStartNotification(); + StartMicrophoneRecording(); + ApplicationManagerImpl::instance()-> + updateRequestTimeout(connection_key(), + correlation_id(), + default_timeout()); + break; + } + case hmi_apis::FunctionID::TTS_OnResetTimeout: { + LOG4CXX_INFO(logger_, "Received TTS_OnResetTimeout event"); + + ApplicationManagerImpl::instance()->updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +void PerformAudioPassThruRequest::SendSpeakRequest() { + // crate HMI TTS speak request + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + if ((*message_)[str::msg_params].keyExists(str::initial_prompt) && + (0 < (*message_)[str::msg_params][str::initial_prompt].length())) { + for (uint32_t i = 0; + i < (*message_)[str::msg_params][str::initial_prompt].length(); + ++i) { + msg_params[hmi_request::tts_chunks][i][str::text] = + (*message_)[str::msg_params][str::initial_prompt][i][str::text]; + msg_params[hmi_request::tts_chunks][i][str::type] = + (*message_)[str::msg_params][str::initial_prompt][i][str::type]; + } + // app_id + msg_params[strings::app_id] = connection_key(); + is_active_tts_speak_ = true; + SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, &msg_params, true); + } +} + +void PerformAudioPassThruRequest::SendPerformAudioPassThruRequest() { + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + msg_params[str::app_id] = connection_key(); + + // duration + msg_params[hmi_request::max_duration] = + (*message_)[str::msg_params][str::max_duration]; + + msg_params[hmi_request::audio_pass_display_texts] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + if ((*message_)[str::msg_params].keyExists(str::audio_pass_display_text1)) { + msg_params[hmi_request::audio_pass_display_texts] + [0][hmi_request::field_name] = static_cast<int32_t> + (hmi_apis::Common_TextFieldName::audioPassThruDisplayText1); + msg_params[hmi_request::audio_pass_display_texts] + [0][hmi_request::field_text] = + (*message_)[str::msg_params][str::audio_pass_display_text1]; + } + + if ((*message_)[str::msg_params].keyExists(str::audio_pass_display_text2)) { + msg_params[hmi_request::audio_pass_display_texts] + [1][hmi_request::field_name] = static_cast<int32_t> + (hmi_apis::Common_TextFieldName::audioPassThruDisplayText2); + msg_params[hmi_request::audio_pass_display_texts] + [1][hmi_request::field_text] = + (*message_)[str::msg_params][str::audio_pass_display_text2]; + } + + if ((*message_)[str::msg_params].keyExists(str::mute_audio)) { + msg_params[str::mute_audio] = + (*message_)[str::msg_params][str::mute_audio].asBool(); + } else { + // If omitted, the value is set to true + msg_params[str::mute_audio] = true; + } + + SendHMIRequest(hmi_apis::FunctionID::UI_PerformAudioPassThru, + &msg_params, true); +} + +void PerformAudioPassThruRequest::SendRecordStartNotification() { + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + msg_params[strings::app_id] = connection_key(); + + CreateHMINotification(hmi_apis::FunctionID::UI_OnRecordStart, msg_params); +} + +void PerformAudioPassThruRequest::StartMicrophoneRecording() { + ApplicationManagerImpl::instance()->begin_audio_pass_thru(); + + ApplicationManagerImpl::instance()->StartAudioPassThruThread( + connection_key(), correlation_id(), + (*message_)[str::msg_params][str::max_duration].asInt(), + (*message_)[str::msg_params][str::sampling_rate].asInt(), + (*message_)[str::msg_params][str::bits_per_sample].asInt(), + (*message_)[str::msg_params][str::audio_type].asInt()); +} + +bool PerformAudioPassThruRequest::IsWhiteSpaceExist() { + LOG4CXX_INFO(logger_, "PerformAudioPassThruRequest::IsWhiteSpaceExist"); + const char* str = NULL; + + if ((*message_)[strings::msg_params].keyExists(strings::initial_prompt)) { + const smart_objects::SmartArray* ip_array = + (*message_)[strings::msg_params][strings::initial_prompt].asArray(); + + smart_objects::SmartArray::const_iterator it_ip = ip_array->begin(); + smart_objects::SmartArray::const_iterator it_ip_end = ip_array->end(); + + for (; it_ip != it_ip_end; ++it_ip) { + str = (*it_ip)[strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid initial_prompt syntax check failed"); + return true; + } + } + } + + if ((*message_)[strings::msg_params]. + keyExists(strings::audio_pass_display_text1)) { + + str = (*message_)[strings::msg_params] + [strings::audio_pass_display_text1].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid audio_pass_display_text1 value syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params]. + keyExists(strings::audio_pass_display_text2)) { + + str = (*message_)[strings::msg_params] + [strings::audio_pass_display_text2].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid audio_pass_display_text2 value syntax check failed"); + return true; + } + } + return false; +} + +void PerformAudioPassThruRequest::FinishTTSSpeak(){ + if (is_active_tts_speak_) { + is_active_tts_speak_ = false; + SendHMIRequest(hmi_apis::FunctionID::TTS_StopSpeaking, NULL); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc new file mode 100644 index 0000000000..a10eaac9f3 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc @@ -0,0 +1,58 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/perform_audio_pass_thru_response.h" +#include "application_manager/application_manager_impl.h" + + +namespace application_manager { + +namespace commands { + +PerformAudioPassThruResponse::PerformAudioPassThruResponse( + const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +PerformAudioPassThruResponse::~PerformAudioPassThruResponse() { +} + +void PerformAudioPassThruResponse::Run() { + LOG4CXX_INFO(logger_, "PerformAudioPassThruResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc new file mode 100644 index 0000000000..12514626a6 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc @@ -0,0 +1,870 @@ +/* + + Copyright (c) 2013, 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 <string.h> +#include <string> +#include "application_manager/commands/mobile/perform_interaction_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "config_profile/profile.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" +#include "utils/file_system.h" + +namespace application_manager { + +namespace commands { + +PerformInteractionRequest::PerformInteractionRequest( + const MessageSharedPtr& message) +: CommandRequestImpl(message), + timer_("PerformInteractionReq", this, &PerformInteractionRequest::onTimer), + vr_perform_interaction_code_(mobile_apis::Result::INVALID_ENUM), + interaction_mode_(mobile_apis::InteractionMode::INVALID_ENUM), + ui_response_recived(false), + vr_response_recived(false) { + + subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); + subscribe_on_event(hmi_apis::FunctionID::VR_OnCommand); + subscribe_on_event(hmi_apis::FunctionID::Buttons_OnButtonPress); +} + +PerformInteractionRequest::~PerformInteractionRequest() { +} + +void PerformInteractionRequest::onTimer() { + LOG4CXX_INFO(logger_, "PerformInteractionRequest::onTimer"); +} + +bool PerformInteractionRequest::Init() { + + /* Timeout in milliseconds. + If omitted a standard value of 10000 milliseconds is used.*/ + if ((*message_)[strings::msg_params].keyExists(strings::timeout)) { + default_timeout_ = + (*message_)[strings::msg_params][strings::timeout].asUInt(); + } + mobile_apis::InteractionMode::eType mode = + static_cast<mobile_apis::InteractionMode::eType>( + (*message_)[strings::msg_params][strings::interaction_mode].asInt()); + + if (mobile_apis::InteractionMode::BOTH == mode || + mobile_apis::InteractionMode::MANUAL_ONLY == mode) { + default_timeout_ *= 2; + } + return true; +} + +void PerformInteractionRequest::Run() { + LOG4CXX_INFO(logger_, "PerformInteractionRequest::Run"); + + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + mobile_apis::LayoutMode::eType interaction_layout = + mobile_apis::LayoutMode::INVALID_ENUM; + if ((*message_)[strings::msg_params].keyExists( + hmi_request::interaction_layout)) { + interaction_layout = static_cast<mobile_apis::LayoutMode::eType>( + (*message_)[strings::msg_params][hmi_request::interaction_layout].asInt()); + } + + if ((mobile_apis::InteractionMode::VR_ONLY == + static_cast<mobile_apis::InteractionMode::eType>( + (*message_)[strings::msg_params][strings::interaction_mode].asInt())) && + (mobile_apis::LayoutMode::KEYBOARD == interaction_layout)) { + LOG4CXX_ERROR_EXT( + logger_, + "PerformInteraction contains InteractionMode = VR_ONLY and " + "interactionLayout=KEYBOARD"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if ((0 == (*message_) + [strings::msg_params][strings::interaction_choice_set_id_list].length()) && + (mobile_apis::InteractionMode::BOTH == + static_cast<mobile_apis::InteractionMode::eType>( + (*message_)[strings::msg_params][strings::interaction_mode].asInt()))) { + LOG4CXX_ERROR_EXT( + logger_, + "interactionChoiceSetIDList is empty and InteractionMode=BOTH"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if ((0 == (*message_) + [strings::msg_params][strings::interaction_choice_set_id_list].length()) && + (mobile_apis::LayoutMode::KEYBOARD != interaction_layout)) { + LOG4CXX_ERROR_EXT( + logger_, + "interactionChoiceSetIDList is empty and without parameter" + "interactionLayout=KEYBOARD"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if ((*message_)[strings::msg_params].keyExists(strings::vr_help)) { + if (mobile_apis::Result::SUCCESS != MessageHelper::VerifyImageVrHelpItems( + (*message_)[strings::msg_params][strings::vr_help], app)) { + LOG4CXX_ERROR_EXT( + logger_, + "MessageHelper::VerifyImageVrHelpItems return INVALID_DATA!"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } + + smart_objects::SmartObject& choice_list = + (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; + + for (size_t i = 0; i < choice_list.length(); ++i) { + if (!app->FindChoiceSet(choice_list[i].asInt())) { + LOG4CXX_ERROR(logger_, "Invalid ID"); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, + "Incoming perform interaction has contains \t\n \\t \\n"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + int32_t mode = + (*message_)[strings::msg_params][strings::interaction_mode].asInt(); + + app->set_perform_interaction_mode(mode); + + interaction_mode_ = static_cast<mobile_apis::InteractionMode::eType>(mode); + + switch (interaction_mode_) { + case mobile_apis::InteractionMode::BOTH: { + LOG4CXX_INFO(logger_, "Interaction Mode: BOTH"); + if (!CheckChoiceSetVRSynonyms(app)) { + return; + } + + if (!CheckChoiceSetMenuNames(app)) { + return; + } + + if (!CheckVrHelpItemPositions(app)) { + return; + } + + app->set_perform_interaction_active(correlation_id()); + SendVRPerformInteractionRequest(app); + SendUIPerformInteractionRequest(app); + break; + } + case mobile_apis::InteractionMode::MANUAL_ONLY: { + LOG4CXX_INFO(logger_, "Interaction Mode: MANUAL_ONLY"); + + if (!CheckChoiceSetVRSynonyms(app)) { + return; + } + + if (!CheckChoiceSetMenuNames(app)) { + return; + } + + if (!CheckVrHelpItemPositions(app)) { + return; + } + + app->set_perform_interaction_active(correlation_id()); + SendVRPerformInteractionRequest(app); + SendUIPerformInteractionRequest(app); + break; + } + case mobile_apis::InteractionMode::VR_ONLY: { + LOG4CXX_INFO(logger_, "Interaction Mode: VR_ONLY"); + if (!CheckChoiceSetVRSynonyms(app)) { + return; + } + + if (!CheckVrHelpItemPositions(app)) { + return; + } + + // TODO(DK): need to implement timeout + app->set_perform_interaction_active(correlation_id()); + SendVRPerformInteractionRequest(app); + SendUIPerformInteractionRequest(app); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Unknown interaction mode"); + return; + } + } + + // TODO(DK): need to implement timeout TTS speak request. +} + +void PerformInteractionRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "PerformInteractionRequest::on_event"); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_OnResetTimeout: { + LOG4CXX_INFO(logger_, "Received UI_OnResetTimeout event"); + ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(), + correlation_id(), + default_timeout()); + break; + } + case hmi_apis::FunctionID::UI_PerformInteraction: { + LOG4CXX_INFO(logger_, "Received UI_PerformInteraction event"); + ProcessPerformInteractionResponse(event.smart_object()); + break; + } + case hmi_apis::FunctionID::VR_PerformInteraction: { + LOG4CXX_INFO(logger_, "Received TTS_PerformInteraction"); + ProcessVRResponse(event.smart_object()); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + break; + } + } +} + +void PerformInteractionRequest::onTimeOut() { + LOG4CXX_INFO(logger_, "PerformInteractionRequest::onTimeOut"); + + switch (interaction_mode_) { + case mobile_apis::InteractionMode::BOTH: { + if (true == vr_response_recived) { + unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction); + DisablePerformInteraction(); + CommandRequestImpl::onTimeOut(); + } else { + ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(), + correlation_id(), + default_timeout()); + } + break; + } + case mobile_apis::InteractionMode::VR_ONLY: { + ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(), + correlation_id(), + default_timeout()); + break; + } + case mobile_apis::InteractionMode::MANUAL_ONLY: { + unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction); + DisablePerformInteraction(); + CommandRequestImpl::onTimeOut(); + break; + } + default: { + LOG4CXX_ERROR(logger_, "INVALID ENUM"); + return; + } + }; +} + + +void PerformInteractionRequest::ProcessVRResponse( + const smart_objects::SmartObject& message) { + LOG4CXX_INFO(logger_, "PerformInteractionRequest::ProcessVRResponse"); + const uint32_t app_id = connection_key(); + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); + if (!app.get()) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + vr_response_recived = true; + vr_perform_interaction_code_ = static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + if (mobile_apis::Result::ABORTED == vr_perform_interaction_code_ || + mobile_apis::Result::TIMED_OUT == vr_perform_interaction_code_) { + LOG4CXX_INFO(logger_, "VR response aborted"); + if (mobile_apis::InteractionMode::VR_ONLY == interaction_mode_) { + LOG4CXX_INFO(logger_, "Aborted or Timeout Send Close Popup"); + TerminatePerformInteraction(); + SendResponse(false, vr_perform_interaction_code_); + return; + } else { + LOG4CXX_INFO(logger_, "Update timeout for UI"); + ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(), + correlation_id(), + default_timeout()); + return; + } + } + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + smart_objects::SmartObject* ptr_msg_params = NULL; + if (message[strings::msg_params].keyExists(strings::choice_id)) { + if (CheckChoiceIDFromResponse( + app, message[strings::msg_params][strings::choice_id].asInt())) { + msg_params[strings::choice_id] = + message[strings::msg_params][strings::choice_id].asInt(); + ptr_msg_params = &msg_params; + } else { + LOG4CXX_ERROR(logger_, "Wrong choiceID was received from HMI"); + TerminatePerformInteraction(); + SendResponse(false, mobile_apis::Result::GENERIC_ERROR, + "Wrong choiceID was received from HMI"); + return; + } + } + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; + + if (mobile_apis::Result::UNSUPPORTED_RESOURCE == + vr_perform_interaction_code_) { + LOG4CXX_INFO(logger_, "VR response WARNINGS"); + result_code = mobile_apis::Result::WARNINGS; + } else { + LOG4CXX_INFO(logger_, "VR response SUCCESS"); + result_code = mobile_apis::Result::SUCCESS; + msg_params[strings::trigger_source] = + static_cast<int32_t>(mobile_apis::TriggerSource::TS_VR); + ptr_msg_params = &msg_params; + } + TerminatePerformInteraction(); + SendResponse(true, result_code, NULL, ptr_msg_params); +} + +void PerformInteractionRequest::ProcessPerformInteractionResponse( + const smart_objects::SmartObject& message) { + LOG4CXX_INFO(logger_, + "PerformInteractionRequest::ProcessPerformInteractionResponse"); + const uint32_t app_id = connection_key(); + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); + if (!app.get()) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + ui_response_recived = true; + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params = message[strings::msg_params]; + bool result = false; + + mobile_apis::Result::eType result_code = + GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asUInt())); + + if ((mobile_apis::Result::SUCCESS == result_code) || + (mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code)) { + if (message[strings::msg_params].keyExists(strings::choice_id) && + !(CheckChoiceIDFromResponse( + app, message[strings::msg_params][strings::choice_id].asInt()))) { + DisablePerformInteraction(); + SendResponse(false, mobile_apis::Result::GENERIC_ERROR, + "Wrong choiceID was received from HMI"); + return; + } + if (message[strings::msg_params].keyExists(strings::manual_text_entry)) { + msg_params[strings::trigger_source] = mobile_apis::TriggerSource::TS_KEYBOARD; + } else { + msg_params[strings::trigger_source] = mobile_apis::TriggerSource::TS_MENU; + } + DisablePerformInteraction(); + result = true; + } else if (mobile_apis::Result::REJECTED == result_code) { + LOG4CXX_ERROR(logger_, "Request was rejected"); + } + + const char* return_info = NULL; + if (result) { + if (mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) { + result_code = mobile_apis::Result::WARNINGS; + return_info = + std::string("Unsupported phoneme type sent in any item").c_str(); + } + } + + if (mobile_apis::Result::TIMED_OUT == result_code) { + DisablePerformInteraction(); + } + + SendResponse(result, result_code, return_info, &(msg_params)); +} + +void PerformInteractionRequest::SendUIPerformInteractionRequest( + application_manager::ApplicationSharedPtr const app) { + smart_objects::SmartObject& choice_set_id_list = + (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + mobile_apis::InteractionMode::eType mode = + static_cast<mobile_apis::InteractionMode::eType>( + (*message_)[strings::msg_params][strings::interaction_mode].asInt()); + + if (mobile_apis::InteractionMode::VR_ONLY != mode) { + msg_params[hmi_request::initial_text][hmi_request::field_name] = + static_cast<int32_t>( + hmi_apis::Common_TextFieldName::initialInteractionText); + msg_params[hmi_request::initial_text][hmi_request::field_text] = + (*message_)[strings::msg_params][hmi_request::initial_text]; + } + bool is_vr_help_item = false; + if (mobile_apis::InteractionMode::MANUAL_ONLY != mode) { + msg_params[strings::vr_help_title] = + (*message_)[strings::msg_params][strings::initial_text].asString(); + if ((*message_)[strings::msg_params].keyExists(strings::vr_help)) { + is_vr_help_item = true; + msg_params[strings::vr_help] = + (*message_)[strings::msg_params][strings::vr_help]; + } + } + + if (mobile_apis::InteractionMode::BOTH == mode || + mobile_apis::InteractionMode::MANUAL_ONLY == mode) { + msg_params[strings::timeout] = default_timeout_/2; + } else { + msg_params[strings::timeout] = default_timeout_; + } + msg_params[strings::app_id] = app->app_id(); + if (mobile_apis::InteractionMode::VR_ONLY != mode) { + msg_params[strings::choice_set] = smart_objects::SmartObject( + smart_objects::SmartType_Array); + } + int32_t index_array_of_vr_help = 0; + for (size_t i = 0; i < choice_set_id_list.length(); ++i) { + smart_objects::SmartObject* choice_set = app->FindChoiceSet( + choice_set_id_list[i].asInt()); + if (choice_set) { + // save perform interaction choice set + app->AddPerformInteractionChoiceSet(choice_set_id_list[i].asInt(), + *choice_set); + for (size_t j = 0; j < (*choice_set)[strings::choice_set].length(); ++j) { + if (mobile_apis::InteractionMode::VR_ONLY != mode) { + size_t index = msg_params[strings::choice_set].length(); + msg_params[strings::choice_set][index] = + (*choice_set)[strings::choice_set][j]; + // vrCommands should be added via VR.AddCommand only + msg_params[strings::choice_set][index].erase(strings::vr_commands); + } + if (mobile_apis::InteractionMode::MANUAL_ONLY != + mode && !is_vr_help_item) { + smart_objects::SmartObject& vr_commands = + (*choice_set)[strings::choice_set][j][strings::vr_commands]; + if (0 < vr_commands.length()) { + // copy only first synonym + smart_objects::SmartObject item(smart_objects::SmartType_Map); + item[strings::text] = vr_commands[0].asString(); + item[strings::position] = index_array_of_vr_help + 1; + msg_params[strings::vr_help][index_array_of_vr_help++] = item; + } + } + } + } + } + if ((*message_)[strings::msg_params] + .keyExists(hmi_request::interaction_layout) + && mobile_apis::InteractionMode::VR_ONLY != mode) { + msg_params[hmi_request::interaction_layout] = + (*message_)[strings::msg_params][hmi_request::interaction_layout]. + asInt(); + } + CreateUIPerformInteraction(msg_params, app); +} + +void PerformInteractionRequest::CreateUIPerformInteraction( + const smart_objects::SmartObject& msg_params, + application_manager::ApplicationSharedPtr const app) { + SendHMIRequest(hmi_apis::FunctionID::UI_PerformInteraction, + &msg_params, true); +} + +void PerformInteractionRequest::SendVRPerformInteractionRequest( + application_manager::ApplicationSharedPtr const app) { + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + smart_objects::SmartObject& choice_list = + (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; + + if (mobile_apis::InteractionMode::MANUAL_ONLY != interaction_mode_) { + msg_params[strings::grammar_id] = smart_objects::SmartObject(smart_objects::SmartType_Array); + int32_t grammar_id_index = 0; + for (uint32_t i = 0; i < choice_list.length(); ++i) { + smart_objects::SmartObject* choice_set = + app->FindChoiceSet(choice_list[i].asInt()); + if (!choice_set) { + LOG4CXX_WARN(logger_, "Couldn't found choiset"); + continue; + } + msg_params[strings::grammar_id][grammar_id_index++]= + (*choice_set)[strings::grammar_id].asUInt(); + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::help_prompt)) { + + msg_params[strings::help_prompt] = + (*message_)[strings::msg_params][strings::help_prompt]; + + } else { + if (choice_list.length() != 0) { + msg_params[strings::help_prompt] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + } + int32_t index = 0; + for (uint32_t i = 0; i < choice_list.length(); ++i) { + smart_objects::SmartObject* choice_set = + app->FindChoiceSet(choice_list[i].asInt()); + + if (choice_set) { + for (uint32_t j = 0; + j < (*choice_set)[strings::choice_set].length(); + ++j) { + smart_objects::SmartObject& vr_commands = + (*choice_set)[strings::choice_set][j][strings::vr_commands]; + if (0 < vr_commands.length()) { + // copy only first synonym + smart_objects::SmartObject item(smart_objects::SmartType_Map); + // Since there is no custom data from application side, SDL should + // construct prompt and append delimiter to each item + item[strings::text] = vr_commands[0].asString() + + profile::Profile::instance()->tts_delimiter(); + msg_params[strings::help_prompt][index++] = item; + } + } + } else { + LOG4CXX_ERROR(logger_, "Can't found choiceSet!"); + } + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::timeout_prompt)) { + msg_params[strings::timeout_prompt] = + (*message_)[strings::msg_params][strings::timeout_prompt]; + } else { + if (msg_params.keyExists(strings::help_prompt)) { + msg_params[strings::timeout_prompt] = msg_params[strings::help_prompt]; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::initial_prompt)) { + msg_params[strings::initial_prompt] = + (*message_)[strings::msg_params][strings::initial_prompt]; + } + + mobile_apis::InteractionMode::eType mode = + static_cast<mobile_apis::InteractionMode::eType>( + (*message_)[strings::msg_params][strings::interaction_mode].asInt()); + + if (mobile_apis::InteractionMode::BOTH == mode || + mobile_apis::InteractionMode::MANUAL_ONLY == mode) { + msg_params[strings::timeout] = default_timeout_/2; + } else { + msg_params[strings::timeout] = default_timeout_; + } + + SendHMIRequest(hmi_apis::FunctionID::VR_PerformInteraction, &msg_params, + true); +} + +bool PerformInteractionRequest::CheckChoiceSetMenuNames( + application_manager::ApplicationSharedPtr const app) { + smart_objects::SmartObject& choice_list = + (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; + + for (size_t i = 0; i < choice_list.length(); ++i) { + // choice_set contains SmartObject msg_params + smart_objects::SmartObject* i_choice_set = app->FindChoiceSet( + choice_list[i].asInt()); + + for (size_t j = 0; j < choice_list.length(); ++j) { + smart_objects::SmartObject* j_choice_set = app->FindChoiceSet( + choice_list[j].asInt()); + + if (i == j) { + // skip check the same element + continue; + } + + if (!i_choice_set || !j_choice_set) { + LOG4CXX_ERROR(logger_, "Invalid ID"); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return false; + } + + size_t ii = 0; + size_t jj = 0; + for (; ii < (*i_choice_set)[strings::choice_set].length(); ++ii) { + for (; jj < (*j_choice_set)[strings::choice_set].length(); ++jj) { + std::string ii_menu_name = + (*i_choice_set)[strings::choice_set][ii][strings::menu_name] + .asString(); + std::string jj_menu_name = + (*j_choice_set)[strings::choice_set][jj][strings::menu_name] + .asString(); + + if (ii_menu_name == jj_menu_name) { + LOG4CXX_ERROR(logger_, "Choice set has duplicated menu name"); + SendResponse(false, mobile_apis::Result::DUPLICATE_NAME, + "Choice set has duplicated menu name"); + return false; + } + } + } + } + } + + return true; +} + +bool PerformInteractionRequest::CheckChoiceSetVRSynonyms( + application_manager::ApplicationSharedPtr const app) { + smart_objects::SmartObject& choice_list = + (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; + + for (size_t i = 0; i < choice_list.length(); ++i) { + // choice_set contains SmartObject msg_params + smart_objects::SmartObject* i_choice_set = app->FindChoiceSet( + choice_list[i].asInt()); + + for (size_t j = 0; j < choice_list.length(); ++j) { + smart_objects::SmartObject* j_choice_set = app->FindChoiceSet( + choice_list[j].asInt()); + + if (i == j) { + // skip check the same element + continue; + } + + if ((!i_choice_set) || (!j_choice_set)) { + LOG4CXX_ERROR(logger_, "Invalid ID"); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return false; + } + + size_t ii = 0; + size_t jj = 0; + for (; ii < (*i_choice_set)[strings::choice_set].length(); ++ii) { + for (; jj < (*j_choice_set)[strings::choice_set].length(); ++jj) { + // choice_set pointer contains SmartObject msg_params + smart_objects::SmartObject& ii_vr_commands = + (*i_choice_set)[strings::choice_set][ii][strings::vr_commands]; + + smart_objects::SmartObject& jj_vr_commands = + (*j_choice_set)[strings::choice_set][jj][strings::vr_commands]; + + for (size_t iii = 0; iii < ii_vr_commands.length(); ++iii) { + for (size_t jjj = 0; jjj < jj_vr_commands.length(); ++jjj) { + std::string vr_cmd_i = ii_vr_commands[iii].asString(); + std::string vr_cmd_j = jj_vr_commands[jjj].asString(); + if (0 == strcasecmp(vr_cmd_i.c_str(), vr_cmd_j.c_str())) { + LOG4CXX_ERROR(logger_, "Choice set has duplicated VR synonym"); + SendResponse(false, mobile_apis::Result::DUPLICATE_NAME, + "Choice set has duplicated VR synonym"); + return false; + } + } + } + } + } + } + } + + return true; +} + +bool PerformInteractionRequest::CheckVrHelpItemPositions( + application_manager::ApplicationSharedPtr const app) { + + if (!(*message_)[strings::msg_params].keyExists(strings::vr_help)) { + LOG4CXX_INFO(logger_, "" + "PerformInteractionRequest::CheckVrHelpItemPositions vr_help omitted"); + return true; + } + + smart_objects::SmartObject& vr_help = + (*message_)[strings::msg_params][strings::vr_help]; + + int32_t position = 1; + for (size_t i = 0; i < vr_help.length(); ++i) { + if (position != vr_help[i][strings::position].asInt()) { + LOG4CXX_ERROR(logger_, "Non-sequential vrHelp item position"); + SendResponse(false, mobile_apis::Result::REJECTED, + "Non-sequential vrHelp item position"); + return false; + } + ++position; + } + return true; +} + +void PerformInteractionRequest::DisablePerformInteraction() { + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->application(connection_key()); + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + if (app->is_perform_interaction_active()) { + app->set_perform_interaction_active(0); + app->set_perform_interaction_mode(-1); + app->DeletePerformInteractionChoiceSetMap(); + } +} + +bool PerformInteractionRequest::IsWhiteSpaceExist() { + LOG4CXX_INFO(logger_, "PerformInteractionRequest::IsWhiteSpaceExist"); + const char* str = NULL; + + str = (*message_)[strings::msg_params][strings::initial_text].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid initial_text syntax check failed"); + return true; + } + + + if ((*message_)[strings::msg_params].keyExists(strings::initial_prompt)) { + const smart_objects::SmartArray* ip_array = + (*message_)[strings::msg_params][strings::initial_prompt].asArray(); + + smart_objects::SmartArray::const_iterator it_ip = ip_array->begin(); + smart_objects::SmartArray::const_iterator it_ip_end = ip_array->end(); + + for (; it_ip != it_ip_end; ++it_ip) { + str = (*it_ip)[strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid initial_prompt syntax check failed"); + return true; + } + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::help_prompt)) { + const smart_objects::SmartArray* hp_array = + (*message_)[strings::msg_params][strings::help_prompt].asArray(); + + smart_objects::SmartArray::const_iterator it_hp = hp_array->begin(); + smart_objects::SmartArray::const_iterator it_hp_end = hp_array->end(); + + for (; it_hp != it_hp_end; ++it_hp) { + str = (*it_hp)[strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid help_prompt syntax check failed"); + return true; + } + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::timeout_prompt)) { + const smart_objects::SmartArray* tp_array = + (*message_)[strings::msg_params][strings::timeout_prompt].asArray(); + + smart_objects::SmartArray::const_iterator it_tp = tp_array->begin(); + smart_objects::SmartArray::const_iterator it_tp_end = tp_array->end(); + + for (; it_tp != it_tp_end; ++it_tp) { + str = (*it_tp)[strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid timeout_prompt syntax check failed"); + return true; + } + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::vr_help)) { + const smart_objects::SmartArray* vh_array = + (*message_)[strings::msg_params][strings::vr_help].asArray(); + + smart_objects::SmartArray::const_iterator it_vh = vh_array->begin(); + smart_objects::SmartArray::const_iterator it_vh_end = vh_array->end(); + + for (; it_vh != it_vh_end; ++it_vh) { + str = (*it_vh)[strings::text].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid vr_help syntax check failed"); + return true; + } + + if ((*it_vh).keyExists(strings::image)) { + str = (*it_vh)[strings::image][strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid vr_help image value syntax check failed"); + return true; + } + } + } + } + return false; +} + +void PerformInteractionRequest::TerminatePerformInteraction() { + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + msg_params[hmi_request::method_name] = "UI.PerformInteraction"; + SendHMIRequest(hmi_apis::FunctionID::UI_ClosePopUp, &msg_params); + DisablePerformInteraction(); +} + +bool PerformInteractionRequest::CheckChoiceIDFromResponse( + ApplicationSharedPtr app, int32_t choice_id) { + LOG4CXX_INFO(logger_, "PerformInteractionRequest::CheckChoiceIDFromResponse"); + const PerformChoiceSetMap& choice_set_map = app + ->performinteraction_choice_set_map(); + + for (PerformChoiceSetMap::const_iterator it = choice_set_map.begin(); + choice_set_map.end() != it; ++it) { + const smart_objects::SmartObject& choice_set = (*it->second).getElement( + strings::choice_set); + for (size_t j = 0; j < choice_set.length(); ++j) { + if (choice_id == + choice_set.getElement(j).getElement(strings::choice_id).asInt()) { + return true; + } + } + } + return false; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc b/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc new file mode 100644 index 0000000000..4ceb4ce3b3 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc @@ -0,0 +1,57 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/perform_interaction_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +PerformInteractionResponse::PerformInteractionResponse( + const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +PerformInteractionResponse::~PerformInteractionResponse() { +} + +void PerformInteractionResponse::Run() { + LOG4CXX_INFO(logger_, "PerformInteractionResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/put_file_request.cc b/src/components/application_manager/src/commands/mobile/put_file_request.cc new file mode 100644 index 0000000000..8bb83888d6 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/put_file_request.cc @@ -0,0 +1,250 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/put_file_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/policies/policy_handler.h" +#include "application_manager/application_impl.h" +#include "config_profile/profile.h" +#include "utils/file_system.h" + +namespace application_manager { + +namespace commands { + +PutFileRequest::PutFileRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) + , offset_(0) + , sync_file_name_() + , length_(0) + , file_type_(mobile_apis::FileType::INVALID_ENUM) + , is_persistent_file_(false) { +} + +PutFileRequest::~PutFileRequest() { +} + +void PutFileRequest::Run() { + LOG4CXX_INFO(logger_, "PutFileRequest::Run"); + + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application(connection_key()); + smart_objects::SmartObject response_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + if (!application) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (mobile_api::HMILevel::HMI_NONE == application->hmi_level() && + profile::Profile::instance()->put_file_in_none() <= + application->put_file_in_none_count()) { + // If application is in the HMI_NONE level the quantity of allowed + // PutFile request is limited by the configuration profile + LOG4CXX_ERROR(logger_, + "Too many requests from the app with HMILevel HMI_NONE "); + SendResponse(false, mobile_apis::Result::REJECTED, + "Too many requests from the app with HMILevel HMI_NONE", + &response_params); + return; + } + + if (!(*message_)[strings::params].keyExists(strings::binary_data)) { + LOG4CXX_ERROR(logger_, "Binary data empty"); + SendResponse(false, mobile_apis::Result::INVALID_DATA, + "Binary data empty", + &response_params); + return; + } + + if (!(*message_)[strings::msg_params].keyExists(strings::sync_file_name)) { + LOG4CXX_ERROR(logger_, "No file name"); + SendResponse(false, mobile_apis::Result::INVALID_DATA, + "No file name", + &response_params); + return; + } + + if (!(*message_)[strings::msg_params].keyExists(strings::file_type)) { + LOG4CXX_ERROR(logger_, "No file type"); + SendResponse(false, mobile_apis::Result::INVALID_DATA, + "No file type", + &response_params); + return; + } + sync_file_name_ = + (*message_)[strings::msg_params][strings::sync_file_name].asString(); + file_type_ = + static_cast<mobile_apis::FileType::eType>( + (*message_)[strings::msg_params][strings::file_type].asInt()); + const std::vector<uint8_t> binary_data = + (*message_)[strings::params][strings::binary_data].asBinary(); + + // Policy table update in json format is currently to be received via PutFile + // TODO(PV): after latest discussion has to be changed + if (mobile_apis::FileType::JSON == file_type_) { + policy::PolicyHandler::instance()->ReceiveMessageFromSDK(sync_file_name_, binary_data); + } + + offset_ = 0; + is_persistent_file_ = false; + bool is_system_file = false; + length_ = binary_data.size(); + bool is_download_compleate = true; + bool offset_exist = + (*message_)[strings::msg_params].keyExists(strings::offset); + + if (offset_exist) { + offset_ = (*message_)[strings::msg_params][strings::offset].asInt64(); + } + + if ((*message_)[strings::msg_params]. + keyExists(strings::persistent_file)) { + is_persistent_file_ = + (*message_)[strings::msg_params][strings::persistent_file].asBool(); + } + if ((*message_)[strings::msg_params]. + keyExists(strings::system_file)) { + is_system_file = + (*message_)[strings::msg_params][strings::system_file].asBool(); + } + + std::string file_path; + + if (is_system_file) { + response_params[strings::space_available] = 0; + file_path = profile::Profile::instance()->system_files_path(); + } else { + file_path = profile::Profile::instance()->app_storage_folder(); + file_path += "/" + application->folder_name(); + + if (binary_data.size() > + ApplicationManagerImpl::instance()->GetAvailableSpaceForApp(application->name())) { + LOG4CXX_ERROR(logger_, "Out of memory"); + SendResponse(false, mobile_apis::Result::OUT_OF_MEMORY, + "Out of memory", &response_params); + return; + } + } + + if (!file_system::CreateDirectoryRecursively(file_path)) { + LOG4CXX_ERROR(logger_, "Cann't create folder"); + SendResponse(false, mobile_apis::Result::GENERIC_ERROR, + "Cann't create folder.", &response_params); + return; + } + + mobile_apis::Result::eType save_result = + ApplicationManagerImpl::instance()->SaveBinary(binary_data, file_path, + sync_file_name_, offset_); + if (!is_system_file) { + response_params[strings::space_available] = static_cast<int32_t>( + ApplicationManagerImpl::instance()->GetAvailableSpaceForApp(application->folder_name())); + } + + sync_file_name_ = file_path + "/" + sync_file_name_; + switch (save_result) { + case mobile_apis::Result::SUCCESS: { + + if (!is_system_file) { + AppFile file(sync_file_name_, is_persistent_file_, + is_download_compleate, file_type_); + + if (0 == offset_) { + LOG4CXX_INFO(logger_, "New file downloading"); + if (!application->AddFile(file)) { + + LOG4CXX_INFO(logger_, + "Couldn't add file to application (File already Exist" + << " in application and was rewritten on FS)"); + /* It can be first part of new big file, so we need to update + information about it's downloading status and persistence */ + if (!application->UpdateFile(file)) { + LOG4CXX_INFO(logger_, "Couldn't update file"); + /* If it is impossible to update file, application doesn't + know about existing this file */ + SendResponse(false, mobile_apis::Result::INVALID_DATA, + "Couldn't update file", + &response_params); + return; + } + } else { + /* if file added - increment it's count + ( may be application->AddFile have to incapsulate it? ) + Any way now this method evals not only in "none"*/ + application->increment_put_file_in_none_count(); + } + } + } + + SendResponse(true, save_result, "File was downloaded", &response_params); + if (is_system_file) { + SendOnPutFileNotification(); + } + break; + } + default: + LOG4CXX_INFO(logger_, "Save in unsuccessful. Result = " << save_result); + SendResponse(false, save_result, "Can't save file", &response_params); + break; + } +} + +void PutFileRequest::SendOnPutFileNotification() { + LOG4CXX_INFO(logger_, "SendOnPutFileNotification" ); + smart_objects::SmartObject* notification = new smart_objects::SmartObject( + smart_objects::SmartType_Map); + + smart_objects::SmartObject& message = *notification; + message[strings::params][strings::function_id] = + hmi_apis::FunctionID::BasicCommunication_OnPutFile; + + message[strings::params][strings::message_type] = MessageType::kNotification; + message[strings::msg_params][strings::app_id] = connection_key(); + message[strings::msg_params][strings::sync_file_name] = sync_file_name_; + message[strings::msg_params][strings::offset] = offset_; + if (0 == offset_) { + message[strings::msg_params][strings::file_size] = + (*message_)[strings::msg_params][strings::length]; + } + message[strings::msg_params][strings::length] = length_; + message[strings::msg_params][strings::persistent_file] = is_persistent_file_; + message[strings::msg_params][strings::file_type] = file_type_; + ApplicationManagerImpl::instance()->ManageHMICommand(&message); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/put_file_response.cc b/src/components/application_manager/src/commands/mobile/put_file_response.cc new file mode 100644 index 0000000000..4ab950d7a8 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/put_file_response.cc @@ -0,0 +1,67 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/put_file_response.h" +#include "utils/file_system.h" +#include "application_manager/application_impl.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +PutFileResponse::PutFileResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +PutFileResponse::~PutFileResponse() { +} + +void PutFileResponse::Run() { + LOG4CXX_INFO(logger_, "PutFileResponse::Run"); + uint32_t app_id = (*message_)[strings::params][strings::connection_key] + .asUInt(); + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); + if (!app) { + LOG4CXX_ERROR(logger_, "Application not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + + SendResponse((*message_)[strings::msg_params][strings::success].asBool()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/read_did_request.cc b/src/components/application_manager/src/commands/mobile/read_did_request.cc new file mode 100644 index 0000000000..1de080df4c --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/read_did_request.cc @@ -0,0 +1,122 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/read_did_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +ReadDIDRequest::ReadDIDRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +ReadDIDRequest::~ReadDIDRequest() { +} + +void ReadDIDRequest::Run() { + LOG4CXX_INFO(logger_, "ReadDIDRequest::Run"); + + uint32_t app_id = (*message_)[strings::params][strings::connection_key] + .asUInt(); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); + LOG4CXX_INFO(logger_, "Correlation_id :" << (*message_)[strings::params][strings::correlation_id] + .asUInt()); + + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "An application is not registered."); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (mobile_api::HMILevel::HMI_NONE == app->hmi_level()) { + SendResponse(false, mobile_apis::Result::REJECTED); + LOG4CXX_ERROR(logger_, "Rejected"); + return; + } + + if (app->IsCommandLimitsExceeded( + static_cast<mobile_apis::FunctionID::eType>(function_id()), + application_manager::TLimitSource::CONFIG_FILE)) { + LOG4CXX_ERROR(logger_, "ReadDID frequency is too high."); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + if ((*message_)[strings::msg_params][strings::did_location].empty()) { + LOG4CXX_ERROR_EXT(logger_, "INVALID_DATA"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + msg_params[strings::app_id] = app->app_id(); + msg_params[strings::ecu_name] = + (*message_)[strings::msg_params][strings::ecu_name]; + msg_params[strings::did_location] = + (*message_)[strings::msg_params][strings::did_location]; + + SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_ReadDID, &msg_params, true); +} + +void ReadDIDRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "ReadDIDRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::VehicleInfo_ReadDID: { + mobile_apis::Result::eType result_code = + static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + bool result = mobile_apis::Result::SUCCESS == result_code; + + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/read_did_response.cc b/src/components/application_manager/src/commands/mobile/read_did_response.cc new file mode 100644 index 0000000000..888b590758 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/read_did_response.cc @@ -0,0 +1,56 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/read_did_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +ReadDIDResponse::ReadDIDResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +ReadDIDResponse::~ReadDIDResponse() { +} + +void ReadDIDResponse::Run() { + LOG4CXX_INFO(logger_, "ReadDIDResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager 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 new file mode 100644 index 0000000000..d33a99a0a9 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -0,0 +1,881 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/register_app_interface_request.h" + +#include <unistd.h> +#include <algorithm> +#include <string.h> + +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler.h" +#include "config_profile/profile.h" +#include "interfaces/MOBILE_API.h" + +namespace { + +mobile_apis::AppHMIType::eType StringToAppHMIType(const std::string& str) { + if ("DEFAULT" == str) { + return mobile_apis::AppHMIType::DEFAULT; + } else if ("COMMUNICATION" == str) { + return mobile_apis::AppHMIType::COMMUNICATION; + } else if ("MEDIA" == str) { + return mobile_apis::AppHMIType::MEDIA; + } else if ("MESSAGING" == str) { + return mobile_apis::AppHMIType::MESSAGING; + } else if ("NAVIGATION" == str) { + return mobile_apis::AppHMIType::NAVIGATION; + } else if ("INFORMATION" == str) { + return mobile_apis::AppHMIType::INFORMATION; + } else if ("SOCIAL" == str) { + return mobile_apis::AppHMIType::SOCIAL; + } else if ("BACKGROUND_PROCESS" == str) { + return mobile_apis::AppHMIType::BACKGROUND_PROCESS; + } else if ("TESTING" == str) { + return mobile_apis::AppHMIType::TESTING; + } else if ("SYSTEM" == str) { + return mobile_apis::AppHMIType::SYSTEM; + } else { + return mobile_apis::AppHMIType::INVALID_ENUM; + } +} + +struct AppHMITypeInserter { + AppHMITypeInserter(smart_objects::SmartObject& so_array) + : index_(0), + so_array_(so_array) { + } + + bool operator()(const std::string& app_hmi_type) { + so_array_[index_] = StringToAppHMIType(app_hmi_type); + ++index_; + return true; + } + + private: + uint32_t index_; + smart_objects::SmartObject& so_array_; +}; + +struct CheckMissedTypes { + CheckMissedTypes(const policy::StringArray& policy_app_types, + std::string& log) + : policy_app_types_(policy_app_types), + log_(log) { + } + + bool operator()(const smart_objects::SmartArray::value_type& value) { + std::string app_type_str = value.asString(); + policy::StringArray::const_iterator it = policy_app_types_.begin(); + policy::StringArray::const_iterator it_end = policy_app_types_.end(); + for (; it != it_end; ++it) { + if (app_type_str == *it) { + return true; + } + } + + log_ += app_type_str; + log_ += ","; + + return true; + } + + private: + const policy::StringArray& policy_app_types_; + std::string& log_; +}; +} + +namespace application_manager { + +namespace commands { + +RegisterAppInterfaceRequest::RegisterAppInterfaceRequest( + const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +RegisterAppInterfaceRequest::~RegisterAppInterfaceRequest() { +} + +bool RegisterAppInterfaceRequest::Init() { + LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::Init"); + return true; +} + +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 + // to RTC + if (true == profile::Profile::instance()->launch_hmi()) { + // wait till HMI started + while (!ApplicationManagerImpl::instance()->IsHMICooperating()) { + sleep(1); + // TODO(DK): timer_->StartWait(1); + ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(), + correlation_id(), + default_timeout()); + } + } + + std::string mobile_app_id = (*message_)[strings::msg_params][strings::app_id] + .asString(); + if (policy::PolicyHandler::instance()->IsApplicationRevoked(mobile_app_id)) { + SendResponse(false, mobile_apis::Result::DISALLOWED); + return; + } + + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (application) { + SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY); + return; + } + + mobile_apis::Result::eType policy_result = CheckWithPolicyData(); + if (mobile_apis::Result::SUCCESS != policy_result + && mobile_apis::Result::WARNINGS != policy_result) { + SendResponse(false, policy_result); + return; + } + + mobile_apis::Result::eType coincidence_result = CheckCoincidence(); + + if (mobile_apis::Result::SUCCESS != coincidence_result) { + LOG4CXX_ERROR_EXT(logger_, "Coincidence check failed."); + if (mobile_apis::Result::DUPLICATE_NAME == coincidence_result) { + usage_statistics::AppCounter count_of_rejections_duplicate_name( + policy::PolicyHandler::instance()->GetStatisticManager(), mobile_app_id, + usage_statistics::REJECTIONS_DUPLICATE_NAME); + ++count_of_rejections_duplicate_name; + } + SendResponse(false, coincidence_result); + return; + } + + if (IsApplicationWithSameAppIdRegistered()) { + SendResponse(false, mobile_apis::Result::DISALLOWED); + 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"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->RegisterApplication(message_); + + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "Application " << + msg_params[strings::app_name].asString() << + " hasn't been registered!"); + } else { + + // For resuming application need to restore hmi_app_id from resumeCtrl + const std::string mobile_app_id = msg_params[strings::app_id].asString(); + ResumeCtrl& resumer = ApplicationManagerImpl::instance()->resume_controller(); + + // there is side affect with 2 mobile app with the same mobile app_id + if (resumer.IsApplicationSaved(mobile_app_id)) { + app->set_hmi_application_id(resumer.GetHMIApplicationID(mobile_app_id)); + } else { + app->set_hmi_application_id( + ApplicationManagerImpl::instance()->GenerateNewHMIAppID()); + } + + app->set_is_media_application( + msg_params[strings::is_media_application].asBool()); + + if (msg_params.keyExists(strings::vr_synonyms)) { + app->set_vr_synonyms(msg_params[strings::vr_synonyms]); + } + + if (msg_params.keyExists(strings::ngn_media_screen_app_name)) { + app->set_ngn_media_screen_name( + msg_params[strings::ngn_media_screen_app_name]); + } + + if (msg_params.keyExists(strings::tts_name)) { + app->set_tts_name(msg_params[strings::tts_name]); + } + + if (msg_params.keyExists(strings::app_hmi_type)) { + app->set_app_types(msg_params[strings::app_hmi_type]); + + // check if app is NAVI + const int32_t is_navi_type = mobile_apis::AppHMIType::NAVIGATION; + const smart_objects::SmartObject& app_type = + msg_params.getElement(strings::app_hmi_type); + + for (size_t i = 0; i < app_type.length(); ++i) { + if (is_navi_type == app_type.getElement(i).asInt()) { + app->set_allowed_support_navigation(true); + } + } + } + + const connection_handler::DeviceHandle handle = app->device(); + // Add device to policy table and set device info, if any + std::string device_mac_address = + application_manager::MessageHelper::GetDeviceMacAddressForHandle(handle); + policy::DeviceParams dev_params; + application_manager::MessageHelper::GetDeviceInfoForHandle(handle, + &dev_params); + policy::DeviceInfo device_info; + device_info.connection_type = dev_params.device_connection_type; + if (msg_params.keyExists(strings::device_info)) { + FillDeviceInfo(&device_info); + } + + policy::PolicyHandler::instance()->SetDeviceInfo(device_mac_address, + device_info); + + SendRegisterAppInterfaceResponseToMobile(); + 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); + + ApplicationManagerImpl* app_manager = ApplicationManagerImpl::instance(); + const HMICapabilities& hmi_capabilities = app_manager->hmi_capabilities(); + const uint32_t key = connection_key(); + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application(key); + + if (!application.valid()) { + 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] = + APIVersion::kAPIV0; + + response_params[strings::language] = hmi_capabilities.active_vr_language(); + response_params[strings::hmi_display_language] = + hmi_capabilities.active_ui_language(); + + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + if (msg_params[strings::language_desired].asInt() != + hmi_capabilities.active_vr_language() || + msg_params[strings::hmi_display_language_desired].asInt() != + hmi_capabilities.active_ui_language()) { + + LOG4CXX_WARN_EXT( + logger_, + "Wrong language on registering application " << application->name()); + + LOG4CXX_ERROR_EXT( + logger_, + "vr " + << msg_params[strings::language_desired].asInt() + << " - " + << hmi_capabilities.active_vr_language() + << "ui " + << msg_params[strings::hmi_display_language_desired].asInt() + << " - " + << hmi_capabilities.active_ui_language()); + + result = mobile_apis::Result::WRONG_LANGUAGE; + } + + if (hmi_capabilities.display_capabilities()) { + response_params[hmi_response::display_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + smart_objects::SmartObject& display_caps = + response_params[hmi_response::display_capabilities]; + + display_caps[hmi_response::display_type] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::display_type); + + display_caps[hmi_response::text_fields] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::text_fields); + + display_caps[hmi_response::image_fields] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::image_fields); + + display_caps[hmi_response::media_clock_formats] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::media_clock_formats); + + display_caps[hmi_response::templates_available] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::templates_available); + + display_caps[hmi_response::screen_params] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::screen_params); + + display_caps[hmi_response::num_custom_presets_available] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::num_custom_presets_available); + + if (hmi_capabilities.display_capabilities()->getElement( + hmi_response::image_capabilities).length() > 0) { + display_caps[hmi_response::graphic_supported] = true; + } else { + display_caps[hmi_response::graphic_supported] = false; + } + + display_caps[hmi_response::templates_available] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::templates_available); + + display_caps[hmi_response::screen_params] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::screen_params); + + display_caps[hmi_response::num_custom_presets_available] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::num_custom_presets_available); + } + + if (hmi_capabilities.button_capabilities()) { + response_params[hmi_response::button_capabilities] = + *hmi_capabilities.button_capabilities(); + } + if (hmi_capabilities.soft_button_capabilities()) { + response_params[hmi_response::soft_button_capabilities] = + *hmi_capabilities.soft_button_capabilities(); + } + if (hmi_capabilities.preset_bank_capabilities()) { + response_params[hmi_response::preset_bank_capabilities] = + *hmi_capabilities.preset_bank_capabilities(); + } + if (hmi_capabilities.hmi_zone_capabilities()) { + response_params[hmi_response::hmi_zone_capabilities] = + *hmi_capabilities.hmi_zone_capabilities(); + } + if (hmi_capabilities.speech_capabilities()) { + response_params[strings::speech_capabilities] = + *hmi_capabilities.speech_capabilities(); + } + if (hmi_capabilities.vr_capabilities()) { + response_params[strings::vr_capabilities] = + *hmi_capabilities.vr_capabilities(); + } + if (hmi_capabilities.audio_pass_thru_capabilities()) { + response_params[strings::audio_pass_thru_capabilities] = + *hmi_capabilities.audio_pass_thru_capabilities(); + } + if (hmi_capabilities.vehicle_type()) { + response_params[hmi_response::vehicle_type] = + *hmi_capabilities.vehicle_type(); + } + if (hmi_capabilities.prerecorded_speech()) { + response_params[strings::prerecorded_speech] = + *(hmi_capabilities.prerecorded_speech()); + } + + const std::vector<uint32_t>& diag_modes = + profile::Profile::instance()->supported_diag_modes(); + if (!diag_modes.empty()) { + std::vector<uint32_t>::const_iterator it = diag_modes.begin(); + uint32_t index = 0; + for (; it != diag_modes.end(); ++it) { + response_params[strings::supported_diag_modes][index] = *it; + ++index; + } + } + + ResumeCtrl& resumer = ApplicationManagerImpl::instance()->resume_controller(); + uint32_t hash_id = 0; + + const char* add_info = ""; + bool resumption = (*message_)[strings::msg_params].keyExists(strings::hash_id); + if (resumption) { + hash_id = (*message_)[strings::msg_params][strings::hash_id].asUInt(); + if (!resumer.CheckApplicationHash(application, hash_id)) { + LOG4CXX_WARN(logger_, "Hash does not matches"); + result = mobile_apis::Result::RESUME_FAILED; + add_info = "Hash does not matches"; + resumption = false; + } else if (!resumer.CheckPersistenceFilesForResumption(application)) { + LOG4CXX_WARN(logger_, "Persistent data is missed"); + result = mobile_apis::Result::RESUME_FAILED; + add_info = "Persistent data is missed"; + resumption = false; + } else { + add_info = " Resume Succeed"; + } + } + + SendResponse(true, result, add_info, params); + + MessageHelper::SendOnAppRegisteredNotificationToHMI(*(application.get()), + resumption); + + MessageHelper::SendChangeRegistrationRequestToHMI(application); + + if (result != mobile_apis::Result::RESUME_FAILED) { + resumer.StartResumption(application, hash_id); + } else { + resumer.StartResumptionOnlyHMILevel(application); + } +} + +mobile_apis::Result::eType +RegisterAppInterfaceRequest::CheckCoincidence() { + LOG4CXX_TRACE_ENTER(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(); + const std::string app_name = msg_params[strings::app_name].asString(); + + for (; applications.end() != it; ++it) { + + // name check + const std::string& cur_name = (*it)->name(); + if (!strcasecmp(app_name.c_str(), cur_name.c_str())) { + LOG4CXX_ERROR(logger_, "Application name is known already."); + return mobile_apis::Result::DUPLICATE_NAME; + } + + const smart_objects::SmartObject* vr = (*it)->vr_synonyms(); + const std::vector<smart_objects::SmartObject>* curr_vr = NULL; + if (NULL != vr) { + curr_vr = vr->asArray(); + CoincidencePredicateVR v(app_name); + + if (0 != std::count_if(curr_vr->begin(), curr_vr->end(), v)) { + LOG4CXX_ERROR(logger_, "Application name is known already."); + return mobile_apis::Result::DUPLICATE_NAME; + } + } + + // vr check + if (msg_params.keyExists(strings::vr_synonyms)) { + const std::vector<smart_objects::SmartObject>* new_vr = + msg_params[strings::vr_synonyms].asArray(); + + CoincidencePredicateVR v(cur_name); + if (0 != std::count_if(new_vr->begin(), new_vr->end(), v)) { + LOG4CXX_ERROR(logger_, "vr_synonyms duplicated with app_name ."); + return mobile_apis::Result::DUPLICATE_NAME; + } + } // end vr check + + } // application for end + + return mobile_apis::Result::SUCCESS; +} // method end + +mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() { + LOG4CXX_INFO(logger_, "CheckWithPolicyData"); + // TODO(AOleynik): Check is necessary to allow register application in case + // of disabled policy + // Remove this check, when HMI will support policy + if (!policy::PolicyHandler::instance()->PolicyEnabled()) { + return mobile_apis::Result::WARNINGS; + } + + smart_objects::SmartObject& message = *message_; + policy::StringArray app_nicknames; + policy::StringArray app_hmi_types; + + std::string mobile_app_id = message[strings::msg_params][strings::app_id].asString(); + const bool init_result = policy::PolicyHandler::instance()->GetInitialAppData( + mobile_app_id, &app_nicknames, &app_hmi_types); + + if (!init_result) { + LOG4CXX_ERROR(logger_, "Error during initial application data check."); + return mobile_apis::Result::INVALID_DATA; + } + + if (!app_nicknames.empty()) { + policy::StringArray::const_iterator it = std::find( + app_nicknames.begin(), app_nicknames.end(), + message[strings::msg_params][strings::app_name].asString()); + if (app_nicknames.end() == it) { + LOG4CXX_WARN(logger_, + "Application name was not found in nicknames list."); + //App should be unregistered, if its name is not present in nicknames list + usage_statistics::AppCounter count_of_rejections_nickname_mismatch( + policy::PolicyHandler::instance()->GetStatisticManager(), mobile_app_id, + usage_statistics::REJECTIONS_NICKNAME_MISMATCH); + ++count_of_rejections_nickname_mismatch; + return mobile_apis::Result::DISALLOWED; + } + } + + mobile_apis::Result::eType result = mobile_apis::Result::SUCCESS; + + // If AppHMIType is not included in policy - allow any type + if (!app_hmi_types.empty()) { + if (message[strings::msg_params].keyExists(strings::app_hmi_type)) { + // If AppHMITypes are partially same, the system should allow those listed + // in the policy table and send warning info on missed values + smart_objects::SmartArray app_types = + *(message[strings::msg_params][strings::app_hmi_type].asArray()); + + std::string log; + CheckMissedTypes checker(app_hmi_types, log); + std::for_each(app_types.begin(), app_types.end(), checker); + if (!log.empty()) { + response_info_ = "Following AppHMITypes are not present in policy " + "table:" + log; + result = mobile_apis::Result::WARNINGS; + } + } + // Replace AppHMITypes in request with values allowed by policy table + message[strings::msg_params][strings::app_hmi_type] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + smart_objects::SmartObject& app_hmi_type = + message[strings::msg_params][strings::app_hmi_type]; + + AppHMITypeInserter inserter(app_hmi_type); + std::for_each(app_hmi_types.begin(), app_hmi_types.end(), inserter); + } + + return result; +} + +void RegisterAppInterfaceRequest::FillDeviceInfo( + policy::DeviceInfo* device_info) { + const std::string hardware = "hardware"; + const std::string firmware_rev = "firmwareRev"; + const std::string os = "os"; + const std::string os_ver = "osVersion"; + const std::string carrier = "carrier"; + const std::string max_number_rfcom_ports = "maxNumberRFCOMMPorts"; + + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + const smart_objects::SmartObject& device_info_so = + msg_params[strings::device_info]; + + if (device_info_so.keyExists(hardware)) { + device_info->hardware = msg_params[strings::device_info][hardware].asString(); + } + if (device_info_so.keyExists(firmware_rev)) { + device_info->firmware_rev = msg_params[strings::device_info][firmware_rev].asString(); + } + if (device_info_so.keyExists(os)) { + device_info->os = device_info_so[os].asString(); + } + if (device_info_so.keyExists(os_ver)) { + device_info->os_ver = device_info_so[os_ver].asString(); + } + if (device_info_so.keyExists(carrier)) { + device_info->carrier = device_info_so[carrier].asString(); + } + if (device_info_so.keyExists(max_number_rfcom_ports)) { + device_info->max_number_rfcom_ports = + device_info_so[max_number_rfcom_ports].asInt(); + } +} + +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(); + + ApplicationManagerImpl::ApplicationListAccessor accessor; + const std::set<ApplicationSharedPtr> applications = accessor.applications(); + + std::set<ApplicationSharedPtr>::const_iterator it = applications.begin(); + std::set<ApplicationSharedPtr>::const_iterator it_end = applications.end(); + + for (; it != it_end; ++it) { + if (mobile_app_id == (*it)->mobile_app_id()->asString()) { + return true; + } + } + + return false; +} + +bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() { + LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::IsWhiteSpaceExist"); + const char* str = NULL; + + str = (*message_)[strings::msg_params][strings::app_name].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid app_name syntax check failed"); + return true; + } + + + if ((*message_)[strings::msg_params].keyExists(strings::tts_name)) { + const smart_objects::SmartArray* tn_array = + (*message_)[strings::msg_params][strings::tts_name].asArray(); + + smart_objects::SmartArray::const_iterator it_tn = tn_array->begin(); + smart_objects::SmartArray::const_iterator it_tn_end = tn_array->end(); + + for (; it_tn != it_tn_end; ++it_tn) { + str = (*it_tn)[strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid tts_name syntax check failed"); + return true; + } + } + } + + if ((*message_)[strings::msg_params]. + keyExists(strings::ngn_media_screen_app_name)) { + str = (*message_)[strings::msg_params] + [strings::ngn_media_screen_app_name].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid ngn_media_screen_app_name syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::vr_synonyms)) { + const smart_objects::SmartArray* vs_array = + (*message_)[strings::msg_params][strings::vr_synonyms].asArray(); + + smart_objects::SmartArray::const_iterator it_vs = vs_array->begin(); + smart_objects::SmartArray::const_iterator it_vs_end = vs_array->end(); + + for (; it_vs != it_vs_end; ++it_vs) { + str = (*it_vs).asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid vr_synonyms syntax check failed"); + return true; + } + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::hash_id)) { + str = (*message_)[strings::msg_params][strings::hash_id].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid hash_id syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::device_info)) { + + if ((*message_)[strings::msg_params][strings::device_info]. + keyExists(strings::hardware)) { + str = (*message_)[strings::msg_params] + [strings::device_info][strings::hardware].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid device_info hardware syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params][strings::device_info]. + keyExists(strings::firmware_rev)) { + str = (*message_)[strings::msg_params] + [strings::device_info][strings::firmware_rev].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid device_info firmware_rev syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params][strings::device_info]. + keyExists(strings::os)) { + str = (*message_)[strings::msg_params] + [strings::device_info][strings::os].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid device_info os syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params][strings::device_info]. + keyExists(strings::os_version)) { + str = (*message_)[strings::msg_params] + [strings::device_info][strings::os_version].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid device_info os_version syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params][strings::device_info]. + keyExists(strings::carrier)) { + str = (*message_)[strings::msg_params] + [strings::device_info][strings::carrier].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid device_info carrier syntax check failed"); + return true; + } + } + + } + + if ((*message_)[strings::msg_params].keyExists(strings::app_id)) { + str = (*message_)[strings::msg_params][strings::app_id].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid app_id syntax check failed"); + return true; + } + } + return false; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc new file mode 100644 index 0000000000..fe6f3a925a --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc @@ -0,0 +1,93 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/register_app_interface_response.h" +#include "interfaces/MOBILE_API.h" +#include "application_manager/policies/policy_handler.h" +#include "application_manager/application_manager_impl.h" +#include "connection_handler/connection_handler.h" + +namespace application_manager { + +namespace commands { + +void RegisterAppInterfaceResponse::Run() { + LOG4CXX_INFO(logger_, "RegisterAppInterfaceResponse::Run"); + + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; + bool success = (*message_)[strings::msg_params][strings::success].asBool(); + bool last_message = !success; + // Do not close connection in case of APPLICATION_NOT_REGISTERED despite it is an error + if (!success && (*message_)[strings::msg_params].keyExists(strings::result_code)) { + result_code = static_cast<mobile_apis::Result::eType>( + (*message_)[strings::msg_params][strings::result_code].asInt()); + if (result_code == mobile_apis::Result::APPLICATION_REGISTERED_ALREADY) { + last_message = false; + } + } + + SendResponse(success, result_code, last_message); + + // Add registered application to the policy db right after response sent to + // mobile to be able to check all other API according to app permissions + uint32_t connection_key = + (*message_)[strings::params][strings::connection_key].asUInt(); + application_manager::ApplicationConstSharedPtr app = + application_manager::ApplicationManagerImpl::instance()-> + application(connection_key); + if (app.valid()) { + policy::PolicyHandler *policy_handler = policy::PolicyHandler::instance(); + std::string mobile_app_id = app->mobile_app_id()->asString(); + policy_handler->AddApplication(mobile_app_id); + SetHeartBeatTimeout(connection_key, mobile_app_id); + } +} + +void RegisterAppInterfaceResponse::SetHeartBeatTimeout( + uint32_t connection_key, const std::string& mobile_app_id) { + LOG4CXX_TRACE_ENTER(logger_); + policy::PolicyHandler *policy_handler = policy::PolicyHandler::instance(); + if (policy_handler->PolicyEnabled()) { + const int32_t timeout = policy_handler->HeartBeatTimeout(mobile_app_id); + if (timeout > 0) { + application_manager::ApplicationManagerImpl::instance()-> + connection_handler()->SetHeartBeatTimeout(connection_key, timeout); + } + } else { + LOG4CXX_INFO(logger_, "Policy is turn off"); + } + LOG4CXX_TRACE_EXIT(logger_); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc new file mode 100644 index 0000000000..5e62b789d8 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc @@ -0,0 +1,302 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/reset_global_properties_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "config_profile/profile.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +ResetGlobalPropertiesRequest::ResetGlobalPropertiesRequest( + const MessageSharedPtr& message) + : CommandRequestImpl(message), + is_ui_send_(false), + is_tts_send_(false), + is_ui_received_(false), + is_tts_received_(false), + ui_result_(hmi_apis::Common_Result::INVALID_ENUM), + tts_result_(hmi_apis::Common_Result::INVALID_ENUM) { +} + +ResetGlobalPropertiesRequest::~ResetGlobalPropertiesRequest() { +} + +void ResetGlobalPropertiesRequest::Run() { + LOG4CXX_INFO(logger_, "ResetGlobalPropertiesRequest::Run"); + + uint32_t app_id = (*message_)[strings::params][strings::connection_key].asUInt(); + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); + + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "No application associated with session key"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + size_t obj_length = (*message_)[strings::msg_params][strings::properties] + .length(); + //if application waits for sending ttsGlobalProperties need to remove this + //application from tts_global_properties_app_list_ + LOG4CXX_INFO(logger_, "RemoveAppFromTTSGlobalPropertiesList"); + ApplicationManagerImpl::instance()->RemoveAppFromTTSGlobalPropertiesList( + app_id); + + bool helpt_promt = false; + bool timeout_prompt = false; + bool vr_help_title_items = false; + bool menu_name = false; + bool menu_icon = false; + bool is_key_board_properties = false; + int number_of_reset_vr = 0; + mobile_apis::GlobalProperty::eType global_property = + mobile_apis::GlobalProperty::INVALID_ENUM; + + for (size_t i = 0; i < obj_length; ++i) { + global_property = static_cast<mobile_apis::GlobalProperty::eType>( + (*message_)[strings::msg_params][strings::properties][i].asInt()); + + if (mobile_apis::GlobalProperty::HELPPROMPT == global_property) { + helpt_promt = ResetHelpPromt(app); + } else if (mobile_apis::GlobalProperty::TIMEOUTPROMPT == global_property) { + timeout_prompt = ResetTimeoutPromt(app); + } else if (((mobile_apis::GlobalProperty::VRHELPTITLE == global_property) || + (mobile_apis::GlobalProperty::VRHELPITEMS == global_property)) && + (0 == number_of_reset_vr)) { + ++number_of_reset_vr; + vr_help_title_items = ResetVrHelpTitleItems(app); + } else if (mobile_apis::GlobalProperty::MENUNAME == global_property) { + menu_name = true; + } else if (mobile_apis::GlobalProperty::MENUICON == global_property) { + menu_icon = true; + } else if (mobile_apis::GlobalProperty::KEYBOARDPROPERTIES == global_property) { + is_key_board_properties = true; + } + } + + if (vr_help_title_items || menu_name || menu_icon || is_key_board_properties) { + is_ui_send_ = true; + } + + if (timeout_prompt || helpt_promt) { + is_tts_send_ = true; + } + + app->set_reset_global_properties_active(true); + + if (vr_help_title_items || menu_name || menu_icon || is_key_board_properties) { + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + if (vr_help_title_items) { + smart_objects::SmartObject* vr_help = MessageHelper::CreateAppVrHelp(app); + if (!vr_help) { + return; + } + msg_params = *vr_help; + } + if (menu_name) { + msg_params[hmi_request::menu_title] = ""; + app->set_menu_title(msg_params[hmi_request::menu_title]); + } + //TODO(DT): clarify the sending parameter menuIcon + //if (menu_icon) { + //} + if (is_key_board_properties) { + smart_objects::SmartObject key_board_properties = smart_objects:: + SmartObject(smart_objects::SmartType_Map); + key_board_properties[strings::language] = static_cast<int32_t> + (hmi_apis::Common_Language::EN_US); + key_board_properties[hmi_request::keyboard_layout] = static_cast<int32_t> + (hmi_apis::Common_KeyboardLayout::QWERTY); + + // Look for APPLINK-4432 for details. + /*smart_objects::SmartObject limited_character_list = smart_objects::SmartObject( + smart_objects::SmartType_Array); + limited_character_list[0] = ""; + key_board_properties[hmi_request::limited_character_list] = + limited_character_list;*/ + + key_board_properties[hmi_request::auto_complete_text] = ""; + msg_params[hmi_request::keyboard_properties] = key_board_properties; + } + + msg_params[strings::app_id] = app->app_id(); + SendHMIRequest(hmi_apis::FunctionID::UI_SetGlobalProperties, + &msg_params, true); + } + + if (timeout_prompt || helpt_promt) { + // create ui request + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + if (helpt_promt) { + msg_params[strings::help_prompt] = (*app->help_prompt()); + } + + if (timeout_prompt) { + msg_params[strings::timeout_prompt] = (*app->timeout_prompt()); + } + + msg_params[strings::app_id] = app->app_id(); + + SendHMIRequest(hmi_apis::FunctionID::TTS_SetGlobalProperties, + &msg_params, true); + } +} + +bool ResetGlobalPropertiesRequest::ResetHelpPromt( + application_manager::ApplicationSharedPtr app) { + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "Null pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return false; + } + smart_objects::SmartObject so_help_prompt = smart_objects::SmartObject( + smart_objects::SmartType_Array); + app->set_help_prompt(so_help_prompt); + return true; +} + +bool ResetGlobalPropertiesRequest::ResetTimeoutPromt( + application_manager::ApplicationSharedPtr const app) { + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "Null pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return false; + } + + const std::vector<std::string>& time_out_promt = profile::Profile::instance() + ->time_out_promt(); + + smart_objects::SmartObject so_time_out_promt = smart_objects::SmartObject( + smart_objects::SmartType_Array); + + for (uint32_t i = 0; i < time_out_promt.size(); ++i) { + smart_objects::SmartObject timeoutPrompt = smart_objects::SmartObject( + smart_objects::SmartType_Map); + timeoutPrompt[strings::text] = time_out_promt[i]; + timeoutPrompt[strings::type] = hmi_apis::Common_SpeechCapabilities::SC_TEXT; + so_time_out_promt[i] = timeoutPrompt; + } + + app->set_timeout_prompt(so_time_out_promt); + + return true; +} + +bool ResetGlobalPropertiesRequest::ResetVrHelpTitleItems( + application_manager::ApplicationSharedPtr const app) { + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "Null pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return false; + } + app->reset_vr_help_title(); + app->reset_vr_help(); + + return true; +} + +void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "ResetGlobalPropertiesRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_SetGlobalProperties: { + LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event"); + is_ui_received_ = true; + ui_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + break; + } + case hmi_apis::FunctionID::TTS_SetGlobalProperties: { + LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event"); + is_tts_received_ = true; + tts_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } + + if (!IsPendingResponseExist()) { + bool result = ((hmi_apis::Common_Result::SUCCESS == ui_result_) + && (hmi_apis::Common_Result::SUCCESS == tts_result_ || + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_)) + || ((hmi_apis::Common_Result::SUCCESS == ui_result_) + && (hmi_apis::Common_Result::INVALID_ENUM == tts_result_)) + || ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_) + && (hmi_apis::Common_Result::SUCCESS == tts_result_)); + + mobile_apis::Result::eType result_code; + const char* return_info = NULL; + + if (result) { + if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_) { + result_code = mobile_apis::Result::WARNINGS; + return_info = std::string("Unsupported phoneme type sent in a prompt").c_str(); + } else { + result_code = static_cast<mobile_apis::Result::eType>( + std::max(ui_result_, tts_result_)); + } + } else { + result_code = static_cast<mobile_apis::Result::eType>( + std::max(ui_result_, tts_result_)); + } + + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application(connection_key()); + SendResponse(result, static_cast<mobile_apis::Result::eType>(result_code), + return_info, &(message[strings::msg_params])); + application->UpdateHash(); + } +} + +bool ResetGlobalPropertiesRequest::IsPendingResponseExist() { + return is_ui_send_ != is_ui_received_ || is_tts_send_ != is_tts_received_; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc b/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc new file mode 100644 index 0000000000..aeacabf9d5 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc @@ -0,0 +1,57 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/reset_global_properties_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +ResetGlobalPropertiesResponse::ResetGlobalPropertiesResponse( + const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +ResetGlobalPropertiesResponse::~ResetGlobalPropertiesResponse() { +} + +void ResetGlobalPropertiesResponse::Run() { + LOG4CXX_INFO(logger_, "ResetGlobalPropertiesResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc b/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc new file mode 100644 index 0000000000..5b3cfa67ac --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc @@ -0,0 +1,155 @@ +/* + + Copyright (c) 2013, 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 <string.h> +#include "application_manager/commands/mobile/scrollable_message_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +ScrollableMessageRequest::ScrollableMessageRequest( + const MessageSharedPtr& message) + : CommandRequestImpl(message) { + subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); +} + +ScrollableMessageRequest::~ScrollableMessageRequest() { +} + +bool ScrollableMessageRequest::Init() { + + /* Timeout in milliseconds. + If omitted a standard value of 10000 milliseconds is used.*/ + if ((*message_)[strings::msg_params].keyExists(strings::timeout)) { + default_timeout_ = + (*message_)[strings::msg_params][strings::timeout].asUInt(); + } else { + const int32_t def_value = 30000; + default_timeout_ = def_value; + } + + return true; +} + +void ScrollableMessageRequest::Run() { + LOG4CXX_INFO(logger_, "ScrollableMessageRequest::Run"); + + ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance() + ->application((*message_)[strings::params][strings::connection_key].asUInt()); + + if (!app) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + //ProcessSoftButtons checks strings on the contents incorrect character + + mobile_apis::Result::eType processing_result = + MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app); + + if (mobile_apis::Result::SUCCESS != processing_result) { + LOG4CXX_ERROR(logger_, "Wrong soft buttons parameters!"); + SendResponse(false, processing_result); + return; + } + + + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + msg_params[hmi_request::message_text][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::scrollableMessageBody); + msg_params[hmi_request::message_text][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::scroll_message_body]; + msg_params[strings::app_id] = app->app_id(); + msg_params[strings::timeout] = default_timeout_; + + if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + msg_params[strings::soft_buttons] = + (*message_)[strings::msg_params][strings::soft_buttons]; + MessageHelper::SubscribeApplicationToSoftButton( + (*message_)[strings::msg_params], app, function_id()); + } + + SendHMIRequest(hmi_apis::FunctionID::UI_ScrollableMessage, &msg_params, true); +} + +void ScrollableMessageRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "ScrollableMessageRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_OnResetTimeout: { + LOG4CXX_INFO(logger_, "Received UI_OnResetTimeout event"); + ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(), + correlation_id(), + default_timeout()); + break; + } + case hmi_apis::FunctionID::UI_ScrollableMessage: { + LOG4CXX_INFO(logger_, "Received UI_ScrollableMessage event"); + + mobile_apis::Result::eType result_code = + static_cast<mobile_apis::Result::eType> + (message[strings::params][hmi_response::code].asInt()); + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + bool result = false; + if (mobile_apis::Result::SUCCESS == result_code || + mobile_apis::Result::ABORTED == result_code) { + result = true; + } else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) && + hmi_capabilities.is_ui_cooperating()) { + result = true; + } + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_,"Received unknown event" << event.id()); + break; + } + } +} + +} // namespace commands +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc b/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc new file mode 100644 index 0000000000..d9692359d0 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc @@ -0,0 +1,64 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/scrollable_message_response.h" +#include "application_manager/application_manager_impl.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +ScrollableMessageResponse::ScrollableMessageResponse( + const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +void ScrollableMessageResponse::Run() { + LOG4CXX_INFO(logger_, "ScrollableMessageResponse::Run"); + mobile_apis::Result::eType result_code = static_cast<mobile_apis::Result::eType>( + (*message_)[strings::msg_params][strings::result_code].asInt()); + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application( + (*message_)[strings::params][strings::connection_key].asInt()); + if ((mobile_apis::Result::REJECTED != result_code) && application) { + application->UnsubscribeFromSoftButtons( + (*message_)[strings::params][strings::function_id].asInt()); + } + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager 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 new file mode 100644 index 0000000000..b5c2e8a9a5 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/send_location_request.cc @@ -0,0 +1,166 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/send_location_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/message_helper.h" + +namespace application_manager { + +namespace commands { + +SendLocationRequest::SendLocationRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +SendLocationRequest::~SendLocationRequest() { +} + +void SendLocationRequest::Run() { + LOG4CXX_INFO(logger_, "SendLocationRequest::Run"); + + ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance() + ->application(connection_key()); + + if (!app) { + LOG4CXX_ERROR_EXT( + logger_, "An application " << app->name() << " is not registered."); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, "Strings contain invalid characters"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if ((*message_)[strings::msg_params].keyExists(strings::location_image)) { + mobile_apis::Result::eType verification_result = + mobile_apis::Result::SUCCESS; + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::location_image], app); + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + SendResponse(false, verification_result); + return; + } + } + + SendHMIRequest(hmi_apis::FunctionID::Navigation_SendLocation, + &((*message_)[strings::msg_params]), + true); +} + +void SendLocationRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "SendLocationRquest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + switch (event.id()) { + case hmi_apis::FunctionID::Navigation_SendLocation: { + LOG4CXX_INFO(logger_, "Received Navigation_SendLocation 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; + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_,"Received unknown event" << event.id()); + break; + } + } +} + +bool SendLocationRequest::IsWhiteSpaceExist() { + LOG4CXX_INFO(logger_, "SendLocationRquest::IsWhiteSpaceExist"); + const char* str; + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + if (msg_params.keyExists(strings::location_name)) { + str = msg_params[strings::location_name].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "parameter locationName contains invalid character"); + return true; + } + } + + if (msg_params.keyExists(strings::location_description)) { + str = msg_params[strings::location_description].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "parameter locationDescription contains invalid character"); + return true; + } + } + + if (msg_params.keyExists(strings::address_lines)) { + const smart_objects::SmartArray* al_array = + msg_params[strings::address_lines].asArray(); + smart_objects::SmartArray::const_iterator it_al = al_array->begin(); + smart_objects::SmartArray::const_iterator it_al_end = al_array->end(); + for (; it_al != it_al_end; ++it_al) { + str = (*it_al).asCharArray(); + if(!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "parameter address_lines contains invalid character"); + return true; + } + } + } + + if (msg_params.keyExists(strings::phone_number)) { + str = msg_params[strings::phone_number].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "parameter phoneNumber contains invalid character"); + return true; + } + } + + if (msg_params.keyExists(strings::location_image)) { + str = msg_params[strings::location_image][strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "parameter value in locationImage contains invalid character"); + return true; + } + } + + return false; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/send_location_response.cc b/src/components/application_manager/src/commands/mobile/send_location_response.cc new file mode 100644 index 0000000000..a13b67dc06 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/send_location_response.cc @@ -0,0 +1,58 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/send_location_response.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +SendLocationResponse::SendLocationResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +SendLocationResponse::~SendLocationResponse() { +} + +void SendLocationResponse::Run() { + LOG4CXX_INFO(logger_, "SendLocationResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc b/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc new file mode 100644 index 0000000000..60a2583287 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc @@ -0,0 +1,123 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/set_display_layout_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" + + +namespace application_manager { + +namespace commands { + +SetDisplayLayoutRequest::SetDisplayLayoutRequest( + const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +SetDisplayLayoutRequest::~SetDisplayLayoutRequest() { +} + +void SetDisplayLayoutRequest::Run() { + LOG4CXX_INFO(logger_, "SetDisplayLayoutRequest::Run"); + ApplicationConstSharedPtr app = ApplicationManagerImpl::instance() + ->application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + (*message_)[strings::msg_params][strings::app_id] = app->app_id(); + SendHMIRequest(hmi_apis::FunctionID::UI_SetDisplayLayout, + &((*message_)[strings::msg_params]), true); + +} + +void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "SetDisplayLayoutRequest::on_event"); + + const smart_objects::SmartObject& message = event.smart_object(); + switch (event.id()) { + case hmi_apis::FunctionID::UI_SetDisplayLayout: { + LOG4CXX_INFO(logger_, "Received UI_SetDisplayLayout event"); + + mobile_apis::Result::eType result_code = + static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + bool response_success = mobile_apis::Result::SUCCESS == result_code; + if (response_success) { + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + if (message[strings::msg_params].keyExists(hmi_response::display_capabilities)) { + hmi_capabilities.set_display_capabilities( + message[strings::msg_params][hmi_response::display_capabilities]); + } + + if (message[strings::msg_params].keyExists( + hmi_response::soft_button_capabilities)) { + if (message[strings::msg_params][hmi_response::soft_button_capabilities].getType() == + smart_objects::SmartType_Array) { + hmi_capabilities.set_soft_button_capabilities( + message[strings::msg_params][hmi_response::soft_button_capabilities][0]); + } else { + hmi_capabilities.set_soft_button_capabilities( + message[strings::msg_params][hmi_response::soft_button_capabilities]); + } + } + + if (message[strings::msg_params].keyExists(hmi_response::button_capabilities)) { + hmi_capabilities.set_button_capabilities( + message[strings::msg_params][hmi_response::button_capabilities]); + } + + if (message[strings::msg_params].keyExists(hmi_response::preset_bank_capabilities)) { + hmi_capabilities.set_preset_bank_capabilities( + message[strings::msg_params][hmi_response::preset_bank_capabilities]); + } + + } + SendResponse(response_success, result_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_,"Received unknown event" << event.id()); + return; + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc b/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc new file mode 100644 index 0000000000..51f8c1f35b --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc @@ -0,0 +1,59 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/set_display_layout_response.h" +#include "application_manager/application_impl.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +SetDisplayLayoutResponse::SetDisplayLayoutResponse( + const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +SetDisplayLayoutResponse::~SetDisplayLayoutResponse() { +} + +void SetDisplayLayoutResponse::Run() { + LOG4CXX_INFO(logger_, "SetDisplayLayoutResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); + +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc new file mode 100644 index 0000000000..f7216c818c --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc @@ -0,0 +1,515 @@ +/* + + Copyright (c) 2013, 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 <string.h> +#include <algorithm> +#include "application_manager/commands/mobile/set_global_properties_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +SetGlobalPropertiesRequest::SetGlobalPropertiesRequest( + const MessageSharedPtr& message) + : CommandRequestImpl(message), + is_ui_send_(false), + is_tts_send_(false), + is_ui_received_(false), + is_tts_received_(false), + ui_result_(hmi_apis::Common_Result::INVALID_ENUM), + tts_result_(hmi_apis::Common_Result::INVALID_ENUM) { +} + +SetGlobalPropertiesRequest::~SetGlobalPropertiesRequest() { +} + +void SetGlobalPropertiesRequest::Run() { + LOG4CXX_INFO(logger_, "SetGlobalPropertiesRequest::Run"); + + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + uint32_t app_id = + (*message_)[strings::params][strings::connection_key].asUInt(); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); + + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "No application associated with session key"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (!ValidateConditionalMandatoryParameters(msg_params)) { + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "There are no parameters present in request."); + return; + } + + mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS; + + if ((*message_)[strings::msg_params].keyExists(strings::menu_icon)) { + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::menu_icon], app); + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR_EXT( + logger_, + "MessageHelper::VerifyImage return " << verification_result); + SendResponse(false, verification_result); + return; + } + } + // Check for image file(s) in vrHelpItem + if ((*message_)[strings::msg_params].keyExists(strings::vr_help)) { + if (mobile_apis::Result::SUCCESS != MessageHelper::VerifyImageVrHelpItems( + (*message_)[strings::msg_params][strings::vr_help], app)) { + LOG4CXX_ERROR_EXT( + logger_, + "MessageHelper::VerifyImage return INVALID_DATA!" ); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } + + if (IsWhiteSpaceExist()) { + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + //if application waits for sending ttsGlobalProperties need to remove this + //application from tts_global_properties_app_list_ + LOG4CXX_INFO(logger_, "RemoveAppFromTTSGlobalPropertiesList"); + ApplicationManagerImpl::instance()->RemoveAppFromTTSGlobalPropertiesList( + app_id); + bool is_help_prompt_present = msg_params.keyExists(strings::help_prompt); + bool is_timeout_prompt_present = msg_params.keyExists( + strings::timeout_prompt); + bool is_vr_help_title_present = msg_params.keyExists(strings::vr_help_title); + bool is_vr_help_present = msg_params.keyExists(strings::vr_help); + bool is_menu_title_present = msg_params.keyExists(hmi_request::menu_title); + bool is_menu_icon_present = msg_params.keyExists(hmi_request::menu_icon); + bool is_keyboard_props_present = + msg_params.keyExists(hmi_request::keyboard_properties); + + // Media-only applications support API v2.1 with less parameters + // Code deleted according to APPLINK-6119 APPLINK-6133 + // Not sure that it is right + +// if (!app->allowed_support_navigation() && +// (is_keyboard_props_present || +// is_menu_icon_present || +// is_menu_title_present) +// ) { +// const std::string app_type = +// app->is_media_application() ? "media" : "non-media"; + +// const std::string message = +// "There are too many parameters for "+app_type+" application."; +// SendResponse(false, +// mobile_apis::Result::INVALID_DATA, +// message.c_str()); +// return; +// } + + if ((is_vr_help_title_present && is_vr_help_present) || + (!is_vr_help_title_present && !is_vr_help_present)) { + is_ui_send_ = true; + } + + if (is_help_prompt_present || is_timeout_prompt_present) { + is_tts_send_ = true; + } + + if (is_vr_help_title_present && is_vr_help_present) { + // check vrhelpitem position index + if (!CheckVrHelpItemsOrder()) { + LOG4CXX_ERROR(logger_, "Request rejected"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + app->set_vr_help_title( + msg_params.getElement(strings::vr_help_title)); + app->set_vr_help( + msg_params.getElement(strings::vr_help)); + + smart_objects::SmartObject params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + params[strings::vr_help_title] = (*app->vr_help_title()); + params[strings::vr_help] = (*app->vr_help()); + params[strings::app_id] = app->app_id(); + if (is_menu_title_present) { + + params[hmi_request::menu_title] = + msg_params[hmi_request::menu_title].asString(); + app->set_menu_title(msg_params[hmi_request::menu_title]); + } + if (is_menu_icon_present) { + + params[hmi_request::menu_icon] = + msg_params[hmi_request::menu_icon]; + app->set_menu_icon(msg_params[hmi_request::menu_icon]); + } + if (is_keyboard_props_present) { + + params[hmi_request::keyboard_properties] = + msg_params[hmi_request::keyboard_properties]; + app->set_keyboard_props(msg_params[hmi_request::keyboard_properties]); + } + + SendHMIRequest(hmi_apis::FunctionID::UI_SetGlobalProperties, + ¶ms, true); + } else if (!is_vr_help_title_present && !is_vr_help_present) { + const CommandsMap& cmdMap = app->commands_map(); + CommandsMap::const_iterator command_it = cmdMap.begin(); + + int32_t index = 0; + smart_objects::SmartObject vr_help_items; + for (; cmdMap.end() != command_it; ++command_it) { + if (false == (*command_it->second).keyExists(strings::vr_commands)) { + LOG4CXX_ERROR(logger_, "VR synonyms are empty"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + // use only first + vr_help_items[index][strings::position] = (index + 1); + vr_help_items[index++][strings::text] = + (*command_it->second)[strings::vr_commands][0]; + } + + app->set_vr_help_title(smart_objects::SmartObject(app->name())); + + smart_objects::SmartObject params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + params[strings::vr_help_title] = (*app->vr_help_title()); + if (vr_help_items.length() > 0) { + app->set_vr_help(vr_help_items); + params[strings::vr_help] = (*app->vr_help()); + } + params[strings::app_id] = app->app_id(); + if (is_menu_title_present) { + + params[hmi_request::menu_title] = + msg_params[hmi_request::menu_title].asString(); + app->set_menu_title(msg_params[hmi_request::menu_title]); + } + if (is_menu_icon_present) { + + params[hmi_request::menu_icon] = + msg_params[hmi_request::menu_icon]; + app->set_menu_icon(msg_params[hmi_request::menu_icon]); + } + if (is_keyboard_props_present) { + + params[hmi_request::keyboard_properties] = + msg_params[hmi_request::keyboard_properties]; + app->set_keyboard_props(msg_params[hmi_request::keyboard_properties]); + } + + SendHMIRequest(hmi_apis::FunctionID::UI_SetGlobalProperties, + ¶ms, true); + } else { + LOG4CXX_ERROR(logger_, "Request rejected"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + + // check TTS params + if (is_help_prompt_present || is_timeout_prompt_present) { + smart_objects::SmartObject params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + if (is_help_prompt_present) { + app->set_help_prompt( + msg_params.getElement(strings::help_prompt)); + params[strings::help_prompt] = (*app->help_prompt()); + } + + if (is_timeout_prompt_present) { + app->set_timeout_prompt( + msg_params.getElement(strings::timeout_prompt)); + params[strings::timeout_prompt] = (*app->timeout_prompt()); + } + + params[strings::app_id] = app->app_id(); + + SendHMIRequest(hmi_apis::FunctionID::TTS_SetGlobalProperties, + ¶ms, true); + } +} + +bool SetGlobalPropertiesRequest::CheckVrHelpItemsOrder() { + const smart_objects::SmartObject vr_help = (*message_)[strings::msg_params] + .getElement(strings::vr_help); + + // vr help item start position must be 1 + const uint32_t vr_help_item_start_position = 1; + + if (vr_help_item_start_position != + vr_help.getElement(0).getElement(strings::position).asUInt()) { + LOG4CXX_ERROR(logger_, "VR help items start position is wrong"); + return false; + } + + // Check if VR Help Items contains sequential positionss + size_t i = 0; + for (size_t j = 1; j < vr_help.length(); ++i, ++j) { + if ((vr_help.getElement(i).getElement(strings::position).asInt() + 1) + != vr_help.getElement(j).getElement(strings::position).asInt()) { + LOG4CXX_ERROR(logger_, "VR help items order is wrong"); + return false; + } + } + + return true; +} + +void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "SetGlobalPropertiesRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(CommandRequestImpl::connection_key()); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_SetGlobalProperties: { + LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event"); + is_ui_received_ = true; + ui_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + break; + } + case hmi_apis::FunctionID::TTS_SetGlobalProperties: { + LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event"); + is_tts_received_ = true; + tts_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } + + if (!IsPendingResponseExist()) { + bool result = ((hmi_apis::Common_Result::SUCCESS == ui_result_) + && (hmi_apis::Common_Result::SUCCESS == tts_result_ || + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_)) + || ((hmi_apis::Common_Result::SUCCESS == ui_result_ || + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_) + && (hmi_apis::Common_Result::INVALID_ENUM == tts_result_)) + || ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_ || + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_) + && (hmi_apis::Common_Result::SUCCESS == tts_result_)); + + mobile_apis::Result::eType result_code; + const char* return_info = NULL; + + if (result) { + if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_) { + result_code = mobile_apis::Result::WARNINGS; + return_info = + std::string("Unsupported phoneme type sent in a prompt").c_str(); + } else { + result_code = static_cast<mobile_apis::Result::eType>( + std::max(ui_result_, tts_result_)); + } + } else { + result_code = static_cast<mobile_apis::Result::eType>( + std::max(ui_result_, tts_result_)); + } + + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application(connection_key()); + SendResponse(result, static_cast<mobile_apis::Result::eType>(result_code), + return_info, &(message[strings::msg_params])); + application->UpdateHash(); + } +} + +bool SetGlobalPropertiesRequest::IsPendingResponseExist() { + + return is_ui_send_ != is_ui_received_ || is_tts_send_ != is_tts_received_; +} + +bool SetGlobalPropertiesRequest::ValidateConditionalMandatoryParameters( + const smart_objects::SmartObject& params) { + return params.keyExists(strings::help_prompt) + || params.keyExists(strings::timeout_prompt) + || params.keyExists(strings::vr_help_title) + || params.keyExists(strings::vr_help) + || params.keyExists(strings::menu_title) + || params.keyExists(strings::menu_icon) + || params.keyExists(strings::keyboard_properties); +} + +bool SetGlobalPropertiesRequest::IsWhiteSpaceExist() { + LOG4CXX_INFO(logger_, "SetGlobalPropertiesRequest::IsWhiteSpaceExist"); + const char* str; + + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + if (msg_params.keyExists(strings::help_prompt)) { + const smart_objects::SmartArray* hp_array = + msg_params[strings::help_prompt].asArray(); + + smart_objects::SmartArray::const_iterator it_hp = hp_array->begin(); + smart_objects::SmartArray::const_iterator it_hp_end = hp_array->end(); + + for (; it_hp != it_hp_end; ++it_hp) { + str = (*it_hp)[strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid help_prompt syntax check failed"); + return true; + } + } + } + + if (msg_params.keyExists(strings::timeout_prompt)) { + const smart_objects::SmartArray* tp_array = + msg_params[strings::timeout_prompt].asArray(); + + smart_objects::SmartArray::const_iterator it_tp = tp_array->begin(); + smart_objects::SmartArray::const_iterator it_tp_end = tp_array->end(); + + for (; it_tp != it_tp_end; ++it_tp) { + str = (*it_tp)[strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid timeout_prompt syntax check failed"); + return true; + } + } + } + + if (msg_params.keyExists(strings::vr_help)) { + const smart_objects::SmartArray* vh_array = + msg_params[strings::vr_help].asArray(); + + smart_objects::SmartArray::const_iterator it_vh = vh_array->begin(); + smart_objects::SmartArray::const_iterator it_vh_end = vh_array->end(); + + for (; it_vh != it_vh_end; ++it_vh) { + str = (*it_vh)[strings::text].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid vr_help text syntax check failed"); + return true; + } + + if ((*it_vh).keyExists(strings::image)) { + str = (*it_vh)[strings::image][strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid vr_help image value syntax check failed"); + return true; + } + } + + } + } + + if (msg_params.keyExists(strings::menu_icon)) { + str = msg_params[strings::menu_icon][strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid menu_icon value syntax check failed"); + return true; + } + } + + if (msg_params.keyExists(strings::vr_help_title)) { + str = msg_params[strings::vr_help_title].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid vr_help_title value syntax check failed"); + return true; + } + } + + if (msg_params.keyExists(strings::menu_title)) { + str = msg_params[strings::menu_title].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid menu_title value syntax check failed"); + return true; + } + } + + + if (msg_params.keyExists(strings::keyboard_properties)) { + if (msg_params[strings::keyboard_properties]. + keyExists(strings::limited_character_list)) { + + const smart_objects::SmartArray* lcl_array = + msg_params[strings::keyboard_properties] + [strings::limited_character_list].asArray(); + + smart_objects::SmartArray::const_iterator it_lcl = lcl_array->begin(); + smart_objects::SmartArray::const_iterator it_lcl_end = lcl_array->end(); + + for (; it_lcl != it_lcl_end; ++it_lcl) { + str = (*it_lcl).asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid keyboard_properties " + "limited_character_list syntax check failed"); + return true; + } + } + } + + if (msg_params[strings::keyboard_properties]. + keyExists(strings::auto_complete_text)) { + + str = msg_params[strings::keyboard_properties] + [strings::auto_complete_text].asCharArray(); + + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid keyboard_properties " + "auto_complete_text syntax check failed"); + return true; + } + } + + } + return false; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc b/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc new file mode 100644 index 0000000000..5f0b62fb4d --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc @@ -0,0 +1,58 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/set_global_properties_response.h" +#include "application_manager/application_manager_impl.h" + + +namespace application_manager { + +namespace commands { + +SetGlobalPropertiesResponse::SetGlobalPropertiesResponse( + const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +SetGlobalPropertiesResponse::~SetGlobalPropertiesResponse() { +} + +void SetGlobalPropertiesResponse::Run() { + LOG4CXX_INFO(logger_, "SetGlobalPropertiesResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/set_icon_request.cc b/src/components/application_manager/src/commands/mobile/set_icon_request.cc new file mode 100644 index 0000000000..4b78833057 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/set_icon_request.cc @@ -0,0 +1,141 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/set_icon_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "config_profile/profile.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" +#include "utils/file_system.h" + +namespace application_manager { + +namespace commands { + +SetIconRequest::SetIconRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +SetIconRequest::~SetIconRequest() { +} + +void SetIconRequest::Run() { + LOG4CXX_INFO(logger_, "SetIconRequest::Run"); + + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + const std::string& sync_file_name = + (*message_)[strings::msg_params][strings::sync_file_name].asString(); + + std::string full_file_path = + profile::Profile::instance()->app_storage_folder() + "/"; + full_file_path += app->folder_name(); + full_file_path += "/"; + full_file_path += sync_file_name; + + if (!file_system::FileExists(full_file_path)) { + LOG4CXX_ERROR(logger_, "No such file " << full_file_path); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + msg_params[strings::app_id] = app->app_id(); + msg_params[strings::sync_file_name] = smart_objects::SmartObject( + smart_objects::SmartType_Map); + +// Requires unchanged path value without encoded special characters + const std::string full_file_path_for_hmi = file_system::ConvertPathForURL( + full_file_path); + + msg_params[strings::sync_file_name][strings::value] = full_file_path_for_hmi; + + // TODO(VS): research why is image_type hardcoded + msg_params[strings::sync_file_name][strings::image_type] = + static_cast<int32_t> (SetIconRequest::ImageType::DYNAMIC); + + // for further use in on_event function + (*message_)[strings::msg_params][strings::sync_file_name] = + msg_params[strings::sync_file_name]; + + SendHMIRequest(hmi_apis::FunctionID::UI_SetAppIcon, &msg_params, true); +} + +void SetIconRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "SetIconRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_SetAppIcon: { + mobile_apis::Result::eType result_code = + static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + bool result = mobile_apis::Result::SUCCESS == result_code; + + if (result) { + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->application(connection_key()); + + const std::string path = (*message_)[strings::msg_params] + [strings::sync_file_name] + [strings::value].asString(); + app->set_app_icon_path(path); + + LOG4CXX_INFO(logger_, + "Icon path was set to '" << app->app_icon_path() << "'"); + } + + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/set_icon_response.cc b/src/components/application_manager/src/commands/mobile/set_icon_response.cc new file mode 100644 index 0000000000..f1580823d1 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/set_icon_response.cc @@ -0,0 +1,56 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/set_icon_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +SetIconResponse::SetIconResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +SetIconResponse::~SetIconResponse() { +} + +void SetIconResponse::Run() { + LOG4CXX_INFO(logger_, "SetIconResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc new file mode 100644 index 0000000000..c9b2eb5ef5 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc @@ -0,0 +1,152 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/set_media_clock_timer_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +SetMediaClockRequest::SetMediaClockRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +SetMediaClockRequest::~SetMediaClockRequest() { +} + +void SetMediaClockRequest::Run() { + LOG4CXX_INFO(logger_, "SetMediaClockRequest::Run"); + + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!app) { + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + LOG4CXX_ERROR(logger_, "Application is not registered"); + return; + } + + if (!app->is_media_application()) { + LOG4CXX_ERROR(logger_, "Application is not media application"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + if (isDataValid()) { + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + // copy entirely msg + msg_params = (*message_)[strings::msg_params]; + msg_params[strings::app_id] = app->app_id(); + + SendHMIRequest(hmi_apis::FunctionID::UI_SetMediaClockTimer, + &msg_params, true); + } else { + SendResponse(false, mobile_apis::Result::INVALID_DATA); + } +} + +void SetMediaClockRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "SetMediaClockRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_SetMediaClockTimer: { + mobile_apis::Result::eType result_code = + static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + bool result = mobile_apis::Result::SUCCESS == result_code; + + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +bool SetMediaClockRequest::isDataValid() { + smart_objects::SmartObject msg_params = (*message_)[strings::msg_params]; + mobile_apis::UpdateMode::eType update_mode = + static_cast<mobile_apis::UpdateMode::eType>( + msg_params[strings::update_mode].asUInt()); + + if (update_mode == mobile_apis::UpdateMode::COUNTUP || + update_mode == mobile_apis::UpdateMode::COUNTDOWN) { + + if (!msg_params.keyExists(strings::start_time)) { + LOG4CXX_INFO(logger_, "Invalid data"); + return false; + } + + if (msg_params.keyExists(strings::end_time)) { + unsigned int start_time_in_seconds = 0; + start_time_in_seconds = + (msg_params[strings::start_time][strings::hours].asUInt()) * 3600; + start_time_in_seconds += + (msg_params[strings::start_time][strings::minutes].asUInt()) * 60; + start_time_in_seconds += + (msg_params[strings::start_time][strings::seconds].asUInt()); + + unsigned int end_time_in_seconds = 0; + end_time_in_seconds = + (msg_params[strings::end_time][strings::hours].asUInt()) * 3600; + end_time_in_seconds += + (msg_params[strings::end_time][strings::minutes].asUInt()) * 60; + end_time_in_seconds += + (msg_params[strings::end_time][strings::seconds].asUInt()); + + if (((end_time_in_seconds > start_time_in_seconds) && + (update_mode == mobile_apis::UpdateMode::COUNTDOWN)) || + ((end_time_in_seconds < start_time_in_seconds) && + (update_mode == mobile_apis::UpdateMode::COUNTUP))) { + LOG4CXX_INFO(logger_, "Invalid data"); + return false; + } + } + } + + LOG4CXX_INFO(logger_, "Data is valid"); + return true; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc new file mode 100644 index 0000000000..73923b0021 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc @@ -0,0 +1,57 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/set_media_clock_timer_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +SetMediaClockTimerResponse::SetMediaClockTimerResponse( + const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +SetMediaClockTimerResponse::~SetMediaClockTimerResponse() { +} + +void SetMediaClockTimerResponse::Run() { + LOG4CXX_INFO(logger_, "SetMediaClockTimerResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc b/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc new file mode 100644 index 0000000000..f4e70c53ac --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc @@ -0,0 +1,283 @@ +/* + + Copyright (c) 2013, 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 <string.h> +#include "application_manager/commands/mobile/show_constant_tbt_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +ShowConstantTBTRequest::ShowConstantTBTRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +ShowConstantTBTRequest::~ShowConstantTBTRequest() { +} + +void ShowConstantTBTRequest::Run() { + LOG4CXX_INFO(logger_, "ShowConstantTBTRequest::Run"); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + (*message_)[strings::params][strings::connection_key].asUInt()); + + if (!app) { + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + LOG4CXX_ERROR(logger_, "Application is not registered"); + return; + } + // SDLAQ-CRS-664, VC3.1 + if ((*message_)[strings::msg_params].empty()) { + LOG4CXX_ERROR(logger_, "INVALID_DATA!"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + msg_params = (*message_)[strings::msg_params]; + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, + "Incoming show constant TBT has contains \t\n \\t \\n"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + //ProcessSoftButtons checks strings on the contents incorrect character + + mobile_apis::Result::eType processing_result = + MessageHelper::ProcessSoftButtons(msg_params, app); + + if (mobile_apis::Result::SUCCESS != processing_result) { + LOG4CXX_ERROR(logger_, "INVALID_DATA!"); + SendResponse(false, processing_result); + return; + } + + + mobile_apis::Result::eType verification_result = + mobile_apis::Result::SUCCESS; + if (msg_params.keyExists(strings::turn_icon)) { + verification_result = MessageHelper::VerifyImage( + msg_params[strings::turn_icon], app); + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + SendResponse(false, verification_result); + return; + } + } + + if (msg_params.keyExists(strings::next_turn_icon)) { + verification_result = MessageHelper::VerifyImage( + msg_params[strings::next_turn_icon], app); + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + SendResponse(false, verification_result); + return; + } + } + + msg_params[strings::app_id] = app->app_id(); + + msg_params[hmi_request::navi_texts] = smart_objects::SmartObject( + smart_objects::SmartType_Array); + + int32_t index = 0; + if (msg_params.keyExists(strings::navigation_text_1)) { + // erase useless parametr + msg_params.erase(strings::navigation_text_1); + msg_params[hmi_request::navi_texts][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::navigationText1); + msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::navigation_text_1]; + } + + if (msg_params.keyExists(strings::navigation_text_2)) { + // erase useless param + msg_params.erase(strings::navigation_text_2); + msg_params[hmi_request::navi_texts][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::navigationText2); + msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::navigation_text_2]; + } + + if (msg_params.keyExists(strings::eta)) { + // erase useless param + msg_params.erase(strings::eta); + msg_params[hmi_request::navi_texts][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::ETA); + msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::eta]; + } + + if (msg_params.keyExists(strings::total_distance)) { + // erase useless param + msg_params.erase(strings::total_distance); + msg_params[hmi_request::navi_texts][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::totalDistance); + msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::total_distance]; + } + + if (msg_params.keyExists(strings::time_to_destination)) { + // erase useless param + msg_params.erase(strings::time_to_destination); + msg_params[hmi_request::navi_texts][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::timeToDestination); + msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::time_to_destination]; + } + + if (msg_params.keyExists(strings::soft_buttons)) { + MessageHelper::SubscribeApplicationToSoftButton(msg_params, app, function_id()); + } + + app->set_tbt_show_command(msg_params); + SendHMIRequest(hmi_apis::FunctionID::Navigation_ShowConstantTBT, &msg_params, + true); +} + + +void ShowConstantTBTRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "ShowConstantTBTRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::Navigation_ShowConstantTBT: { + LOG4CXX_INFO(logger_, "Received Navigation_ShowConstantTBT event"); + + mobile_apis::Result::eType result_code = + GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt())); + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + bool result = false; + if (mobile_apis::Result::SUCCESS == result_code) { + result = true; + } else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) && + hmi_capabilities.is_ui_cooperating()) { + result = true; + } + + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_,"Received unknown event" << event.id()); + break; + } + } +} + +bool ShowConstantTBTRequest::IsWhiteSpaceExist() { + LOG4CXX_INFO(logger_, "ShowConstantTBTRequest::IsWhiteSpaceExist"); + const char* str = NULL; + + if ((*message_)[strings::msg_params].keyExists(strings::turn_icon)) { + str = (*message_)[strings::msg_params] + [strings::turn_icon][strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid turn_icon value syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::next_turn_icon)) { + str = (*message_)[strings::msg_params] + [strings::next_turn_icon][strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid next_turn_icon value syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::navigation_text_1)) { + str = (*message_)[strings::msg_params] + [strings::navigation_text_1].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid navigation_text_1 value syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::navigation_text_2)) { + str = (*message_)[strings::msg_params] + [strings::navigation_text_2].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid navigation_text_2 value syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::eta)) { + str = (*message_)[strings::msg_params][strings::eta].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid eta value syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::total_distance)) { + str = (*message_)[strings::msg_params] + [strings::total_distance].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid total_distance value syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::time_to_destination)) { + str = (*message_)[strings::msg_params] + [strings::time_to_destination].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid time_to_destination value syntax check failed"); + return true; + } + } + return false; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc b/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc new file mode 100644 index 0000000000..d5539d148c --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc @@ -0,0 +1,58 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/show_constant_tbt_response.h" +#include "application_manager/application_manager_impl.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +ShowConstantTBTResponse::ShowConstantTBTResponse( + const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +ShowConstantTBTResponse::~ShowConstantTBTResponse() { +} + +void ShowConstantTBTResponse::Run() { + LOG4CXX_INFO(logger_, "ShowConstantTBTResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/show_request.cc b/src/components/application_manager/src/commands/mobile/show_request.cc new file mode 100644 index 0000000000..eeef60101e --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/show_request.cc @@ -0,0 +1,341 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/show_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application.h" +#include "application_manager/message_helper.h" +#include "utils/file_system.h" + +#include <string.h> + +namespace application_manager { + +namespace commands { + +ShowRequest::ShowRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +ShowRequest::~ShowRequest() { +} + +void ShowRequest::Run() { + LOG4CXX_INFO(logger_, "ShowRequest::Run"); + + ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance() + ->application( + (*message_)[strings::params][strings::connection_key].asInt()); + + if (!app) { + LOG4CXX_ERROR_EXT( + logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + //SDLAQ-CRS-494, VC3.1 + if ((*message_)[strings::msg_params].empty()) { + LOG4CXX_ERROR(logger_, "INVALID_DATA!"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if (!CheckStringsOfShowRequest()) { + LOG4CXX_ERROR(logger_, "Incorrect characters in string"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + //ProcessSoftButtons checks strings on the contents incorrect character + + mobile_apis::Result::eType processing_result = mobile_apis::Result::SUCCESS; + if(((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) && + ((*message_)[strings::msg_params][strings::soft_buttons].length() > 0)) { + processing_result = + MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app); + } + + if (mobile_apis::Result::SUCCESS != processing_result) { + LOG4CXX_ERROR(logger_, "INVALID_DATA!"); + SendResponse(false, processing_result); + return; + } + + mobile_apis::Result::eType verification_result = + mobile_apis::Result::SUCCESS; + if (((*message_)[strings::msg_params].keyExists(strings::graphic)) && + ((*message_)[strings::msg_params] + [strings::graphic][strings::value].asString()).length()) { + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::graphic], app); + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + SendResponse(false, verification_result); + return; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::secondary_graphic)) { + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::secondary_graphic], app); + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + SendResponse(false, verification_result); + return; + } + } + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + msg_params[strings::app_id] = app->app_id(); + + msg_params[hmi_request::show_strings] = smart_objects::SmartObject( + smart_objects::SmartType_Array); + + int32_t index = 0; + if ((*message_)[strings::msg_params].keyExists(strings::main_field_1)) { + msg_params[hmi_request::show_strings][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::mainField1); + msg_params[hmi_request::show_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::main_field_1]; + ++index; + } + + if ((*message_)[strings::msg_params].keyExists(strings::main_field_2)) { + msg_params[hmi_request::show_strings][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::mainField2); + msg_params[hmi_request::show_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::main_field_2]; + ++index; + } + + if ((*message_)[strings::msg_params].keyExists(strings::main_field_3)) { + msg_params[hmi_request::show_strings][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::mainField3); + msg_params[hmi_request::show_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::main_field_3]; + ++index; + } + + if ((*message_)[strings::msg_params].keyExists(strings::main_field_4)) { + msg_params[hmi_request::show_strings][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::mainField4); + msg_params[hmi_request::show_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::main_field_4]; + ++index; + } + + if ((*message_)[strings::msg_params].keyExists(strings::media_clock)) { + msg_params[hmi_request::show_strings][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::mediaClock); + msg_params[hmi_request::show_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::media_clock]; + ++index; + } + + if ((*message_)[strings::msg_params].keyExists(strings::media_track)) { + msg_params[hmi_request::show_strings][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::mediaTrack); + msg_params[hmi_request::show_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::media_track]; + ++index; + } + + if ((*message_)[strings::msg_params].keyExists(strings::status_bar)) { + msg_params[hmi_request::show_strings][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::statusBar); + msg_params[hmi_request::show_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::status_bar]; + ++index; + } + + if ((*message_)[strings::msg_params].keyExists(strings::alignment)) { + msg_params[strings::alignment] = + (*message_)[strings::msg_params][strings::alignment]; + } + + if ((*message_)[strings::msg_params].keyExists(strings::graphic)) { + msg_params[strings::graphic] = + (*message_)[strings::msg_params][strings::graphic]; + } + + if ((*message_)[strings::msg_params].keyExists(strings::secondary_graphic)) { + msg_params[strings::secondary_graphic] = + (*message_)[strings::msg_params][strings::secondary_graphic]; + } + + if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + msg_params[strings::soft_buttons] = + (*message_)[strings::msg_params][strings::soft_buttons]; + if ((*message_)[strings::msg_params][strings::soft_buttons].length() == 0) { + app->UnsubscribeFromSoftButtons(function_id()); + } else { + MessageHelper::SubscribeApplicationToSoftButton( + (*message_)[strings::msg_params], app, function_id()); + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::custom_presets)) { + msg_params[strings::custom_presets] = + (*message_)[strings::msg_params][strings::custom_presets]; + } + + SendHMIRequest(hmi_apis::FunctionID::UI_Show, &msg_params, true); + + MessageSharedPtr persistentData = new smart_objects::SmartObject(msg_params); + app->set_show_command(*persistentData); +} + +void ShowRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "ShowRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_Show: { + LOG4CXX_INFO(logger_, "Received UI_Show event"); + std::string response_info(""); + mobile_apis::Result::eType result_code = + static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + bool result = false; + + if (mobile_apis::Result::SUCCESS == result_code) { + result = true; + } else if (mobile_apis::Result::WARNINGS == result_code) { + result = true; + if (message[strings::params].keyExists(hmi_response::message)) { + response_info = message[strings::params][hmi_response::message].asString(); + } + } + + SendResponse(result, result_code, + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_,"Received unknown event" << event.id()); + break; + } + } +} + +bool ShowRequest::CheckStringsOfShowRequest() { + LOG4CXX_INFO(logger_, "ShowRequest::CheckStringsOfShowRequest"); + const char* str; + + if ((*message_)[strings::msg_params].keyExists(strings::main_field_4)) { + str = (*message_)[strings::msg_params][strings::main_field_4].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid main_field_4 syntax check failed"); + return false; + } + } + if ((*message_)[strings::msg_params].keyExists(strings::main_field_3)) { + str = (*message_)[strings::msg_params][strings::main_field_3].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid main_field_3 syntax check failed"); + return false; + } + } + if ((*message_)[strings::msg_params].keyExists(strings::main_field_2)) { + str = (*message_)[strings::msg_params][strings::main_field_2].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid main_field_2 syntax check failed"); + return false; + } + } + if ((*message_)[strings::msg_params].keyExists(strings::main_field_1)) { + str = (*message_)[strings::msg_params][strings::main_field_1].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid main_field_1 syntax check failed"); + return false; + } + } + if ((*message_)[strings::msg_params].keyExists(strings::status_bar)) { + str = (*message_)[strings::msg_params][strings::status_bar].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid status_bar syntax check failed"); + return false; + } + } + if ((*message_)[strings::msg_params].keyExists(strings::media_clock)) { + str = (*message_)[strings::msg_params][strings::media_clock].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid media_clock syntax check failed"); + return false; + } + } + if ((*message_)[strings::msg_params].keyExists(strings::media_track)) { + str = (*message_)[strings::msg_params][strings::media_track].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid media_track syntax check failed"); + return false; + } + } + if ((*message_)[strings::msg_params].keyExists(strings::custom_presets)) { + smart_objects::SmartObject& custom_presets_array = + (*message_)[strings::msg_params][strings::custom_presets]; + for (size_t i = 0; i < custom_presets_array.length(); ++i) { + str = custom_presets_array[i].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid custom_presets syntax check failed"); + return false; + } + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::graphic)) { + str = (*message_)[strings::msg_params] + [strings::graphic][strings::value].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid graphic value syntax check failed"); + return false; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::secondary_graphic)) { + str = (*message_)[strings::msg_params] + [strings::secondary_graphic][strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid secondary_graphic value syntax check failed"); + return false; + } + } + return true; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/show_response.cc b/src/components/application_manager/src/commands/mobile/show_response.cc new file mode 100644 index 0000000000..1f9c59c6fc --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/show_response.cc @@ -0,0 +1,58 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/show_response.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +ShowResponse::ShowResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +ShowResponse::~ShowResponse() { +} + +void ShowResponse::Run() { + LOG4CXX_INFO(logger_, "ShowResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/slider_request.cc b/src/components/application_manager/src/commands/mobile/slider_request.cc new file mode 100644 index 0000000000..bf200d72d3 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/slider_request.cc @@ -0,0 +1,185 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/slider_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" + +namespace application_manager { + +namespace commands { + +SliderRequest::SliderRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { + subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); +} + +SliderRequest::~SliderRequest() { +} + +bool SliderRequest::Init() { + + /* Timeout in milliseconds. + If omitted a standard value of 10000 milliseconds is used.*/ + if ((*message_)[strings::msg_params].keyExists(strings::timeout)) { + default_timeout_ = + (*message_)[strings::msg_params][strings::timeout].asUInt(); + } + + return true; +} + +void SliderRequest::Run() { + LOG4CXX_INFO(logger_, "SliderRequest::Run"); + + ApplicationSharedPtr application = + application_manager::ApplicationManagerImpl::instance()->application( + (*message_)[strings::params][strings::connection_key].asUInt()); + + if (!application) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if ((*message_)[strings::msg_params][strings::num_ticks].asInt() + < (*message_)[strings::msg_params][strings::position].asInt()) { + LOG4CXX_ERROR(logger_, "INVALID_DATA"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if ((*message_)[strings::msg_params].keyExists(strings::slider_footer)) { + if (1 < (*message_)[strings::msg_params][strings::slider_footer].length()) { + if ((*message_)[strings::msg_params][strings::num_ticks].asUInt() + != (*message_)[strings::msg_params] + [strings::slider_footer].length()) { + LOG4CXX_ERROR(logger_, "INVALID_DATA"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, "Incoming slider has contains \t\n \\t \\n"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + msg_params = (*message_)[strings::msg_params]; + msg_params[strings::app_id] = application->app_id(); + + if (!(*message_)[strings::msg_params].keyExists(strings::timeout)) { + msg_params[strings::timeout] = default_timeout_; + } + + SendHMIRequest(hmi_apis::FunctionID::UI_Slider, &msg_params, true); +} + +void SliderRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "SliderRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + const event_engine::Event::EventID event_id = event.id(); + if (event_id == hmi_apis::FunctionID::UI_OnResetTimeout) { + LOG4CXX_INFO(logger_, "Received UI_OnResetTimeout event"); + ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(), + correlation_id(), + default_timeout()); + return; + } + if (event_id != hmi_apis::FunctionID::UI_Slider) { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + + //event_id == hmi_apis::FunctionID::UI_Slider: + LOG4CXX_INFO(logger_, "Received UI_Slider event"); + + const int response_code = + message[strings::params][hmi_response::code].asInt(); + + smart_objects::SmartObject response_msg_params = message[strings::msg_params]; + if (response_code == hmi_apis::Common_Result::ABORTED) { + //Copy slider_position info to msg_params section + response_msg_params[strings::slider_position] = + message[strings::params][strings::data][strings::slider_position]; + } + + const bool is_response_success = + (mobile_apis::Result::SUCCESS == response_code) || + //Aborted has slider_position data + (mobile_apis::Result::ABORTED == response_code) || + //according with SDLAQ-CRS-2904 + (mobile_apis::Result::TIMED_OUT == response_code); + + SendResponse(is_response_success, + mobile_apis::Result::eType(response_code), + 0, + &response_msg_params); +} + +bool SliderRequest::IsWhiteSpaceExist() { + LOG4CXX_INFO(logger_, "PerformAudioPassThruRequest::IsWhiteSpaceExist"); + const char* str = NULL; + + str = (*message_)[strings::msg_params][strings::slider_header].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid slider_header value syntax check failed"); + return true; + } + + if ((*message_)[strings::msg_params].keyExists(strings::slider_footer)) { + const smart_objects::SmartArray* sf_array = + (*message_)[strings::msg_params][strings::slider_footer].asArray(); + + smart_objects::SmartArray::const_iterator it_sf = sf_array->begin(); + smart_objects::SmartArray::const_iterator it_sf_end = sf_array->end(); + + for (; it_sf != it_sf_end; ++it_sf) { + str = (*it_sf).asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid slider_footer syntax check failed"); + return true; + } + } + } + return false; +} + +} // namespace commands +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/mobile/slider_response.cc b/src/components/application_manager/src/commands/mobile/slider_response.cc new file mode 100644 index 0000000000..bfb6b0a1e6 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/slider_response.cc @@ -0,0 +1,56 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/slider_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +SliderResponse::SliderResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +SliderResponse::~SliderResponse() { +} + +void SliderResponse::Run() { + LOG4CXX_INFO(logger_, "SliderResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/speak_request.cc b/src/components/application_manager/src/commands/mobile/speak_request.cc new file mode 100644 index 0000000000..de37e8b49e --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/speak_request.cc @@ -0,0 +1,160 @@ +/* + + Copyright (c) 2013, 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 <string.h> +#include "application_manager/commands/mobile/speak_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" + +namespace application_manager { + +namespace commands { + +SpeakRequest::SpeakRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { + subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout); +} + +SpeakRequest::~SpeakRequest() { +} + +void SpeakRequest::Run() { + LOG4CXX_INFO(logger_, "SpeakRequest::Run"); + + ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance() + ->application(connection_key()); + + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, + "Incoming speak has contains \\t\\n \\\\t \\\\n " + " text contains only whitespace in ttsChunks"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + (*message_)[strings::msg_params][strings::app_id] = app->app_id(); + (*message_)[strings::msg_params][hmi_request::speak_type] = + hmi_apis::Common_SpeakType::SPEAK; + SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, + &message_->getElement(strings::msg_params), true); +} + +void SpeakRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "SpeakRequest::on_event"); + switch (event.id()) { + case hmi_apis::FunctionID::TTS_Speak: { + LOG4CXX_INFO(logger_, "Received TTS_Speak event"); + + ProcessTTSSpeakResponse(event.smart_object()); + break; + } + case hmi_apis::FunctionID::TTS_OnResetTimeout: { + LOG4CXX_INFO(logger_, "Received TTS_OnResetTimeout event"); + + ApplicationManagerImpl::instance()->updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + break; + } + } +} + +void SpeakRequest::ProcessTTSSpeakResponse( + const smart_objects::SmartObject& message) { + LOG4CXX_INFO(logger_, "SpeakRequest::ProcessTTSSpeakResponse"); + ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application( + connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + bool result = false; + mobile_apis::Result::eType result_code = + static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + if (hmi_apis::Common_Result::SUCCESS == + static_cast<hmi_apis::Common_Result::eType>(result_code)) { + result = true; + } + (*message_)[strings::params][strings::function_id] = + mobile_apis::FunctionID::SpeakID; + + const char* return_info = NULL; + + if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == + static_cast<hmi_apis::Common_Result::eType>(result_code)) { + result_code = mobile_apis::Result::WARNINGS; + return_info = std::string( + "Unsupported phoneme type sent in a prompt").c_str(); + } + + SendResponse(result, static_cast<mobile_apis::Result::eType>(result_code), + return_info, &(message[strings::msg_params])); +} + +bool SpeakRequest::IsWhiteSpaceExist() { + LOG4CXX_INFO(logger_, "SpeakRequest::IsWhiteSpaceExist"); + const char* str = NULL; + + if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) { + const smart_objects::SmartArray* tc_array = + (*message_)[strings::msg_params][strings::tts_chunks].asArray(); + + smart_objects::SmartArray::const_iterator it_tc = tc_array->begin(); + smart_objects::SmartArray::const_iterator it_tc_end = tc_array->end(); + + for (; it_tc != it_tc_end; ++it_tc) { + str = (*it_tc)[strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid tts_chunks syntax check failed"); + return true; + } + } + } + return false; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/speak_response.cc b/src/components/application_manager/src/commands/mobile/speak_response.cc new file mode 100644 index 0000000000..92b85bbb84 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/speak_response.cc @@ -0,0 +1,58 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/speak_response.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +SpeakResponse::SpeakResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +SpeakResponse::~SpeakResponse() { +} + +void SpeakResponse::Run() { + LOG4CXX_INFO(logger_, "SpeakResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc new file mode 100644 index 0000000000..b6a4d8a28e --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc @@ -0,0 +1,101 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/subscribe_button_request.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +namespace str = strings; + +SubscribeButtonRequest::SubscribeButtonRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +SubscribeButtonRequest::~SubscribeButtonRequest() { +} + +void SubscribeButtonRequest::Run() { + LOG4CXX_INFO(logger_, "SubscribeButtonRequest::Run"); + + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "APPLICATION_NOT_REGISTERED"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + const mobile_apis::ButtonName::eType btn_id = + static_cast<mobile_apis::ButtonName::eType>( + (*message_)[str::msg_params][str::button_name].asUInt()); + + if (!IsSubscribtionAllowed(app, btn_id)) { + LOG4CXX_ERROR_EXT(logger_, "Subscribe on button " << btn_id + << " isn't allowed"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + if (app->IsSubscribedToButton(btn_id)) { + LOG4CXX_ERROR_EXT(logger_, "Already subscribed to button " << btn_id); + SendResponse(false, mobile_apis::Result::IGNORED); + return; + } + + app->SubscribeToButton(static_cast<mobile_apis::ButtonName::eType>(btn_id)); + SendResponse(true, mobile_apis::Result::SUCCESS); + + app->UpdateHash(); +} + +bool SubscribeButtonRequest::IsSubscribtionAllowed( + ApplicationSharedPtr app, mobile_apis::ButtonName::eType btn_id) { + + if (!app->is_media_application() && + ((mobile_apis::ButtonName::SEEKLEFT == btn_id) || + (mobile_apis::ButtonName::SEEKRIGHT == btn_id)|| + (mobile_apis::ButtonName::TUNEUP == btn_id) || + (mobile_apis::ButtonName::TUNEDOWN == btn_id))) { + return false; + } + + return true; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/subscribe_button_response.cc b/src/components/application_manager/src/commands/mobile/subscribe_button_response.cc new file mode 100644 index 0000000000..6253f8ca3d --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/subscribe_button_response.cc @@ -0,0 +1,66 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/subscribe_button_response.h" + +namespace application_manager { + +namespace commands { + +SubscribeButtonResponse::SubscribeButtonResponse( + const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +SubscribeButtonResponse::~SubscribeButtonResponse() { +} + +void SubscribeButtonResponse::Run() { + LOG4CXX_INFO(logger_, "SubscribeButtonResponse::Run"); + + // check if response false + if (true == (*message_)[strings::msg_params].keyExists(strings::success)) { + if ((*message_)[strings::msg_params][strings::success].asBool() == false) { + LOG4CXX_ERROR(logger_, "Success = false"); + SendResponse(false); + return; + } + } + + // TODO(DK): Some logic + SendResponse(true); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc new file mode 100644 index 0000000000..35595c2df6 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc @@ -0,0 +1,283 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/subscribe_vehicle_data_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" + +namespace application_manager { +namespace commands { + +SubscribeVehicleDataRequest::SubscribeVehicleDataRequest( + const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +SubscribeVehicleDataRequest::~SubscribeVehicleDataRequest() { +} + +#ifdef HMI_DBUS_API +namespace { + struct Subrequest { + hmi_apis::FunctionID::eType func_id; + const char* str; + }; + Subrequest subrequests[] = { + { hmi_apis::FunctionID::VehicleInfo_SubscribeGps, strings::gps}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeSpeed, strings::speed}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeRpm, strings::rpm}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeFuelLevel, strings::fuel_level}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeFuelLevel_State, strings::fuel_level_state}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeInstantFuelConsumption, strings::instant_fuel_consumption}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeExternalTemperature, strings::external_temp}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeVin, strings::vin}, + { hmi_apis::FunctionID::VehicleInfo_SubscribePrndl, strings::prndl}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeTirePressure, strings::tire_pressure}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeOdometer, strings::odometer}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeBeltStatus, strings::belt_status}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeBodyInformation, strings::body_information}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeDeviceStatus, strings::device_status}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeDriverBraking, strings::driver_braking}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeWiperStatus, strings::wiper_status}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeHeadLampStatus, strings::head_lamp_status}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeEngineTorque, strings::engine_torque}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeAccPedalPosition, strings::acc_pedal_pos}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeSteeringWheelAngle, strings::steering_wheel_angle}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeECallInfo, strings::e_call_info}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeAirbagStatus, strings::airbag_status}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeEmergencyEvent, strings::emergency_event}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeClusterModeStatus, strings::cluster_mode_status}, + { hmi_apis::FunctionID::VehicleInfo_SubscribeMyKey, strings::my_key}, + }; +} +#endif // #ifdef HMI_DBUS_API + +void SubscribeVehicleDataRequest::Run() { + LOG4CXX_INFO(logger_, "SubscribeVehicleDataRequest::Run"); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + CommandRequestImpl::connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + // counter for items to subscribe + int32_t items_to_subscribe = 0; + // counter for subscribed items by application + int32_t subscribed_items = 0; + + const VehicleData& vehicle_data = MessageHelper::vehicle_data(); + VehicleData::const_iterator it = vehicle_data.begin(); + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + smart_objects::SmartObject response_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + msg_params[strings::app_id] = app->app_id(); + + for (; vehicle_data.end() != it; ++it) { + std::string key_name = it->first; + if ((*message_)[strings::msg_params].keyExists(key_name)) { + bool is_key_enabled = (*message_)[strings::msg_params][key_name].asBool(); + if (is_key_enabled) { + ++items_to_subscribe; + msg_params[key_name] = is_key_enabled; + + VehicleDataType key_type = it->second; + if (app->SubscribeToIVI(static_cast<uint32_t>(key_type))) { + ++subscribed_items; + } else { + response_params[key_name][strings::data_type] = key_type; + response_params[key_name][strings::result_code] = + mobile_apis::VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED; + } + } + } + } + + if (0 == items_to_subscribe) { + if (HasDisallowedParams()) { + SendResponse(false, mobile_apis::Result::DISALLOWED); + } else { + SendResponse(false, mobile_apis::Result::INVALID_DATA, + "No data in the request"); + } + return; + } else if (0 == subscribed_items) { + SendResponse(false, + mobile_apis::Result::IGNORED, + "Already subscribed on provided VehicleData.", + &response_params); + return; + } + +#ifdef HMI_DBUS_API + //Generate list of subrequests + for (size_t i = 0; i < sizeof(subrequests) / sizeof(subrequests[0]); ++i) { + const Subrequest& sr = subrequests[i]; + if (true == (*message_)[strings::msg_params].keyExists(sr.str) + && true == (*message_)[strings::msg_params][sr.str].asBool()) { + HmiRequest hmi_request; + hmi_request.str = sr.str; + hmi_request.func_id = sr.func_id; + hmi_request.complete = false; + hmi_requests_.push_back(hmi_request); + } + } + LOG4CXX_INFO(logger_, hmi_requests_.size() << " requests are going to be sent to HMI"); + + //Send subrequests + for (HmiRequests::const_iterator it = hmi_requests_.begin(); it != hmi_requests_.end(); ++it) + SendHMIRequest(it->func_id, &msg_params, true); +#else + SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData, + &msg_params, true); +#endif // #ifdef HMI_DBUS_API +} + +void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "SubscribeVehicleDataRequest::on_event"); + + const smart_objects::SmartObject& message = event.smart_object(); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + CommandRequestImpl::connection_key()); + +#ifdef HMI_DBUS_API + for (HmiRequests::iterator it = hmi_requests_.begin(); + it != hmi_requests_.end(); ++it) { + HmiRequest & hmi_request = *it; + if (hmi_request.func_id == event.id()) { + hmi_request.status = + static_cast<hmi_apis::Common_Result::eType>(message[strings::params][hmi_response::code] + .asInt()); + if (hmi_apis::Common_Result::SUCCESS == hmi_request.status) + hmi_request.value = message[strings::msg_params][hmi_request.str]; + hmi_request.complete = true; + break; + } + } + bool all_complete = true; + bool any_arg_success = false; + mobile_api::Result::eType status = mobile_api::Result::eType::SUCCESS; + for (HmiRequests::const_iterator it = hmi_requests_.begin(); + it != hmi_requests_.end(); ++it) { + if (!it->complete) { + all_complete = false; + break; + } + if (hmi_apis::Common_Result::SUCCESS != it->status) { + if (mobile_api::Result::SUCCESS == status) { + status = static_cast<mobile_apis::Result::eType>(it->status); + } else if (status + != static_cast<mobile_apis::Result::eType>(it->status)) { + status = mobile_api::Result::eType::GENERIC_ERROR; + } + LOG4CXX_TRACE(logger_, "Status from HMI: " << it->status << + ", so response status become " << status); + } else { + any_arg_success = true; + } + } + + if (all_complete) { + smart_objects::SmartObject response_params(smart_objects::SmartType_Map); + if (any_arg_success) { + for (HmiRequests::const_iterator it = hmi_requests_.begin(); + it != hmi_requests_.end(); ++it) { + response_params[it->str] = it->value; + } + } + LOG4CXX_INFO(logger_, "All HMI requests are complete"); + SendResponse(any_arg_success, status, NULL, &response_params); + app->UpdateHash(); + } +#else + hmi_apis::Common_Result::eType hmi_result = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + bool result = + hmi_result == hmi_apis::Common_Result::SUCCESS; + + mobile_apis::Result::eType result_code = + hmi_result == hmi_apis::Common_Result::SUCCESS + ? mobile_apis::Result::SUCCESS + : static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + const char* return_info = NULL; + if (result) { + if (IsAnythingAlreadySubscribed(message[strings::msg_params])) { + result_code = mobile_apis::Result::IGNORED; + return_info = + std::string("Already subscribed on some provided VehicleData.").c_str(); + } + } + + SendResponse(result, + result_code, + return_info, + &(message[strings::msg_params])); + app->UpdateHash(); +#endif // #ifdef HMI_DBUS_API +} + +bool SubscribeVehicleDataRequest::IsAnythingAlreadySubscribed( + const smart_objects::SmartObject& msg_params) const { + LOG4CXX_INFO(logger_, "IsAnythingAlreadySubscribed"); + + const VehicleData& vehicle_data = MessageHelper::vehicle_data(); + VehicleData::const_iterator it = vehicle_data.begin(); + + for (; vehicle_data.end() != it; ++it) { + if (msg_params.keyExists(it->first)) { + if (msg_params[it->first][strings::result_code].asInt() == + hmi_apis::Common_VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED) { + return true; + } + } + } + + return false; +} + + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc new file mode 100644 index 0000000000..972a654188 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc @@ -0,0 +1,56 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/subscribe_vehicle_data_response.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { +namespace commands { + +SubscribeVehicleDataResponse::SubscribeVehicleDataResponse( + const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +SubscribeVehicleDataResponse::~SubscribeVehicleDataResponse() { +} + +void SubscribeVehicleDataResponse::Run() { + LOG4CXX_INFO(logger_, "SubscribeVehicleDataResponse::Run"); + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/system_request.cc b/src/components/application_manager/src/commands/mobile/system_request.cc new file mode 100644 index 0000000000..2765aad8d7 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/system_request.cc @@ -0,0 +1,168 @@ +/* + +Copyright (c) 2013, 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 <vector> +#include <string> +#include <stdio.h> +#include "application_manager/commands/mobile/system_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" +#include "config_profile/profile.h" +#include "utils/file_system.h" + +namespace application_manager { + +namespace commands { + +uint32_t SystemRequest::index = 0; + +SystemRequest::SystemRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +SystemRequest::~SystemRequest() { +} + +void SystemRequest::Run() { + LOG4CXX_INFO(logger_, "SystemRequest::Run"); + + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!(application.valid())) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + mobile_apis::RequestType::eType request_type = + static_cast<mobile_apis::RequestType::eType>( + (*message_)[strings::msg_params][strings::request_type].asInt()); + + if (!(*message_)[strings::params].keyExists(strings::binary_data) && + mobile_apis::RequestType::PROPRIETARY == request_type) { + LOG4CXX_ERROR(logger_, "Binary data empty"); + + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + std::vector<uint8_t> binary_data; + if ((*message_)[strings::params].keyExists(strings::binary_data)) { + binary_data = (*message_)[strings::params][strings::binary_data].asBinary(); + } + + std::string file_path = profile::Profile::instance()->system_files_path(); + if (!file_system::CreateDirectoryRecursively(file_path)) { + LOG4CXX_ERROR(logger_, "Cann't create folder."); + SendResponse(false, mobile_apis::Result::GENERIC_ERROR); + return; + } + + std::string file_name = "SYNC"; + if ((*message_)[strings::msg_params].keyExists(strings::file_name)) { + file_name = (*message_)[strings::msg_params][strings::file_name].asString(); + } + + // to avoid override existing file + const uint8_t max_size = 255; + char buf[max_size] = {'\0'}; + snprintf(buf, sizeof(buf)/sizeof(buf[0]), "%d%s", index++, file_name.c_str()); + file_name = buf; + + std::string full_file_path = file_path + "/" + file_name; + if (binary_data.size()) { + if (mobile_apis::Result::SUCCESS != + (ApplicationManagerImpl::instance()->SaveBinary( + binary_data, file_path, file_name, 0))) { + SendResponse(false, mobile_apis::Result::GENERIC_ERROR); + return; + } + } else { + if (!(file_system::CreateFile(full_file_path))) { + SendResponse(false, mobile_apis::Result::GENERIC_ERROR); + return; + } + } + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + if (std::string::npos != file_name.find("IVSU")) { + msg_params[strings::file_name] = file_name.c_str(); + } else { + msg_params[strings::file_name] = full_file_path; + } + + if (mobile_apis::RequestType::PROPRIETARY != request_type) { + msg_params[strings::app_id] = (application->mobile_app_id())->asString(); + } + msg_params[strings::request_type] = + (*message_)[strings::msg_params][strings::request_type]; + SendHMIRequest(hmi_apis::FunctionID::BasicCommunication_SystemRequest, + &msg_params, true); + +} + +void SystemRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "AddSubMenuRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::BasicCommunication_SystemRequest: { + 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; + + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!(application.valid())) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/system_response.cc b/src/components/application_manager/src/commands/mobile/system_response.cc new file mode 100644 index 0000000000..e77ab08450 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/system_response.cc @@ -0,0 +1,56 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/system_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +SystemResponse::SystemResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +SystemResponse::~SystemResponse() { +} + +void SystemResponse::Run() { + LOG4CXX_INFO(logger_, "SystemResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc new file mode 100644 index 0000000000..a07cfcd8f0 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc @@ -0,0 +1,60 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/unregister_app_interface_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/message_helper.h" + +namespace application_manager { + +namespace commands { + +void UnregisterAppInterfaceRequest::Run() { + LOG4CXX_INFO(logger_, "UnregisterAppInterfaceRequest::Run"); + + ApplicationManagerImpl* app_manager = ApplicationManagerImpl::instance(); + + if (!app_manager->application(connection_key())) { + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + LOG4CXX_ERROR(logger_, "Application is not registered"); + return; + } + + app_manager->UnregisterApplication(connection_key(), + mobile_apis::Result::SUCCESS); + SendResponse(true, mobile_apis::Result::SUCCESS); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/unregister_app_interface_response.cc b/src/components/application_manager/src/commands/mobile/unregister_app_interface_response.cc new file mode 100644 index 0000000000..8ef0eb3ed0 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/unregister_app_interface_response.cc @@ -0,0 +1,47 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/unregister_app_interface_response.h" + +namespace application_manager { + +namespace commands { + +void UnregisterAppInterfaceResponse::Run() { + LOG4CXX_INFO(logger_, "UnregisterAppInterfaceResponse::Run"); + + SendResponse((*message_)[strings::msg_params][strings::success].asBool()); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc new file mode 100644 index 0000000000..f22d1c0a2f --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc @@ -0,0 +1,79 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/unsubscribe_button_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" + +namespace application_manager { + +namespace commands { + +namespace str = strings; + +UnsubscribeButtonRequest::UnsubscribeButtonRequest( + const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +UnsubscribeButtonRequest::~UnsubscribeButtonRequest() { +} + +void UnsubscribeButtonRequest::Run() { + LOG4CXX_INFO(logger_, "UnsubscribeButtonRequest::Run"); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + (*message_)[str::params][str::connection_key].asUInt()); + + if (!app) { + LOG4CXX_ERROR_EXT(logger_, "APPLICATION_NOT_REGISTERED"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + const uint32_t btn_id = (*message_)[str::msg_params][str::button_name] + .asUInt(); + + if (!app->IsSubscribedToButton(static_cast<mobile_apis::ButtonName::eType>(btn_id))) { + LOG4CXX_ERROR_EXT(logger_, "App doesn't subscibe to button " << btn_id); + SendResponse(false, mobile_apis::Result::IGNORED); + return; + } + + app->UnsubscribeFromButton(static_cast<mobile_apis::ButtonName::eType>(btn_id)); + SendResponse(true, mobile_apis::Result::SUCCESS); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc new file mode 100644 index 0000000000..1331eac27f --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc @@ -0,0 +1,69 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/unsubscribe_button_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +UnsubscribeButtonResponse::UnsubscribeButtonResponse( + const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +UnsubscribeButtonResponse::~UnsubscribeButtonResponse() { +} + +void UnsubscribeButtonResponse::Run() { + LOG4CXX_INFO(logger_, "UnsubscribeButtonResponse::Run"); + + namespace smart_objects = NsSmartDeviceLink::NsSmartObjects; + + // check if response false + if (true == (*message_)[strings::msg_params].keyExists(strings::success)) { + if ((*message_)[strings::msg_params][strings::success].asBool() == false) { + LOG4CXX_ERROR(logger_, "Success = false"); + SendResponse(false); + return; + } + } + + // TODO(DK): Some logic + SendResponse(true); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc new file mode 100644 index 0000000000..fc7145078f --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc @@ -0,0 +1,279 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/unsubscribe_vehicle_data_request.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" +#include "application_manager/smart_object_keys.h" + +namespace application_manager { +namespace commands { + +UnsubscribeVehicleDataRequest::UnsubscribeVehicleDataRequest( + const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +UnsubscribeVehicleDataRequest::~UnsubscribeVehicleDataRequest() { +} + +#ifdef HMI_DBUS_API +namespace { + struct Subrequest { + hmi_apis::FunctionID::eType func_id; + const char* str; + }; + Subrequest subrequests[] = { + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeGps, strings::gps}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeSpeed, strings::speed}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeRpm, strings::rpm}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeFuelLevel, strings::fuel_level}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeFuelLevel_State, strings::fuel_level_state}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeInstantFuelConsumption, strings::instant_fuel_consumption}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeExternalTemperature, strings::external_temp}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeVin, strings::vin}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribePrndl, strings::prndl}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeTirePressure, strings::tire_pressure}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeOdometer, strings::odometer}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeBeltStatus, strings::belt_status}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeBodyInformation, strings::body_information}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeDeviceStatus, strings::device_status}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeDriverBraking, strings::driver_braking}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeWiperStatus, strings::wiper_status}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeHeadLampStatus, strings::head_lamp_status}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeEngineTorque, strings::engine_torque}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeAccPedalPosition, strings::acc_pedal_pos}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeSteeringWheelAngle, strings::steering_wheel_angle}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeECallInfo, strings::e_call_info}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeAirbagStatus, strings::airbag_status}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeEmergencyEvent, strings::emergency_event}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeClusterModeStatus, strings::cluster_mode_status}, + { hmi_apis::FunctionID::VehicleInfo_UnsubscribeMyKey, strings::my_key}, + }; +} +#endif // #ifdef HMI_DBUS_API + +void UnsubscribeVehicleDataRequest::Run() { + LOG4CXX_INFO(logger_, "UnsubscribeVehicleDataRequest::Run"); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + CommandRequestImpl::connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + // counter for items to subscribe + int32_t items_to_unsubscribe = 0; + // counter for subscribed items by application + int32_t unsubscribed_items = 0; + + const VehicleData& vehicle_data = MessageHelper::vehicle_data(); + VehicleData::const_iterator it = vehicle_data.begin(); + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + smart_objects::SmartObject response_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + + msg_params[strings::app_id] = app->app_id(); + + for (; vehicle_data.end() != it; ++it) { + std::string key_name = it->first; + if ((*message_)[strings::msg_params].keyExists(key_name)) { + bool is_key_enabled = (*message_)[strings::msg_params][key_name].asBool(); + if (is_key_enabled) { + ++items_to_unsubscribe; + msg_params[key_name] = is_key_enabled; + + VehicleDataType key_type = it->second; + if (app->UnsubscribeFromIVI(static_cast<uint32_t>(key_type))) { + ++unsubscribed_items; + } else { + response_params[key_name][strings::data_type] = key_type; + response_params[key_name][strings::result_code] = + mobile_apis::VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED; + } + } + } + } + + if (0 == items_to_unsubscribe) { + if (HasDisallowedParams()) { + SendResponse(false, mobile_apis::Result::DISALLOWED); + } else { + SendResponse(false, mobile_apis::Result::INVALID_DATA, + "No data in the request."); + } + return; + } else if (0 == unsubscribed_items) { + SendResponse(false, mobile_apis::Result::IGNORED, + "Was not subscribed on any VehicleData.", &response_params); + return; + } + +#ifdef HMI_DBUS_API + //Generate list of subrequests + for (size_t i = 0; i < sizeof(subrequests) / sizeof(subrequests[0]); ++i) { + const Subrequest& sr = subrequests[i]; + if (true == (*message_)[strings::msg_params].keyExists(sr.str) + && true == (*message_)[strings::msg_params][sr.str].asBool()) { + HmiRequest hmi_request; + hmi_request.str = sr.str; + hmi_request.func_id = sr.func_id; + hmi_request.complete = false; + hmi_requests_.push_back(hmi_request); + } + } + LOG4CXX_INFO(logger_, + hmi_requests_.size() << " requests are going to be sent to HMI"); + + //Send subrequests + for (HmiRequests::const_iterator it = hmi_requests_.begin(); + it != hmi_requests_.end(); ++it) + SendHMIRequest(it->func_id, &msg_params, true); +#else + SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData, + &msg_params, true); +#endif // #ifdef HMI_DBUS_API +} + +void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "UnsubscribeVehicleDataRequest::on_event"); + + const smart_objects::SmartObject& message = event.smart_object(); + +#ifdef HMI_DBUS_API + for (HmiRequests::iterator it = hmi_requests_.begin(); + it != hmi_requests_.end(); ++it) { + HmiRequest & hmi_request = *it; + if (hmi_request.func_id == event.id()) { + hmi_request.status = + static_cast<hmi_apis::Common_Result::eType>(message[strings::params][hmi_response::code] + .asInt()); + if (hmi_apis::Common_Result::SUCCESS == hmi_request.status) + hmi_request.value = message[strings::msg_params][hmi_request.str]; + hmi_request.complete = true; + break; + } + } + bool all_complete = true; + bool any_arg_success = false; + mobile_api::Result::eType status = mobile_api::Result::eType::SUCCESS; + for (HmiRequests::const_iterator it = hmi_requests_.begin(); + it != hmi_requests_.end(); ++it) { + if (!it->complete) { + all_complete = false; + break; + } + if (hmi_apis::Common_Result::SUCCESS != it->status) { + if (mobile_api::Result::SUCCESS == status) { + status = static_cast<mobile_apis::Result::eType>(it->status); + } else if (status + != static_cast<mobile_apis::Result::eType>(it->status)) { + status = mobile_api::Result::eType::GENERIC_ERROR; + } LOG4CXX_TRACE(logger_, "Status from HMI: " << it->status << + ", so response status become " << status); + } else { + any_arg_success = true; + } + } + if (all_complete) { + smart_objects::SmartObject response_params(smart_objects::SmartType_Map); + if (any_arg_success) { + for (HmiRequests::const_iterator it = hmi_requests_.begin(); + it != hmi_requests_.end(); ++it) { + response_params[it->str] = it->value; + } + } + LOG4CXX_INFO(logger_, "All HMI requests are complete"); + SendResponse(any_arg_success, status, NULL, &response_params); + } +#else + hmi_apis::Common_Result::eType hmi_result = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + bool result = + hmi_result == hmi_apis::Common_Result::SUCCESS; + + mobile_apis::Result::eType result_code = + hmi_result == hmi_apis::Common_Result::SUCCESS + ? mobile_apis::Result::SUCCESS + : static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + const char* return_info = NULL; + + if (result) { + if (IsAnythingAlreadyUnsubscribed(message[strings::msg_params])) { + result_code = mobile_apis::Result::IGNORED; + return_info = + std::string("Some provided VehicleData was not subscribed.").c_str(); + } + } + + SendResponse(result, result_code, return_info, + &(message[strings::msg_params])); +#endif // #ifdef HMI_DBUS_API +} + +bool UnsubscribeVehicleDataRequest::IsAnythingAlreadyUnsubscribed( + const smart_objects::SmartObject& msg_params) const { + LOG4CXX_INFO(logger_, "IsAnythingAlreadyUnsubscribed"); + + const VehicleData& vehicle_data = MessageHelper::vehicle_data(); + VehicleData::const_iterator it = vehicle_data.begin(); + + for (; vehicle_data.end() != it; ++it) { + if (msg_params.keyExists(it->first)) { + if (msg_params[it->first][strings::result_code].asInt() == + hmi_apis::Common_VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED) { + return true; + } + } + } + + return false; +} + + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc new file mode 100644 index 0000000000..60f7077da7 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc @@ -0,0 +1,66 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/unsubscribe_vehicle_data_response.h" + +namespace application_manager { +namespace commands { + +UnsubscribeVehicleDataResponse::UnsubscribeVehicleDataResponse( + const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +UnsubscribeVehicleDataResponse::~UnsubscribeVehicleDataResponse() { +} + +void UnsubscribeVehicleDataResponse::Run() { + LOG4CXX_INFO(logger_, "UnsubscribeVehicleDataResponse::Run"); + + namespace smart_objects = NsSmartDeviceLink::NsSmartObjects; + + // check if response false + if (true == (*message_)[strings::msg_params].keyExists(strings::success)) { + if ((*message_)[strings::msg_params][strings::success].asBool() == false) { + LOG4CXX_ERROR(logger_, "Success = false"); + SendResponse(false); + return; + } + } + + // TODO(DK): Some logic + SendResponse(true); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc new file mode 100644 index 0000000000..9447772568 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc @@ -0,0 +1,227 @@ +/* + + Copyright (c) 2013, 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 <string> +#include "application_manager/commands/mobile/update_turn_list_request.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +UpdateTurnListRequest::UpdateTurnListRequest(const MessageSharedPtr& message) + : CommandRequestImpl(message) { +} + +UpdateTurnListRequest::~UpdateTurnListRequest() { +} + +void UpdateTurnListRequest::Run() { + LOG4CXX_INFO(logger_, "UpdateTurnListRequest::Run"); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + (*message_)[strings::params][strings::connection_key].asUInt()); + + if (!app) { + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + LOG4CXX_ERROR(logger_, "Application is not registered"); + return; + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, + "Incoming update turn list has contains \t\n \\t \\n"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + //ProcessSoftButtons checks strings on the contents incorrect character + + mobile_apis::Result::eType processing_result = + MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app); + + if (mobile_apis::Result::SUCCESS != processing_result) { + LOG4CXX_ERROR(logger_, "INVALID_DATA!"); + SendResponse(false, processing_result); + return; + } + + if ((*message_)[strings::msg_params].keyExists(strings::turn_list)) { + smart_objects::SmartObject& turn_list_array = + ((*message_)[strings::msg_params][strings::turn_list]); + for (uint32_t i = 0; i < turn_list_array.length(); ++i) { + if((turn_list_array[i].keyExists(strings::turn_icon)) && + (mobile_apis::Result::SUCCESS != MessageHelper::VerifyImage( + turn_list_array[i][strings::turn_icon], app))) { + LOG4CXX_ERROR_EXT( + logger_, + "MessageHelper::VerifyImage return INVALID_DATA"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } + } + + smart_objects::SmartObject msg_params = smart_objects::SmartObject( + smart_objects::SmartType_Map); + msg_params = (*message_)[strings::msg_params]; + + if ((*message_)[strings::msg_params].keyExists(strings::turn_list)) { + if (!CheckTurnListArray()) { + LOG4CXX_ERROR(logger_, "INVALID_DATA!"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + for (uint32_t i = 0; i < msg_params[strings::turn_list].length(); ++i) { + if (msg_params[strings::turn_list][i].keyExists(hmi_request::navi_text)) { + std::string navigation_text = + msg_params[strings::turn_list][i][hmi_request::navi_text].asString(); + msg_params[strings::turn_list][i].erase(hmi_request::navi_text); + msg_params[strings::turn_list] + [i][hmi_request::navi_text][hmi_request::field_name] = + static_cast<int>(hmi_apis::Common_TextFieldName::turnText); + msg_params[strings::turn_list] + [i][hmi_request::navi_text][hmi_request::field_text] = + navigation_text; + } + } + } + + msg_params[strings::app_id] = app->app_id(); + + if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + MessageHelper::SubscribeApplicationToSoftButton((*message_)[strings::msg_params], + app, function_id()); + } + + if ((*message_)[strings::msg_params].keyExists(strings::turn_list) || + (*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + SendHMIRequest(hmi_apis::FunctionID::Navigation_UpdateTurnList, &msg_params, + true); + } else { + // conditional mandatory + LOG4CXX_ERROR(logger_, "INVALID_DATA!"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + } +} + +void UpdateTurnListRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "UpdateTurnListRequest::on_event"); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::Navigation_UpdateTurnList: { + LOG4CXX_INFO(logger_, "Received Navigation_UpdateTurnList event"); + + mobile_apis::Result::eType result_code = + static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + + bool result = (mobile_apis::Result::SUCCESS == result_code) || + ((mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) && + (hmi_capabilities.is_ui_cooperating())); + + + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_,"Received unknown event" << event.id()); + break; + } + } +} + +bool UpdateTurnListRequest::CheckTurnListArray() { + int32_t length = + (*message_)[strings::msg_params][strings::turn_list].length(); + if (0 == length) { + return false; + } + + for (int32_t i = 0; i < length; ++i) { + if (!((*message_)[strings::msg_params][strings::turn_list][i]. + keyExists(hmi_request::navi_text)) && + !((*message_)[strings::msg_params][strings::turn_list][i]. + keyExists(strings::turn_icon))) { + return false; + } + } + return true; +} + +bool UpdateTurnListRequest::IsWhiteSpaceExist() { + LOG4CXX_INFO(logger_, "UpdateTurnListRequest::IsWhiteSpaceExist"); + const char* str = NULL; + + if ((*message_)[strings::msg_params].keyExists(strings::turn_list)) { + const smart_objects::SmartArray* tl_array = + (*message_)[strings::msg_params][strings::turn_list].asArray(); + + smart_objects::SmartArray::const_iterator it_tl = tl_array->begin(); + smart_objects::SmartArray::const_iterator it_tl_end = tl_array->end(); + + for (; it_tl != it_tl_end; ++it_tl) { + if ((*it_tl).keyExists(strings::navigation_text)) { + str = (*it_tl)[strings::navigation_text].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid turn_list navigation_text text syntax check failed"); + return true; + } + } + + if ((*it_tl).keyExists(strings::turn_icon)) { + str = (*it_tl)[strings::turn_icon][strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid turn_list turn_icon value syntax check failed"); + return true; + } + } + + } + } + return false; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc b/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc new file mode 100644 index 0000000000..ec1e0bce8a --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc @@ -0,0 +1,57 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/mobile/update_turn_list_response.h" +#include "application_manager/application_manager_impl.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +UpdateTurnListResponse::UpdateTurnListResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +UpdateTurnListResponse::~UpdateTurnListResponse() { +} + +void UpdateTurnListResponse::Run() { + LOG4CXX_INFO(logger_, "UpdateTurnListResponse::Run"); + + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/pending.cc b/src/components/application_manager/src/commands/pending.cc new file mode 100644 index 0000000000..0c04464af3 --- /dev/null +++ b/src/components/application_manager/src/commands/pending.cc @@ -0,0 +1,67 @@ +/* + + Copyright (c) 2013, 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 "application_manager/commands/pending.h" + +namespace application_manager { + +namespace commands { + + +Pending::Pending() +: last_(hmi_apis::FunctionID::INVALID_ENUM) { +} + +Pending::~Pending() { +} + +void Pending::Add(hmi_apis::FunctionID::eType id) { + sync_primitives::AutoLock L(lock_); + pending_.insert(id); +} + +void Pending::Remove(hmi_apis::FunctionID::eType id) { + sync_primitives::AutoLock L(lock_); + pending_.erase(id); + + if (pending_.empty()) { + last_ = id; + } +} + +bool Pending::IsFinal(hmi_apis::FunctionID::eType id) { + return id == last_; +} + +} // namespace commands +} // namespace application_manager |