From 48aaf09ba9619ec040a29dea3257529aa27ff957 Mon Sep 17 00:00:00 2001 From: Andrey Oleynik Date: Mon, 4 Apr 2016 15:14:20 +0300 Subject: Adds implementation of DialNumber RPC DialNumber allows to initiate call from user's device trough device attached to the system. Implements: APPLINK-11266 --- src/components/application_manager/CMakeLists.txt | 2 + .../commands/hmi/dial_number_request.h | 75 +++++++++++++++++ .../commands/hmi/dial_number_response.h | 76 +++++++++++++++++ .../commands/mobile/dial_number_request.h | 23 +++++- .../commands/mobile/dial_number_response.h | 72 ++++++++++++++++ .../application_manager/smart_object_keys.h | 1 + .../src/commands/hmi/dial_number_request.cc | 57 +++++++++++++ .../src/commands/hmi/dial_number_response.cc | 57 +++++++++++++ .../src/commands/mobile/dial_number_request.cc | 96 ++++++++++++++++++++-- .../src/commands/mobile/dial_number_response.cc | 53 ++++++++++++ .../application_manager/src/hmi_command_factory.cc | 10 +++ .../src/mobile_command_factory.cc | 11 +++ src/components/interfaces/HMI_API.xml | 12 +++ 13 files changed, 537 insertions(+), 8 deletions(-) create mode 100644 src/components/application_manager/include/application_manager/commands/hmi/dial_number_request.h create mode 100644 src/components/application_manager/include/application_manager/commands/hmi/dial_number_response.h create mode 100644 src/components/application_manager/include/application_manager/commands/mobile/dial_number_response.h create mode 100644 src/components/application_manager/src/commands/hmi/dial_number_request.cc create mode 100644 src/components/application_manager/src/commands/hmi/dial_number_response.cc create mode 100644 src/components/application_manager/src/commands/mobile/dial_number_response.cc (limited to 'src/components') diff --git a/src/components/application_manager/CMakeLists.txt b/src/components/application_manager/CMakeLists.txt index bef3cdd8fe..e8db4d46c8 100644 --- a/src/components/application_manager/CMakeLists.txt +++ b/src/components/application_manager/CMakeLists.txt @@ -279,6 +279,8 @@ file (GLOB MOBILE_COMMANDS_SOURCES ${AM_SOURCE_DIR}/src/commands/hmi/on_device_state_changed_notification.cc ${AM_SOURCE_DIR}/src/commands/hmi/on_tts_reset_timeout_notification.cc ${AM_SOURCE_DIR}/src/commands/hmi/on_phone_call_notification.cc + ${AM_SOURCE_DIR}/src/commands/hmi/dial_number_request.cc + ${AM_SOURCE_DIR}/src/commands/hmi/dial_number_response.cc ) set (HMI_COMMANDS_SOURCES_JSON diff --git a/src/components/application_manager/include/application_manager/commands/hmi/dial_number_request.h b/src/components/application_manager/include/application_manager/commands/hmi/dial_number_request.h new file mode 100644 index 0000000000..807a54f3fd --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/hmi/dial_number_request.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2016, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_DIAL_NUMBER_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_DIAL_NUMBER_REQUEST_H_ + +#include "application_manager/commands/hmi/request_to_hmi.h" + +namespace application_manager { + +namespace commands { + +namespace hmi { +/** + * @brief DialNumberRequest command class + **/ +class DialNumberRequest : public RequestToHMI { + public: + /** + * @brief DialNumberRequest class constructor + * + * @param message Incoming SmartObject message + **/ + explicit DialNumberRequest(const MessageSharedPtr& message); + + /** + * @brief DialNumberRequest class destructor + **/ + virtual ~DialNumberRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(DialNumberRequest); +}; + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_DIAL_NUMBER_REQUEST_H_ diff --git a/src/components/application_manager/include/application_manager/commands/hmi/dial_number_response.h b/src/components/application_manager/include/application_manager/commands/hmi/dial_number_response.h new file mode 100644 index 0000000000..d26b86a907 --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/hmi/dial_number_response.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_DIAL_NUMBER_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_DIAL_NUMBER_RESPONSE_H_ + +#include "application_manager/commands/hmi/response_from_hmi.h" + +namespace application_manager { + +namespace commands { + +namespace hmi { + +/** + * @brief DialNumberResponse command class + **/ +class DialNumberResponse : public ResponseFromHMI { + public: + /** + * @brief DialNumberResponse class constructor + * + * @param message Incoming SmartObject message + **/ + explicit DialNumberResponse(const MessageSharedPtr& message); + + /** + * @brief DialNumberResponse class destructor + **/ + virtual ~DialNumberResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(DialNumberResponse); +}; + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_DIAL_NUMBER_RESPONSE_H_ diff --git a/src/components/application_manager/include/application_manager/commands/mobile/dial_number_request.h b/src/components/application_manager/include/application_manager/commands/mobile/dial_number_request.h index 10ffa5b324..1820f2cefd 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/dial_number_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/dial_number_request.h @@ -1,6 +1,5 @@ /* - - Copyright (c) 2013, Ford Motor Company + Copyright (c) 2016, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without @@ -56,12 +55,32 @@ class DialNumberRequest : public CommandRequestImpl { **/ virtual ~DialNumberRequest(); + /** + * @brief Initialize request params + **/ + virtual bool Init(); + /** * @brief Execute command **/ virtual void Run(); + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + void on_event(const event_engine::Event& event); + private: + + /** + * @brief Removes from number param all characters + * except the + character and digits. + * + */ + void StripNumberParam(std::string &number); + DISALLOW_COPY_AND_ASSIGN(DialNumberRequest); }; diff --git a/src/components/application_manager/include/application_manager/commands/mobile/dial_number_response.h b/src/components/application_manager/include/application_manager/commands/mobile/dial_number_response.h new file mode 100644 index 0000000000..1b713e0184 --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/mobile/dial_number_response.h @@ -0,0 +1,72 @@ +/* + Copyright (c) 2016, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_DIAL_NUMBER_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_DIAL_NUMBER_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "utils/macro.h" + +namespace application_manager { + +namespace commands { + +/** + * @brief DialNumberResponse command class + **/ +class DialNumberResponse : public CommandResponseImpl { + public: + /** + * @brief DialNumberResponse class constructor + * + * @param message Incoming SmartObject message + **/ + explicit DialNumberResponse(const MessageSharedPtr& message); + + /** + * @brief DialNumberResponse class destructor + **/ + virtual ~DialNumberResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(DialNumberResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_DIAL_NUMBER_RESPONSE_H_ diff --git a/src/components/application_manager/include/application_manager/smart_object_keys.h b/src/components/application_manager/include/application_manager/smart_object_keys.h index c76886daca..cebac3fef3 100644 --- a/src/components/application_manager/include/application_manager/smart_object_keys.h +++ b/src/components/application_manager/include/application_manager/smart_object_keys.h @@ -280,6 +280,7 @@ const char location_name[] = "locationName"; const char location_description[] = "locationDescription"; const char address_lines[] = "addressLines"; const char phone_number[] = "phoneNumber"; +const char number[] = "number"; const char location_image[] = "locationImage"; const char is_suscribed[] = "isSubscribed"; const char message_data[] = "messageData"; diff --git a/src/components/application_manager/src/commands/hmi/dial_number_request.cc b/src/components/application_manager/src/commands/hmi/dial_number_request.cc new file mode 100644 index 0000000000..0e8e359e7e --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/dial_number_request.cc @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2016, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * 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/dial_number_request.h" + +namespace application_manager { + +namespace commands { + +namespace hmi { + +DialNumberRequest::DialNumberRequest(const MessageSharedPtr& message) + : RequestToHMI(message) { +} + +DialNumberRequest::~DialNumberRequest() { +} + +void DialNumberRequest::Run() { + SendRequest(); +} + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/dial_number_response.cc b/src/components/application_manager/src/commands/hmi/dial_number_response.cc new file mode 100644 index 0000000000..3f616bf47f --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/dial_number_response.cc @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2016, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * 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/dial_number_response.h" + +namespace application_manager { + +namespace commands { + +namespace hmi { + +DialNumberResponse::DialNumberResponse(const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +DialNumberResponse::~DialNumberResponse() { +} + +void DialNumberResponse::Run() { + event_engine::Event event(hmi_apis::FunctionID::BasicCommunication_DialNumber); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace hmi + +} // 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 index 749b19a520..d9dde280cd 100644 --- a/src/components/application_manager/src/commands/mobile/dial_number_request.cc +++ b/src/components/application_manager/src/commands/mobile/dial_number_request.cc @@ -1,6 +1,5 @@ /* - - Copyright (c) 2013, Ford Motor Company + Copyright (c) 2016, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without @@ -31,6 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include +#include #include "application_manager/commands/mobile/dial_number_request.h" #include "application_manager/application_manager_impl.h" #include "application_manager/application_impl.h" @@ -40,16 +41,99 @@ namespace application_manager { namespace commands { DialNumberRequest::DialNumberRequest(const MessageSharedPtr& message) - : CommandRequestImpl(message) { -} + : CommandRequestImpl(message) {} + +DialNumberRequest::~DialNumberRequest() {} + +bool DialNumberRequest::Init() { + LOG4CXX_AUTO_TRACE(logger_); -DialNumberRequest::~DialNumberRequest() { + default_timeout_ = 0; + + return true; } void DialNumberRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); - SendResponse(false, mobile_apis::Result::UNSUPPORTED_REQUEST); + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + std::string number = + (*message_)[strings::msg_params][strings::number].asString(); + if (!CheckSyntax(number)) { + LOG4CXX_ERROR(logger_, "Invalid incoming data"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + StripNumberParam(number); + if (number.empty()) { + LOG4CXX_WARN(logger_, + "After strip number param is empty. Invalid incoming data"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[strings::number] = + (*message_)[strings::msg_params][strings::number].asString(); + msg_params[strings::app_id] = application->hmi_app_id(); + + SendHMIRequest( + hmi_apis::FunctionID::BasicCommunication_DialNumber, &msg_params, true); +} + +void DialNumberRequest::on_event(const event_engine::Event& event) { + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + const smart_objects::SmartObject& message = event.smart_object(); + mobile_apis::Result::eType result_code = mobile_apis::Result::SUCCESS; + switch (event.id()) { + case hmi_apis::FunctionID::BasicCommunication_DialNumber: { + LOG4CXX_INFO(logger_, "Received DialNumber event"); + result_code = CommandRequestImpl::GetMobileResultCode( + static_cast( + message[strings::params][hmi_response::code].asInt())); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } + + const bool is_success = mobile_apis::Result::SUCCESS == result_code; + const bool is_info_valid = + message[strings::msg_params].keyExists(strings::info); + + if (is_info_valid) { + const char* info_char_array = + message[strings::msg_params][strings::info].asCharArray(); + SendResponse(is_success, result_code, info_char_array); + return; + } + + SendResponse(is_success, result_code); +} + +void DialNumberRequest::StripNumberParam(std::string& number) { + std::size_t found = 0; + while (std::string::npos != + (found = number.find_first_not_of("+0123456789"))) { + number.erase(number.begin() + found); + } + (*message_)[strings::msg_params][strings::number] = number; } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/dial_number_response.cc b/src/components/application_manager/src/commands/mobile/dial_number_response.cc new file mode 100644 index 0000000000..1daab5a4e1 --- /dev/null +++ b/src/components/application_manager/src/commands/mobile/dial_number_response.cc @@ -0,0 +1,53 @@ +/* + Copyright (c) 2016, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + 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_response.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +DialNumberResponse::DialNumberResponse(const MessageSharedPtr& message) + : CommandResponseImpl(message) { +} + +DialNumberResponse::~DialNumberResponse() { +} + +void DialNumberResponse::Run() { + ApplicationManagerImpl::instance()->SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/hmi_command_factory.cc b/src/components/application_manager/src/hmi_command_factory.cc index f8bf47bb71..2fc3499c09 100644 --- a/src/components/application_manager/src/hmi_command_factory.cc +++ b/src/components/application_manager/src/hmi_command_factory.cc @@ -264,6 +264,8 @@ #include "application_manager/commands/hmi/navi_send_location_response.h" #include "application_manager/commands/hmi/on_tts_reset_timeout_notification.h" #include "application_manager/commands/hmi/on_phone_call_notification.h" +#include "application_manager/commands/hmi/dial_number_request.h" +#include "application_manager/commands/hmi/dial_number_response.h" namespace application_manager { @@ -2060,6 +2062,14 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset(new commands::hmi::OnPhoneCallNotification(message)); break; } + case hmi_apis::FunctionID::BasicCommunication_DialNumber: { + if (is_response) { + command.reset(new commands::hmi::DialNumberResponse(message)); + } else { + command.reset(new commands::hmi::DialNumberRequest(message)); + } + break; + } } return command; diff --git a/src/components/application_manager/src/mobile_command_factory.cc b/src/components/application_manager/src/mobile_command_factory.cc index 0d592e9562..2bb1dff921 100644 --- a/src/components/application_manager/src/mobile_command_factory.cc +++ b/src/components/application_manager/src/mobile_command_factory.cc @@ -125,6 +125,8 @@ #include "application_manager/commands/mobile/diagnostic_message_response.h" #include "application_manager/commands/mobile/send_location_request.h" #include "application_manager/commands/mobile/send_location_response.h" +#include "application_manager/commands/mobile/dial_number_request.h" +#include "application_manager/commands/mobile/dial_number_response.h" #include "interfaces/MOBILE_API.h" namespace application_manager { @@ -478,6 +480,15 @@ commands::Command *MobileCommandFactory::CreateCommand( } break; } + case mobile_apis::FunctionID::DialNumberID: { + if ((*message)[strings::params][strings::message_type] + == static_cast(application_manager::MessageType::kResponse)) { + return new commands::DialNumberResponse(message); + } else { + return new commands::DialNumberRequest(message); + } + break; + } case mobile_apis::FunctionID::OnButtonEventID: { return new commands::mobile::OnButtonEventNotification(message); break; diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 62f3d2a10f..621695a0c0 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -2188,6 +2188,18 @@ Defines the name of app's request that initiates playing a tone + + Request from SDL to call a specific number. + + The number to dial. Only the character + and numbers are allowed. + + + ID of application that concerns this RPC. + + + + + -- cgit v1.2.1 From 05797355fa6858badc0b42e019eefc15558925a3 Mon Sep 17 00:00:00 2001 From: Andrey Oleynik Date: Mon, 4 Apr 2016 15:37:01 +0300 Subject: Adds latest number validation changes According to latest information number should be verified as: "Phone number is a string, which can be up to 40 chars. All characters shall be stripped from string except digits 0-9 and * # , ; +" Implements: APPLINK-11266 --- .../application_manager/src/commands/mobile/dial_number_request.cc | 2 +- src/components/interfaces/HMI_API.xml | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/components') 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 index d9dde280cd..6e8f5e15ad 100644 --- a/src/components/application_manager/src/commands/mobile/dial_number_request.cc +++ b/src/components/application_manager/src/commands/mobile/dial_number_request.cc @@ -130,7 +130,7 @@ void DialNumberRequest::on_event(const event_engine::Event& event) { void DialNumberRequest::StripNumberParam(std::string& number) { std::size_t found = 0; while (std::string::npos != - (found = number.find_first_not_of("+0123456789"))) { + (found = number.find_first_not_of("+*#,;0123456789"))) { number.erase(number.begin() + found); } (*message_)[strings::msg_params][strings::number] = number; diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 621695a0c0..d5e4e879fe 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -2191,7 +2191,9 @@ Request from SDL to call a specific number. - The number to dial. Only the character + and numbers are allowed. + Phone number is a string, which can be up to 40 chars. + All characters shall be stripped from string except digits 0-9 and * # , ; + + ID of application that concerns this RPC. -- cgit v1.2.1 From 2013219874fc227221a53abf3bfe9b3368fa5d93 Mon Sep 17 00:00:00 2001 From: Andrey Oleynik Date: Tue, 5 Apr 2016 15:34:16 +0300 Subject: Code style changes --- .../include/application_manager/commands/hmi/dial_number_request.h | 2 +- .../include/application_manager/commands/hmi/dial_number_response.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/components') diff --git a/src/components/application_manager/include/application_manager/commands/hmi/dial_number_request.h b/src/components/application_manager/include/application_manager/commands/hmi/dial_number_request.h index 807a54f3fd..ab9959f538 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/dial_number_request.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/dial_number_request.h @@ -60,7 +60,7 @@ class DialNumberRequest : public RequestToHMI { /** * @brief Execute command **/ - virtual void Run(); + void Run() OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(DialNumberRequest); diff --git a/src/components/application_manager/include/application_manager/commands/hmi/dial_number_response.h b/src/components/application_manager/include/application_manager/commands/hmi/dial_number_response.h index d26b86a907..9e3b72066d 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/dial_number_response.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/dial_number_response.h @@ -61,7 +61,7 @@ class DialNumberResponse : public ResponseFromHMI { /** * @brief Execute command **/ - virtual void Run(); + void Run() OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(DialNumberResponse); -- cgit v1.2.1 From 85172a5531462dc0ed7e923859faad5471dfb73e Mon Sep 17 00:00:00 2001 From: Andrey Oleynik Date: Wed, 6 Apr 2016 10:22:30 +0300 Subject: More style changes --- .../include/application_manager/commands/hmi/dial_number_request.h | 2 +- .../include/application_manager/commands/hmi/dial_number_response.h | 2 +- .../application_manager/commands/mobile/dial_number_request.h | 6 +++--- .../application_manager/commands/mobile/dial_number_response.h | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/components') diff --git a/src/components/application_manager/include/application_manager/commands/hmi/dial_number_request.h b/src/components/application_manager/include/application_manager/commands/hmi/dial_number_request.h index ab9959f538..7d59abdadd 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/dial_number_request.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/dial_number_request.h @@ -55,7 +55,7 @@ class DialNumberRequest : public RequestToHMI { /** * @brief DialNumberRequest class destructor **/ - virtual ~DialNumberRequest(); + ~DialNumberRequest() OVERRIDE; /** * @brief Execute command diff --git a/src/components/application_manager/include/application_manager/commands/hmi/dial_number_response.h b/src/components/application_manager/include/application_manager/commands/hmi/dial_number_response.h index 9e3b72066d..93a2e06c5f 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/dial_number_response.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/dial_number_response.h @@ -56,7 +56,7 @@ class DialNumberResponse : public ResponseFromHMI { /** * @brief DialNumberResponse class destructor **/ - virtual ~DialNumberResponse(); + ~DialNumberResponse() OVERRIDE; /** * @brief Execute command diff --git a/src/components/application_manager/include/application_manager/commands/mobile/dial_number_request.h b/src/components/application_manager/include/application_manager/commands/mobile/dial_number_request.h index 1820f2cefd..ea8556f6e0 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/dial_number_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/dial_number_request.h @@ -53,17 +53,17 @@ class DialNumberRequest : public CommandRequestImpl { /** * \brief DialNumberRequest class destructor **/ - virtual ~DialNumberRequest(); + ~DialNumberRequest() OVERRIDE; /** * @brief Initialize request params **/ - virtual bool Init(); + bool Init() OVERRIDE; /** * @brief Execute command **/ - virtual void Run(); + void Run() OVERRIDE; /** * @brief Interface method that is called whenever new event received diff --git a/src/components/application_manager/include/application_manager/commands/mobile/dial_number_response.h b/src/components/application_manager/include/application_manager/commands/mobile/dial_number_response.h index 1b713e0184..0cdeb9eb90 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/dial_number_response.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/dial_number_response.h @@ -55,12 +55,12 @@ class DialNumberResponse : public CommandResponseImpl { /** * @brief DialNumberResponse class destructor **/ - virtual ~DialNumberResponse(); + ~DialNumberResponse() OVERRIDE; /** * @brief Execute command **/ - virtual void Run(); + void Run() OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(DialNumberResponse); -- cgit v1.2.1