From 72a9e815be5cb5f4237dc66db5072f9c5147f602 Mon Sep 17 00:00:00 2001 From: "Oleksandr Lohvinenko (GitHub)" Date: Wed, 23 May 2018 13:29:46 +0300 Subject: Moved mobile RPCs. --- .../commands/mobile/diagnostic_message_request.h | 85 ---- .../commands/mobile/diagnostic_message_response.h | 79 ---- .../commands/mobile/get_dtcs_request.h | 85 ---- .../commands/mobile/get_dtcs_response.h | 78 ---- .../commands/mobile/get_vehicle_data_request.h | 98 ---- .../commands/mobile/get_vehicle_data_response.h | 78 ---- .../commands/mobile/on_vehicle_data_notification.h | 88 ---- .../commands/mobile/read_did_request.h | 85 ---- .../commands/mobile/read_did_response.h | 78 ---- .../mobile/subscribe_vehicle_data_request.h | 179 -------- .../mobile/subscribe_vehicle_data_response.h | 80 ---- .../mobile/unsubscribe_vehicle_data_request.h | 133 ------ .../mobile/unsubscribe_vehicle_data_response.h | 80 ---- .../commands/mobile/diagnostic_message_request.cc | 130 ------ .../commands/mobile/diagnostic_message_response.cc | 64 --- .../src/commands/mobile/get_dtcs_request.cc | 119 ----- .../src/commands/mobile/get_dtcs_response.cc | 64 --- .../commands/mobile/get_vehicle_data_request.cc | 319 ------------- .../commands/mobile/get_vehicle_data_response.cc | 65 --- .../mobile/on_vehicle_data_notification.cc | 121 ----- .../src/commands/mobile/read_did_request.cc | 134 ------ .../src/commands/mobile/read_did_response.cc | 64 --- .../mobile/subscribe_vehicle_data_request.cc | 506 --------------------- .../mobile/subscribe_vehicle_data_response.cc | 63 --- .../mobile/unsubscribe_vehicle_data_request.cc | 416 ----------------- .../mobile/unsubscribe_vehicle_data_response.cc | 72 --- .../commands/mobile/diagnostic_message_request.h | 85 ++++ .../commands/mobile/diagnostic_message_response.h | 79 ++++ .../commands/mobile/get_dtcs_request.h | 85 ++++ .../commands/mobile/get_dtcs_response.h | 78 ++++ .../commands/mobile/get_vehicle_data_request.h | 98 ++++ .../commands/mobile/get_vehicle_data_response.h | 78 ++++ .../commands/mobile/on_vehicle_data_notification.h | 88 ++++ .../commands/mobile/read_did_request.h | 85 ++++ .../commands/mobile/read_did_response.h | 78 ++++ .../mobile/subscribe_vehicle_data_request.h | 179 ++++++++ .../mobile/subscribe_vehicle_data_response.h | 80 ++++ .../mobile/unsubscribe_vehicle_data_request.h | 133 ++++++ .../mobile/unsubscribe_vehicle_data_response.h | 80 ++++ .../vehicle_info_command_factory.h | 4 +- .../vehicle_info_mobile_command_factory.h | 2 + .../commands/mobile/diagnostic_message_request.cc | 130 ++++++ .../commands/mobile/diagnostic_message_response.cc | 64 +++ .../src/commands/mobile/get_dtcs_request.cc | 119 +++++ .../src/commands/mobile/get_dtcs_response.cc | 64 +++ .../commands/mobile/get_vehicle_data_request.cc | 319 +++++++++++++ .../commands/mobile/get_vehicle_data_response.cc | 65 +++ .../mobile/on_vehicle_data_notification.cc | 121 +++++ .../src/commands/mobile/read_did_request.cc | 134 ++++++ .../src/commands/mobile/read_did_response.cc | 64 +++ .../mobile/subscribe_vehicle_data_request.cc | 506 +++++++++++++++++++++ .../mobile/subscribe_vehicle_data_response.cc | 63 +++ .../mobile/unsubscribe_vehicle_data_request.cc | 416 +++++++++++++++++ .../mobile/unsubscribe_vehicle_data_response.cc | 72 +++ .../src/vehicle_info_command_factory.cc | 14 +- .../src/vehicle_info_hmi_command_factory.cc | 19 + .../src/vehicle_info_mobile_command_factory.cc | 96 +++- 57 files changed, 3485 insertions(+), 3376 deletions(-) delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/diagnostic_message_request.h delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/diagnostic_message_response.h delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_dtcs_request.h delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_dtcs_response.h delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_vehicle_data_request.h delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_vehicle_data_response.h delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_vehicle_data_notification.h delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/read_did_request.h delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/read_did_response.h delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_vehicle_data_request.h delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_vehicle_data_response.h delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_vehicle_data_request.h delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_vehicle_data_response.h delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/diagnostic_message_request.cc delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/diagnostic_message_response.cc delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_dtcs_request.cc delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_dtcs_response.cc delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_vehicle_data_request.cc delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_vehicle_data_response.cc delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_vehicle_data_notification.cc delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/read_did_request.cc delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/read_did_response.cc delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_request.h create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_response.h create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_request.h create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_response.h create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_request.h create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_response.h create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_request.cc create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_response.cc create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_request.cc create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_response.cc create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_response.cc create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_request.cc create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_response.cc create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc create mode 100644 src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/diagnostic_message_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/diagnostic_message_request.h deleted file mode 100644 index 8e65d20ba1..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/diagnostic_message_request.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAGNOSTIC_MESSAGE_REQUEST_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAGNOSTIC_MESSAGE_REQUEST_H_ - -#include "application_manager/commands/command_request_impl.h" -#include "utils/macro.h" - -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -namespace commands { - -/** - * @brief DiagnosticMessageRequest command class - **/ -class DiagnosticMessageRequest : public app_mngr::commands::CommandRequestImpl { - public: - /** - * @brief DiagnosticMessageRequest class constructor - * - * @param message Incoming SmartObject message - **/ - DiagnosticMessageRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - - /** - * @brief DiagnosticMessageRequest class destructor - **/ - virtual ~DiagnosticMessageRequest(); - - /** - * @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 app_mngr::event_engine::Event& event); - - private: - DISALLOW_COPY_AND_ASSIGN(DiagnosticMessageRequest); -}; - -} // namespace commands -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAGNOSTIC_MESSAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/diagnostic_message_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/diagnostic_message_response.h deleted file mode 100644 index bc5f375096..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/diagnostic_message_response.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAGNOSTIC_MESSAGE_RESPONSE_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAGNOSTIC_MESSAGE_RESPONSE_H_ - -#include "application_manager/commands/command_response_impl.h" -#include "utils/macro.h" - -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -namespace commands { - -/** - * @brief DiagnosticMessageResponse command class - **/ -class DiagnosticMessageResponse - : public app_mngr::commands::CommandResponseImpl { - public: - /** - * @brief DiagnosticMessageResponse class constructor - * - * @param message Incoming SmartObject message - **/ - DiagnosticMessageResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - - /** - * @brief DiagnosticMessageResponse class destructor - **/ - virtual ~DiagnosticMessageResponse(); - - /** - * @brief Execute command - **/ - virtual void Run(); - - private: - DISALLOW_COPY_AND_ASSIGN(DiagnosticMessageResponse); -}; - -} // namespace commands -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAGNOSTIC_MESSAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_dtcs_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_dtcs_request.h deleted file mode 100644 index cfdc305b53..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_dtcs_request.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_DTCS_REQUEST_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_DTCS_REQUEST_H_ - -#include "application_manager/commands/command_request_impl.h" -#include "utils/macro.h" - -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -namespace commands { - -/** - * @brief GetDTCsRequest command class - **/ -class GetDTCsRequest : public app_mngr::commands::CommandRequestImpl { - public: - /** - * @brief GetDTCsRequest class constructor - * - * @param message Incoming SmartObject message - **/ - GetDTCsRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - - /** - * @brief GetDTCsRequest class destructor - **/ - virtual ~GetDTCsRequest(); - - /** - * @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 app_mngr::event_engine::Event& event); - - private: - DISALLOW_COPY_AND_ASSIGN(GetDTCsRequest); -}; - -} // namespace commands -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_DTCS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_dtcs_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_dtcs_response.h deleted file mode 100644 index 80207809d0..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_dtcs_response.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_DTCS_RESPONSE_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_DTCS_RESPONSE_H_ - -#include "application_manager/commands/command_response_impl.h" -#include "utils/macro.h" - -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -namespace commands { - -/** - * @brief GetDTCsResponse command class - **/ -class GetDTCsResponse : public app_mngr::commands::CommandResponseImpl { - public: - /** - * @brief GetDTCsResponse class constructor - * - * @param message Incoming SmartObject message - **/ - GetDTCsResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - - /** - * @brief GetDTCsResponse class destructor - **/ - virtual ~GetDTCsResponse(); - - /** - * @brief Execute command - **/ - virtual void Run(); - - private: - DISALLOW_COPY_AND_ASSIGN(GetDTCsResponse); -}; - -} // namespace commands -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_DTCS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_vehicle_data_request.h deleted file mode 100644 index d25b7b7a93..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_vehicle_data_request.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_VEHICLE_DATA_REQUEST_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_VEHICLE_DATA_REQUEST_H_ - -#include "application_manager/commands/command_request_impl.h" -#include "utils/macro.h" - -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -class SmartObject; - -namespace commands { - -/** - * @brief GetVehicleDataRequest command class - **/ -class GetVehicleDataRequest : public app_mngr::commands::CommandRequestImpl { - public: - /** - * @brief GetVehicleDataRequest class constructor - * - * @param message Incoming SmartObject message - **/ - GetVehicleDataRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - - /** - * @brief GetVehicleDataRequest class destructor - **/ - virtual ~GetVehicleDataRequest(); - - /** - * @brief Execute command - **/ - virtual void Run(); - - protected: - virtual void on_event(const app_mngr::event_engine::Event& event); - -#ifdef HMI_DBUS_API - private: - void SendRequestsToHmi(const int32_t app_id); - - struct HmiRequest { - hmi_apis::Common_Result::eType status; - bool complete; - smart_objects::SmartObject value; - const char* str; - hmi_apis::FunctionID::eType func_id; - }; - - typedef std::vector HmiRequests; - HmiRequests hmi_requests_; -#endif // #ifdef HMI_DBUS_API - - DISALLOW_COPY_AND_ASSIGN(GetVehicleDataRequest); -}; - -} // namespace commands -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_vehicle_data_response.h deleted file mode 100644 index 79080b5dd0..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_vehicle_data_response.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_VEHICLE_DATA_RESPONSE_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_VEHICLE_DATA_RESPONSE_H_ - -#include "application_manager/commands/command_response_impl.h" -#include "utils/macro.h" - -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -namespace commands { - -/** - * @brief GetVehicleDataResponse command class - **/ -class GetVehicleDataResponse : public app_mngr::commands::CommandResponseImpl { - public: - /** - * @brief GetVehicleDataResponse class constructor - * - * @param message Incoming SmartObject message - **/ - GetVehicleDataResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - - /** - * @brief GetVehicleDataResponse class destructor - **/ - virtual ~GetVehicleDataResponse(); - - /** - * @brief Execute command - **/ - virtual void Run(); - - private: - DISALLOW_COPY_AND_ASSIGN(GetVehicleDataResponse); -}; - -} // namespace commands -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_vehicle_data_notification.h deleted file mode 100644 index 34a685963f..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_vehicle_data_notification.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_VEHICLE_DATA_NOTIFICATION_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_VEHICLE_DATA_NOTIFICATION_H_ - -#include "application_manager/commands/command_notification_impl.h" -#include "application_manager/application.h" -#include "utils/macro.h" - -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -namespace commands { - -/** - * @brief OnVehicleDataNotification class is used to send notification - * to mobile device that some button was pressed on HMI. - **/ -class OnVehicleDataNotification - : public app_mngr::commands::CommandNotificationImpl { - public: - /** - * @brief OnVehicleDataNotification class constructor - * - * @param message Incoming SmartObject message - **/ - OnVehicleDataNotification(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - - /** - * @brief OnVehicleDataNotification class destructor - **/ - virtual ~OnVehicleDataNotification(); - - /** - * @brief Execute command - **/ - virtual void Run(); - - private: - /* - * @brief Sends vehicle data notification to mobile device - * - * @param app Application to receive notification - */ - void SendVehicleData(app_mngr::ApplicationConstSharedPtr app); - - DISALLOW_COPY_AND_ASSIGN(OnVehicleDataNotification); -}; - -} // namespace commands -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_VEHICLE_DATA_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/read_did_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/read_did_request.h deleted file mode 100644 index b2d7460ad0..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/read_did_request.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_READ_DID_REQUEST_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_READ_DID_REQUEST_H_ - -#include "application_manager/commands/command_request_impl.h" -#include "utils/macro.h" - -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -namespace commands { - -/** - * @brief ReadDIDRequest command class - **/ -class ReadDIDRequest : public app_mngr::commands::CommandRequestImpl { - public: - /** - * @brief ReadDIDRequest class constructor - * - * @param message Incoming SmartObject message - **/ - ReadDIDRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - - /** - * @brief ReadDIDRequest class destructor - **/ - virtual ~ReadDIDRequest(); - - /** - * @brief Interface method that is called whenever new event received - * - * @param event The received event - */ - void on_event(const app_mngr::event_engine::Event& event); - - /** - * @brief Execute command - **/ - virtual void Run(); - - private: - DISALLOW_COPY_AND_ASSIGN(ReadDIDRequest); -}; - -} // namespace commands -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_READ_DID_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/read_did_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/read_did_response.h deleted file mode 100644 index 25c091b61d..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/read_did_response.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_READ_DID_RESPONSE_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_READ_DID_RESPONSE_H_ - -#include "application_manager/commands/command_response_impl.h" -#include "utils/macro.h" - -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -namespace commands { - -/** - * @brief ReadDIDResponse command class - **/ -class ReadDIDResponse : public app_mngr::commands::CommandResponseImpl { - public: - /** - * @brief ReadDIDResponse class constructor - * - * @param message Incoming SmartObject message - **/ - ReadDIDResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - - /** - * @brief ReadDIDResponse class destructor - **/ - virtual ~ReadDIDResponse(); - - /** - * @brief Execute command - **/ - virtual void Run(); - - private: - DISALLOW_COPY_AND_ASSIGN(ReadDIDResponse); -}; - -} // namespace commands -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_READ_DID_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_vehicle_data_request.h deleted file mode 100644 index e836dee669..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_vehicle_data_request.h +++ /dev/null @@ -1,179 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Copyright (c) 2018, Livio, Inc. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ - -#include "application_manager/commands/command_request_impl.h" -#include "application_manager/application.h" -#include "utils/macro.h" - -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -namespace commands { - -/** - * @brief SubscribeVehicleDataRequest command class - **/ -class SubscribeVehicleDataRequest - : public app_mngr::commands::CommandRequestImpl { - public: - /** - * @brief SubscribeVehicleDataRequest class constructor - * - * @param message Incoming SmartObject message - **/ - SubscribeVehicleDataRequest( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - - /** - * @brief SubscribeButtonCommandRequest class destructor - **/ - ~SubscribeVehicleDataRequest(); - - /** - * @brief Execute command - **/ - void Run() FINAL; - - /** - * @brief Interface method that is called whenever new event received - * - * @param event The received event - */ - void on_event(const app_mngr::event_engine::Event& event) FINAL; - - /** - * @brief Init sets hash update mode for request - */ - bool Init() FINAL; - -#ifdef HMI_DBUS_API - private: - struct HmiRequest { - hmi_apis::Common_Result::eType status; - bool complete; - smart_objects::SmartObject value; - const char* str; - hmi_apis::FunctionID::eType func_id; - }; - - typedef std::vector HmiRequests; - HmiRequests hmi_requests_; -#endif // #ifdef HMI_DBUS_API - - private: - /** - * @brief Checks, if any app is subscribed for particular VI parameter - * @param param_id VI parameter id - * @return true, if there are registered apps subscribed for VI parameter, - * otherwise - false - */ - bool IsSomeoneSubscribedFor(const uint32_t param_id) const; - - /** - * @brief Adds VI parameters being subscribed by another or the same app to - * response with appropriate results - * @param msg_params 'message_params' response section reference - */ - void AddAlreadySubscribedVI(smart_objects::SmartObject& msg_params) const; - - /** - * @brief Removes subscription for VI parameters which subsription attempt - * returned an error - * @param app Pointer to application sent subscribe request - * @param msg_params 'message_parameters' response section reference - */ - void UnsubscribeFailedSubscriptions( - app_mngr::ApplicationSharedPtr app, - const smart_objects::SmartObject& msg_params) const; - - DEPRECATED void CheckVISubscribtions( - app_mngr::ApplicationSharedPtr app, - std::string& out_info, - mobile_apis::Result::eType& out_result_code, - smart_objects::SmartObject& out_response_params, - smart_objects::SmartObject& out_request_params, - bool& out_result); - - /** - * @brief Checks if current application and other applications - * were subscribed to VI, prepare data that need to send to mobile app - * or HMI. - * @param app contains application - * @param out_info contains resulting info for sending to mobile app - * @param out_result_code contains result code for sending to mobile app - * @param out_response_params contains parameters that SDL sends to - * mobile application - * @param out_request_params contains parameters that SDL sends to - * HMI - * @param result contains result that SDL sends to mobile app. - */ - void CheckVISubscriptions(app_mngr::ApplicationSharedPtr app, - std::string& out_info, - mobile_apis::Result::eType& out_result_code, - smart_objects::SmartObject& out_response_params, - smart_objects::SmartObject& out_request_params, - bool& out_result); - - /** - * @brief VI parameters which had been already subscribed by another apps - * befor particular app subscribed for these parameters - */ - app_mngr::VehicleInfoSubscriptions vi_already_subscribed_by_another_apps_; - - /** - * @brief VI parameters which had been subscribed already by particular app - */ - app_mngr::VehicleInfoSubscriptions vi_already_subscribed_by_this_app_; - - /** - * @brief VI parameters which wait for subscribe after HMI respond - */ - app_mngr::VehicleInfoSubscriptions vi_waiting_for_subscribe_; - - DISALLOW_COPY_AND_ASSIGN(SubscribeVehicleDataRequest); -}; - -} // namespace commands -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_vehicle_data_response.h deleted file mode 100644 index 94ec195849..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_vehicle_data_response.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ - -#include "application_manager/commands/command_response_impl.h" -#include "utils/macro.h" - -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -namespace commands { - -/** - * @brief SubscribeVehicleDataResponse command class - **/ -class SubscribeVehicleDataResponse - : public app_mngr::commands::CommandResponseImpl { - public: - /** - * @brief SubscribeVehicleDataResponse class constructor - * - * @param message Incoming SmartObject message - **/ - SubscribeVehicleDataResponse( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - - /** - * @brief UnsubscribeVehicleDataCommandRequest class destructor - **/ - virtual ~SubscribeVehicleDataResponse(); - - /** - * @brief Execute command - **/ - virtual void Run(); - - private: - DISALLOW_COPY_AND_ASSIGN(SubscribeVehicleDataResponse); -}; - -} // namespace commands -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_vehicle_data_request.h deleted file mode 100644 index a22da4490a..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_vehicle_data_request.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_H_ - -#include "application_manager/commands/command_request_impl.h" -#include "application_manager/application.h" -#include "utils/macro.h" - -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -namespace commands { - -/** - * @brief UnsubscribeVehicleDataRequest command class - **/ -class UnsubscribeVehicleDataRequest - : public app_mngr::commands::CommandRequestImpl { - public: - /** - * @brief UnsubscribeVehicleDataRequest class constructor - * - * @param message Incoming SmartObject message - **/ - UnsubscribeVehicleDataRequest( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - - /** - * @brief UnsubscribeVehicleDataRequest class destructor - **/ - ~UnsubscribeVehicleDataRequest(); - - /** - * @brief Execute command - **/ - void Run() FINAL; - - /** - * @brief Interface method that is called whenever new event received - * - * @param event The received event - */ - void on_event(const app_mngr::event_engine::Event& event) FINAL; - - /** - * @brief Init sets hash update mode for request - */ - bool Init() FINAL; - -#ifdef HMI_DBUS_API - private: - struct HmiRequest { - hmi_apis::Common_Result::eType status; - bool complete; - smart_objects::SmartObject value; - const char* str; - hmi_apis::FunctionID::eType func_id; - }; - - typedef std::vector HmiRequests; - HmiRequests hmi_requests_; -#endif // #ifdef HMI_DBUS_API - - private: - /** - * @brief Checks, if any app is subscribed for particular VI parameter - * @param param_id VI parameter id - * @return true, if there are registered apps subscribed for VI parameter, - * otherwise - false - */ - bool IsSomeoneSubscribedFor(const uint32_t param_id) const; - - /** - * @brief Adds VI parameters being unsubscribed by another or the same app to - * response with appropriate results - * @param msg_params 'message_params' response section reference - */ - void AddAlreadyUnsubscribedVI(smart_objects::SmartObject& response) const; - - /** - * @brief VI parameters which still being subscribed by another apps after - * particular app had been unsubscribed from these parameters - */ - app_mngr::VehicleInfoSubscriptions vi_still_subscribed_by_another_apps_; - - /** - * @brief VI parameters which had been unsubscribed already by particular app - */ - app_mngr::VehicleInfoSubscriptions vi_already_unsubscribed_by_this_app_; - - DISALLOW_COPY_AND_ASSIGN(UnsubscribeVehicleDataRequest); -}; - -} // namespace commands -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_vehicle_data_response.h deleted file mode 100644 index 5d24730d5a..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_vehicle_data_response.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ - -#include "application_manager/commands/command_response_impl.h" -#include "utils/macro.h" - -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -namespace commands { - -/** - * @brief UnsubscribeVehicleDataResponse command class - **/ -class UnsubscribeVehicleDataResponse - : public app_mngr::commands::CommandResponseImpl { - public: - /** - * @brief UnsubscribeVehicleDataResponse class constructor - * - * @param message Incoming SmartObject message - **/ - UnsubscribeVehicleDataResponse( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - - /** - * @brief UnsubscribeVehicleDataResponse class destructor - **/ - virtual ~UnsubscribeVehicleDataResponse(); - - /** - * @brief Execute command - **/ - virtual void Run(); - - private: - DISALLOW_COPY_AND_ASSIGN(UnsubscribeVehicleDataResponse); -}; - -} // namespace commands -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/diagnostic_message_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/diagnostic_message_request.cc deleted file mode 100644 index 1a46f4c085..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/diagnostic_message_request.cc +++ /dev/null @@ -1,130 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "sdl_rpc_plugin/commands/mobile/diagnostic_message_request.h" - -#include "application_manager/application_impl.h" - -#include "interfaces/HMI_API.h" -#include "application_manager/message_helper.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; - -namespace commands { - -DiagnosticMessageRequest::DiagnosticMessageRequest( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} - -DiagnosticMessageRequest::~DiagnosticMessageRequest() {} - -void DiagnosticMessageRequest::Run() { - LOG4CXX_AUTO_TRACE(logger_); - - ApplicationSharedPtr app = application_manager_.application(connection_key()); - - if (!app) { - LOG4CXX_ERROR(logger_, "Application is not registered."); - SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); - return; - } - - const std::vector& supported_diag_modes = - application_manager_.get_settings().supported_diag_modes(); - - smart_objects::SmartObject& msg_data = - (*message_)[strings::msg_params][strings::message_data]; - - const uint8_t mode_position = 0; - const uint32_t msg_diagnostic_mode = msg_data[mode_position].asUInt(); - if (supported_diag_modes.end() == std::find(supported_diag_modes.begin(), - supported_diag_modes.end(), - msg_diagnostic_mode)) { - LOG4CXX_ERROR(logger_, - "Received diagnostic mode " << msg_diagnostic_mode - << " is not supported."); - SendResponse(false, - mobile_apis::Result::REJECTED, - "Received diagnostic mode is not supported."); - return; - } - - // Add app_id for HMI request - (*message_)[strings::msg_params][strings::app_id] = app->app_id(); - - StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); - SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage, - &(*message_)[strings::msg_params], - true); -} - -void DiagnosticMessageRequest::on_event(const event_engine::Event& event) { - LOG4CXX_AUTO_TRACE(logger_); - const smart_objects::SmartObject& message = event.smart_object(); - - switch (event.id()) { - case hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage: { - EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); - hmi_apis::Common_Result::eType result_code = - static_cast( - message[strings::params][hmi_response::code].asInt()); - const bool result = PrepareResultForMobileResponse( - result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo); - std::string response_info; - GetInfo(message, response_info); - SendResponse(result, - MessageHelper::HMIToMobileResult(result_code), - response_info.empty() ? NULL : response_info.c_str(), - &(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/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/diagnostic_message_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/diagnostic_message_response.cc deleted file mode 100644 index eb0f8cf3c7..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/diagnostic_message_response.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sdl_rpc_plugin/commands/mobile/diagnostic_message_response.h" -#include "application_manager/rpc_service.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; - -namespace commands { - -DiagnosticMessageResponse::DiagnosticMessageResponse( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} - -DiagnosticMessageResponse::~DiagnosticMessageResponse() {} - -void DiagnosticMessageResponse::Run() { - LOG4CXX_AUTO_TRACE(logger_); - - rpc_service_.SendMessageToMobile(message_); -} - -} // namespace commands - -} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_dtcs_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_dtcs_request.cc deleted file mode 100644 index 1785595bf8..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_dtcs_request.cc +++ /dev/null @@ -1,119 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sdl_rpc_plugin/commands/mobile/get_dtcs_request.h" - -#include "application_manager/application_impl.h" -#include "interfaces/HMI_API.h" -#include "application_manager/message_helper.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; - -namespace commands { - -GetDTCsRequest::GetDTCsRequest( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} - -GetDTCsRequest::~GetDTCsRequest() {} - -void GetDTCsRequest::Run() { - LOG4CXX_AUTO_TRACE(logger_); - - ApplicationSharedPtr app = application_manager_.application( - (*message_)[strings::params][strings::connection_key].asUInt()); - - if (!app) { - LOG4CXX_ERROR(logger_, "NULL pointer"); - SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); - 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(); - - StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); - SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_GetDTCs, &msg_params, true); -} - -void GetDTCsRequest::on_event(const event_engine::Event& event) { - LOG4CXX_AUTO_TRACE(logger_); - const smart_objects::SmartObject& message = event.smart_object(); - - switch (event.id()) { - case hmi_apis::FunctionID::VehicleInfo_GetDTCs: { - EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); - hmi_apis::Common_Result::eType result_code = - static_cast( - message[strings::params][hmi_response::code].asInt()); - - const bool result = PrepareResultForMobileResponse( - result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo); - std::string response_info; - GetInfo(message, response_info); - - SendResponse(result, - MessageHelper::HMIToMobileResult(result_code), - response_info.empty() ? NULL : response_info.c_str(), - &(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/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_dtcs_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_dtcs_response.cc deleted file mode 100644 index 8fac129ade..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_dtcs_response.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sdl_rpc_plugin/commands/mobile/get_dtcs_response.h" -#include "application_manager/rpc_service.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; - -namespace commands { - -GetDTCsResponse::GetDTCsResponse( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} - -GetDTCsResponse::~GetDTCsResponse() {} - -void GetDTCsResponse::Run() { - LOG4CXX_AUTO_TRACE(logger_); - - rpc_service_.SendMessageToMobile(message_); -} - -} // namespace commands - -} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_vehicle_data_request.cc deleted file mode 100644 index 3305514017..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_vehicle_data_request.cc +++ /dev/null @@ -1,319 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "sdl_rpc_plugin/commands/mobile/get_vehicle_data_request.h" - -#include "application_manager/application_impl.h" -#include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; - -namespace commands { - -namespace str = strings; - -#ifdef HMI_DBUS_API -GetVehicleDataRequest::GetVehicleDataRequest( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandRequestImpl(message, application_manager) {} - -GetVehicleDataRequest::~GetVehicleDataRequest() {} - -void GetVehicleDataRequest::Run() { - LOG4CXX_AUTO_TRACE(logger_); - - int32_t app_id = - (*message_)[strings::params][strings::connection_key].asUInt(); - ApplicationSharedPtr app = application_manager_.application(app_id); - - if (!app) { - LOG4CXX_ERROR(logger_, "NULL pointer"); - SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); - 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( - 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(it->status); - } else if (status != - static_cast(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 application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} - -GetVehicleDataRequest::~GetVehicleDataRequest() {} - -void GetVehicleDataRequest::Run() { - LOG4CXX_AUTO_TRACE(logger_); - - int32_t app_id = - (*message_)[strings::params][strings::connection_key].asUInt(); - ApplicationSharedPtr app = application_manager_.application(app_id); - - if (!app) { - LOG4CXX_ERROR(logger_, "NULL pointer"); - SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); - return; - } - - if (app->AreCommandLimitsExceeded( - static_cast(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) { - StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); - 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_AUTO_TRACE(logger_); - smart_objects::SmartObject message = event.smart_object(); - - switch (event.id()) { - case hmi_apis::FunctionID::VehicleInfo_GetVehicleData: { - EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); - hmi_apis::Common_Result::eType result_code = - static_cast( - message[strings::params][hmi_response::code].asInt()); - bool result = PrepareResultForMobileResponse( - result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo); - std::string response_info; - GetInfo(message, response_info); - result = result || - ((hmi_apis::Common_Result::DATA_NOT_AVAILABLE == result_code) && - (message[strings::msg_params].length() > 1)); - - 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)) { - response_info = message[strings::params][strings::error_msg].asString(); - } - SendResponse(result, - MessageHelper::HMIToMobileResult(result_code), - response_info.empty() ? NULL : response_info.c_str(), - &(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/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_vehicle_data_response.cc deleted file mode 100644 index 69b4166555..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_vehicle_data_response.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sdl_rpc_plugin/commands/mobile/get_vehicle_data_response.h" -#include "application_manager/rpc_service.h" -#include "interfaces/HMI_API.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; - -namespace commands { - -GetVehicleDataResponse::GetVehicleDataResponse( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} - -GetVehicleDataResponse::~GetVehicleDataResponse() {} - -void GetVehicleDataResponse::Run() { - LOG4CXX_AUTO_TRACE(logger_); - - rpc_service_.SendMessageToMobile(message_); -} - -} // namespace commands - -} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_vehicle_data_notification.cc deleted file mode 100644 index b507d6a462..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_vehicle_data_notification.cc +++ /dev/null @@ -1,121 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sdl_rpc_plugin/commands/mobile/on_vehicle_data_notification.h" - -#include "application_manager/application_impl.h" -#include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; - -namespace commands { - -OnVehicleDataNotification::OnVehicleDataNotification( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandNotificationImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} - -OnVehicleDataNotification::~OnVehicleDataNotification() {} - -void OnVehicleDataNotification::Run() { - LOG4CXX_AUTO_TRACE(logger_); - - std::vector appNotification; - std::vector::iterator appNotification_it = - appNotification.begin(); - std::vector appSO; - - 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& applications = - application_manager_.IviInfoUpdated( - it->second, (*message_)[strings::msg_params][it->first].asInt()); - - std::vector::const_iterator app_it = - applications.begin(); - - for (; applications.end() != app_it; ++app_it) { - const ApplicationSharedPtr app = *app_it; - if (!app) { - LOG4CXX_ERROR(logger_, "NULL pointer"); - continue; - } - - appNotification_it = - find(appNotification.begin(), appNotification.end(), app); - if (appNotification_it == appNotification.end()) { - appNotification.push_back(app); - smart_objects::SmartObject msg_param = - smart_objects::SmartObject(smart_objects::SmartType_Map); - msg_param[it->first] = (*message_)[strings::msg_params][it->first]; - appSO.push_back(msg_param); - } else { - size_t idx = - std::distance(appNotification.begin(), appNotification_it); - appSO[idx][it->first] = (*message_)[strings::msg_params][it->first]; - } - } - } - } - - LOG4CXX_DEBUG( - logger_, - "Number of Notifications to be send: " << appNotification.size()); - - for (size_t idx = 0; idx < appNotification.size(); idx++) { - LOG4CXX_INFO(logger_, - "Send OnVehicleData PRNDL notification to " - << appNotification[idx]->name().c_str() - << " application id " << appNotification[idx]->app_id()); - (*message_)[strings::params][strings::connection_key] = - appNotification[idx]->app_id(); - (*message_)[strings::msg_params] = appSO[idx]; - SendNotification(); - } -} - -} // namespace commands - -} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/read_did_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/read_did_request.cc deleted file mode 100644 index a942aa1610..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/read_did_request.cc +++ /dev/null @@ -1,134 +0,0 @@ -/* - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "sdl_rpc_plugin/commands/mobile/read_did_request.h" - -#include "application_manager/application_impl.h" -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" -#include "application_manager/message_helper.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; - -namespace commands { - -ReadDIDRequest::ReadDIDRequest( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} - -ReadDIDRequest::~ReadDIDRequest() {} - -void ReadDIDRequest::Run() { - LOG4CXX_AUTO_TRACE(logger_); - - uint32_t app_id = - (*message_)[strings::params][strings::connection_key].asUInt(); - - ApplicationSharedPtr app = application_manager_.application(app_id); - LOG4CXX_INFO( - logger_, - "Correlation_id :" - << (*message_)[strings::params][strings::correlation_id].asUInt()); - - if (!app) { - LOG4CXX_ERROR(logger_, "An application is not registered."); - SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); - return; - } - - if (app->AreCommandLimitsExceeded( - static_cast(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(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]; - StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); - - SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_ReadDID, &msg_params, true); -} - -void ReadDIDRequest::on_event(const event_engine::Event& event) { - LOG4CXX_AUTO_TRACE(logger_); - const smart_objects::SmartObject& message = event.smart_object(); - - switch (event.id()) { - case hmi_apis::FunctionID::VehicleInfo_ReadDID: { - EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); - hmi_apis::Common_Result::eType result_code = - static_cast( - message[strings::params][hmi_response::code].asInt()); - const bool result = PrepareResultForMobileResponse( - result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo); - std::string response_info; - GetInfo(message, response_info); - - SendResponse(result, - MessageHelper::HMIToMobileResult(result_code), - response_info.empty() ? NULL : response_info.c_str(), - &(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/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/read_did_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/read_did_response.cc deleted file mode 100644 index 3ce1d8b766..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/read_did_response.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sdl_rpc_plugin/commands/mobile/read_did_response.h" -#include "application_manager/rpc_service.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; - -namespace commands { - -ReadDIDResponse::ReadDIDResponse( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} - -ReadDIDResponse::~ReadDIDResponse() {} - -void ReadDIDResponse::Run() { - LOG4CXX_AUTO_TRACE(logger_); - - rpc_service_.SendMessageToMobile(message_); -} - -} // namespace commands - -} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc deleted file mode 100644 index 61caf37e03..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc +++ /dev/null @@ -1,506 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Copyright (c) 2018, Livio, Inc. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sdl_rpc_plugin/commands/mobile/subscribe_vehicle_data_request.h" - -#include "application_manager/application_impl.h" -#include "application_manager/message_helper.h" -#include "utils/helpers.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; -namespace commands { - -SubscribeVehicleDataRequest::SubscribeVehicleDataRequest( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} - -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_AUTO_TRACE(logger_); - - ApplicationSharedPtr app = application_manager_.application(connection_key()); - - if (!app) { - LOG4CXX_ERROR(logger_, "NULL pointer"); - SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); - return; - } - std::string info; - mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; - smart_objects::SmartObject msg_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - smart_objects::SmartObject response_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - bool result = false; - CheckVISubscriptions( - app, info, result_code, response_params, msg_params, result); - - if (mobile_apis::Result::INVALID_ENUM != result_code) { - SendResponse(result, - result_code, - info.empty() ? NULL : info.c_str(), - response_params.empty() ? NULL : &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_DEBUG( - 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 - StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); - SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData, - &msg_params, - true); -#endif // #ifdef HMI_DBUS_API -} - -void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { - LOG4CXX_AUTO_TRACE(logger_); - using namespace helpers; - - const smart_objects::SmartObject& message = event.smart_object(); - - if (hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData != event.id()) { - LOG4CXX_ERROR(logger_, "Received unknown event."); - return; - } - EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); - ApplicationSharedPtr app = - application_manager_.application(CommandRequestImpl::connection_key()); - - if (!app) { - LOG4CXX_ERROR(logger_, "NULL pointer."); - return; - } - -#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( - 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(it->status); - } else if (status != - static_cast(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_DEBUG(logger_, "All HMI requests are complete"); - const bool result = any_arg_success; - SendResponse(any_arg_success, status, NULL, &response_params); - if (result) { - app->UpdateHash(); - } - } -#else - - hmi_apis::Common_Result::eType hmi_result = - static_cast( - message[strings::params][hmi_response::code].asInt()); - std::string response_info; - GetInfo(message, response_info); - const bool result = PrepareResultForMobileResponse( - hmi_result, HmiInterfaces::HMI_INTERFACE_VehicleInfo); - - bool is_succeeded = result || !vi_already_subscribed_by_another_apps_.empty(); - - mobile_apis::Result::eType result_code = - MessageHelper::HMIToMobileResult(hmi_result); - - if (is_succeeded) { - if (!vi_already_subscribed_by_this_app_.empty()) { - result_code = mobile_apis::Result::IGNORED; - response_info = "Already subscribed on some provided VehicleData."; - } - - if (!vi_waiting_for_subscribe_.empty()) { - LOG4CXX_DEBUG(logger_, "Subscribing to all pending VehicleData"); - app_mngr::VehicleInfoSubscriptions::const_iterator key = - vi_waiting_for_subscribe_.begin(); - for (; key != vi_waiting_for_subscribe_.end(); ++key) { - app->SubscribeToIVI(*key); - } - } - } - - UnsubscribeFailedSubscriptions(app, message[strings::msg_params]); - - if (!vi_already_subscribed_by_another_apps_.empty() || - !vi_already_subscribed_by_this_app_.empty()) { - AddAlreadySubscribedVI( - const_cast(message[strings::msg_params])); - } - - SendResponse(is_succeeded, - result_code, - response_info.empty() ? NULL : response_info.c_str(), - &(message[strings::msg_params])); -#endif // #ifdef HMI_DBUS_API -} - -bool SubscribeVehicleDataRequest::Init() { - hash_update_mode_ = HashUpdateMode::kDoHashUpdate; - return true; -} - -void SubscribeVehicleDataRequest::AddAlreadySubscribedVI( - smart_objects::SmartObject& msg_params) const { - LOG4CXX_AUTO_TRACE(logger_); - using namespace mobile_apis; - auto vi_to_string = - [](const mobile_apis::VehicleDataType::eType vehicle_data) { - for (auto& vi_str_to_int_pair : MessageHelper::vehicle_data()) { - if (vehicle_data == vi_str_to_int_pair.second) { - return vi_str_to_int_pair.first; - } - } - return std::string(); - }; - - app_mngr::VehicleInfoSubscriptions::const_iterator it_same_app = - vi_already_subscribed_by_this_app_.begin(); - for (; vi_already_subscribed_by_this_app_.end() != it_same_app; - ++it_same_app) { - msg_params[vi_to_string(*it_same_app)][strings::result_code] = - VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED; - msg_params[vi_to_string(*it_same_app)][strings::data_type] = *it_same_app; - } - - app_mngr::VehicleInfoSubscriptions::const_iterator it_another_app = - vi_already_subscribed_by_another_apps_.begin(); - for (; vi_already_subscribed_by_another_apps_.end() != it_another_app; - ++it_another_app) { - msg_params[vi_to_string(*it_another_app)][strings::result_code] = - VehicleDataResultCode::VDRC_SUCCESS; - msg_params[vi_to_string(*it_another_app)][strings::data_type] = - *it_another_app; - } -} - -void SubscribeVehicleDataRequest::UnsubscribeFailedSubscriptions( - ApplicationSharedPtr app, - const smart_objects::SmartObject& msg_params) const { - LOG4CXX_AUTO_TRACE(logger_); - 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_SUCCESS) { - LOG4CXX_DEBUG(logger_, - "Subscription for VehicleDataType " - << it->first - << " is unsuccessfull. " - "Unsubscribing app with connection key " - << connection_key() << " from it."); - app->UnsubscribeFromIVI(it->second); - } - } - } -} - -struct SubscribedToIVIPredicate { - int32_t vehicle_info_; - SubscribedToIVIPredicate(int32_t vehicle_info) - : vehicle_info_(vehicle_info) {} - bool operator()(const ApplicationSharedPtr app) const { - return app ? app->IsSubscribedToIVI(vehicle_info_) : false; - } -}; - -bool SubscribeVehicleDataRequest::IsSomeoneSubscribedFor( - const uint32_t param_id) const { - LOG4CXX_AUTO_TRACE(logger_); - SubscribedToIVIPredicate finder(param_id); - DataAccessor accessor = application_manager_.applications(); - ApplicationSetConstIt it = std::find_if( - accessor.GetData().begin(), accessor.GetData().end(), finder); - return it != accessor.GetData().end(); -} - -void SubscribeVehicleDataRequest::CheckVISubscribtions( - ApplicationSharedPtr app, - std::string& out_info, - mobile_apis::Result::eType& out_result_code, - smart_objects::SmartObject& out_response_params, - smart_objects::SmartObject& out_request_params, - bool& out_result) { - CheckVISubscriptions(app, - out_info, - out_result_code, - out_response_params, - out_request_params, - out_result); -} - -void SubscribeVehicleDataRequest::CheckVISubscriptions( - ApplicationSharedPtr app, - std::string& out_info, - mobile_apis::Result::eType& out_result_code, - smart_objects::SmartObject& out_response_params, - smart_objects::SmartObject& out_request_params, - bool& out_result) { - // counter for items to subscribe - app_mngr::VehicleInfoSubscriptions::size_type items_to_subscribe = 0; - // counter for subscribed items by application - uint32_t subscribed_items = 0; - - const VehicleData& vehicle_data = MessageHelper::vehicle_data(); - VehicleData::const_iterator it = vehicle_data.begin(); - - HmiInterfaces::InterfaceState interface_state = - application_manager_.hmi_interfaces().GetInterfaceState( - HmiInterfaces::HMI_INTERFACE_VehicleInfo); - - const bool is_interface_not_available = - interface_state == HmiInterfaces::STATE_NOT_AVAILABLE; - - for (; vehicle_data.end() != it; ++it) { - const std::string& key_name = it->first; - if ((*message_)[strings::msg_params].keyExists(key_name)) { - const bool is_key_enabled = - (*message_)[strings::msg_params][key_name].asBool(); - if (is_key_enabled) { - ++items_to_subscribe; - } - if (!is_interface_not_available && is_key_enabled) { - mobile_apis::VehicleDataType::eType key_type = it->second; - if (app->IsSubscribedToIVI(key_type)) { - LOG4CXX_DEBUG(logger_, - "App with connection key " - << connection_key() - << " is subscribed already for VehicleDataType: " - << key_type); - ++subscribed_items; - vi_already_subscribed_by_this_app_.insert(key_type); - out_response_params[key_name][strings::data_type] = key_type; - out_response_params[key_name][strings::result_code] = - mobile_apis::VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED; - continue; - } - - if (IsSomeoneSubscribedFor(key_type)) { - LOG4CXX_DEBUG(logger_, - "There are apps subscribed already for " - "VehicleDataType: " - << key_type); - if (!app->SubscribeToIVI(static_cast(key_type))) { - LOG4CXX_ERROR( - logger_, - "Unable to subscribe for VehicleDataType: " << key_type); - continue; - } - LOG4CXX_DEBUG( - logger_, - "App with connection key " - << connection_key() - << " have been subscribed for VehicleDataType: " << key_type); - ++subscribed_items; - vi_already_subscribed_by_another_apps_.insert(key_type); - out_response_params[key_name][strings::data_type] = key_type; - out_response_params[key_name][strings::result_code] = - mobile_apis::VehicleDataResultCode::VDRC_SUCCESS; - continue; - } - - out_request_params[key_name] = is_key_enabled; - - if (is_key_enabled) { - vi_waiting_for_subscribe_.insert(key_type); - LOG4CXX_DEBUG( - logger_, - "App with connection key " - << connection_key() - << " will be subscribed for VehicleDataType: " << key_type); - ++subscribed_items; - } - } - } - } - - const bool is_everything_already_subscribed = - items_to_subscribe == - vi_already_subscribed_by_another_apps_.size() + - vi_already_subscribed_by_this_app_.size(); - - if (0 == items_to_subscribe) { - if (HasDisallowedParams()) { - out_result_code = mobile_apis::Result::DISALLOWED; - } else { - out_result_code = mobile_apis::Result::INVALID_DATA; - out_info = "No data in the request"; - } - out_result = false; - } - - if (0 == subscribed_items && !is_interface_not_available) { - out_result_code = mobile_apis::Result::IGNORED; - out_info = "Already subscribed on provided VehicleData."; - out_result = false; - } - - if (is_everything_already_subscribed) { - out_result_code = vi_already_subscribed_by_this_app_.size() - ? mobile_apis::Result::IGNORED - : mobile_apis::Result::SUCCESS; - if (!(vi_already_subscribed_by_this_app_.empty())) { - out_info = "Already subscribed on some provided VehicleData."; - } - out_result = true; - } -} - -} // namespace commands -} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc deleted file mode 100644 index 209a1968b7..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sdl_rpc_plugin/commands/mobile/subscribe_vehicle_data_response.h" -#include "application_manager/rpc_service.h" -#include "application_manager/application_impl.h" -#include "interfaces/MOBILE_API.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; -namespace commands { - -SubscribeVehicleDataResponse::SubscribeVehicleDataResponse( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} - -SubscribeVehicleDataResponse::~SubscribeVehicleDataResponse() {} - -void SubscribeVehicleDataResponse::Run() { - LOG4CXX_AUTO_TRACE(logger_); - rpc_service_.SendMessageToMobile(message_); -} - -} // namespace commands -} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc deleted file mode 100644 index e63ec89ec7..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc +++ /dev/null @@ -1,416 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sdl_rpc_plugin/commands/mobile/unsubscribe_vehicle_data_request.h" -#include "application_manager/commands/command_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" -#include "utils/helpers.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; -namespace commands { - -UnsubscribeVehicleDataRequest::UnsubscribeVehicleDataRequest( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} - -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_AUTO_TRACE(logger_); - - ApplicationSharedPtr app = application_manager_.application(connection_key()); - - if (!app) { - LOG4CXX_ERROR(logger_, "NULL pointer"); - SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); - return; - } - - int32_t items_to_unsubscribe = 0; - 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); - - for (; vehicle_data.end() != it; ++it) { - const 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; - - mobile_apis::VehicleDataType::eType key_type = it->second; - if (!app->IsSubscribedToIVI(key_type)) { - ++unsubscribed_items; - vi_already_unsubscribed_by_this_app_.insert(key_type); - response_params[key_name][strings::data_type] = key_type; - response_params[key_name][strings::result_code] = - mobile_apis::VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED; - continue; - } - - if (!app->UnsubscribeFromIVI(static_cast(key_type))) { - LOG4CXX_ERROR(logger_, - "Unable to unsubscribe from " - "VehicleDataType: " - << key_type); - continue; - } - - LOG4CXX_DEBUG(logger_, - "Unsubscribed app with connection key " - << connection_key() - << " from VehicleDataType: " << key_type); - - ++unsubscribed_items; - - if (IsSomeoneSubscribedFor(key_type)) { - LOG4CXX_DEBUG(logger_, - "There are another apps still subscribed for " - "VehicleDataType: " - << key_type); - - vi_still_subscribed_by_another_apps_.insert(key_type); - response_params[key_name][strings::data_type] = key_type; - response_params[key_name][strings::result_code] = - mobile_apis::VehicleDataResultCode::VDRC_SUCCESS; - continue; - } - - msg_params[key_name] = is_key_enabled; - } - } - } - - bool is_everything_already_unsubscribed = - static_cast(items_to_unsubscribe) == - vi_still_subscribed_by_another_apps_.size() + - vi_already_unsubscribed_by_this_app_.size(); - - 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; - } - - if (0 == unsubscribed_items) { - SendResponse(false, - mobile_apis::Result::IGNORED, - "Was not subscribed on any VehicleData.", - &response_params); - return; - } - - if (is_everything_already_unsubscribed) { - if (!vi_already_unsubscribed_by_this_app_.empty()) { - SendResponse(false, - mobile_apis::Result::IGNORED, - "Some provided VehicleData was not subscribed.", - &response_params); - } else { - SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &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 - StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); - SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData, - &msg_params, - true); -#endif // #ifdef HMI_DBUS_API -} - -void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { - LOG4CXX_AUTO_TRACE(logger_); - using namespace helpers; - - const smart_objects::SmartObject& message = event.smart_object(); - - if (hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData != event.id()) { - LOG4CXX_ERROR(logger_, "Received unknown event."); - return; - } - EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); - - ApplicationSharedPtr app = - application_manager_.application(CommandRequestImpl::connection_key()); - - if (!app) { - LOG4CXX_ERROR(logger_, "NULL pointer."); - return; - } - -#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( - 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(it->status); - } else if (status != - static_cast(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"); - if (true == any_arg_success) { - SetAllowedToTerminate(false); - } - SendResponse(any_arg_success, status, NULL, &response_params); - if (true == any_arg_success) { - app->UpdateHash(); - } - } -#else - hmi_apis::Common_Result::eType hmi_result = - static_cast( - message[strings::params][hmi_response::code].asInt()); - std::string response_info; - GetInfo(message, response_info); - const bool result = PrepareResultForMobileResponse( - hmi_result, HmiInterfaces::HMI_INTERFACE_VehicleInfo); - - mobile_apis::Result::eType result_code = - MessageHelper::HMIToMobileResult(hmi_result); - - if (result) { - if (vi_already_unsubscribed_by_this_app_.size()) { - result_code = mobile_apis::Result::IGNORED; - response_info = "Some provided VehicleData was not subscribed."; - } - } - - if (!vi_still_subscribed_by_another_apps_.empty() || - !vi_already_unsubscribed_by_this_app_.empty()) { - AddAlreadyUnsubscribedVI( - const_cast(message[strings::msg_params])); - } - - if (result) { - SetAllowedToTerminate(false); - } - SendResponse(result, - result_code, - response_info.empty() ? NULL : response_info.c_str(), - &(message[strings::msg_params])); - if (result) { - application_manager_.TerminateRequest( - connection_key(), correlation_id(), function_id()); - } -#endif // #ifdef HMI_DBUS_API -} - -bool UnsubscribeVehicleDataRequest::Init() { - hash_update_mode_ = HashUpdateMode::kDoHashUpdate; - return true; -} - -struct SubscribedToIVIPredicate { - int32_t vehicle_info_; - SubscribedToIVIPredicate(int32_t vehicle_info) - : vehicle_info_(vehicle_info) {} - bool operator()(const ApplicationSharedPtr app) const { - return app ? app->IsSubscribedToIVI(vehicle_info_) : false; - } -}; - -bool UnsubscribeVehicleDataRequest::IsSomeoneSubscribedFor( - const uint32_t param_id) const { - LOG4CXX_AUTO_TRACE(logger_); - SubscribedToIVIPredicate finder(param_id); - DataAccessor accessor = application_manager_.applications(); - ApplicationSetConstIt it = std::find_if( - accessor.GetData().begin(), accessor.GetData().end(), finder); - return it != accessor.GetData().end(); -} - -void UnsubscribeVehicleDataRequest::AddAlreadyUnsubscribedVI( - smart_objects::SmartObject& response) const { - LOG4CXX_AUTO_TRACE(logger_); - using namespace mobile_apis; - app_mngr::VehicleInfoSubscriptions::const_iterator it_same_app = - vi_already_unsubscribed_by_this_app_.begin(); - for (; vi_already_unsubscribed_by_this_app_.end() != it_same_app; - ++it_same_app) { - response[*it_same_app][strings::result_code] = - VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED; - } - - app_mngr::VehicleInfoSubscriptions::const_iterator it_another_app = - vi_still_subscribed_by_another_apps_.begin(); - for (; vi_still_subscribed_by_another_apps_.end() != it_another_app; - ++it_another_app) { - response[*it_another_app][strings::result_code] = - VehicleDataResultCode::VDRC_SUCCESS; - } -} - -} // namespace commands -} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc deleted file mode 100644 index e7d4cd8e27..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* - - Copyright (c) 2018, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sdl_rpc_plugin/commands/mobile/unsubscribe_vehicle_data_response.h" -#include "smart_objects/smart_object.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; -namespace commands { - -UnsubscribeVehicleDataResponse::UnsubscribeVehicleDataResponse( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} - -UnsubscribeVehicleDataResponse::~UnsubscribeVehicleDataResponse() {} - -void UnsubscribeVehicleDataResponse::Run() { - LOG4CXX_AUTO_TRACE(logger_); - - // 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/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_request.h new file mode 100644 index 0000000000..e2bc7c4dfd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_request.h @@ -0,0 +1,85 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAGNOSTIC_MESSAGE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAGNOSTIC_MESSAGE_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "utils/macro.h" + +namespace vehicle_info_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief DiagnosticMessageRequest command class + **/ +class DiagnosticMessageRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief DiagnosticMessageRequest class constructor + * + * @param message Incoming SmartObject message + **/ + DiagnosticMessageRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief DiagnosticMessageRequest class destructor + **/ + virtual ~DiagnosticMessageRequest(); + + /** + * @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 app_mngr::event_engine::Event& event); + + private: + DISALLOW_COPY_AND_ASSIGN(DiagnosticMessageRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAGNOSTIC_MESSAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_response.h new file mode 100644 index 0000000000..d69a6a0155 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_response.h @@ -0,0 +1,79 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAGNOSTIC_MESSAGE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAGNOSTIC_MESSAGE_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "utils/macro.h" + +namespace vehicle_info_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief DiagnosticMessageResponse command class + **/ +class DiagnosticMessageResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief DiagnosticMessageResponse class constructor + * + * @param message Incoming SmartObject message + **/ + DiagnosticMessageResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief DiagnosticMessageResponse class destructor + **/ + virtual ~DiagnosticMessageResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(DiagnosticMessageResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAGNOSTIC_MESSAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_request.h new file mode 100644 index 0000000000..01f007697d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_request.h @@ -0,0 +1,85 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_DTCS_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_DTCS_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "utils/macro.h" + +namespace vehicle_info_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief GetDTCsRequest command class + **/ +class GetDTCsRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief GetDTCsRequest class constructor + * + * @param message Incoming SmartObject message + **/ + GetDTCsRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief GetDTCsRequest class destructor + **/ + virtual ~GetDTCsRequest(); + + /** + * @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 app_mngr::event_engine::Event& event); + + private: + DISALLOW_COPY_AND_ASSIGN(GetDTCsRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_DTCS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_response.h new file mode 100644 index 0000000000..87024b1860 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_response.h @@ -0,0 +1,78 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_DTCS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_DTCS_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "utils/macro.h" + +namespace vehicle_info_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief GetDTCsResponse command class + **/ +class GetDTCsResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief GetDTCsResponse class constructor + * + * @param message Incoming SmartObject message + **/ + GetDTCsResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief GetDTCsResponse class destructor + **/ + virtual ~GetDTCsResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(GetDTCsResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_DTCS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h new file mode 100644 index 0000000000..17ae1ffd09 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h @@ -0,0 +1,98 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_VEHICLE_DATA_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_VEHICLE_DATA_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "utils/macro.h" + +namespace vehicle_info_plugin { +namespace app_mngr = application_manager; + +class SmartObject; + +namespace commands { + +/** + * @brief GetVehicleDataRequest command class + **/ +class GetVehicleDataRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief GetVehicleDataRequest class constructor + * + * @param message Incoming SmartObject message + **/ + GetVehicleDataRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief GetVehicleDataRequest class destructor + **/ + virtual ~GetVehicleDataRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + protected: + virtual void on_event(const app_mngr::event_engine::Event& event); + +#ifdef HMI_DBUS_API + private: + void SendRequestsToHmi(const int32_t app_id); + + struct HmiRequest { + hmi_apis::Common_Result::eType status; + bool complete; + smart_objects::SmartObject value; + const char* str; + hmi_apis::FunctionID::eType func_id; + }; + + typedef std::vector HmiRequests; + HmiRequests hmi_requests_; +#endif // #ifdef HMI_DBUS_API + + DISALLOW_COPY_AND_ASSIGN(GetVehicleDataRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h new file mode 100644 index 0000000000..22ec1a5a78 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h @@ -0,0 +1,78 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_VEHICLE_DATA_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_VEHICLE_DATA_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "utils/macro.h" + +namespace vehicle_info_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief GetVehicleDataResponse command class + **/ +class GetVehicleDataResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief GetVehicleDataResponse class constructor + * + * @param message Incoming SmartObject message + **/ + GetVehicleDataResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief GetVehicleDataResponse class destructor + **/ + virtual ~GetVehicleDataResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(GetVehicleDataResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h new file mode 100644 index 0000000000..57c30164e4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h @@ -0,0 +1,88 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_VEHICLE_DATA_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_VEHICLE_DATA_NOTIFICATION_H_ + +#include "application_manager/commands/command_notification_impl.h" +#include "application_manager/application.h" +#include "utils/macro.h" + +namespace vehicle_info_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVehicleDataNotification class is used to send notification + * to mobile device that some button was pressed on HMI. + **/ +class OnVehicleDataNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + /** + * @brief OnVehicleDataNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVehicleDataNotification(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief OnVehicleDataNotification class destructor + **/ + virtual ~OnVehicleDataNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + /* + * @brief Sends vehicle data notification to mobile device + * + * @param app Application to receive notification + */ + void SendVehicleData(app_mngr::ApplicationConstSharedPtr app); + + DISALLOW_COPY_AND_ASSIGN(OnVehicleDataNotification); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_VEHICLE_DATA_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_request.h new file mode 100644 index 0000000000..9a8fbbd62e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_request.h @@ -0,0 +1,85 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_READ_DID_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_READ_DID_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "utils/macro.h" + +namespace vehicle_info_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ReadDIDRequest command class + **/ +class ReadDIDRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief ReadDIDRequest class constructor + * + * @param message Incoming SmartObject message + **/ + ReadDIDRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief ReadDIDRequest class destructor + **/ + virtual ~ReadDIDRequest(); + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + void on_event(const app_mngr::event_engine::Event& event); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ReadDIDRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_READ_DID_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_response.h new file mode 100644 index 0000000000..2b7ab04768 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_response.h @@ -0,0 +1,78 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_READ_DID_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_READ_DID_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "utils/macro.h" + +namespace vehicle_info_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ReadDIDResponse command class + **/ +class ReadDIDResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief ReadDIDResponse class constructor + * + * @param message Incoming SmartObject message + **/ + ReadDIDResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief ReadDIDResponse class destructor + **/ + virtual ~ReadDIDResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ReadDIDResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_READ_DID_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h new file mode 100644 index 0000000000..5859d724ca --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h @@ -0,0 +1,179 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Copyright (c) 2018, Livio, Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/application.h" +#include "utils/macro.h" + +namespace vehicle_info_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SubscribeVehicleDataRequest command class + **/ +class SubscribeVehicleDataRequest + : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief SubscribeVehicleDataRequest class constructor + * + * @param message Incoming SmartObject message + **/ + SubscribeVehicleDataRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief SubscribeButtonCommandRequest class destructor + **/ + ~SubscribeVehicleDataRequest(); + + /** + * @brief Execute command + **/ + void Run() FINAL; + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + void on_event(const app_mngr::event_engine::Event& event) FINAL; + + /** + * @brief Init sets hash update mode for request + */ + bool Init() FINAL; + +#ifdef HMI_DBUS_API + private: + struct HmiRequest { + hmi_apis::Common_Result::eType status; + bool complete; + smart_objects::SmartObject value; + const char* str; + hmi_apis::FunctionID::eType func_id; + }; + + typedef std::vector HmiRequests; + HmiRequests hmi_requests_; +#endif // #ifdef HMI_DBUS_API + + private: + /** + * @brief Checks, if any app is subscribed for particular VI parameter + * @param param_id VI parameter id + * @return true, if there are registered apps subscribed for VI parameter, + * otherwise - false + */ + bool IsSomeoneSubscribedFor(const uint32_t param_id) const; + + /** + * @brief Adds VI parameters being subscribed by another or the same app to + * response with appropriate results + * @param msg_params 'message_params' response section reference + */ + void AddAlreadySubscribedVI(smart_objects::SmartObject& msg_params) const; + + /** + * @brief Removes subscription for VI parameters which subsription attempt + * returned an error + * @param app Pointer to application sent subscribe request + * @param msg_params 'message_parameters' response section reference + */ + void UnsubscribeFailedSubscriptions( + app_mngr::ApplicationSharedPtr app, + const smart_objects::SmartObject& msg_params) const; + + DEPRECATED void CheckVISubscribtions( + app_mngr::ApplicationSharedPtr app, + std::string& out_info, + mobile_apis::Result::eType& out_result_code, + smart_objects::SmartObject& out_response_params, + smart_objects::SmartObject& out_request_params, + bool& out_result); + + /** + * @brief Checks if current application and other applications + * were subscribed to VI, prepare data that need to send to mobile app + * or HMI. + * @param app contains application + * @param out_info contains resulting info for sending to mobile app + * @param out_result_code contains result code for sending to mobile app + * @param out_response_params contains parameters that SDL sends to + * mobile application + * @param out_request_params contains parameters that SDL sends to + * HMI + * @param result contains result that SDL sends to mobile app. + */ + void CheckVISubscriptions(app_mngr::ApplicationSharedPtr app, + std::string& out_info, + mobile_apis::Result::eType& out_result_code, + smart_objects::SmartObject& out_response_params, + smart_objects::SmartObject& out_request_params, + bool& out_result); + + /** + * @brief VI parameters which had been already subscribed by another apps + * befor particular app subscribed for these parameters + */ + app_mngr::VehicleInfoSubscriptions vi_already_subscribed_by_another_apps_; + + /** + * @brief VI parameters which had been subscribed already by particular app + */ + app_mngr::VehicleInfoSubscriptions vi_already_subscribed_by_this_app_; + + /** + * @brief VI parameters which wait for subscribe after HMI respond + */ + app_mngr::VehicleInfoSubscriptions vi_waiting_for_subscribe_; + + DISALLOW_COPY_AND_ASSIGN(SubscribeVehicleDataRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h new file mode 100644 index 0000000000..60670afee1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h @@ -0,0 +1,80 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "utils/macro.h" + +namespace vehicle_info_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SubscribeVehicleDataResponse command class + **/ +class SubscribeVehicleDataResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief SubscribeVehicleDataResponse class constructor + * + * @param message Incoming SmartObject message + **/ + SubscribeVehicleDataResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief UnsubscribeVehicleDataCommandRequest class destructor + **/ + virtual ~SubscribeVehicleDataResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SubscribeVehicleDataResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h new file mode 100644 index 0000000000..6a3fb2a0b9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h @@ -0,0 +1,133 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/application.h" +#include "utils/macro.h" + +namespace vehicle_info_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UnsubscribeVehicleDataRequest command class + **/ +class UnsubscribeVehicleDataRequest + : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief UnsubscribeVehicleDataRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UnsubscribeVehicleDataRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief UnsubscribeVehicleDataRequest class destructor + **/ + ~UnsubscribeVehicleDataRequest(); + + /** + * @brief Execute command + **/ + void Run() FINAL; + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + void on_event(const app_mngr::event_engine::Event& event) FINAL; + + /** + * @brief Init sets hash update mode for request + */ + bool Init() FINAL; + +#ifdef HMI_DBUS_API + private: + struct HmiRequest { + hmi_apis::Common_Result::eType status; + bool complete; + smart_objects::SmartObject value; + const char* str; + hmi_apis::FunctionID::eType func_id; + }; + + typedef std::vector HmiRequests; + HmiRequests hmi_requests_; +#endif // #ifdef HMI_DBUS_API + + private: + /** + * @brief Checks, if any app is subscribed for particular VI parameter + * @param param_id VI parameter id + * @return true, if there are registered apps subscribed for VI parameter, + * otherwise - false + */ + bool IsSomeoneSubscribedFor(const uint32_t param_id) const; + + /** + * @brief Adds VI parameters being unsubscribed by another or the same app to + * response with appropriate results + * @param msg_params 'message_params' response section reference + */ + void AddAlreadyUnsubscribedVI(smart_objects::SmartObject& response) const; + + /** + * @brief VI parameters which still being subscribed by another apps after + * particular app had been unsubscribed from these parameters + */ + app_mngr::VehicleInfoSubscriptions vi_still_subscribed_by_another_apps_; + + /** + * @brief VI parameters which had been unsubscribed already by particular app + */ + app_mngr::VehicleInfoSubscriptions vi_already_unsubscribed_by_this_app_; + + DISALLOW_COPY_AND_ASSIGN(UnsubscribeVehicleDataRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h new file mode 100644 index 0000000000..397ae3cbce --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h @@ -0,0 +1,80 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "utils/macro.h" + +namespace vehicle_info_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UnsubscribeVehicleDataResponse command class + **/ +class UnsubscribeVehicleDataResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief UnsubscribeVehicleDataResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UnsubscribeVehicleDataResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief UnsubscribeVehicleDataResponse class destructor + **/ + virtual ~UnsubscribeVehicleDataResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UnsubscribeVehicleDataResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_factory.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_factory.h index a2069ade5f..21d6afa768 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_factory.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_factory.h @@ -68,8 +68,8 @@ private: app_mngr::rpc_service::RPCService& rpc_service_; app_mngr::HMICapabilities& hmi_capabilities_; policy::PolicyHandlerInterface& policy_handler_; - std::unique_ptr hmi_command_factory_; - std::unique_ptr mob_command_factory_; + std::unique_ptr hmi_command_factory_; + std::unique_ptr mob_command_factory_; }; } diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_mobile_command_factory.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_mobile_command_factory.h index 330151c104..cd90219fc1 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_mobile_command_factory.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_mobile_command_factory.h @@ -64,6 +64,8 @@ private: app_mngr::HMICapabilities& hmi_capabilities_; policy::PolicyHandlerInterface& policy_handler_; + app_mngr::CommandCreator& buildCommandCreator(int32_t function_id, int32_t message_type); + DISALLOW_COPY_AND_ASSIGN(VehicleInfoMobileCommandFactory); }; diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_request.cc new file mode 100644 index 0000000000..4eba894025 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_request.cc @@ -0,0 +1,130 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "vehicle_info_plugin/commands/mobile/diagnostic_message_request.h" + +#include "application_manager/application_impl.h" + +#include "interfaces/HMI_API.h" +#include "application_manager/message_helper.h" + +namespace vehicle_info_plugin { +using namespace application_manager; + +namespace commands { + +DiagnosticMessageRequest::DiagnosticMessageRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +DiagnosticMessageRequest::~DiagnosticMessageRequest() {} + +void DiagnosticMessageRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "Application is not registered."); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + const std::vector& supported_diag_modes = + application_manager_.get_settings().supported_diag_modes(); + + smart_objects::SmartObject& msg_data = + (*message_)[strings::msg_params][strings::message_data]; + + const uint8_t mode_position = 0; + const uint32_t msg_diagnostic_mode = msg_data[mode_position].asUInt(); + if (supported_diag_modes.end() == std::find(supported_diag_modes.begin(), + supported_diag_modes.end(), + msg_diagnostic_mode)) { + LOG4CXX_ERROR(logger_, + "Received diagnostic mode " << msg_diagnostic_mode + << " is not supported."); + SendResponse(false, + mobile_apis::Result::REJECTED, + "Received diagnostic mode is not supported."); + return; + } + + // Add app_id for HMI request + (*message_)[strings::msg_params][strings::app_id] = app->app_id(); + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); + SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage, + &(*message_)[strings::msg_params], + true); +} + +void DiagnosticMessageRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); + hmi_apis::Common_Result::eType result_code = + static_cast( + message[strings::params][hmi_response::code].asInt()); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo); + std::string response_info; + GetInfo(message, response_info); + SendResponse(result, + MessageHelper::HMIToMobileResult(result_code), + response_info.empty() ? NULL : response_info.c_str(), + &(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/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_response.cc new file mode 100644 index 0000000000..54d8382f5d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_response.cc @@ -0,0 +1,64 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "vehicle_info_plugin/commands/mobile/diagnostic_message_response.h" +#include "application_manager/rpc_service.h" + +namespace vehicle_info_plugin { +using namespace application_manager; + +namespace commands { + +DiagnosticMessageResponse::DiagnosticMessageResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +DiagnosticMessageResponse::~DiagnosticMessageResponse() {} + +void DiagnosticMessageResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_request.cc new file mode 100644 index 0000000000..6c04e874e8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_request.cc @@ -0,0 +1,119 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "vehicle_info_plugin/commands/mobile/get_dtcs_request.h" + +#include "application_manager/application_impl.h" +#include "interfaces/HMI_API.h" +#include "application_manager/message_helper.h" + +namespace vehicle_info_plugin { +using namespace application_manager; + +namespace commands { + +GetDTCsRequest::GetDTCsRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +GetDTCsRequest::~GetDTCsRequest() {} + +void GetDTCsRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application( + (*message_)[strings::params][strings::connection_key].asUInt()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + 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(); + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); + SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_GetDTCs, &msg_params, true); +} + +void GetDTCsRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::VehicleInfo_GetDTCs: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); + hmi_apis::Common_Result::eType result_code = + static_cast( + message[strings::params][hmi_response::code].asInt()); + + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo); + std::string response_info; + GetInfo(message, response_info); + + SendResponse(result, + MessageHelper::HMIToMobileResult(result_code), + response_info.empty() ? NULL : response_info.c_str(), + &(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/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_response.cc new file mode 100644 index 0000000000..3686094b73 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_response.cc @@ -0,0 +1,64 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "vehicle_info_plugin/commands/mobile/get_dtcs_response.h" +#include "application_manager/rpc_service.h" + +namespace vehicle_info_plugin { +using namespace application_manager; + +namespace commands { + +GetDTCsResponse::GetDTCsResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +GetDTCsResponse::~GetDTCsResponse() {} + +void GetDTCsResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc new file mode 100644 index 0000000000..7c7a5e61f7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc @@ -0,0 +1,319 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h" + +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace vehicle_info_plugin { +using namespace application_manager; + +namespace commands { + +namespace str = strings; + +#ifdef HMI_DBUS_API +GetVehicleDataRequest::GetVehicleDataRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, application_manager) {} + +GetVehicleDataRequest::~GetVehicleDataRequest() {} + +void GetVehicleDataRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + int32_t app_id = + (*message_)[strings::params][strings::connection_key].asUInt(); + ApplicationSharedPtr app = application_manager_.application(app_id); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + 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( + 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(it->status); + } else if (status != + static_cast(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 application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +GetVehicleDataRequest::~GetVehicleDataRequest() {} + +void GetVehicleDataRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + int32_t app_id = + (*message_)[strings::params][strings::connection_key].asUInt(); + ApplicationSharedPtr app = application_manager_.application(app_id); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (app->AreCommandLimitsExceeded( + static_cast(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) { + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); + 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_AUTO_TRACE(logger_); + smart_objects::SmartObject message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::VehicleInfo_GetVehicleData: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); + hmi_apis::Common_Result::eType result_code = + static_cast( + message[strings::params][hmi_response::code].asInt()); + bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo); + std::string response_info; + GetInfo(message, response_info); + result = result || + ((hmi_apis::Common_Result::DATA_NOT_AVAILABLE == result_code) && + (message[strings::msg_params].length() > 1)); + + 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)) { + response_info = message[strings::params][strings::error_msg].asString(); + } + SendResponse(result, + MessageHelper::HMIToMobileResult(result_code), + response_info.empty() ? NULL : response_info.c_str(), + &(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/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_response.cc new file mode 100644 index 0000000000..3a7d663756 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_response.cc @@ -0,0 +1,65 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h" +#include "application_manager/rpc_service.h" +#include "interfaces/HMI_API.h" + +namespace vehicle_info_plugin { +using namespace application_manager; + +namespace commands { + +GetVehicleDataResponse::GetVehicleDataResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +GetVehicleDataResponse::~GetVehicleDataResponse() {} + +void GetVehicleDataResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc new file mode 100644 index 0000000000..5dac08c539 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc @@ -0,0 +1,121 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h" + +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" + +namespace vehicle_info_plugin { +using namespace application_manager; + +namespace commands { + +OnVehicleDataNotification::OnVehicleDataNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandNotificationImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnVehicleDataNotification::~OnVehicleDataNotification() {} + +void OnVehicleDataNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + std::vector appNotification; + std::vector::iterator appNotification_it = + appNotification.begin(); + std::vector appSO; + + 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& applications = + application_manager_.IviInfoUpdated( + it->second, (*message_)[strings::msg_params][it->first].asInt()); + + std::vector::const_iterator app_it = + applications.begin(); + + for (; applications.end() != app_it; ++app_it) { + const ApplicationSharedPtr app = *app_it; + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + continue; + } + + appNotification_it = + find(appNotification.begin(), appNotification.end(), app); + if (appNotification_it == appNotification.end()) { + appNotification.push_back(app); + smart_objects::SmartObject msg_param = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_param[it->first] = (*message_)[strings::msg_params][it->first]; + appSO.push_back(msg_param); + } else { + size_t idx = + std::distance(appNotification.begin(), appNotification_it); + appSO[idx][it->first] = (*message_)[strings::msg_params][it->first]; + } + } + } + } + + LOG4CXX_DEBUG( + logger_, + "Number of Notifications to be send: " << appNotification.size()); + + for (size_t idx = 0; idx < appNotification.size(); idx++) { + LOG4CXX_INFO(logger_, + "Send OnVehicleData PRNDL notification to " + << appNotification[idx]->name().c_str() + << " application id " << appNotification[idx]->app_id()); + (*message_)[strings::params][strings::connection_key] = + appNotification[idx]->app_id(); + (*message_)[strings::msg_params] = appSO[idx]; + SendNotification(); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_request.cc new file mode 100644 index 0000000000..010cce4c63 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_request.cc @@ -0,0 +1,134 @@ +/* + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "vehicle_info_plugin/commands/mobile/read_did_request.h" + +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" +#include "application_manager/message_helper.h" + +namespace vehicle_info_plugin { +using namespace application_manager; + +namespace commands { + +ReadDIDRequest::ReadDIDRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ReadDIDRequest::~ReadDIDRequest() {} + +void ReadDIDRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + uint32_t app_id = + (*message_)[strings::params][strings::connection_key].asUInt(); + + ApplicationSharedPtr app = application_manager_.application(app_id); + LOG4CXX_INFO( + logger_, + "Correlation_id :" + << (*message_)[strings::params][strings::correlation_id].asUInt()); + + if (!app) { + LOG4CXX_ERROR(logger_, "An application is not registered."); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (app->AreCommandLimitsExceeded( + static_cast(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(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]; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); + + SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_ReadDID, &msg_params, true); +} + +void ReadDIDRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::VehicleInfo_ReadDID: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); + hmi_apis::Common_Result::eType result_code = + static_cast( + message[strings::params][hmi_response::code].asInt()); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo); + std::string response_info; + GetInfo(message, response_info); + + SendResponse(result, + MessageHelper::HMIToMobileResult(result_code), + response_info.empty() ? NULL : response_info.c_str(), + &(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/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_response.cc new file mode 100644 index 0000000000..82d49574f0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_response.cc @@ -0,0 +1,64 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "vehicle_info_plugin/commands/mobile/read_did_response.h" +#include "application_manager/rpc_service.h" + +namespace vehicle_info_plugin { +using namespace application_manager; + +namespace commands { + +ReadDIDResponse::ReadDIDResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ReadDIDResponse::~ReadDIDResponse() {} + +void ReadDIDResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc new file mode 100644 index 0000000000..766e720217 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc @@ -0,0 +1,506 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Copyright (c) 2018, Livio, Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h" + +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "utils/helpers.h" + +namespace vehicle_info_plugin { +using namespace application_manager; +namespace commands { + +SubscribeVehicleDataRequest::SubscribeVehicleDataRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +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_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + std::string info; + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + smart_objects::SmartObject response_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + bool result = false; + CheckVISubscriptions( + app, info, result_code, response_params, msg_params, result); + + if (mobile_apis::Result::INVALID_ENUM != result_code) { + SendResponse(result, + result_code, + info.empty() ? NULL : info.c_str(), + response_params.empty() ? NULL : &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_DEBUG( + 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 + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); + SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData, + &msg_params, + true); +#endif // #ifdef HMI_DBUS_API +} + +void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + + const smart_objects::SmartObject& message = event.smart_object(); + + if (hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData != event.id()) { + LOG4CXX_ERROR(logger_, "Received unknown event."); + return; + } + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); + ApplicationSharedPtr app = + application_manager_.application(CommandRequestImpl::connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer."); + return; + } + +#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( + 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(it->status); + } else if (status != + static_cast(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_DEBUG(logger_, "All HMI requests are complete"); + const bool result = any_arg_success; + SendResponse(any_arg_success, status, NULL, &response_params); + if (result) { + app->UpdateHash(); + } + } +#else + + hmi_apis::Common_Result::eType hmi_result = + static_cast( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(message, response_info); + const bool result = PrepareResultForMobileResponse( + hmi_result, HmiInterfaces::HMI_INTERFACE_VehicleInfo); + + bool is_succeeded = result || !vi_already_subscribed_by_another_apps_.empty(); + + mobile_apis::Result::eType result_code = + MessageHelper::HMIToMobileResult(hmi_result); + + if (is_succeeded) { + if (!vi_already_subscribed_by_this_app_.empty()) { + result_code = mobile_apis::Result::IGNORED; + response_info = "Already subscribed on some provided VehicleData."; + } + + if (!vi_waiting_for_subscribe_.empty()) { + LOG4CXX_DEBUG(logger_, "Subscribing to all pending VehicleData"); + app_mngr::VehicleInfoSubscriptions::const_iterator key = + vi_waiting_for_subscribe_.begin(); + for (; key != vi_waiting_for_subscribe_.end(); ++key) { + app->SubscribeToIVI(*key); + } + } + } + + UnsubscribeFailedSubscriptions(app, message[strings::msg_params]); + + if (!vi_already_subscribed_by_another_apps_.empty() || + !vi_already_subscribed_by_this_app_.empty()) { + AddAlreadySubscribedVI( + const_cast(message[strings::msg_params])); + } + + SendResponse(is_succeeded, + result_code, + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); +#endif // #ifdef HMI_DBUS_API +} + +bool SubscribeVehicleDataRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +void SubscribeVehicleDataRequest::AddAlreadySubscribedVI( + smart_objects::SmartObject& msg_params) const { + LOG4CXX_AUTO_TRACE(logger_); + using namespace mobile_apis; + auto vi_to_string = + [](const mobile_apis::VehicleDataType::eType vehicle_data) { + for (auto& vi_str_to_int_pair : MessageHelper::vehicle_data()) { + if (vehicle_data == vi_str_to_int_pair.second) { + return vi_str_to_int_pair.first; + } + } + return std::string(); + }; + + app_mngr::VehicleInfoSubscriptions::const_iterator it_same_app = + vi_already_subscribed_by_this_app_.begin(); + for (; vi_already_subscribed_by_this_app_.end() != it_same_app; + ++it_same_app) { + msg_params[vi_to_string(*it_same_app)][strings::result_code] = + VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED; + msg_params[vi_to_string(*it_same_app)][strings::data_type] = *it_same_app; + } + + app_mngr::VehicleInfoSubscriptions::const_iterator it_another_app = + vi_already_subscribed_by_another_apps_.begin(); + for (; vi_already_subscribed_by_another_apps_.end() != it_another_app; + ++it_another_app) { + msg_params[vi_to_string(*it_another_app)][strings::result_code] = + VehicleDataResultCode::VDRC_SUCCESS; + msg_params[vi_to_string(*it_another_app)][strings::data_type] = + *it_another_app; + } +} + +void SubscribeVehicleDataRequest::UnsubscribeFailedSubscriptions( + ApplicationSharedPtr app, + const smart_objects::SmartObject& msg_params) const { + LOG4CXX_AUTO_TRACE(logger_); + 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_SUCCESS) { + LOG4CXX_DEBUG(logger_, + "Subscription for VehicleDataType " + << it->first + << " is unsuccessfull. " + "Unsubscribing app with connection key " + << connection_key() << " from it."); + app->UnsubscribeFromIVI(it->second); + } + } + } +} + +struct SubscribedToIVIPredicate { + int32_t vehicle_info_; + SubscribedToIVIPredicate(int32_t vehicle_info) + : vehicle_info_(vehicle_info) {} + bool operator()(const ApplicationSharedPtr app) const { + return app ? app->IsSubscribedToIVI(vehicle_info_) : false; + } +}; + +bool SubscribeVehicleDataRequest::IsSomeoneSubscribedFor( + const uint32_t param_id) const { + LOG4CXX_AUTO_TRACE(logger_); + SubscribedToIVIPredicate finder(param_id); + DataAccessor accessor = application_manager_.applications(); + ApplicationSetConstIt it = std::find_if( + accessor.GetData().begin(), accessor.GetData().end(), finder); + return it != accessor.GetData().end(); +} + +void SubscribeVehicleDataRequest::CheckVISubscribtions( + ApplicationSharedPtr app, + std::string& out_info, + mobile_apis::Result::eType& out_result_code, + smart_objects::SmartObject& out_response_params, + smart_objects::SmartObject& out_request_params, + bool& out_result) { + CheckVISubscriptions(app, + out_info, + out_result_code, + out_response_params, + out_request_params, + out_result); +} + +void SubscribeVehicleDataRequest::CheckVISubscriptions( + ApplicationSharedPtr app, + std::string& out_info, + mobile_apis::Result::eType& out_result_code, + smart_objects::SmartObject& out_response_params, + smart_objects::SmartObject& out_request_params, + bool& out_result) { + // counter for items to subscribe + app_mngr::VehicleInfoSubscriptions::size_type items_to_subscribe = 0; + // counter for subscribed items by application + uint32_t subscribed_items = 0; + + const VehicleData& vehicle_data = MessageHelper::vehicle_data(); + VehicleData::const_iterator it = vehicle_data.begin(); + + HmiInterfaces::InterfaceState interface_state = + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_VehicleInfo); + + const bool is_interface_not_available = + interface_state == HmiInterfaces::STATE_NOT_AVAILABLE; + + for (; vehicle_data.end() != it; ++it) { + const std::string& key_name = it->first; + if ((*message_)[strings::msg_params].keyExists(key_name)) { + const bool is_key_enabled = + (*message_)[strings::msg_params][key_name].asBool(); + if (is_key_enabled) { + ++items_to_subscribe; + } + if (!is_interface_not_available && is_key_enabled) { + mobile_apis::VehicleDataType::eType key_type = it->second; + if (app->IsSubscribedToIVI(key_type)) { + LOG4CXX_DEBUG(logger_, + "App with connection key " + << connection_key() + << " is subscribed already for VehicleDataType: " + << key_type); + ++subscribed_items; + vi_already_subscribed_by_this_app_.insert(key_type); + out_response_params[key_name][strings::data_type] = key_type; + out_response_params[key_name][strings::result_code] = + mobile_apis::VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED; + continue; + } + + if (IsSomeoneSubscribedFor(key_type)) { + LOG4CXX_DEBUG(logger_, + "There are apps subscribed already for " + "VehicleDataType: " + << key_type); + if (!app->SubscribeToIVI(static_cast(key_type))) { + LOG4CXX_ERROR( + logger_, + "Unable to subscribe for VehicleDataType: " << key_type); + continue; + } + LOG4CXX_DEBUG( + logger_, + "App with connection key " + << connection_key() + << " have been subscribed for VehicleDataType: " << key_type); + ++subscribed_items; + vi_already_subscribed_by_another_apps_.insert(key_type); + out_response_params[key_name][strings::data_type] = key_type; + out_response_params[key_name][strings::result_code] = + mobile_apis::VehicleDataResultCode::VDRC_SUCCESS; + continue; + } + + out_request_params[key_name] = is_key_enabled; + + if (is_key_enabled) { + vi_waiting_for_subscribe_.insert(key_type); + LOG4CXX_DEBUG( + logger_, + "App with connection key " + << connection_key() + << " will be subscribed for VehicleDataType: " << key_type); + ++subscribed_items; + } + } + } + } + + const bool is_everything_already_subscribed = + items_to_subscribe == + vi_already_subscribed_by_another_apps_.size() + + vi_already_subscribed_by_this_app_.size(); + + if (0 == items_to_subscribe) { + if (HasDisallowedParams()) { + out_result_code = mobile_apis::Result::DISALLOWED; + } else { + out_result_code = mobile_apis::Result::INVALID_DATA; + out_info = "No data in the request"; + } + out_result = false; + } + + if (0 == subscribed_items && !is_interface_not_available) { + out_result_code = mobile_apis::Result::IGNORED; + out_info = "Already subscribed on provided VehicleData."; + out_result = false; + } + + if (is_everything_already_subscribed) { + out_result_code = vi_already_subscribed_by_this_app_.size() + ? mobile_apis::Result::IGNORED + : mobile_apis::Result::SUCCESS; + if (!(vi_already_subscribed_by_this_app_.empty())) { + out_info = "Already subscribed on some provided VehicleData."; + } + out_result = true; + } +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc new file mode 100644 index 0000000000..2bea839320 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc @@ -0,0 +1,63 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h" +#include "application_manager/rpc_service.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace vehicle_info_plugin { +using namespace application_manager; +namespace commands { + +SubscribeVehicleDataResponse::SubscribeVehicleDataResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +SubscribeVehicleDataResponse::~SubscribeVehicleDataResponse() {} + +void SubscribeVehicleDataResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc new file mode 100644 index 0000000000..a6a3b11111 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc @@ -0,0 +1,416 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h" +#include "application_manager/commands/command_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" +#include "utils/helpers.h" + +namespace vehicle_info_plugin { +using namespace application_manager; +namespace commands { + +UnsubscribeVehicleDataRequest::UnsubscribeVehicleDataRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +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_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + int32_t items_to_unsubscribe = 0; + 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); + + for (; vehicle_data.end() != it; ++it) { + const 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; + + mobile_apis::VehicleDataType::eType key_type = it->second; + if (!app->IsSubscribedToIVI(key_type)) { + ++unsubscribed_items; + vi_already_unsubscribed_by_this_app_.insert(key_type); + response_params[key_name][strings::data_type] = key_type; + response_params[key_name][strings::result_code] = + mobile_apis::VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED; + continue; + } + + if (!app->UnsubscribeFromIVI(static_cast(key_type))) { + LOG4CXX_ERROR(logger_, + "Unable to unsubscribe from " + "VehicleDataType: " + << key_type); + continue; + } + + LOG4CXX_DEBUG(logger_, + "Unsubscribed app with connection key " + << connection_key() + << " from VehicleDataType: " << key_type); + + ++unsubscribed_items; + + if (IsSomeoneSubscribedFor(key_type)) { + LOG4CXX_DEBUG(logger_, + "There are another apps still subscribed for " + "VehicleDataType: " + << key_type); + + vi_still_subscribed_by_another_apps_.insert(key_type); + response_params[key_name][strings::data_type] = key_type; + response_params[key_name][strings::result_code] = + mobile_apis::VehicleDataResultCode::VDRC_SUCCESS; + continue; + } + + msg_params[key_name] = is_key_enabled; + } + } + } + + bool is_everything_already_unsubscribed = + static_cast(items_to_unsubscribe) == + vi_still_subscribed_by_another_apps_.size() + + vi_already_unsubscribed_by_this_app_.size(); + + 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; + } + + if (0 == unsubscribed_items) { + SendResponse(false, + mobile_apis::Result::IGNORED, + "Was not subscribed on any VehicleData.", + &response_params); + return; + } + + if (is_everything_already_unsubscribed) { + if (!vi_already_unsubscribed_by_this_app_.empty()) { + SendResponse(false, + mobile_apis::Result::IGNORED, + "Some provided VehicleData was not subscribed.", + &response_params); + } else { + SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &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 + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); + SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData, + &msg_params, + true); +#endif // #ifdef HMI_DBUS_API +} + +void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + + const smart_objects::SmartObject& message = event.smart_object(); + + if (hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData != event.id()) { + LOG4CXX_ERROR(logger_, "Received unknown event."); + return; + } + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); + + ApplicationSharedPtr app = + application_manager_.application(CommandRequestImpl::connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer."); + return; + } + +#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( + 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(it->status); + } else if (status != + static_cast(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"); + if (true == any_arg_success) { + SetAllowedToTerminate(false); + } + SendResponse(any_arg_success, status, NULL, &response_params); + if (true == any_arg_success) { + app->UpdateHash(); + } + } +#else + hmi_apis::Common_Result::eType hmi_result = + static_cast( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(message, response_info); + const bool result = PrepareResultForMobileResponse( + hmi_result, HmiInterfaces::HMI_INTERFACE_VehicleInfo); + + mobile_apis::Result::eType result_code = + MessageHelper::HMIToMobileResult(hmi_result); + + if (result) { + if (vi_already_unsubscribed_by_this_app_.size()) { + result_code = mobile_apis::Result::IGNORED; + response_info = "Some provided VehicleData was not subscribed."; + } + } + + if (!vi_still_subscribed_by_another_apps_.empty() || + !vi_already_unsubscribed_by_this_app_.empty()) { + AddAlreadyUnsubscribedVI( + const_cast(message[strings::msg_params])); + } + + if (result) { + SetAllowedToTerminate(false); + } + SendResponse(result, + result_code, + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); + if (result) { + application_manager_.TerminateRequest( + connection_key(), correlation_id(), function_id()); + } +#endif // #ifdef HMI_DBUS_API +} + +bool UnsubscribeVehicleDataRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +struct SubscribedToIVIPredicate { + int32_t vehicle_info_; + SubscribedToIVIPredicate(int32_t vehicle_info) + : vehicle_info_(vehicle_info) {} + bool operator()(const ApplicationSharedPtr app) const { + return app ? app->IsSubscribedToIVI(vehicle_info_) : false; + } +}; + +bool UnsubscribeVehicleDataRequest::IsSomeoneSubscribedFor( + const uint32_t param_id) const { + LOG4CXX_AUTO_TRACE(logger_); + SubscribedToIVIPredicate finder(param_id); + DataAccessor accessor = application_manager_.applications(); + ApplicationSetConstIt it = std::find_if( + accessor.GetData().begin(), accessor.GetData().end(), finder); + return it != accessor.GetData().end(); +} + +void UnsubscribeVehicleDataRequest::AddAlreadyUnsubscribedVI( + smart_objects::SmartObject& response) const { + LOG4CXX_AUTO_TRACE(logger_); + using namespace mobile_apis; + app_mngr::VehicleInfoSubscriptions::const_iterator it_same_app = + vi_already_unsubscribed_by_this_app_.begin(); + for (; vi_already_unsubscribed_by_this_app_.end() != it_same_app; + ++it_same_app) { + response[*it_same_app][strings::result_code] = + VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED; + } + + app_mngr::VehicleInfoSubscriptions::const_iterator it_another_app = + vi_still_subscribed_by_another_apps_.begin(); + for (; vi_still_subscribed_by_another_apps_.end() != it_another_app; + ++it_another_app) { + response[*it_another_app][strings::result_code] = + VehicleDataResultCode::VDRC_SUCCESS; + } +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc new file mode 100644 index 0000000000..143a727455 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc @@ -0,0 +1,72 @@ +/* + + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h" +#include "smart_objects/smart_object.h" + +namespace vehicle_info_plugin { +using namespace application_manager; +namespace commands { + +UnsubscribeVehicleDataResponse::UnsubscribeVehicleDataResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +UnsubscribeVehicleDataResponse::~UnsubscribeVehicleDataResponse() {} + +void UnsubscribeVehicleDataResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // 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/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc index 56ac6cba71..edc80951e3 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc @@ -32,6 +32,8 @@ #include "vehicle_info_plugin/vehicle_info_command_factory.h" +CREATE_LOGGERPTR_GLOBAL(logger_, "Vehicle Info Plugin") + namespace vehicle_info_plugin { VehicleInfoCommandFactory::VehicleInfoCommandFactory( @@ -42,12 +44,12 @@ VehicleInfoCommandFactory::VehicleInfoCommandFactory( : application_manager_(application_manager), rpc_service_(rpc_service), hmi_capabilities_(hmi_capabilities), - policy_handler_(policy_handler) { - - hmi_command_factory_.reset(new VehicleInfoHmiCommandFactory( - application_manager, rpc_service, hmi_capabilities, policy_handler)); - mob_command_factory_.reset(new VehicleInfoMobileCommandFactory( - application_manager, rpc_service, hmi_capabilities, policy_handler)); + policy_handler_(policy_handler), + hmi_command_factory_(std::make_shared(new VehicleInfoHmiCommandFactory( + application_manager, rpc_service, hmi_capabilities, policy_handler))), + mob_command_factory_(std::make_shared(new VehicleInfoMobileCommandFactory( + application_manager, rpc_service, hmi_capabilities, policy_handler))) { + LOG4CXX_AUTO_TRACE(logger_); } VehicleInfoCommandFactory::~VehicleInfoCommandFactory() {} diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc index 71b9b7993e..bebe1f3b27 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc @@ -57,6 +57,7 @@ VehicleInfoHmiCommandFactory::VehicleInfoHmiCommandFactory( app_mngr::CommandSharedPtr VehicleInfoHmiCommandFactory::CreateCommand( const app_mngr::commands::MessageSharedPtr& message, app_mngr::commands::Command::CommandSource source) { + UNUSED(source); const hmi_apis::FunctionID::eType function_id = static_cast( @@ -89,6 +90,24 @@ app_mngr::CommandSharedPtr VehicleInfoHmiCommandFactory::CreateCommand( ? factory.GetCreator() : factory.GetCreator(); break; + case hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData: + // SubscribeVehicleData HMI request/response + break; + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData: + // UnsubscribeVehicleData HMI request/response + break; + case hmi_apis::FunctionID::VehicleInfo_OnVehicleData: + // OnVehicleData HMI notification + break; + case hmi_apis::FunctionID::VehicleInfo_ReadDID: + // ReadDID HMI request/response + break; + case hmi_apis::FunctionID::VehicleInfo_GetDTCs: + // GetDTCs HMI request/response + break; + case hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage: + // DiagnosticMessage HMI request/response + break; default: LOG4CXX_WARN(logger_, "Unsupported function_id: " << function_id); break; diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc index eb6975acdb..c2e4a26745 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc @@ -32,6 +32,23 @@ #include "vehicle_info_plugin/vehicle_info_mobile_command_factory.h" +#include "application_manager/message.h" +#include "interfaces/MOBILE_API.h" + +#include "vehicle_info_plugin/commands/mobile/diagnostic_message_request.h" +#include "vehicle_info_plugin/commands/mobile/diagnostic_message_response.h" +#include "vehicle_info_plugin/commands/mobile/get_dtcs_request.h" +#include "vehicle_info_plugin/commands/mobile/get_dtcs_response.h" +#include "vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h" +#include "vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h" +#include "vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h" +#include "vehicle_info_plugin/commands/mobile/read_did_request.h" +#include "vehicle_info_plugin/commands/mobile/read_did_response.h" +#include "vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h" +#include "vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h" +#include "vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h" +#include "vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h" + CREATE_LOGGERPTR_GLOBAL(logger_, "Vehicle Info Plugin") namespace vehicle_info_plugin { @@ -51,18 +68,87 @@ VehicleInfoMobileCommandFactory::VehicleInfoMobileCommandFactory( app_mngr::CommandSharedPtr VehicleInfoMobileCommandFactory::CreateCommand( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::commands::Command::CommandSource command_source) { + app_mngr::commands::Command::CommandSource source) { + UNUSED(source); + + const mobile_apis::FunctionID::eType function_id = + static_cast( + (*message)[strings::params][strings::function_id].asInt()); + + const mobile_apis::messageType::eType message_type = + static_cast( + (*message)[strings::params][strings::message_type].asInt()); + + auto message_type_str = ""; + if (mobile_apis::messageType::response == message_type) { + message_type_str = "response"; + } else if (mobile_apis::messageType::notification == message_type) { + message_type_str = "notification"; + } else { + message_type_str = "request"; + } - // TODO: Implement - throw -1; + LOG4CXX_DEBUG( + logger_, "HMICommandFactory::CreateCommand function_id: " << function_id + << ", message type: " << message_type_str); + + return buildCommandCreator(function_id, message_type).create(message); } bool VehicleInfoMobileCommandFactory::IsAbleToProcess( const int32_t function_id, const app_mngr::commands::Command::CommandSource source) const { + UNUSED(source); + return buildCommandCreator( + function_id, mobile_apis::messageType::INVALID_ENUM).CanBeCreated(); +} + +app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::buildCommandCreator( + int32_t function_id, int32_t message_type) { + auto factory = + app_mngr::CommandCreatorFactory(application_manager_, rpc_service_, hmi_capabilities_, policy_handler_); + auto &creator = factory.GetCreator(); + + switch (function_id) { + case mobile_apis::FunctionID::GetVehicleDataID: + creator = mobile_apis::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + break; + case mobile_apis::FunctionID::SubscribeVehicleDataID: + creator = mobile_apis::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + break; + case mobile_apis::FunctionID::UnsubscribeVehicleDataID: + creator = mobile_apis::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + break; + case mobile_apis::FunctionID::OnVehicleDataID: + creator = factory.GetCreator(); + break; + case mobile_apis::FunctionID::ReadDIDID: + creator = mobile_apis::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + break; + case mobile_apis::FunctionID::GetDTCsID: + creator = mobile_apis::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + break; + case mobile_apis::FunctionID::DiagnosticMessageID: + creator = mobile_apis::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + break; + default: + LOG4CXX_WARN(logger_, "Unsupported function_id: " << function_id); + break; + } - // TODO: Implement - throw -1; + return creator; } } -- cgit v1.2.1