diff options
author | fronneburg <fronneburg@xevo.com> | 2018-07-05 10:12:28 -0700 |
---|---|---|
committer | fronneburg <fronneburg@xevo.com> | 2018-07-05 10:12:28 -0700 |
commit | bf5c81d55c8bbb839680d0eab29d892a82330341 (patch) | |
tree | e952d6d173599306614efd15962491c97f34d171 /src/components/application_manager/rpc_plugins/sdl_rpc_plugin | |
parent | d4159c1768e28dccdd6027a714de59f93e06c8b2 (diff) | |
parent | ba1da7bc2ff3fd37638620f6bea526384646ab0e (diff) | |
download | sdl_core-bf5c81d55c8bbb839680d0eab29d892a82330341.tar.gz |
Merge branch 'develop' of https://github.com/smartdevicelink/sdl_core into feat/mt_transport_changes
Conflicts:
src/components/application_manager/src/application_manager_impl.cc
src/components/application_manager/test/application_manager_impl_test.cc
src/components/remote_control/test/include/mock_application.h
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin')
754 files changed, 88605 insertions, 0 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt new file mode 100644 index 0000000000..11dd35d061 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt @@ -0,0 +1,77 @@ +# 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 copyright holders nor the names of their contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +include_directories(include) + +set (COMMANDS_SOURCE_DIR + ${CMAKE_CURRENT_SOURCE_DIR}/src/commands +) + +set (MOBILE_COMMANDS_SOURCE_DIR + ${COMMANDS_SOURCE_DIR}/mobile +) + +set (HMI_COMMANDS_SOURCE_DIR + ${COMMANDS_SOURCE_DIR}/hmi +) + +collect_sources(MOBILE_COMMANDS "${MOBILE_COMMANDS_SOURCE_DIR}") +collect_sources(HMI_COMMANDS "${HMI_COMMANDS_SOURCE_DIR}") +collect_sources(RPC_PLUGIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src") + +set(LIBRARIES + HMI_API + MOBILE_API + ApplicationManager + v4_protocol_v1_2_no_extra + SmartObjects + Utils + Policy +) + +if(ENABLE_LOG) + list(APPEND LIBRARIES log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) +endif() + +add_library("sdl_rpc_plugin" SHARED ${MOBILE_COMMANDS} ${HMI_COMMANDS} ${RPC_PLUGIN_SOURCES}) +target_link_libraries("sdl_rpc_plugin" ${LIBRARIES}) + +set(INSTALL_DESTINATION bin) + +install(TARGETS sdl_rpc_plugin + DESTINATION ${INSTALL_DESTINATION} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE +) + +if(BUILD_TESTS) + add_subdirectory(test) +endif() diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_request.h new file mode 100644 index 0000000000..7b0911fef9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_ACTIVATE_APP_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ACTIVATE_APP_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ActivateAppRequest command class + **/ +class ActivateAppRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief ActivateAppRequest class constructor + * + * @param message Incoming SmartObject message + **/ + ActivateAppRequest(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_handle); + + /** + * @brief ActivateAppRequest class destructor + **/ + virtual ~ActivateAppRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ActivateAppRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ACTIVATE_APP_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_response.h new file mode 100644 index 0000000000..f937b4f63b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_ACTIVATE_APP_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ACTIVATE_APP_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ActivateAppResponse command class + **/ +class ActivateAppResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief ActivateAppResponse class constructor + * + * @param message Incoming SmartObject message + **/ + ActivateAppResponse(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_handle); + + /** + * @brief ActivateAppResponse class destructor + **/ + virtual ~ActivateAppResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ActivateAppResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ACTIVATE_APP_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/add_statistics_info_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/add_statistics_info_notification.h new file mode 100644 index 0000000000..4e9e4d54d7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/add_statistics_info_notification.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_HMI_ADD_STATISTICS_INFO_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ADD_STATISTICS_INFO_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief AddStatisticsInfoNotification command class + **/ +class AddStatisticsInfoNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief AddStatisticsInfoNotification class constructor + * + * @param message Incoming SmartObject message + **/ + AddStatisticsInfoNotification( + 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_handle); + + /** + * @brief AddStatisticsInfoNotification class destructor + **/ + virtual ~AddStatisticsInfoNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(AddStatisticsInfoNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ADD_STATISTICS_INFO_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h new file mode 100644 index 0000000000..45acb3a424 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_ALLOW_ALL_APPS_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ALLOW_ALL_APPS_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief AllowAllAppsRequest command class + **/ +class AllowAllAppsRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief AllowAllAppsRequest class constructor + * + * @param message Incoming SmartObject message + **/ + AllowAllAppsRequest(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_handle); + + /** + * @brief AllowAllAppsRequest class destructor + **/ + virtual ~AllowAllAppsRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(AllowAllAppsRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ALLOW_ALL_APPS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_response.h new file mode 100644 index 0000000000..41d1c9e752 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_ALLOW_ALL_APPS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ALLOW_ALL_APPS_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief AllowAllAppsResponse command class + **/ +class AllowAllAppsResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief AllowAllAppsResponse class constructor + * + * @param message Incoming SmartObject message + **/ + AllowAllAppsResponse(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_handle); + + /** + * @brief AllowAllAppsResponse class destructor + **/ + virtual ~AllowAllAppsResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(AllowAllAppsResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ALLOW_ALL_APPS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_request.h new file mode 100644 index 0000000000..b3a2d88d7d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_ALLOW_APP_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ALLOW_APP_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief AllowAppRequest command class + **/ +class AllowAppRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief AllowAppRequest class constructor + * + * @param message Incoming SmartObject message + **/ + AllowAppRequest(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_handle); + + /** + * @brief AllowAppRequest class destructor + **/ + virtual ~AllowAppRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(AllowAppRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ALLOW_APP_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_response.h new file mode 100644 index 0000000000..55637e1756 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_ALLOW_APP_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ALLOW_APP_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief AllowAppResponse command class + **/ +class AllowAppResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief AllowAppResponse class constructor + * + * @param message Incoming SmartObject message + **/ + AllowAppResponse(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_handle); + + /** + * @brief AllowAppResponse class destructor + **/ + virtual ~AllowAppResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(AllowAppResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ALLOW_APP_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_request.h new file mode 100644 index 0000000000..2208671e0b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_request.h @@ -0,0 +1,74 @@ +/* + * 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_HMI_BASIC_COMMUNICATION_GET_SYSTEM_TIME_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_GET_SYSTEM_TIME_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +/** + * @brief The BasicCommunicationGetSystemTimeRequest class sends the request + * to the HMI in order to receive current system time. + */ +class BasicCommunicationGetSystemTimeRequest + : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief BasicCommunicationGetSystemTimeRequest does nothing except of + * initializing base class with the passed parameters. + * @param message the message to send to HMI + * @param application_manager application manager. Location service which + * is provides neccessary api to send the request. + */ + BasicCommunicationGetSystemTimeRequest( + 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 onTimeOut allows to handle case when + * system does not respond for certain request in + * appropriate time window. + */ + void onTimeOut() FINAL; +}; + +} // namespace commands +} // namespace sdl_rpc_plugin +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_GET_SYSTEM_TIME_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h new file mode 100644 index 0000000000..90160d9953 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h @@ -0,0 +1,76 @@ +/* + * 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_HMI_BASIC_COMMUNICATION_GET_SYSTEM_TIME_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_GET_SYSTEM_TIME_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +#include "utils/macro.h" +#include "application_manager/application_manager_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +/** + * @brief The BasicCommunicationGetSystemTimeResponse class represents the + * HMI response which is contains data obtained from HMI. + */ +class BasicCommunicationGetSystemTimeResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief BasicCommunicationGetSystemTimeResponse does nothing except of + * initializing base class with the passed parameters. + * @param message the message to send to HMI + * @param application_manager Location service which which is provides + * neccessary api to send the request. + */ + BasicCommunicationGetSystemTimeResponse( + 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 Run takes the message obtained from the HMI and + * sends this data to the subscribed on certain event class + */ + void Run() FINAL; +}; + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_GET_SYSTEM_TIME_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_on_awake_sdl.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_on_awake_sdl.h new file mode 100644 index 0000000000..2ac1be2580 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_on_awake_sdl.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_BASIC_COMMUNICATION_ON_AWAKE_SDL_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_ON_AWAKE_SDL_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnAwakeSDLNotification command class + **/ +class OnAwakeSDLNotification : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnAwakeSDLNotification class constructor + * @param message Incoming SmartObject message + * @param application_manager reference to ApplicationManager instance + **/ + OnAwakeSDLNotification(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_handle); + + /** + * @brief OnAwakeSDLNotification class destructor + **/ + virtual ~OnAwakeSDLNotification(); + + /** + * @brief Execute command + **/ + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(OnAwakeSDLNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_ON_AWAKE_SDL_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h new file mode 100644 index 0000000000..a7eb820146 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_request.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_HMI_BASIC_COMMUNICATION_SYSTEM_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_SYSTEM_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief BasicCommunicationSystemRequest command class + **/ +class BasicCommunicationSystemRequest + : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief BasicCommunicationSystemRequest class constructor + * + * @param message Incoming SmartObject message + **/ + BasicCommunicationSystemRequest( + 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_handle); + + /** + * @brief BasicCommunicationSystemRequest class destructor + **/ + virtual ~BasicCommunicationSystemRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(BasicCommunicationSystemRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_SYSTEM_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_response.h new file mode 100644 index 0000000000..20483a45e3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_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_HMI_BASIC_COMMUNICATION_SYSTEM_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_SYSTEM_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief BasicCommunicationSystemResponse command class + **/ +class BasicCommunicationSystemResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief BasicCommunicationSystemResponse class constructor + * + * @param message Incoming SmartObject message + **/ + BasicCommunicationSystemResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + application_manager::rpc_service::RPCService& rpc_service, + application_manager::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief BasicCommunicationSystemResponse class destructor + **/ + virtual ~BasicCommunicationSystemResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(BasicCommunicationSystemResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_SYSTEM_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h new file mode 100644 index 0000000000..5c650fb8e4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.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_HMI_BUTTON_GET_CAPABILITIES_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BUTTON_GET_CAPABILITIES_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ButtonGetCapabilitiesRequest command class + **/ +class ButtonGetCapabilitiesRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief ButtonGetCapabilitiesRequest class constructor + * + * @param message Incoming SmartObject message + **/ + ButtonGetCapabilitiesRequest( + 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_handle); + + /** + * @brief ButtonGetCapabilitiesRequest class destructor + **/ + virtual ~ButtonGetCapabilitiesRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ButtonGetCapabilitiesRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BUTTON_GET_CAPABILITIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_response.h new file mode 100644 index 0000000000..bf2f15c18a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_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_HMI_BUTTON_GET_CAPABILITIES_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BUTTON_GET_CAPABILITIES_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ButtonGetCapabilitiesResponse command class + **/ +class ButtonGetCapabilitiesResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief ButtonGetCapabilitiesResponse class constructor + * + * @param message Incoming SmartObject message + **/ + ButtonGetCapabilitiesResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + application_manager::rpc_service::RPCService& rpc_service, + application_manager::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ButtonGetCapabilitiesResponse class destructor + **/ + virtual ~ButtonGetCapabilitiesResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ButtonGetCapabilitiesResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BUTTON_GET_CAPABILITIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_request.h new file mode 100644 index 0000000000..635b0579f4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_CLOSE_POPUP_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_CLOSE_POPUP_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ClosePopupRequest command class + **/ +class ClosePopupRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief ClosePopupRequest class constructor + * + * @param message Incoming SmartObject message + **/ + ClosePopupRequest(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_handle); + + /** + * @brief ClosePopupRequest class destructor + **/ + virtual ~ClosePopupRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ClosePopupRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_CLOSE_POPUP_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_response.h new file mode 100644 index 0000000000..199b40f070 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_CLOSE_POPUP_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_CLOSE_POPUP_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ClosePopupResponse command class + **/ +class ClosePopupResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief ClosePopupResponse class constructor + * + * @param message Incoming SmartObject message + **/ + ClosePopupResponse(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_handle); + + /** + * @brief ClosePopupResponse class destructor + **/ + virtual ~ClosePopupResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ClosePopupResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_CLOSE_POPUP_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_request.h new file mode 100644 index 0000000000..a70bff2553 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_request.h @@ -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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_DECRYPT_CERTIFICATE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_DECRYPT_CERTIFICATE_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief DecryptCertificateRequest command class + **/ +class DecryptCertificateRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief DecryptCertificateRequest class constructor + * + * @param message Incoming SmartObject message + **/ + DecryptCertificateRequest(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_handle); + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(DecryptCertificateRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_DECRYPT_CERTIFICATE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_response.h new file mode 100644 index 0000000000..88b216eeea --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_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_HMI_DECRYPT_CERTIFICATE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_DECRYPT_CERTIFICATE_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief DecryptCertificateResponse command class + **/ +class DecryptCertificateResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief DecryptCertificateResponse class constructor + * + * @param message Incoming SmartObject message + **/ + DecryptCertificateResponse( + 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_handle); + + /** + * @brief DecryptCertificateResponse class destructor + **/ + virtual ~DecryptCertificateResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(DecryptCertificateResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_DECRYPT_CERTIFICATE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_request.h new file mode 100644 index 0000000000..fa0efb90e6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_request.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_HMI_DIAL_NUMBER_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_DIAL_NUMBER_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +namespace hmi { +/** + * @brief DialNumberRequest command class + **/ +class DialNumberRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief DialNumberRequest class constructor + * + * @param message Incoming SmartObject message + **/ + DialNumberRequest(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_handle); + + /** + * @brief DialNumberRequest class destructor + **/ + virtual ~DialNumberRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(DialNumberRequest); +}; + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_DIAL_NUMBER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_response.h new file mode 100644 index 0000000000..33d4788eca --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_response.h @@ -0,0 +1,81 @@ +/* + * 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_HMI_DIAL_NUMBER_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_DIAL_NUMBER_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +namespace hmi { + +/** + * @brief DialNumberResponse command class + **/ +class DialNumberResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief DialNumberResponse class constructor + * + * @param message Incoming SmartObject message + **/ + DialNumberResponse(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_handle); + + /** + * @brief DialNumberResponse class destructor + **/ + virtual ~DialNumberResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(DialNumberResponse); +}; + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_DIAL_NUMBER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_request.h new file mode 100644 index 0000000000..d771167798 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_GET_SYSTEM_INFO_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_SYSTEM_INFO_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief GetSystemInfoRequest command class + **/ +class GetSystemInfoRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief GetSystemInfoRequest class constructor + * + * @param message Incoming SmartObject message + **/ + GetSystemInfoRequest(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_handle); + + /** + * @brief GetSystemInfoRequest class destructor + **/ + virtual ~GetSystemInfoRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(GetSystemInfoRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_SYSTEM_INFO_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_response.h new file mode 100644 index 0000000000..5bf5f41b73 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_response.h @@ -0,0 +1,87 @@ +/* + * 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_HMI_GET_SYSTEM_INFO_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_SYSTEM_INFO_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +struct SystemInfo { + std::string ccpu_version; + std::string wers_country_code; + std::string language; +}; + +/** + * @brief GetSystemInfoResponse command class + **/ +class GetSystemInfoResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief GetSystemInfoResponse class constructor + * + * @param message Incoming SmartObject message + **/ + GetSystemInfoResponse(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_handle); + + /** + * @brief GetSystemInfoResponse class destructor + **/ + virtual ~GetSystemInfoResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + const SystemInfo GetSystemInfo( + const hmi_apis::Common_Result::eType code) const; + + DISALLOW_COPY_AND_ASSIGN(GetSystemInfoResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_SYSTEM_INFO_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls.h new file mode 100644 index 0000000000..93b414c8c4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls.h @@ -0,0 +1,96 @@ +/* + * 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_HMI_GET_URLS_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_H_ + +#include "application_manager/commands/request_from_hmi.h" +#include "policy/policy_types.h" +#include "smart_objects/smart_object.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { +/** + * @brief GetUrls command class + **/ +class GetUrls : public app_mngr::commands::RequestFromHMI { + public: + /** + * @brief GetUrls class constructor + * + * @param message Incoming SmartObject message + **/ + GetUrls(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_handle); + + /** + * @brief GetUrls class destructor + **/ + virtual ~GetUrls(); + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: +#ifdef PROPRIETARY_MODE + /** + * @brief Processes URLs collecting for policy service + * @param endpoints Endpoints section of policy table + */ + void ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints); +#endif // PROPRIETARY_MODE + + /** + * @brief Process URLs collecting for service + * @param endpoints Endpoints section of policy table + */ + void ProcessServiceURLs(const policy::EndpointUrls& endpoints); + + /** + * @brief Sends response to HMI + * @param result Result code + */ + void SendResponseToHMI(hmi_apis::Common_Result::eType result); + + DISALLOW_COPY_AND_ASSIGN(GetUrls); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls_response.h new file mode 100644 index 0000000000..1ff38194b8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls_response.h @@ -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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_RESPONSE_H_ + +#include "application_manager/commands/response_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +class GetUrlsResponse : public app_mngr::commands::ResponseToHMI { + public: + /** + * @brief GetUrlsResponse class constructor + * + * @param message Incoming SmartObject message + **/ + GetUrlsResponse(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_handle); + + /** + * @brief GetUrlsResponse class destructor + **/ + virtual ~GetUrlsResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(GetUrlsResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_request.h new file mode 100644 index 0000000000..34c10cedf1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_request.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_HMI_MIXING_AUDIO_SUPPORTED_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_MIXING_AUDIO_SUPPORTED_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief MixingAudioSupportedRequest command class + **/ +class MixingAudioSupportedRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief MixingAudioSupportedRequest class constructor + * + * @param message Incoming SmartObject message + **/ + MixingAudioSupportedRequest( + 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_handle); + + /** + * @brief MixingAudioSupportedRequest class destructor + **/ + virtual ~MixingAudioSupportedRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(MixingAudioSupportedRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_MIXING_AUDIO_SUPPORTED_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_response.h new file mode 100644 index 0000000000..5c67666225 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_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_HMI_MIXING_AUDIO_SUPPORTED_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_MIXING_AUDIO_SUPPORTED_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief MixingAudioSupportedResponse command class + **/ +class MixingAudioSupportedResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief MixingAudioSupportedResponse class constructor + * + * @param message Incoming SmartObject message + **/ + MixingAudioSupportedResponse( + 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_handle); + + /** + * @brief MixingAudioSupportedResponse class destructor + **/ + virtual ~MixingAudioSupportedResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(MixingAudioSupportedResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_MIXING_AUDIO_SUPPORTED_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h new file mode 100644 index 0000000000..3f63ef883d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_NAVI_ALERT_MANEUVER_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_ALERT_MANEUVER_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviAlertManeuverRequest command class + **/ +class NaviAlertManeuverRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief NaviAlertManeuverRequest class constructor + * + * @param message Incoming SmartObject message + **/ + NaviAlertManeuverRequest(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_handle); + + /** + * @brief NaviAlertManeuverRequest class destructor + **/ + virtual ~NaviAlertManeuverRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(NaviAlertManeuverRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_ALERT_MANEUVER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h new file mode 100644 index 0000000000..7d7c4de85e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_NAVI_ALERT_MANEUVER_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_ALERT_MANEUVER_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviAlertManeuverResponse command class + **/ +class NaviAlertManeuverResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief NaviAlertManeuverResponse class constructor + * + * @param message Incoming SmartObject message + **/ + NaviAlertManeuverResponse(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_handle); + + /** + * @brief NaviAlertManeuverResponse class destructor + **/ + virtual ~NaviAlertManeuverResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(NaviAlertManeuverResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_ALERT_MANEUVER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h new file mode 100644 index 0000000000..80e948ad25 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h @@ -0,0 +1,95 @@ +/* + * 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_HMI_NAVI_AUDIO_START_STREAM_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_AUDIO_START_STREAM_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief AudioStartStreamRequest command class + **/ +class AudioStartStreamRequest : public app_mngr::commands::RequestToHMI, + public app_mngr::event_engine::EventObserver { + public: + /** + * @brief AudioStartStreamRequest class constructor + * + * @param message Incoming SmartObject message + **/ + AudioStartStreamRequest(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_handle); + + /** + * @brief OnNaviStartStreamRequest class destructor + **/ + virtual ~AudioStartStreamRequest(); + + /** + * @brief onTimeOut from requrst Controller + */ + virtual void onTimeOut(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief On event callback + **/ + virtual void on_event(const app_mngr::event_engine::Event& event); + + /** + * @brief RetryStartSession resend HMI startSession request if needed. + * If limit expired, set audio_stream_retry_number counter to 0 + */ + void RetryStartSession(); + + private: + uint32_t retry_number_; + DISALLOW_COPY_AND_ASSIGN(AudioStartStreamRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_AUDIO_START_STREAM_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h new file mode 100644 index 0000000000..926cfc36ed --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h @@ -0,0 +1,76 @@ +/* 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_HMI_NAVI_AUDIO_START_STREAM_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_AUDIO_START_STREAM_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief AudioStartStreamResponse command class + **/ +class AudioStartStreamResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief AudioStartStreamResponse class constructor + * + * @param message Incoming SmartObject message + **/ + AudioStartStreamResponse(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_handle); + + /** + * @brief AudioStartStreamResponse class destructor + **/ + virtual ~AudioStartStreamResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(AudioStartStreamResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_AUDIO_START_STREAM_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h new file mode 100644 index 0000000000..7c5fbbdd3d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h @@ -0,0 +1,76 @@ +/* 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_HMI_NAVI_AUDIO_STOP_STREAM_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_AUDIO_STOP_STREAM_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief AudioStopStreamRequest command class + **/ +class AudioStopStreamRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief AudioStopStreamRequest class constructor + * + * @param message Incoming SmartObject message + **/ + AudioStopStreamRequest(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_handle); + + /** + * @brief NaviStopStreamRequest class destructor + **/ + virtual ~AudioStopStreamRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(AudioStopStreamRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_AUDIO_STOP_STREAM_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_response.h new file mode 100644 index 0000000000..8eb091dd92 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_response.h @@ -0,0 +1,76 @@ +/* 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_HMI_NAVI_AUDIO_STOP_STREAM_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_AUDIO_STOP_STREAM_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviStopStreamResponse command class + **/ +class AudioStopStreamResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief AudioStopStreamResponse class constructor + * + * @param message Incoming SmartObject message + **/ + AudioStopStreamResponse(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_handle); + + /** + * @brief OnNaviStopStreamResponse class destructor + **/ + virtual ~AudioStopStreamResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(AudioStopStreamResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_AUDIO_STOP_STREAM_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h new file mode 100644 index 0000000000..dab5fc1022 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h @@ -0,0 +1,75 @@ +/* + * 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_HMI_NAVI_GET_WAY_POINTS_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_GET_WAY_POINTS_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviGetWayPointsRequest command class + **/ +class NaviGetWayPointsRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief NaviGetWayPointsRequest class constructor + * + * @param message Incoming SmartObject message + **/ + NaviGetWayPointsRequest(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_handle); + /** + * @brief NaviGetWayPointsRequest class destructor + **/ + virtual ~NaviGetWayPointsRequest(); + /** + * @brief Execute command + **/ + virtual void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(NaviGetWayPointsRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_GET_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_response.h new file mode 100644 index 0000000000..fb93c2c64a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_NAVI_GET_WAY_POINTS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_GET_WAY_POINTS_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviGetWaypoints command class + **/ +class NaviGetWayPointsResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief NaviGetWaypoints class constructor + * + * @param message Incoming SmartObject message + **/ + NaviGetWayPointsResponse(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_handle); + + /** + * @brief NaviGetWaypoints class destructor + **/ + virtual ~NaviGetWayPointsResponse(); + + /** + * @brief Execute command + **/ + virtual void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(NaviGetWayPointsResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_GET_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_request.h new file mode 100644 index 0000000000..404ddc9f00 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_request.h @@ -0,0 +1,83 @@ +/* + * 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_HMI_NAVI_IS_READY_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_IS_READY_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviIsReadyRequest command class + **/ +class NaviIsReadyRequest : public app_mngr::commands::RequestToHMI, + public app_mngr::event_engine::EventObserver { + public: + /** + * @brief NaviIsReadyRequest class constructor + * + * @param message Incoming SmartObject message + **/ + NaviIsReadyRequest(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_handle); + + /** + * @brief NaviIsReadyRequest class destructor + **/ + virtual ~NaviIsReadyRequest(); + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + /** + * @brief On event callback + **/ + void on_event(const app_mngr::event_engine::Event& event) OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(NaviIsReadyRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_IS_READY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_response.h new file mode 100644 index 0000000000..7f94312d04 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_NAVI_IS_READY_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_IS_READY_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviIsReadyResponse command class + **/ +class NaviIsReadyResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief NaviIsReadyResponse class constructor + * + * @param message Incoming SmartObject message + **/ + NaviIsReadyResponse(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_handle); + + /** + * @brief NaviIsReadyResponse class destructor + **/ + virtual ~NaviIsReadyResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(NaviIsReadyResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_IS_READY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_request.h new file mode 100644 index 0000000000..7bdf0e4787 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_NAVI_SEND_LOCATION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SEND_LOCATION_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviSendLocationRequest command class + */ +class NaviSendLocationRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief NaviSendLocationRequest class constructor + * + * @param message Incoming SmartObject message + */ + NaviSendLocationRequest(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_handle); + + /** + * @brief NaviSendLocationRequest class destructor + */ + virtual ~NaviSendLocationRequest(); + + /** + * @brief Execute command + */ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(NaviSendLocationRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SEND_LOCATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_response.h new file mode 100644 index 0000000000..6a65eb00a1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_NAVI_SEND_LOCATION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SEND_LOCATION_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviSendLocationResponse command class + */ +class NaviSendLocationResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief NaviSendLocationResponse class constructor + * + * @param message Incoming SmartObject message + */ + NaviSendLocationResponse(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_handle); + + /** + * @brief NaviSendLocationResponse class destructor + */ + virtual ~NaviSendLocationResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(NaviSendLocationResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SEND_LOCATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_request.h new file mode 100644 index 0000000000..a981b8ff81 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_request.h @@ -0,0 +1,89 @@ +/* + * 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_HMI_NAVI_SET_VIDEO_CONFIG_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SET_VIDEO_CONFIG_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviSetVideoConfigRequest command class + **/ +class NaviSetVideoConfigRequest : public app_mngr::commands::RequestToHMI, + public app_mngr::event_engine::EventObserver { + public: + /** + * @brief NaviSetVideoConfigRequest class constructor + * + * @param message Incoming SmartObject message + * @param application_manager Reference of application manager + **/ + NaviSetVideoConfigRequest(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_handle); + + /** + * @brief NaviSetVideoConfigRequest class destructor + **/ + virtual ~NaviSetVideoConfigRequest(); + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + /** + * @brief On event callback + **/ + void on_event(const app_mngr::event_engine::Event& event) OVERRIDE; + + /** + * @brief onTimeOut callback + */ + void onTimeOut() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(NaviSetVideoConfigRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SET_VIDEO_CONFIG_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_response.h new file mode 100644 index 0000000000..f5f9e7a5ee --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_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_HMI_NAVI_SET_VIDEO_CONFIG_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SET_VIDEO_CONFIG_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviSetVideoConfigResponse command class + **/ +class NaviSetVideoConfigResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief NaviSetVideoConfigResponse class constructor + * + * @param message Incoming SmartObject message + * @param application_manager Reference of application manager + **/ + NaviSetVideoConfigResponse( + 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_handle); + + /** + * @brief NaviSetVideoConfigResponse class destructor + **/ + virtual ~NaviSetVideoConfigResponse(); + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(NaviSetVideoConfigResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SET_VIDEO_CONFIG_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.h new file mode 100644 index 0000000000..f64bdf6ce0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.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_HMI_NAVI_SHOW_CONSTANT_TBT_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SHOW_CONSTANT_TBT_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviShowConstantTBTRequest command class + **/ +class NaviShowConstantTBTRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief NaviShowConstantTBTRequest class constructor + * + * @param message Incoming SmartObject message + **/ + NaviShowConstantTBTRequest( + 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 NaviShowConstantTBTRequest class destructor + **/ + virtual ~NaviShowConstantTBTRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(NaviShowConstantTBTRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SHOW_CONSTANT_TBT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_response.h new file mode 100644 index 0000000000..fd4da08cf0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_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_HMI_NAVI_SHOW_CONSTANT_TBT_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SHOW_CONSTANT_TBT_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviShowConstantTBTResponse command class + **/ +class NaviShowConstantTBTResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief NaviShowConstantTBTResponse class constructor + * + * @param message Incoming SmartObject message + **/ + NaviShowConstantTBTResponse( + 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_handle); + + /** + * @brief NaviShowConstantTBTResponse class destructor + **/ + virtual ~NaviShowConstantTBTResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(NaviShowConstantTBTResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SHOW_CONSTANT_TBT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h new file mode 100644 index 0000000000..d5aae67661 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h @@ -0,0 +1,95 @@ +/* + * 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_HMI_NAVI_START_STREAM_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_START_STREAM_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviStartStreamRequest command class + **/ +class NaviStartStreamRequest : public app_mngr::commands::RequestToHMI, + public app_mngr::event_engine::EventObserver { + public: + /** + * @brief NaviStartStreamRequest class constructor + * + * @param message Incoming SmartObject message + **/ + NaviStartStreamRequest(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_handle); + + /** + * @brief OnNaviStartStreamRequest class destructor + **/ + virtual ~NaviStartStreamRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief On event callback + **/ + virtual void on_event(const app_mngr::event_engine::Event& event); + + /** + * @brief onTimeOut from requrst Controller + */ + virtual void onTimeOut(); + + /** + * @brief RetryStartSession resend HMI startSession request if needed. + * If limit expired, set video_stream_retry_number counter to 0 + */ + void RetryStartSession(); + + private: + uint32_t retry_number_; + DISALLOW_COPY_AND_ASSIGN(NaviStartStreamRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_START_STREAM_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h new file mode 100644 index 0000000000..b4770e82fe --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h @@ -0,0 +1,76 @@ +/* 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_HMI_NAVI_START_STREAM_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_START_STREAM_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviStartStreamResponse command class + **/ +class NaviStartStreamResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief NaviStartStreamResponse class constructor + * + * @param message Incoming SmartObject message + **/ + NaviStartStreamResponse(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_handle); + + /** + * @brief NaviStartStreamResponse class destructor + **/ + virtual ~NaviStartStreamResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(NaviStartStreamResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_START_STREAM_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h new file mode 100644 index 0000000000..400c61ba07 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h @@ -0,0 +1,76 @@ +/* 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_HMI_NAVI_STOP_STREAM_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_STOP_STREAM_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviStopStreamRequest command class + **/ +class NaviStopStreamRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief NaviStopStreamRequest class constructor + * + * @param message Incoming SmartObject message + **/ + NaviStopStreamRequest(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_handle); + + /** + * @brief NaviStopStreamRequest class destructor + **/ + virtual ~NaviStopStreamRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(NaviStopStreamRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_STOP_STREAM_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_response.h new file mode 100644 index 0000000000..39512ac2bb --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_response.h @@ -0,0 +1,76 @@ +/* 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_HMI_NAVI_STOP_STREAM_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_STOP_STREAM_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviStopStreamResponse command class + **/ +class NaviStopStreamResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief NaviStopStreamResponse class constructor + * + * @param message Incoming SmartObject message + **/ + NaviStopStreamResponse(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_handle); + + /** + * @brief OnNaviStopStreamResponse class destructor + **/ + virtual ~NaviStopStreamResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(NaviStopStreamResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_STOP_STREAM_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h new file mode 100644 index 0000000000..052c3c7151 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h @@ -0,0 +1,76 @@ +/* + * 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_HMI_NAVI_SUBSCRIBE_WAY_POINTS_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SUBSCRIBE_WAY_POINTS_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviSubscribeWayPointsRequest command class + **/ +class NaviSubscribeWayPointsRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief NaviSubscribeWayPointsRequest class constructor + * + * @param message Incoming SmartObject message + **/ + NaviSubscribeWayPointsRequest( + const app_mngr::commands::MessageSharedPtr& messag, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + /** + * @brief NaviSubscribeWayPointsRequest class destructor + **/ + virtual ~NaviSubscribeWayPointsRequest(); + /** + * @brief Execute command + **/ + virtual void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(NaviSubscribeWayPointsRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SUBSCRIBE_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_response.h new file mode 100644 index 0000000000..73aab4633f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_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_HMI_NAVI_SUBSCRIBE_WAY_POINTS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SUBSCRIBE_WAY_POINTS_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviSubscribeWaypoints command class + **/ +class NaviSubscribeWayPointsResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief NaviSubscribeWaypoints class constructor + * + * @param message Incoming SmartObject message + **/ + NaviSubscribeWayPointsResponse( + 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_handle); + + /** + * @brief NaviSubscribeWaypoints class destructor + **/ + virtual ~NaviSubscribeWayPointsResponse(); + + /** + * @brief Execute command + **/ + virtual void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(NaviSubscribeWayPointsResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SUBSCRIBE_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h new file mode 100644 index 0000000000..6061858e5c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_NAVI_UNSUBSCRIBE_WAY_POINTS_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_UNSUBSCRIBE_WAY_POINTS_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviSubscribeWayPointsRequest command class + **/ +class NaviUnSubscribeWayPointsRequest + : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief NaviUnSubscribeWayPointsRequest class constructor + * + * @param message Incoming SmartObject message + **/ + NaviUnSubscribeWayPointsRequest( + 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_handle); + /** + * @brief NaviUnSubscribeWayPointsRequest class destructor + **/ + virtual ~NaviUnSubscribeWayPointsRequest(); + /** + * @brief Execute command + **/ + virtual void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(NaviUnSubscribeWayPointsRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_UNSUBSCRIBE_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h new file mode 100644 index 0000000000..3a02228b8b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_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_HMI_NAVI_UNSUBSCRIBE_WAY_POINTS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_UNSUBSCRIBE_WAY_POINTS_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviUnSubscribeWaypoints command class + **/ +class NaviUnsubscribeWayPointsResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief NaviUnSubscribeWaypoints class constructor + * + * @param message Incoming SmartObject message + **/ + NaviUnsubscribeWayPointsResponse( + 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_handle); + + /** + * @brief NaviUnSubscribeWaypoints class destructor + **/ + virtual ~NaviUnsubscribeWayPointsResponse(); + + /** + * @brief Execute command + **/ + virtual void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(NaviUnsubscribeWayPointsResponse); +}; + +} // namespace commands + +} // namespace application_manager +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_UNSUBSCRIBE_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h new file mode 100644 index 0000000000..db269a65d3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_NAVI_UPDATE_TURN_LIST_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_UPDATE_TURN_LIST_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviUpdateTurnListRequest command class + **/ +class NaviUpdateTurnListRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief NaviUpdateTurnListRequest class constructor + * + * @param message Incoming SmartObject message + **/ + NaviUpdateTurnListRequest(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_handle); + + /** + * @brief NaviUpdateTurnListRequest class destructor + **/ + virtual ~NaviUpdateTurnListRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(NaviUpdateTurnListRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_UPDATE_TURN_LIST_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_response.h new file mode 100644 index 0000000000..20295485a3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_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_HMI_NAVI_UPDATE_TURN_LIST_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_UPDATE_TURN_LIST_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief NaviUpdateTurnListResponse command class + **/ +class NaviUpdateTurnListResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief NaviUpdateTurnListResponse class constructor + * + * @param message Incoming SmartObject message + **/ + NaviUpdateTurnListResponse( + 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_handle); + + /** + * @brief NaviUpdateTurnListResponse class destructor + **/ + virtual ~NaviUpdateTurnListResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(NaviUpdateTurnListResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_UPDATE_TURN_LIST_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h new file mode 100644 index 0000000000..42bf877f2d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.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_HMI_ON_ALLOW_SDL_FUNCTIONALITY_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_ALLOW_SDL_FUNCTIONALITY_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnAllowSDLFunctionalityNotification command class + **/ +class OnAllowSDLFunctionalityNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnAllowSDLFunctionalityNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnAllowSDLFunctionalityNotification( + 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_handle); + + /** + * @brief OnAllowSDLFunctionalityNotification class destructor + **/ + virtual ~OnAllowSDLFunctionalityNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnAllowSDLFunctionalityNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_ALLOW_SDL_FUNCTIONALITY_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h new file mode 100644 index 0000000000..cc21d699fb --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_activated_notification.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_HMI_ON_APP_ACTIVATED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_ACTIVATED_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnAppActivatedNotification command class + **/ +class OnAppActivatedNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnAppActivatedNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnAppActivatedNotification( + 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_handle); + + /** + * @brief OnAppActivatedNotification class destructor + **/ + virtual ~OnAppActivatedNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnAppActivatedNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_ACTIVATED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h new file mode 100644 index 0000000000..9b4a6ba5a0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.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_HMI_ON_APP_DEACTIVATED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_DEACTIVATED_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnAppDeactivatedNotification command class + **/ +class OnAppDeactivatedNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnAppDeactivatedNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnAppDeactivatedNotification( + 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_handle); + + /** + * @brief OnAppDeactivatedNotification class destructor + **/ + virtual ~OnAppDeactivatedNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnAppDeactivatedNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_DEACTIVATED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h new file mode 100644 index 0000000000..6008a8ce51 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.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_HMI_ON_APP_PERMISSION_CHANGED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_PERMISSION_CHANGED_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnAppPermissionChangedNotification command class + **/ +class OnAppPermissionChangedNotification + : public app_mngr::commands::NotificationToHMI { + public: + /** + * @brief OnAppPermissionChangedNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnAppPermissionChangedNotification( + 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_handle); + + /** + * @brief OnAppPermissionChangedNotification class destructor + **/ + virtual ~OnAppPermissionChangedNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnAppPermissionChangedNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_PERMISSION_CHANGED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h new file mode 100644 index 0000000000..a751b25d85 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.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_HMI_ON_APP_PERMISSION_CONSENT_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_PERMISSION_CONSENT_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnAppPermissionConsentNotification command class + **/ +class OnAppPermissionConsentNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnAppPermissionConsentNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnAppPermissionConsentNotification( + 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_handle); + + /** + * @brief OnAppPermissionConsentNotification class destructor + **/ + virtual ~OnAppPermissionConsentNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnAppPermissionConsentNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_PERMISSION_CONSENT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_registered_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_registered_notification.h new file mode 100644 index 0000000000..3548786d1d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_registered_notification.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_HMI_ON_APP_REGISTERED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_REGISTERED_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnAppRegisteredNotification command class + **/ +class OnAppRegisteredNotification + : public app_mngr::commands::NotificationToHMI { + public: + /** + * @brief OnAppRegisteredNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnAppRegisteredNotification( + 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_handle); + + /** + * @brief OnAppRegisteredNotification class destructor + **/ + virtual ~OnAppRegisteredNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnAppRegisteredNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_REGISTERED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h new file mode 100644 index 0000000000..097eb1eb28 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h @@ -0,0 +1,89 @@ +/* + * 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_HMI_ON_APP_UNREGISTERED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_UNREGISTERED_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnAppUnregisteredNotification command class + **/ +class OnAppUnregisteredNotification + : public app_mngr::commands::NotificationToHMI { + public: + /** + * @brief OnAppUnregisteredNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnAppUnregisteredNotification( + 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_handle); + + /** + * @brief OnAppUnregisteredNotification class destructor + **/ + ~OnAppUnregisteredNotification() FINAL; + + /** + * @brief Init overrides and skips replacement of app id with hmi id since + * 1) at the moment this notification is being sent there is no application + * registered in application manager + * 2) hmi id is already used whenever this message is being constructed, so + * its already there + * @return True in any case + */ + bool Init() FINAL; + + /** + * @brief Execute command + **/ + virtual void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(OnAppUnregisteredNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_UNREGISTERED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_audio_data_streaming_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_audio_data_streaming_notification.h new file mode 100644 index 0000000000..cac306f760 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_audio_data_streaming_notification.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_HMI_ON_AUDIO_DATA_STREAMING_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_AUDIO_DATA_STREAMING_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnAudioDataStreamingNotification command class + **/ +class OnAudioDataStreamingNotification + : public app_mngr::commands::NotificationToHMI { + public: + /** + * @brief OnAudioDataStreamingNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnAudioDataStreamingNotification( + 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_handle); + + /** + * @brief OnAudioDataStreamingNotification class destructor + **/ + virtual ~OnAudioDataStreamingNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnAudioDataStreamingNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_AUDIO_DATA_STREAMING_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_event_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_event_notification.h new file mode 100644 index 0000000000..b83fe1bfe0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_event_notification.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_HMI_ON_BUTTON_EVENT_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BUTTON_EVENT_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +class Application; + +namespace commands { + +namespace hmi { + +/** + * @brief OnButtonEventNotification command class + **/ +class OnButtonEventNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnButtonEventNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnButtonEventNotification(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_handle); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnButtonEventNotification); +}; + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BUTTON_EVENT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_press_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_press_notification.h new file mode 100644 index 0000000000..e996c9952c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_press_notification.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_HMI_ON_BUTTON_PRESS_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BUTTON_PRESS_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +class Application; + +namespace commands { + +namespace hmi { + +/** + * @brief OnButtonPressNotification command class + **/ +class OnButtonPressNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnButtonPressNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnButtonPressNotification(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_handle); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnButtonPressNotification); +}; + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BUTTON_PRESS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_subscription_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_subscription_notification.h new file mode 100644 index 0000000000..4ed60f9a07 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_subscription_notification.h @@ -0,0 +1,83 @@ +/* + * 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_HMI_ON_BUTTON_SUBSCRIPTION_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BUTTON_SUBSCRIPTION_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +namespace hmi { + +/** + * @brief OnButtonSubscriptionNotification command class + **/ +class OnButtonSubscriptionNotification + : public app_mngr::commands::NotificationToHMI { + public: + /** + * @brief OnButtonSubscriptionNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnButtonSubscriptionNotification( + 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_handle); + + /** + * @brief OnButtonSubscriptionNotification class destructor + **/ + virtual ~OnButtonSubscriptionNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnButtonSubscriptionNotification); +}; + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BUTTON_SUBSCRIPTION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h new file mode 100644 index 0000000000..99c165c12f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.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_HMI_ON_DEVICE_CHOSEN_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_DEVICE_CHOSEN_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnDeviceChosenNotification command class + **/ +class OnDeviceChosenNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnDeviceChosenNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnDeviceChosenNotification( + 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_handle); + + /** + * @brief OnDeviceChosenNotification class destructor + **/ + virtual ~OnDeviceChosenNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnDeviceChosenNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_DEVICE_CHOSEN_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h new file mode 100644 index 0000000000..7701e2a601 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.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_HMI_ON_DEVICE_STATE_CHANGED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_DEVICE_STATE_CHANGED_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnDeviceStateChangedNotification command class + **/ +class OnDeviceStateChangedNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnDeviceStateChangedNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnDeviceStateChangedNotification( + 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_handle); + + /** + * @brief OnDeviceStateChangedNotification class destructor + **/ + virtual ~OnDeviceStateChangedNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnDeviceStateChangedNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_DEVICE_STATE_CHANGED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h new file mode 100644 index 0000000000..51fb49c6bc --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.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_HMI_ON_DRIVER_DISTRACTION_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_DRIVER_DISTRACTION_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +class Application; + +namespace commands { + +namespace hmi { + +/** + * @brief OnDriverDistractionNotification command class + **/ +class OnDriverDistractionNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnDriverDistractionNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnDriverDistractionNotification( + 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_handle); + + /** + * @brief OnDriverDistractionNotification class destructor + **/ + virtual ~OnDriverDistractionNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnDriverDistractionNotification); +}; + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_DRIVER_DISTRACTION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h new file mode 100644 index 0000000000..cff0a0e617 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_event_changed_notification.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_HMI_ON_EVENT_CHANGED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_EVENT_CHANGED_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnEventChangedNotification command class + **/ +class OnEventChangedNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnEventChangedNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnEventChangedNotification( + 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_handle); + + /** + * @brief OnEventChangedNotification class destructor + **/ + virtual ~OnEventChangedNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnEventChangedNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_EVENT_CHANGED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h new file mode 100644 index 0000000000..116932d87a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h @@ -0,0 +1,84 @@ +/* + * 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_HMI_ON_EXIT_ALL_APPLICATIONS_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_EXIT_ALL_APPLICATIONS_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnExitAllApplicationsNotification command class + **/ +class OnExitAllApplicationsNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnExitAllApplicationsNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnExitAllApplicationsNotification( + 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_handle); + + /** + * @brief OnExitAllApplicationsNotification class destructor + **/ + virtual ~OnExitAllApplicationsNotification(); + + /** + * @brief Execute command + **/ + void Run() FINAL; + + private: + /** + * @brief Notify's HMI that SDL stored all data required for resumption + **/ + void SendOnSDLPersistenceComplete(); + + DISALLOW_COPY_AND_ASSIGN(OnExitAllApplicationsNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_EXIT_ALL_APPLICATIONS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h new file mode 100644 index 0000000000..11c397bfe7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_application_notification.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_HMI_ON_EXIT_APPLICATION_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_EXIT_APPLICATION_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnExitApplicationNotification command class + **/ +class OnExitApplicationNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnExitApplicationNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnExitApplicationNotification( + 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_handle); + + /** + * @brief OnExitApplicationNotification class destructor + **/ + virtual ~OnExitApplicationNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnExitApplicationNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_EXIT_APPLICATION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h new file mode 100644 index 0000000000..38c5dcf535 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_ON_FILE_REMOVED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_FILE_REMOVED_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnFileRemovedNotification command class + **/ +class OnFileRemovedNotification : public app_mngr::commands::NotificationToHMI { + public: + /** + * @brief OnFileRemovedNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnFileRemovedNotification(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_handle); + + /** + * @brief OnFileRemovedNotification class destructor + **/ + virtual ~OnFileRemovedNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnFileRemovedNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_FILE_REMOVED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_find_applications.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_find_applications.h new file mode 100644 index 0000000000..672ded9dcf --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_find_applications.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_ON_FIND_APPLICATIONS_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_FIND_APPLICATIONS_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnFindApplications command class + **/ +class OnFindApplications : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnFindApplications class constructor + * + * @param message Incoming SmartObject message + **/ + OnFindApplications(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_handle); + + /** + * @brief OnFindApplications class destructor + **/ + virtual ~OnFindApplications(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnFindApplications); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_FIND_APPLICATIONS_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h new file mode 100644 index 0000000000..85b7ed356e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.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_HMI_ON_IGNITION_CYCLE_OVER_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_IGNITION_CYCLE_OVER_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnIgnitionCycleOverNotification command class + **/ +class OnIgnitionCycleOverNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnIgnitionCycleOverNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnIgnitionCycleOverNotification( + 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_handle); + + /** + * @brief OnIgnitionCycleOverNotification class destructor + **/ + virtual ~OnIgnitionCycleOverNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnIgnitionCycleOverNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_IGNITION_CYCLE_OVER_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h new file mode 100644 index 0000000000..075dc2cb5c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.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_HMI_ON_NAVI_TBT_CLIENT_STATE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_NAVI_TBT_CLIENT_STATE_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnNaviTBTClientStateNotification command class + **/ +class OnNaviTBTClientStateNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnNaviTBTClientStateNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnNaviTBTClientStateNotification( + 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_handle); + + /** + * @brief OnNaviTBTClientStateNotification class destructor + **/ + virtual ~OnNaviTBTClientStateNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnNaviTBTClientStateNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_NAVI_TBT_CLIENT_STATE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h new file mode 100644 index 0000000000..3efde9c8c1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.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_HMI_ON_NAVI_WAY_POINT_CHANGE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_NAVI_WAY_POINT_CHANGE_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnNaviWayPointChangeNotification command class + **/ +class OnNaviWayPointChangeNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnNaviWayPointChangeNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnNaviWayPointChangeNotification( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& app_man, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief OnNaviWayPointChangeNotification class destructor + **/ + virtual ~OnNaviWayPointChangeNotification(); + + /** + * @brief Execute command + **/ + virtual void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(OnNaviWayPointChangeNotification); +}; + +} // namespace commands + +} // namespace application_manager +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_NAVI_WAY_POINT_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_policy_update.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_policy_update.h new file mode 100644 index 0000000000..331e352795 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_policy_update.h @@ -0,0 +1,71 @@ +/* + * 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_HMI_ON_POLICY_UPDATE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_POLICY_UPDATE_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +class OnPolicyUpdate : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnPolicyUpdate class constructor + * + * @param message Incoming SmartObject message + **/ + OnPolicyUpdate(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_handle); + + /** + * @brief OnPolicyUpdate class destructor + **/ + virtual ~OnPolicyUpdate(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnPolicyUpdate); +}; +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_POLICY_UPDATE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_put_file_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_put_file_notification.h new file mode 100644 index 0000000000..503013ff58 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_put_file_notification.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_HMI_ON_PUT_FILE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_PUT_FILE_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" +#include "application_manager/application_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnPutFileNotification command class + **/ +class OnPutFileNotification : public app_mngr::commands::NotificationToHMI { + public: + /** + * @brief OnPutFileNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnPutFileNotification(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_handle); + + /** + * @brief OnPutFileNotification class destructor + **/ + virtual ~OnPutFileNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnPutFileNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_PUT_FILE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ready_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ready_notification.h new file mode 100644 index 0000000000..c4adc20090 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ready_notification.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_HMI_ON_READY_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_READY_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnReadyNotification command class + **/ +class OnReadyNotification : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnReadyNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnReadyNotification(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_handle); + + /** + * @brief OnReadyNotification class destructor + **/ + virtual ~OnReadyNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnReadyNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_READY_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_received_policy_update.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_received_policy_update.h new file mode 100644 index 0000000000..c1e1b01a18 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_received_policy_update.h @@ -0,0 +1,74 @@ +/* + * 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_HMI_ON_RECEIVED_POLICY_UPDATE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RECEIVED_POLICY_UPDATE_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +class OnReceivedPolicyUpdate : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnReceivedPolicyUpdate class constructor + * + * @param message Incoming SmartObject message + **/ + OnReceivedPolicyUpdate(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_handle); + + /** + * @brief OnReceivedPolicyUpdate class destructor + **/ + ~OnReceivedPolicyUpdate() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(OnReceivedPolicyUpdate); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RECEIVED_POLICY_UPDATE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_record_start_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_record_start_notification.h new file mode 100644 index 0000000000..c5755a364c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_record_start_notification.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_HMI_ON_RECORD_START_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RECORD_START_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnRecordStartdNotification command class + **/ +class OnRecordStartdNotification + : public app_mngr::commands::NotificationToHMI { + public: + /** + * @brief OnRecordStartdNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnRecordStartdNotification( + 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_handle); + + /** + * @brief OnRecordStartdNotification class destructor + **/ + virtual ~OnRecordStartdNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnRecordStartdNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RECORD_START_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_resume_audio_source_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_resume_audio_source_notification.h new file mode 100644 index 0000000000..ef2b5a34eb --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_resume_audio_source_notification.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_HMI_ON_RESUME_AUDIO_SOURCE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RESUME_AUDIO_SOURCE_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" +#include "application_manager/application_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnResumeAudioSourceNotification command class + **/ +class OnResumeAudioSourceNotification + : public app_mngr::commands::NotificationToHMI { + public: + /** + * @brief OnResumeAudioSourceNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnResumeAudioSourceNotification( + 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_handle); + + /** + * @brief OnResumeAudioSourceNotification class destructor + **/ + virtual ~OnResumeAudioSourceNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnResumeAudioSourceNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RESUME_AUDIO_SOURCE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h new file mode 100644 index 0000000000..34fe41de81 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_ON_SDL_CLOSE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SDL_CLOSE_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnSDLCloseNotification command class + **/ +class OnSDLCloseNotification : public app_mngr::commands::NotificationToHMI { + public: + /** + * @brief OnSDLCloseNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnSDLCloseNotification(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_handle); + + /** + * @brief OnSdlCloseNotification class destructor + **/ + virtual ~OnSDLCloseNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnSDLCloseNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SDL_CLOSE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h new file mode 100644 index 0000000000..9fe736a595 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.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_HMI_ON_SDL_CONSENT_NEEDED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SDL_CONSENT_NEEDED_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnSDLConsentNeededNotification command class + **/ +class OnSDLConsentNeededNotification + : public app_mngr::commands::NotificationToHMI { + public: + /** + * @brief OnSDLConsentNeededNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnSDLConsentNeededNotification( + 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_handle); + + /** + * @brief OnSDLConsentNeededNotification class destructor + **/ + virtual ~OnSDLConsentNeededNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnSDLConsentNeededNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SDL_CONSENT_NEEDED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.h new file mode 100644 index 0000000000..96f63845e1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.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_HMI_ON_SDL_PERSISTENCE_COMPLETE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SDL_PERSISTENCE_COMPLETE_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnSDLPersistenceCompleteNotification command class + **/ +class OnSDLPersistenceCompleteNotification + : public app_mngr::commands::NotificationToHMI { + public: + /** + * @brief OnSDLPersistenceCompleteNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnSDLPersistenceCompleteNotification( + 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_handle); + + /** + * @brief OnSDLPersistenceCompleteNotification class destructor + **/ + virtual ~OnSDLPersistenceCompleteNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnSDLPersistenceCompleteNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SDL_PERSISTENCE_COMPLETE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h new file mode 100644 index 0000000000..da049b1dc4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_ON_START_DEVICE_DISCOVERY_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_START_DEVICE_DISCOVERY_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnStartDeviceDiscovery command class + **/ +class OnStartDeviceDiscovery : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnStartDeviceDiscovery class constructor + * + * @param message Incoming SmartObject message + **/ + OnStartDeviceDiscovery(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_handle); + + /** + * @brief OnStartDeviceDiscovery class destructor + **/ + virtual ~OnStartDeviceDiscovery(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnStartDeviceDiscovery); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_START_DEVICE_DISCOVERY_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_status_update_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_status_update_notification.h new file mode 100644 index 0000000000..7c61fac041 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_status_update_notification.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_HMI_ON_STATUS_UPDATE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_STATUS_UPDATE_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnGetStatusUpdateNotification command class + **/ +class OnStatusUpdateNotification + : public app_mngr::commands::NotificationToHMI { + public: + /** + * @brief OnGetStatusUpdateNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnStatusUpdateNotification( + 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_handle); + + /** + * @brief OnGetStatusUpdateNotification class destructor + **/ + virtual ~OnStatusUpdateNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnStatusUpdateNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_STATUS_UPDATE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_context_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_context_notification.h new file mode 100644 index 0000000000..d4c940bac7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_context_notification.h @@ -0,0 +1,81 @@ +/* + * 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_HMI_ON_SYSTEM_CONTEXT_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_CONTEXT_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +namespace mobile_api = mobile_apis; +/** + * @brief OnSystemContextNotification command class + **/ +class OnSystemContextNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnSystemContextNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnSystemContextNotification( + 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_handle); + + /** + * @brief OnSystemContextNotification class destructor + **/ + virtual ~OnSystemContextNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnSystemContextNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_CONTEXT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_error_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_error_notification.h new file mode 100644 index 0000000000..76325b078f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_error_notification.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_HMI_ON_SYSTEM_ERROR_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_ERROR_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnSystemErrorNotification command class + **/ +class OnSystemErrorNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnSystemErrorNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnSystemErrorNotification(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_handle); + + /** + * @brief OnSystemErrorNotification class destructor + **/ + virtual ~OnSystemErrorNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnSystemErrorNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_ERROR_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h new file mode 100644 index 0000000000..1e4046b83b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.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_HMI_ON_SYSTEM_INFO_CHANGED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_INFO_CHANGED_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnSystemInfoChangedNotification command class + **/ +class OnSystemInfoChangedNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnSystemInfoChangedNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnSystemInfoChangedNotification( + 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_handle); + + /** + * @brief OnSystemInfoChangedNotification class destructor + **/ + virtual ~OnSystemInfoChangedNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnSystemInfoChangedNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_INFO_CHANGED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_request_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_request_notification.h new file mode 100644 index 0000000000..1e1e1818b8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_request_notification.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_HMI_ON_SYSTEM_REQUEST_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_REQUEST_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnSystemRequestNotification command class + **/ +class OnSystemRequestNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnSystemRequestNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnSystemRequestNotification( + 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_handle); + + /** + * @brief OnSystemRequestNotification class destructor + **/ + virtual ~OnSystemRequestNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnSystemRequestNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_REQUEST_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h new file mode 100644 index 0000000000..0beba8dc6b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.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_HMI_ON_SYSTEM_TIME_READY_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_TIME_READY_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +/** + * @brief OnSystemTimeReadyNotification command class. + * Notifies SDL whenever system time module is ready. + * It could be GPS or any other module which is allows + * to obtain system time. Once SDL receive this notification + * it is allowed to use GetSystemTimeRequest to rerieve system time. + */ +class OnSystemTimeReadyNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnSystemTimeReadyNotification create the command. + * @param message content of the command. Passed directy to base class. + */ + OnSystemTimeReadyNotification( + 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 ~OnSystemTimeReadyNotification destroys the command object. + */ + ~OnSystemTimeReadyNotification(); + + /** + * @brief Run creates SystemTimeReady event + * and notifies all the subscribers. + */ + void Run() FINAL; +}; + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_TIME_READY_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h new file mode 100644 index 0000000000..33c7d98b6f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.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_HMI_ON_TTS_LANGUAGE_CHANGE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_LANGUAGE_CHANGE_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnTTSLanguageChangeNotification command class + **/ +class OnTTSLanguageChangeNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnTTSLanguageChangeNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnTTSLanguageChangeNotification( + 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_handle); + + /** + * @brief OnTTSLanguageChangeNotification class destructor + **/ + virtual ~OnTTSLanguageChangeNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnTTSLanguageChangeNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_LANGUAGE_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h new file mode 100644 index 0000000000..70050a667e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h @@ -0,0 +1,83 @@ +/* + * 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_HMI_ON_TTS_RESET_TIMEOUT_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_RESET_TIMEOUT_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +namespace hmi { + +/** + * @brief OnTTSResetTimeoutNotification command class + **/ +class OnTTSResetTimeoutNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnTTSResetTimeoutNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnTTSResetTimeoutNotification( + 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_handle); + + /** + * @brief OnTTSResetTimeoutNotification class destructor + **/ + virtual ~OnTTSResetTimeoutNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnTTSResetTimeoutNotification); +}; + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_RESET_TIMEOUT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h new file mode 100644 index 0000000000..93dac3f292 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_started_notification.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_HMI_ON_TTS_STARTED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_STARTED_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnTTSStartedNotification command class + **/ +class OnTTSStartedNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnTTSStartedNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnTTSStartedNotification(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_handle); + + /** + * @brief OnTTSStartedNotification class destructor + **/ + virtual ~OnTTSStartedNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnTTSStartedNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_STARTED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h new file mode 100644 index 0000000000..362e96f4be --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.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_HMI_ON_TTS_STOPPED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_STOPPED_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnTTSStoppedNotification command class + **/ +class OnTTSStoppedNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnTTSStoppedNotification class constructor + * + * @param message Incoming SmartObject OnTTSStartedNotificationmessage + **/ + OnTTSStoppedNotification(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_handle); + + /** + * @brief OnTTSStoppedNotification class destructor + **/ + virtual ~OnTTSStoppedNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnTTSStoppedNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_STOPPED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h new file mode 100644 index 0000000000..0cc4e9e772 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_ON_UI_COMMAND_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_COMMAND_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnUICommandNotification command class + **/ +class OnUICommandNotification : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnUICommandNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnUICommandNotification(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_handle); + + /** + * @brief OnUICommandNotification class destructor + **/ + virtual ~OnUICommandNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnUICommandNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_COMMAND_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h new file mode 100644 index 0000000000..c487894770 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h @@ -0,0 +1,84 @@ +/* + * 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_HMI_ON_UI_KEYBOARD_INPUT_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_KEYBOARD_INPUT_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +namespace hmi { + +/** + * @brief OnUIKeyBoardInputNotification command class + **/ +class OnUIKeyBoardInputNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnUIKeyBoardInputNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnUIKeyBoardInputNotification( + 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_handle); + + /** + * @brief OnUIKeyBoardInputNotification class destructor + **/ + virtual ~OnUIKeyBoardInputNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnUIKeyBoardInputNotification); +}; + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_KEYBOARD_INPUT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h new file mode 100644 index 0000000000..f30b8573aa --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.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_HMI_ON_UI_LANGUAGE_CHANGE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_LANGUAGE_CHANGE_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnUILanguageChangeNotification command class + **/ +class OnUILanguageChangeNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnUILanguageChangeNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnUILanguageChangeNotification( + 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_handle); + + /** + * @brief OnUILanguageChangeNotification class destructor + **/ + virtual ~OnUILanguageChangeNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnUILanguageChangeNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_LANGUAGE_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h new file mode 100644 index 0000000000..bbdf4d04ef --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h @@ -0,0 +1,83 @@ +/* + * 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_HMI_ON_UI_RESET_TIMEOUT_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_RESET_TIMEOUT_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +namespace hmi { + +/** + * @brief OnUIResetTimeoutNotification command class + **/ +class OnUIResetTimeoutNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnUIResetTimeoutNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnUIResetTimeoutNotification( + 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_handle); + + /** + * @brief OnUIResetTimeoutNotification class destructor + **/ + virtual ~OnUIResetTimeoutNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnUIResetTimeoutNotification); +}; + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_RESET_TIMEOUT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h new file mode 100644 index 0000000000..5c7dd0128b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h @@ -0,0 +1,84 @@ +/* + * 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_HMI_ON_UI_TOUCH_EVENT_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_TOUCH_EVENT_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +namespace hmi { + +/** + * @brief OnUITouchEventNotification command class + **/ +class OnUITouchEventNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnUITouchEventNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnUITouchEventNotification( + 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_handle); + + /** + * @brief OnUITouchEventNotification class destructor + **/ + virtual ~OnUITouchEventNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnUITouchEventNotification); +}; + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_TOUCH_EVENT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_update_device_list.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_update_device_list.h new file mode 100644 index 0000000000..2942c36053 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_update_device_list.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_ON_UPDATE_DEVICE_LIST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UPDATE_DEVICE_LIST_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnUpdateDeviceList command class + **/ +class OnUpdateDeviceList : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnUpdateDeviceList class constructor + * + * @param message Incoming SmartObject message + **/ + OnUpdateDeviceList(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_handle); + + /** + * @brief OnUpdateDeviceList class destructor + **/ + virtual ~OnUpdateDeviceList(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnUpdateDeviceList); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UPDATE_DEVICE_LIST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_acc_pedal_position_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_acc_pedal_position_notification.h new file mode 100644 index 0000000000..ed0b1572ff --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_acc_pedal_position_notification.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_HMI_ON_VI_ACC_PEDAL_POSITION_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ACC_PEDAL_POSITION_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVIAccPedalPositionNotification command class + **/ +class OnVIAccPedalPositionNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVIAccPedalPositionNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVIAccPedalPositionNotification( + 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_handle); + + /** + * @brief OnVIAccPedalPositionNotification class destructor + **/ + virtual ~OnVIAccPedalPositionNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVIAccPedalPositionNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ACC_PEDAL_POSITION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_belt_status_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_belt_status_notification.h new file mode 100644 index 0000000000..cc81160ccb --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_belt_status_notification.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_HMI_ON_VI_BELT_STATUS_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_BELT_STATUS_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVIBeltStatusNotification command class + **/ +class OnVIBeltStatusNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVIBeltStatusNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVIBeltStatusNotification( + 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_handle); + + /** + * @brief OnVIBeltStatusNotification class destructor + **/ + virtual ~OnVIBeltStatusNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVIBeltStatusNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_BELT_STATUS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_body_information_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_body_information_notification.h new file mode 100644 index 0000000000..2b46b69f55 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_body_information_notification.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_HMI_ON_VI_BODY_INFORMATION_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_BODY_INFORMATION_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVIBodyInformationNotification command class + **/ +class OnVIBodyInformationNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVIBodyInformationNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVIBodyInformationNotification( + 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_handle); + + /** + * @brief OnVIBodyInformationNotification class destructor + **/ + virtual ~OnVIBodyInformationNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVIBodyInformationNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_BODY_INFORMATION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_device_status_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_device_status_notification.h new file mode 100644 index 0000000000..05da9a775d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_device_status_notification.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_HMI_ON_VI_DEVICE_STATUS_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_DEVICE_STATUS_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVIDeviceStatusNotification command class + **/ +class OnVIDeviceStatusNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVIDeviceStatusNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVIDeviceStatusNotification( + 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_handle); + + /** + * @brief OnVIDeviceStatusNotification class destructor + **/ + virtual ~OnVIDeviceStatusNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVIDeviceStatusNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_DEVICE_STATUS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_driver_braking_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_driver_braking_notification.h new file mode 100644 index 0000000000..6640d7953a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_driver_braking_notification.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_HMI_ON_VI_DRIVER_BRAKING_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_DRIVER_BRAKING_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVIDriverBrakingNotification command class + **/ +class OnVIDriverBrakingNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVIDriverBrakingNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVIDriverBrakingNotification( + 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_handle); + + /** + * @brief OnVIDriverBrakingNotification class destructor + **/ + virtual ~OnVIDriverBrakingNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVIDriverBrakingNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_DRIVER_BRAKING_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_engine_torque_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_engine_torque_notification.h new file mode 100644 index 0000000000..f8c0526f8c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_engine_torque_notification.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_HMI_ON_VI_ENGINE_TORQUE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ENGINE_TORQUE_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVIEngineTorqueNotification command class + **/ +class OnVIEngineTorqueNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVIEngineTorqueNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVIEngineTorqueNotification( + 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_handle); + + /** + * @brief OnVIEngineTorqueNotification class destructor + **/ + virtual ~OnVIEngineTorqueNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVIEngineTorqueNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ENGINE_TORQUE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_external_temperature_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_external_temperature_notification.h new file mode 100644 index 0000000000..900aecd845 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_external_temperature_notification.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_HMI_ON_VI_EXTERNAL_TEMPERATURE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_EXTERNAL_TEMPERATURE_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVIExternalTemperatureNotification command class + **/ +class OnVIExternalTemperatureNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVIExternalTemperatureNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVIExternalTemperatureNotification( + 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_handle); + + /** + * @brief OnVIExternalTemperatureNotification class destructor + **/ + virtual ~OnVIExternalTemperatureNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVIExternalTemperatureNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_EXTERNAL_TEMPERATURE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_notification.h new file mode 100644 index 0000000000..7374de9ad9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_notification.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_HMI_ON_VI_FUEL_LEVEL_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_FUEL_LEVEL_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVIFuelLevelNotification command class + **/ +class OnVIFuelLevelNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVIFuelLevelNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVIFuelLevelNotification(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_handle); + + /** + * @brief OnVIFuelLevelNotification class destructor + **/ + virtual ~OnVIFuelLevelNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVIFuelLevelNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_FUEL_LEVEL_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_state_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_state_notification.h new file mode 100644 index 0000000000..a705fcbd04 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_state_notification.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_HMI_ON_VI_FUEL_LEVEL_STATE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_FUEL_LEVEL_STATE_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVIFuelLevelStateNotification command class + **/ +class OnVIFuelLevelStateNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVIFuelLevelStateNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVIFuelLevelStateNotification( + 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_handle); + + /** + * @brief OnVIFuelLevelStateNotification class destructor + **/ + virtual ~OnVIFuelLevelStateNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVIFuelLevelStateNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_FUEL_LEVEL_STATE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_gps_data_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_gps_data_notification.h new file mode 100644 index 0000000000..984e1e4c0b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_gps_data_notification.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_HMI_ON_VI_GPS_DATA_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_GPS_DATA_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVIGpsDataNotification command class + **/ +class OnVIGpsDataNotification : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVIGpsDataNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVIGpsDataNotification(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_handle); + + /** + * @brief OnVIGpsDataNotification class destructor + **/ + virtual ~OnVIGpsDataNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVIGpsDataNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_GPS_DATA_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_head_lamp_status_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_head_lamp_status_notification.h new file mode 100644 index 0000000000..1dfda8a9e0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_head_lamp_status_notification.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_HMI_ON_VI_HEAD_LAMP_STATUS_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_HEAD_LAMP_STATUS_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVIHeadLampStatusNotification command class + **/ +class OnVIHeadLampStatusNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVIHeadLampStatusNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVIHeadLampStatusNotification( + 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_handle); + + /** + * @brief OnVIHeadLampStatusNotification class destructor + **/ + virtual ~OnVIHeadLampStatusNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVIHeadLampStatusNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_HEAD_LAMP_STATUS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_instant_fuel_consumption_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_instant_fuel_consumption_notification.h new file mode 100644 index 0000000000..fd8743907c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_instant_fuel_consumption_notification.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_HMI_ON_VI_INSTANT_FUEL_CONSUMPTION_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_INSTANT_FUEL_CONSUMPTION_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVIInstantFuelConsumptionNotification command class + **/ +class OnVIInstantFuelConsumptionNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVIInstantFuelConsumptionNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVIInstantFuelConsumptionNotification( + 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_handle); + + /** + * @brief OnVIInstantFuelConsumptionNotification class destructor + **/ + virtual ~OnVIInstantFuelConsumptionNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVIInstantFuelConsumptionNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_INSTANT_FUEL_CONSUMPTION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_my_key_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_my_key_notification.h new file mode 100644 index 0000000000..25ace2821d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_my_key_notification.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_HMI_ON_VI_MY_KEY_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_MY_KEY_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVIMyKeyNotification command class + **/ +class OnVIMyKeyNotification : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVIMyKeyNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVIMyKeyNotification(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_handle); + + /** + * @brief OnVIMyKeyNotification class destructor + **/ + virtual ~OnVIMyKeyNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVIMyKeyNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_MY_KEY_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_odometer_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_odometer_notification.h new file mode 100644 index 0000000000..ad141e733c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_odometer_notification.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_HMI_ON_VI_ODOMETER_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ODOMETER_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVIOdometerNotification command class + **/ +class OnVIOdometerNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVIOdometerNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVIOdometerNotification(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_handle); + + /** + * @brief OnVIOdometerNotification class destructor + **/ + virtual ~OnVIOdometerNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVIOdometerNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ODOMETER_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_prndl_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_prndl_notification.h new file mode 100644 index 0000000000..95fb873957 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_prndl_notification.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_HMI_ON_VI_PRNDL_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_PRNDL_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVIPrndlNotification command class + **/ +class OnVIPrndlNotification : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVIPrndlNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVIPrndlNotification(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_handle); + + /** + * @brief OnVIPrndlNotification class destructor + **/ + virtual ~OnVIPrndlNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVIPrndlNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_PRNDL_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_rpm_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_rpm_notification.h new file mode 100644 index 0000000000..d4b121a96f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_rpm_notification.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_HMI_ON_VI_RPM_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_RPM_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVIRpmNotification command class + **/ +class OnVIRpmNotification : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVIRpmNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVIRpmNotification(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_handle); + + /** + * @brief OnVIRpmNotification class destructor + **/ + virtual ~OnVIRpmNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVIRpmNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_RPM_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_speed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_speed_notification.h new file mode 100644 index 0000000000..4afaafc9ff --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_speed_notification.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_HMI_ON_VI_SPEED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_SPEED_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVISpeedNotification command class + **/ +class OnVISpeedNotification : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVISpeedNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVISpeedNotification(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_handle); + + /** + * @brief OnVISpeedNotification class destructor + **/ + virtual ~OnVISpeedNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVISpeedNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_SPEED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_steering_wheel_angle_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_steering_wheel_angle_notification.h new file mode 100644 index 0000000000..0d0aeadad8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_steering_wheel_angle_notification.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_HMI_ON_VI_STEERING_WHEEL_ANGLE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_STEERING_WHEEL_ANGLE_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVISteeringWheelAngleNotification command class + **/ +class OnVISteeringWheelAngleNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVISteeringWheelAngleNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVISteeringWheelAngleNotification( + 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_handle); + + /** + * @brief OnVISteeringWheelAngleNotification class destructor + **/ + virtual ~OnVISteeringWheelAngleNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVISteeringWheelAngleNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_STEERING_WHEEL_ANGLE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_tire_pressure_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_tire_pressure_notification.h new file mode 100644 index 0000000000..c358ed37e9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_tire_pressure_notification.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_HMI_ON_VI_TIRE_PRESSURE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_TIRE_PRESSURE_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVITirePressureNotification command class + **/ +class OnVITirePressureNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVITirePressureNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVITirePressureNotification( + 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_handle); + + /** + * @brief OnVITirePressureNotification class destructor + **/ + virtual ~OnVITirePressureNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVITirePressureNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_TIRE_PRESSURE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_vin_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_vin_notification.h new file mode 100644 index 0000000000..75062a51e1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_vin_notification.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_HMI_ON_VI_VIN_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_VIN_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVIVinNotification command class + **/ +class OnVIVinNotification : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVIVinNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVIVinNotification(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_handle); + + /** + * @brief OnVIVinNotification class destructor + **/ + virtual ~OnVIVinNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVIVinNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_VIN_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_wiper_status_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_wiper_status_notification.h new file mode 100644 index 0000000000..de7a5dfc9e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_wiper_status_notification.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_HMI_ON_VI_WIPER_STATUS_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_WIPER_STATUS_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVIWiperStatusNotification command class + **/ +class OnVIWiperStatusNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVIWiperStatusNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVIWiperStatusNotification( + 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_handle); + + /** + * @brief OnVIWiperStatusNotification class destructor + **/ + virtual ~OnVIWiperStatusNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVIWiperStatusNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_WIPER_STATUS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h new file mode 100644 index 0000000000..7a7cf3cd96 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.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_HMI_ON_VIDEO_DATA_STREAMING_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VIDEO_DATA_STREAMING_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVideoDataStreamingNotification command class + **/ +class OnVideoDataStreamingNotification + : public app_mngr::commands::NotificationToHMI { + public: + /** + * @brief OnVideoDataStreamingNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVideoDataStreamingNotification( + 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_handle); + + /** + * @brief OnVideoDataStreamingNotification class destructor + **/ + virtual ~OnVideoDataStreamingNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVideoDataStreamingNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VIDEO_DATA_STREAMING_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h new file mode 100644 index 0000000000..3ef21fc568 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_command_notification.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_HMI_ON_VR_COMMAND_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_COMMAND_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/application_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVRCommandNotification command class + **/ +class OnVRCommandNotification : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVRCommandNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVRCommandNotification(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_handle); + + /** + * @brief OnVRCommandNotification class destructor + **/ + virtual ~OnVRCommandNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVRCommandNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_COMMAND_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h new file mode 100644 index 0000000000..e6bd39d46e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.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_HMI_ON_VR_LANGUAGE_CHANGE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_LANGUAGE_CHANGE_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVRLanguageChangeNotification command class + **/ +class OnVRLanguageChangeNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVRLanguageChangeNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVRLanguageChangeNotification( + 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_handle); + + /** + * @brief OnVRLanguageChangeNotification class destructor + **/ + virtual ~OnVRLanguageChangeNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVRLanguageChangeNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_LANGUAGE_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h new file mode 100644 index 0000000000..abca9db91d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_ON_VR_STARTED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_STARTED_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVRStartedNotification command class + **/ +class OnVRStartedNotification : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVRStartedNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVRStartedNotification(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_handle); + + /** + * @brief OnVRStartedNotification class destructor + **/ + virtual ~OnVRStartedNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVRStartedNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_STARTED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h new file mode 100644 index 0000000000..9b53214f8f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_ON_VR_STOPPED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_STOPPED_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnVRStoppedNotification command class + **/ +class OnVRStoppedNotification : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnVRStoppedNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnVRStoppedNotification(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_handle); + + /** + * @brief OnVRStoppedNotification class destructor + **/ + virtual ~OnVRStoppedNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnVRStoppedNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_STOPPED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h new file mode 100644 index 0000000000..8f94d4876a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_RC_GET_CAPABILITIES_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_GET_CAPABILITIES_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief RCGetCapabilitiesRequest command class + **/ +class RCGetCapabilitiesRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief RCGetCapabilitiesRequest class constructor + * + * @param message Incoming SmartObject message + **/ + RCGetCapabilitiesRequest(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_handle); + + /** + * @brief RCGetCapabilitiesRequest class destructor + **/ + virtual ~RCGetCapabilitiesRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(RCGetCapabilitiesRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_GET_CAPABILITIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h new file mode 100644 index 0000000000..dec31c9ea1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_RC_GET_CAPABILITIES_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_GET_CAPABILITIES_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief RCGetCapabilitiesResponse command class + **/ +class RCGetCapabilitiesResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief RCGetCapabilitiesResponse class constructor + * + * @param message Incoming SmartObject message + **/ + RCGetCapabilitiesResponse(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_handle); + + /** + * @brief RCGetCapabilitiesResponse class destructor + **/ + virtual ~RCGetCapabilitiesResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(RCGetCapabilitiesResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_GET_CAPABILITIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_request.h new file mode 100644 index 0000000000..3ba614f823 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_request.h @@ -0,0 +1,94 @@ +/* + * 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_HMI_RC_IS_READY_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_IS_READY_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief RCIsReadyRequest command class + **/ +class RCIsReadyRequest : public app_mngr::commands::RequestToHMI, + public app_mngr::event_engine::EventObserver { + public: + /** + * @brief RCIsReadyRequest class constructor + * + * @param message Incoming SmartObject message + **/ + RCIsReadyRequest(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_handle); + + /** + * @brief RCIsReadyRequest class destructor + **/ + virtual ~RCIsReadyRequest(); + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + /** + * @brief On event callback + **/ + void on_event(const app_mngr::event_engine::Event& event) OVERRIDE; + + /** + * @brief onTimeOut from requrst Controller + */ + void onTimeOut() OVERRIDE; + + /** + * @brief Send request to HMI for fetching of cappabilities + */ + void SendMessageToHMI(); + + private: + DISALLOW_COPY_AND_ASSIGN(RCIsReadyRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_IS_READY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h new file mode 100644 index 0000000000..93f30e795c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_RC_IS_READY_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_IS_READY_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief RCIsReadyResponse command class + **/ +class RCIsReadyResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief RCIsReadyResponse class constructor + * + * @param message Incoming SmartObject message + **/ + RCIsReadyResponse(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_handle); + + /** + * @brief RCIsReadyResponse class destructor + **/ + virtual ~RCIsReadyResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(RCIsReadyResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_IS_READY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h new file mode 100644 index 0000000000..e97312b881 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h @@ -0,0 +1,114 @@ +/* + * 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_HMI_SDL_ACTIVATE_APP_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_ACTIVATE_APP_REQUEST_H_ + +#include "application_manager/commands/request_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SDLActivateAppRequest command class + **/ +class SDLActivateAppRequest : public app_mngr::commands::RequestFromHMI { + public: + /** + * @brief Applications registered over protocol v4 + */ + typedef std::vector<application_manager::ApplicationSharedPtr> V4ProtoApps; + + /** + * @brief SDLActivateAppRequest class constructor + * + * @param message Incoming SmartObject message + **/ + SDLActivateAppRequest(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_handle); + + /** + * @brief SDLActivateAppRequest class destructor + **/ + ~SDLActivateAppRequest() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + /** + * @brief onTimeOut allows to process case when timeout has appeared + * during request execution. + */ + void onTimeOut() OVERRIDE; + + /** + * @brief on_event allows to handle events + * + * @param event event type that current request subscribed on. + */ + void on_event(const app_mngr::event_engine::Event& event) OVERRIDE; + + private: + uint32_t app_id() const; + uint32_t hmi_app_id(const smart_objects::SmartObject& so) const; + + /** + * @brief Retrieves all v4 protocol applications for particular device + * @param handle Device handle + * @return List of applications registered over v4 protocol + */ + V4ProtoApps get_v4_proto_apps( + const connection_handler::DeviceHandle handle) const; + + /** + * @brief Get v4 protocol application reported as forgrounded on device + * @param handle Device + * @return Pointer to application or empty pointer + */ + app_mngr::ApplicationSharedPtr get_foreground_app( + const connection_handler::DeviceHandle handle) const; + + DISALLOW_COPY_AND_ASSIGN(SDLActivateAppRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_ACTIVATE_APP_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h new file mode 100644 index 0000000000..7a3f5157da --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h @@ -0,0 +1,76 @@ +/* + * 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_HMI_SDL_ACTIVATE_APP_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_ACTIVATE_APP_RESPONSE_H_ + +#include "application_manager/commands/response_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SDLActivateAppResponse command class + **/ +class SDLActivateAppResponse : public app_mngr::commands::ResponseToHMI { + public: + /** + * @brief SDLActivateAppResponse class constructor + * + * @param message Incoming SmartObject message + **/ + SDLActivateAppResponse(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_handle); + + /** + * @brief SDLActivateAppResponse class destructor + **/ + virtual ~SDLActivateAppResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SDLActivateAppResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_ACTIVATE_APP_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h new file mode 100644 index 0000000000..61426e0af3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.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_HMI_SDL_GET_LIST_OF_PERMISSIONS_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_LIST_OF_PERMISSIONS_REQUEST_H_ + +#include "application_manager/commands/request_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SDLGetListOfPermissionsRequest command class + **/ +class SDLGetListOfPermissionsRequest + : public app_mngr::commands::RequestFromHMI { + public: + /** + * @brief SDLGetListOfPermissionsRequest class constructor + * + * @param message Incoming SmartObject message + **/ + SDLGetListOfPermissionsRequest( + 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_handle); + + /** + * @brief SDLGetListOfPermissionsRequest class destructor + **/ + virtual ~SDLGetListOfPermissionsRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SDLGetListOfPermissionsRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_LIST_OF_PERMISSIONS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h new file mode 100644 index 0000000000..e2556bac3d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_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_HMI_SDL_GET_LIST_OF_PERMISSIONS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_LIST_OF_PERMISSIONS_RESPONSE_H_ + +#include "application_manager/commands/response_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SDLGetListOfPermissionsResponse command class + **/ +class SDLGetListOfPermissionsResponse + : public app_mngr::commands::ResponseToHMI { + public: + /** + * @brief SDLGetListOfPermissionsResponse class constructor + * + * @param message Incoming SmartObject message + **/ + SDLGetListOfPermissionsResponse( + 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_handle); + + /** + * @brief SDLGetListOfPermissionsResponse class destructor + **/ + virtual ~SDLGetListOfPermissionsResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SDLGetListOfPermissionsResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_LIST_OF_PERMISSIONS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h new file mode 100644 index 0000000000..b6376bacc6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h @@ -0,0 +1,76 @@ +/* + * 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_HMI_SDL_GET_STATUS_UPDATE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_STATUS_UPDATE_REQUEST_H_ + +#include "application_manager/commands/request_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SDLGetStatusUpdateRequest command class + **/ +class SDLGetStatusUpdateRequest : public app_mngr::commands::RequestFromHMI { + public: + /** + * @brief SDLGetStatusUpdateRequest class constructor + * + * @param message Incoming SmartObject message + **/ + SDLGetStatusUpdateRequest(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_handle); + + /** + * @brief SDLGetStatusUpdateRequest class destructor + **/ + virtual ~SDLGetStatusUpdateRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SDLGetStatusUpdateRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_STATUS_UPDATE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h new file mode 100644 index 0000000000..4e6da22370 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_SDL_GET_STATUS_UPDATE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_STATUS_UPDATE_RESPONSE_H_ + +#include "application_manager/commands/response_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SDLGetStatusUpdateResponse command class + **/ +class SDLGetStatusUpdateResponse : public app_mngr::commands::ResponseToHMI { + public: + /** + * @brief SDLGetStatusUpdateResponse class constructor + * + * @param message Incoming SmartObject message + **/ + SDLGetStatusUpdateResponse( + 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_handle); + + /** + * @brief SDLGetStatusUpdateResponse class destructor + **/ + virtual ~SDLGetStatusUpdateResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SDLGetStatusUpdateResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_STATUS_UPDATE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h new file mode 100644 index 0000000000..75902e2733 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.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_HMI_SDL_GET_USER_FRIENDLY_MESSAGE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_USER_FRIENDLY_MESSAGE_REQUEST_H_ + +#include "application_manager/commands/request_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SDLGetUserFriendlyMessageRequest command class + **/ +class SDLGetUserFriendlyMessageRequest + : public app_mngr::commands::RequestFromHMI { + public: + /** + * @brief SDLGetUserFriendlyMessageRequest class constructor + * + * @param message Incoming SmartObject message + **/ + SDLGetUserFriendlyMessageRequest( + 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_handle); + + /** + * @brief SDLGetUserFriendlyMessageRequest class destructor + **/ + virtual ~SDLGetUserFriendlyMessageRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SDLGetUserFriendlyMessageRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_USER_FRIENDLY_MESSAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h new file mode 100644 index 0000000000..a02d6894e3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_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_HMI_SDL_GET_USER_FRIENDLY_MESSAGE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_USER_FRIENDLY_MESSAGE_RESPONSE_H_ + +#include "application_manager/commands/response_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SDLGetUserFriendlyMessageResponse command class + **/ +class SDLGetUserFriendlyMessageResponse + : public app_mngr::commands::ResponseToHMI { + public: + /** + * @brief SDLGetUserFriendlyMessageResponse class constructor + * + * @param message Incoming SmartObject message + **/ + SDLGetUserFriendlyMessageResponse( + 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_handle); + + /** + * @brief SDLGetUserFriendlyMessageResponse class destructor + **/ + virtual ~SDLGetUserFriendlyMessageResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SDLGetUserFriendlyMessageResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_USER_FRIENDLY_MESSAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update.h new file mode 100644 index 0000000000..f164aed775 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update.h @@ -0,0 +1,71 @@ +/* + * 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_HMI_SDL_POLICY_UPDATE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_POLICY_UPDATE_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +class SDLPolicyUpdate : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief SDLPolicyUpdate class constructor + * + * @param message Incoming SmartObject message + **/ + SDLPolicyUpdate(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_handle); + + ~SDLPolicyUpdate() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(SDLPolicyUpdate); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_POLICY_UPDATE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update_response.h new file mode 100644 index 0000000000..63f33477b6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update_response.h @@ -0,0 +1,74 @@ +/* + * 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_HMI_SDL_POLICY_UPDATE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_POLICY_UPDATE_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +class SDLPolicyUpdateResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief SDLPolicyUpdateResponse class constructor + * + * @param message Incoming SmartObject message + **/ + SDLPolicyUpdateResponse(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_handle); + + /** + * @brief SDLPolicyUpdateResponse class destructor + **/ + virtual ~SDLPolicyUpdateResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SDLPolicyUpdateResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_POLICY_UPDATE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h new file mode 100644 index 0000000000..229ed92947 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_request.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_HMI_TTS_CHANGE_REGISTRATION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_CHANGE_REGISTRATION_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief TTSChangeRegistrationRequest command class + **/ +class TTSChangeRegistrationRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief TTSChangeRegistrationRequest class constructor + * + * @param message Incoming SmartObject message + **/ + TTSChangeRegistrationRequest( + 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_handle); + + /** + * @brief TTSChangeRegistrationRequest class destructor + **/ + virtual ~TTSChangeRegistrationRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(TTSChangeRegistrationRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_CHANGE_REGISTRATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_response.h new file mode 100644 index 0000000000..8462178283 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_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_HMI_TTS_CHANGE_REGISTRATION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_CHANGE_REGISTRATION_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief TTSChangeRegistratioResponse command class + **/ +class TTSChangeRegistratioResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief TTSChangeRegistratioResponse class constructor + * + * @param message Incoming SmartObject message + **/ + TTSChangeRegistratioResponse( + 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_handle); + + /** + * @brief TTSChangeRegistratioResponse class destructor + **/ + virtual ~TTSChangeRegistratioResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(TTSChangeRegistratioResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_CHANGE_REGISTRATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h new file mode 100644 index 0000000000..df6cf3b4a4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_TTS_GET_CAPABILITIES_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_CAPABILITIES_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief TTSGetCapabilitiesRequest command class + **/ +class TTSGetCapabilitiesRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief TTSGetCapabilitiesRequest class constructor + * + * @param message Incoming SmartObject message + **/ + TTSGetCapabilitiesRequest(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_handle); + + /** + * @brief TTSGetCapabilitiesRequest class destructor + **/ + virtual ~TTSGetCapabilitiesRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(TTSGetCapabilitiesRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_CAPABILITIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_response.h new file mode 100644 index 0000000000..7919f213a4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_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_HMI_TTS_GET_CAPABILITIES_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_CAPABILITIES_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief TTSGetCapabilitiesResponse command class + **/ +class TTSGetCapabilitiesResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief TTSGetCapabilitiesResponse class constructor + * + * @param message Incoming SmartObject message + **/ + TTSGetCapabilitiesResponse( + 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_handle); + + /** + * @brief TTSGetCapabilitiesResponse class destructor + **/ + virtual ~TTSGetCapabilitiesResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(TTSGetCapabilitiesResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_CAPABILITIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_request.h new file mode 100644 index 0000000000..09345c02d7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_TTS_GET_LANGUAGE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_LANGUAGE_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief TTSGetLanguageRequest command class + **/ +class TTSGetLanguageRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief TTSGetLanguageRequest class constructor + * + * @param message Incoming SmartObject message + **/ + TTSGetLanguageRequest(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_handle); + + /** + * @brief TTSGetLanguageRequest class destructor + **/ + virtual ~TTSGetLanguageRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(TTSGetLanguageRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_LANGUAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_response.h new file mode 100644 index 0000000000..e52dbf1ada --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_TTS_GET_LANGUAGE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_LANGUAGE_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief TTSGetLanguageResponse command class + **/ +class TTSGetLanguageResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief TTSGetLanguageResponse class constructor + * + * @param message Incoming SmartObject message + **/ + TTSGetLanguageResponse(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_handle); + + /** + * @brief TTSGetLanguageResponse class destructor + **/ + virtual ~TTSGetLanguageResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(TTSGetLanguageResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_LANGUAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h new file mode 100644 index 0000000000..c42d0257d3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.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_HMI_TTS_GET_SUPPORTED_LANGUAGES_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_SUPPORTED_LANGUAGES_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief TTSGetSupportedLanguagesRequest command class + **/ +class TTSGetSupportedLanguagesRequest + : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief TTSGetSupportedLanguagesRequest class constructor + * + * @param message Incoming SmartObject message + **/ + TTSGetSupportedLanguagesRequest( + 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_handle); + + /** + * @brief TTSGetSupportedLanguagesRequest class destructor + **/ + virtual ~TTSGetSupportedLanguagesRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(TTSGetSupportedLanguagesRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_SUPPORTED_LANGUAGES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_response.h new file mode 100644 index 0000000000..cc24db22b9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_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_HMI_TTS_GET_SUPPORTED_LANGUAGES_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_SUPPORTED_LANGUAGES_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief TTSGetSupportedLanguagesResponse command class + **/ +class TTSGetSupportedLanguagesResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief TTSGetSupportedLanguagesResponse class constructor + * + * @param message Incoming SmartObject message + **/ + TTSGetSupportedLanguagesResponse( + 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_handle); + + /** + * @brief TTSGetSupportedLanguagesResponse class destructor + **/ + virtual ~TTSGetSupportedLanguagesResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(TTSGetSupportedLanguagesResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_SUPPORTED_LANGUAGES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h new file mode 100644 index 0000000000..b7dffd5bde --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h @@ -0,0 +1,93 @@ +/* + * 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_HMI_TTS_IS_READY_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_IS_READY_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief TTSIsReadyRequest command class + **/ +class TTSIsReadyRequest : public app_mngr::commands::RequestToHMI, + public app_mngr::event_engine::EventObserver { + public: + /** + * @brief TTSIsReadyRequest class constructor + * + * @param message Incoming SmartObject message + **/ + TTSIsReadyRequest(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 TTSIsReadyRequest class destructor + **/ + virtual ~TTSIsReadyRequest(); + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + /** + * @brief On event callback + **/ + void on_event(const app_mngr::event_engine::Event& event) OVERRIDE; + + /** + * @brief onTimeOut from requrst Controller + */ + void onTimeOut() OVERRIDE; + + /** + * @brief Send request to HMI for fetching of cappabilities + */ + void SendMessageToHMI(); + + private: + DISALLOW_COPY_AND_ASSIGN(TTSIsReadyRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_IS_READY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_response.h new file mode 100644 index 0000000000..268edd0eeb --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_TTS_IS_READY_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_IS_READY_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief TTSIsReadyResponse command class + **/ +class TTSIsReadyResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief TTSIsReadyResponse class constructor + * + * @param message Incoming SmartObject message + **/ + TTSIsReadyResponse(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_handle); + + /** + * @brief TTSIsReadyResponse class destructor + **/ + virtual ~TTSIsReadyResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(TTSIsReadyResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_IS_READY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h new file mode 100644 index 0000000000..f416b3a787 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.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_HMI_TTS_SET_GLOBAL_PROPERTIES_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_SET_GLOBAL_PROPERTIES_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief TTSSetGlobalPropertiesRequest command class + **/ +class TTSSetGlobalPropertiesRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief TTSSetGlobalPropertiesRequest class constructor + * + * @param message Incoming SmartObject message + **/ + TTSSetGlobalPropertiesRequest( + 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 TTSSetGlobalPropertiesRequest class destructor + **/ + virtual ~TTSSetGlobalPropertiesRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(TTSSetGlobalPropertiesRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_SET_GLOBAL_PROPERTIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_response.h new file mode 100644 index 0000000000..ff5622296c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_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_HMI_TTS_SET_GLOBAL_PROPERTIES_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_SET_GLOBAL_PROPERTIES_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief TTSSetGlobalPropertiesResponse command class + **/ +class TTSSetGlobalPropertiesResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief TTSSetGlobalPropertiesResponse class constructor + * + * @param message Incoming SmartObject message + **/ + TTSSetGlobalPropertiesResponse( + 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_handle); + + /** + * @brief TTSSetGlobalPropertiesResponse class destructor + **/ + virtual ~TTSSetGlobalPropertiesResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(TTSSetGlobalPropertiesResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_SET_GLOBAL_PROPERTIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_request.h new file mode 100644 index 0000000000..9e8915a440 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_TTS_SPEAK_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_SPEAK_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief TTSSpeakRequest command class + **/ +class TTSSpeakRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief TTSSpeakRequest class constructor + * + * @param message Incoming SmartObject message + **/ + TTSSpeakRequest(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_handle); + + /** + * @brief TTSSpeakRequest class destructor + **/ + virtual ~TTSSpeakRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(TTSSpeakRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_SPEAK_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_response.h new file mode 100644 index 0000000000..e4b2c8adbd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_TTS_SPEAK_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_SPEAK_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief TTSSpeakResponse command class + **/ +class TTSSpeakResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief TTSSpeakResponse class constructor + * + * @param message Incoming SmartObject message + **/ + TTSSpeakResponse(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_handle); + + /** + * @brief TTSSpeakResponse class destructor + **/ + virtual ~TTSSpeakResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(TTSSpeakResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_SPEAK_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h new file mode 100644 index 0000000000..8eb6a66c95 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_TTS_STOP_SPEAKING_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_STOP_SPEAKING_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief TTSStopSpeakingRequest command class + **/ +class TTSStopSpeakingRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief TTSStopSpeakingRequest class constructor + * + * @param message Incoming SmartObject message + **/ + TTSStopSpeakingRequest(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_handle); + + /** + * @brief TTSStopSpeakingRequest class destructor + **/ + virtual ~TTSStopSpeakingRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(TTSStopSpeakingRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_STOP_SPEAKING_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h new file mode 100644 index 0000000000..d433fe2280 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_TTS_STOP_SPEAKING_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_STOP_SPEAKING_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief TTSStopSpeakingResponse command class + **/ +class TTSStopSpeakingResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief TTSStopSpeakingResponse class constructor + * + * @param message Incoming SmartObject message + **/ + TTSStopSpeakingResponse(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_handle); + + /** + * @brief TTSStopSpeakingResponse class destructor + **/ + virtual ~TTSStopSpeakingResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(TTSStopSpeakingResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_STOP_SPEAKING_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_request.h new file mode 100644 index 0000000000..e5d2483576 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_ADD_COMMAND_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ADD_COMMAND_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIAddCommandRequest command class + **/ +class UIAddCommandRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UIAddCommandRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UIAddCommandRequest(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_handle); + + /** + * @brief UIAddCommandRequest class destructor + **/ + virtual ~UIAddCommandRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIAddCommandRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ADD_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_response.h new file mode 100644 index 0000000000..90a9666561 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_ADD_COMMAND_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ADD_COMMAND_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIAddCommandResponse command class + **/ +class UIAddCommandResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UIAddCommandResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UIAddCommandResponse(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_handle); + + /** + * @brief UIAddCommandResponse class destructor + **/ + virtual ~UIAddCommandResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIAddCommandResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ADD_COMMAND_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_request.h new file mode 100644 index 0000000000..5de5e41cd6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_ADD_SUBMENU_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ADD_SUBMENU_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIAddSubmenuRequest command class + **/ +class UIAddSubmenuRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UIAddSubmenuRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UIAddSubmenuRequest(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_handle); + + /** + * @brief UIAddSubmenuRequest class destructor + **/ + virtual ~UIAddSubmenuRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIAddSubmenuRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ADD_SUBMENU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_response.h new file mode 100644 index 0000000000..20f830be27 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_ADD_SUBMENU_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ADD_SUBMENU_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIAddSubmenuResponse command class + **/ +class UIAddSubmenuResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UIAddSubmenuResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UIAddSubmenuResponse(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_handle); + + /** + * @brief UIAddSubmenuResponse class destructor + **/ + virtual ~UIAddSubmenuResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIAddSubmenuResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ADD_SUBMENU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_request.h new file mode 100644 index 0000000000..6235a51c7d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_ALERT_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ALERT_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIAlertRequest command class + **/ +class UIAlertRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UIAlertRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UIAlertRequest(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_handle); + + /** + * @brief UIAlertRequest class destructor + **/ + virtual ~UIAlertRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIAlertRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ALERT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_response.h new file mode 100644 index 0000000000..b43185af78 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_ALERT_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ALERT_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIAlertResponse command class + **/ +class UIAlertResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UIAlertResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UIAlertResponse(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_handle); + + /** + * @brief UIAlertResponse class destructor + **/ + virtual ~UIAlertResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIAlertResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ALERT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_request.h new file mode 100644 index 0000000000..c504c55727 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_request.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_HMI_UI_CHANGE_REGISTRATION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CHANGE_REGISTRATION_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIChangeRegistrationRequest command class + **/ +class UIChangeRegistrationRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UIChangeRegistrationRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UIChangeRegistrationRequest( + 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_handlel); + + /** + * @brief UIChangeRegistrationRequest class destructor + **/ + virtual ~UIChangeRegistrationRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIChangeRegistrationRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CHANGE_REGISTRATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_response.h new file mode 100644 index 0000000000..d7fca83d3e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_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_HMI_UI_CHANGE_REGISTRATION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CHANGE_REGISTRATION_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIChangeRegistratioResponse command class + **/ +class UIChangeRegistratioResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UIChangeRegistratioResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UIChangeRegistratioResponse( + 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_handle); + + /** + * @brief UIChangeRegistratioResponse class destructor + **/ + virtual ~UIChangeRegistratioResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIChangeRegistratioResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CHANGE_REGISTRATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h new file mode 100644 index 0000000000..ecc0b44495 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_DELETE_COMMAND_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_COMMAND_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIDeleteCommandRequest command class + **/ +class UIDeleteCommandRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UIDeleteCommandRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UIDeleteCommandRequest(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_handle); + + /** + * @brief UIDeleteCommandRequest class destructor + **/ + virtual ~UIDeleteCommandRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIDeleteCommandRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_response.h new file mode 100644 index 0000000000..f9601b7491 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_DELETE_COMMAND_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_COMMAND_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIDeleteCommandResponse command class + **/ +class UIDeleteCommandResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UIDeleteCommandResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UIDeleteCommandResponse(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_handle); + + /** + * @brief UIDeleteCommandResponse class destructor + **/ + virtual ~UIDeleteCommandResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIDeleteCommandResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_COMMAND_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_request.h new file mode 100644 index 0000000000..3161c84b7c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_DELETE_SUBMENU_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_SUBMENU_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIAddSubmenuRequest command class + **/ +class UIDeleteSubmenuRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UIDeleteSubmenuRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UIDeleteSubmenuRequest(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_handle); + + /** + * @brief UIDeleteSubmenuRequest class destructor + **/ + virtual ~UIDeleteSubmenuRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIDeleteSubmenuRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_SUBMENU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_response.h new file mode 100644 index 0000000000..7c73a53c3e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_DELETE_SUBMENU_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_SUBMENU_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIDeleteSubmenuResponse command class + **/ +class UIDeleteSubmenuResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UIDeleteSubmenuResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UIDeleteSubmenuResponse(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_handle); + + /** + * @brief UIDeleteSubmenuResponse class destructor + **/ + virtual ~UIDeleteSubmenuResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIDeleteSubmenuResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_SUBMENU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.h new file mode 100644 index 0000000000..8d34e1852b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.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_HMI_UI_END_AUDIO_PASS_THRU_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_END_AUDIO_PASS_THRU_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIEndAudioPassThruRequest command class + * When this request is invoked, the audio capture stops + **/ +class UIEndAudioPassThruRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UIEndAudioPassThruRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UIEndAudioPassThruRequest(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_handle); + + /** + * @brief UIEndAudioPassThruRequest class destructor + **/ + virtual ~UIEndAudioPassThruRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIEndAudioPassThruRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_END_AUDIO_PASS_THRU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_response.h new file mode 100644 index 0000000000..b1c3bfd87a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_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_HMI_UI_END_AUDIO_PASS_THRU_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_END_AUDIO_PASS_THRU_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIEndAudioPassThruResponse command class + **/ +class UIEndAudioPassThruResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UIEndAudioPassThruResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UIEndAudioPassThruResponse( + 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_handle); + + /** + * @brief UIEndAudioPassThruResponse class destructor + **/ + virtual ~UIEndAudioPassThruResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIEndAudioPassThruResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_END_AUDIO_PASS_THRU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_request.h new file mode 100644 index 0000000000..47782cc7a9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_GET_CAPABILITIES_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_CAPABILITIES_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIGetCapabilitiesRequest command class + **/ +class UIGetCapabilitiesRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UIGetCapabilitiesRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UIGetCapabilitiesRequest(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_handle); + + /** + * @brief UIGetCapabilitiesRequest class destructor + **/ + virtual ~UIGetCapabilitiesRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIGetCapabilitiesRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_CAPABILITIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_response.h new file mode 100644 index 0000000000..421844560d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_GET_CAPABILITIES_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_CAPABILITIES_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIGetCapabilitiesResponse command class + **/ +class UIGetCapabilitiesResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UIGetCapabilitiesResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UIGetCapabilitiesResponse(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_handle); + + /** + * @brief UIGetCapabilitiesResponse class destructor + **/ + virtual ~UIGetCapabilitiesResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIGetCapabilitiesResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_CAPABILITIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_request.h new file mode 100644 index 0000000000..7c82584178 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_GET_LANGUAGE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_LANGUAGE_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIGetLanguageRequest command class + **/ +class UIGetLanguageRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UIGetLanguageRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UIGetLanguageRequest(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_handle); + + /** + * @brief UIGetLanguageRequest class destructor + **/ + virtual ~UIGetLanguageRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIGetLanguageRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_LANGUAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_response.h new file mode 100644 index 0000000000..7354e87ee4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_GET_LANGUAGE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_LANGUAGE_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIGetLanguageResponse command class + **/ +class UIGetLanguageResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UIGetLanguageResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UIGetLanguageResponse(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_handle); + + /** + * @brief UIGetLanguageResponse class destructor + **/ + virtual ~UIGetLanguageResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIGetLanguageResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_LANGUAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.h new file mode 100644 index 0000000000..7fd456b92b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.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_HMI_UI_GET_SUPPORTED_LANGUAGES_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_SUPPORTED_LANGUAGES_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIGetSupportedLanguagesRequest command class + **/ +class UIGetSupportedLanguagesRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UIGetSupportedLanguagesRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UIGetSupportedLanguagesRequest( + 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_handle); + + /** + * @brief UIGetSupportedLanguagesRequest class destructor + **/ + virtual ~UIGetSupportedLanguagesRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIGetSupportedLanguagesRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_SUPPORTED_LANGUAGES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_response.h new file mode 100644 index 0000000000..26d8e98892 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_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_HMI_UI_GET_SUPPORTED_LANGUAGES_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_SUPPORTED_LANGUAGES_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIGetSupportedLanguagesResponse command class + **/ +class UIGetSupportedLanguagesResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UIGetSupportedLanguagesResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UIGetSupportedLanguagesResponse( + 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_handle); + + /** + * @brief UIGetSupportedLanguagesResponse class destructor + **/ + virtual ~UIGetSupportedLanguagesResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIGetSupportedLanguagesResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_SUPPORTED_LANGUAGES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h new file mode 100644 index 0000000000..2e7806cd2b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h @@ -0,0 +1,93 @@ +/* + * 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_HMI_UI_IS_READY_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_IS_READY_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIIsReadyRequest command class + **/ +class UIIsReadyRequest : public app_mngr::commands::RequestToHMI, + public app_mngr::event_engine::EventObserver { + public: + /** + * @brief UIIsReadyRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UIIsReadyRequest(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_handle); + + /** + * @brief UIIsReadyRequest class destructor + **/ + virtual ~UIIsReadyRequest(); + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + /** + * @brief On event callback + **/ + void on_event(const app_mngr::event_engine::Event& event) OVERRIDE; + + /** + * @brief onTimeOut from requrst Controller + */ + virtual void onTimeOut() OVERRIDE; + + /** + * @brief Send request to HMI for fetching of cappabilities + */ + void SendMessageToHMI(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIIsReadyRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_IS_READY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_response.h new file mode 100644 index 0000000000..f2b4f201f3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_IS_READY_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_IS_READY_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIIsReadyResponse command class + **/ +class UIIsReadyResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UIIsReadyResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UIIsReadyResponse(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_handle); + + /** + * @brief UIIsReadyResponse class destructor + **/ + virtual ~UIIsReadyResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIIsReadyResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_IS_READY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h new file mode 100644 index 0000000000..6d4e870228 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.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_HMI_UI_PERFORM_AUDIO_PASS_THRU_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_PERFORM_AUDIO_PASS_THRU_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIPerformAudioPassThruRequest command class + **/ +class UIPerformAudioPassThruRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UIPerformAudioPassThruRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UIPerformAudioPassThruRequest( + 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_handle); + + /** + * @brief UIPerformAudioPassThruRequest class destructor + **/ + virtual ~UIPerformAudioPassThruRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIPerformAudioPassThruRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_PERFORM_AUDIO_PASS_THRU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_response.h new file mode 100644 index 0000000000..e36a292573 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_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_HMI_UI_PERFORM_AUDIO_PASS_THRU_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_PERFORM_AUDIO_PASS_THRU_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIPerformAudioPassThruResponse command class + **/ +class UIPerformAudioPassThruResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UIPerformAudioPassThruResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UIPerformAudioPassThruResponse( + 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_handle); + + /** + * @brief UIPerformAudioPassThruResponse class destructor + **/ + virtual ~UIPerformAudioPassThruResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIPerformAudioPassThruResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_PERFORM_AUDIO_PASS_THRU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h new file mode 100644 index 0000000000..ff4540de23 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.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_HMI_UI_PERFORM_INTERACTION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_PERFORM_INTERACTION_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIPerformInteractionRequest command class + **/ +class UIPerformInteractionRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UIPerformInteractionRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UIPerformInteractionRequest( + 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_handle); + + /** + * @brief UIPerformInteractionRequest class destructor + **/ + virtual ~UIPerformInteractionRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIPerformInteractionRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_PERFORM_INTERACTION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_response.h new file mode 100644 index 0000000000..caf5716e18 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_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_HMI_UI_PERFORM_INTERACTION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_PERFORM_INTERACTION_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIPerformInteractionResponse command class + **/ +class UIPerformInteractionResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UIPerformInteractionResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UIPerformInteractionResponse( + 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_handle); + + /** + * @brief UIPerformInteractionResponse class destructor + **/ + virtual ~UIPerformInteractionResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIPerformInteractionResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_PERFORM_INTERACTION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h new file mode 100644 index 0000000000..f5acf41c8d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.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_HMI_UI_SCROLLABLE_MESSAGE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SCROLLABLE_MESSAGE_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIScrollableMessageRequest command class + **/ +class UIScrollableMessageRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UIScrollableMessageRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UIScrollableMessageRequest( + 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_handle); + + /** + * @brief UIScrollableMessageRequest class destructor + **/ + virtual ~UIScrollableMessageRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIScrollableMessageRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SCROLLABLE_MESSAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_response.h new file mode 100644 index 0000000000..e46265c0e4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_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_HMI_UI_SCROLLABLE_MESSAGE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SCROLLABLE_MESSAGE_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIScrollableMessageResponse command class + **/ +class UIScrollableMessageResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UIScrollableMessageResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UIScrollableMessageResponse( + 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_handle); + + /** + * @brief UIScrollableMessageResponse class destructor + **/ + virtual ~UIScrollableMessageResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIScrollableMessageResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SCROLLABLE_MESSAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h new file mode 100644 index 0000000000..4e260a99ff --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.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_HMI_UI_SEND_HAPTIC_DATA_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SEND_HAPTIC_DATA_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UISendHapticDataRequest command class + **/ +class UISendHapticDataRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UISendHapticDataRequest class constructor + * + * @param message Incoming SmartObject message + * @param application_manager Reference of application manager + **/ + UISendHapticDataRequest(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_handle); + + /** + * @brief UISendHapticDataRequest class destructor + **/ + ~UISendHapticDataRequest() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(UISendHapticDataRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SEND_HAPTIC_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_response.h new file mode 100644 index 0000000000..1bf38939be --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_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_HMI_UI_SEND_HAPTIC_DATA_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SEND_HAPTIC_DATA_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UISendHapticDataResponse command class + **/ +class UISendHapticDataResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UISendHapticDataResponse class constructor + * + * @param message Incoming SmartObject message + * @param application_manager Reference of application manager + **/ + UISendHapticDataResponse(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_handle); + + /** + * @brief UISendHapticDataResponse class destructor + **/ + ~UISendHapticDataResponse() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(UISendHapticDataResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SEND_HAPTIC_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h new file mode 100644 index 0000000000..ea526df135 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_SET_APP_ICON_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_APP_ICON_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UISetIconRequest command class + **/ +class UISetAppIconRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UISetIconRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UISetAppIconRequest(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_handle); + + /** + * @brief UISetIconRequest class destructor + **/ + virtual ~UISetAppIconRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UISetAppIconRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_APP_ICON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_response.h new file mode 100644 index 0000000000..af2c4fafea --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_SET_APP_ICON_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_APP_ICON_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UISetIconResponse command class + **/ +class UISetAppIconResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UISetIconResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UISetAppIconResponse(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_handle); + + /** + * @brief UISetIconResponse class destructor + **/ + virtual ~UISetAppIconResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UISetAppIconResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_APP_ICON_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h new file mode 100644 index 0000000000..f60f7325fd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h @@ -0,0 +1,76 @@ +/* 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_HMI_UI_SET_DISPLAY_LAYOUT_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_DISPLAY_LAYOUT_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UiSetDisplayLayoutRequest command class + **/ +class UiSetDisplayLayoutRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UiSetDisplayLayoutRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UiSetDisplayLayoutRequest(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_handle); + + /** + * @brief UiSetDisplayLayoutRequest class destructor + **/ + virtual ~UiSetDisplayLayoutRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UiSetDisplayLayoutRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_DISPLAY_LAYOUT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_response.h new file mode 100644 index 0000000000..ce404a4049 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_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_HMI_UI_SET_DISPLAY_LAYOUT_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_DISPLAY_LAYOUT_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UiSetDisplayLayoutResponse command class + **/ +class UiSetDisplayLayoutResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UiSetDisplayLayoutResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UiSetDisplayLayoutResponse( + 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_handle); + + /** + * @brief UiSetDisplayLayoutResponse class destructor + **/ + virtual ~UiSetDisplayLayoutResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UiSetDisplayLayoutResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_DISPLAY_LAYOUT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h new file mode 100644 index 0000000000..44e8bba450 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.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_HMI_UI_SET_GLOBAL_PROPERTIES_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_GLOBAL_PROPERTIES_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UISetGlobalPropertiesRequest command class + **/ +class UISetGlobalPropertiesRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UISetGlobalPropertiesRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UISetGlobalPropertiesRequest( + 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_handle); + + /** + * @brief UIShowRequest class destructor + **/ + virtual ~UISetGlobalPropertiesRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UISetGlobalPropertiesRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_GLOBAL_PROPERTIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_response.h new file mode 100644 index 0000000000..a9c27a423b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_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_HMI_UI_SET_GLOBAL_PROPERTIES_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_GLOBAL_PROPERTIES_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UISetGlobalPropertiesResponse command class + **/ +class UISetGlobalPropertiesResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UISetGlobalPropertiesResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UISetGlobalPropertiesResponse( + 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_handle); + + /** + * @brief UISetGlobalPropertiesResponse class destructor + **/ + virtual ~UISetGlobalPropertiesResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UISetGlobalPropertiesResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_GLOBAL_PROPERTIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_icon_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_icon_request.h new file mode 100644 index 0000000000..84c275ec5a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_icon_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_SET_ICON_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_ICON_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UISetIconRequest command class + **/ +class UISetIconRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UISetIconRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UISetIconRequest(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_handle); + + /** + * @brief UISetIconRequest class destructor + **/ + virtual ~UISetIconRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UISetIconRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_ICON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_icon_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_icon_response.h new file mode 100644 index 0000000000..654dff25b5 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_icon_response.h @@ -0,0 +1,76 @@ +/* + * 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_HMI_UI_SET_ICON_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_ICON_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UISetIconResponse command class + **/ +class UISetIconResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UISetIconResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UISetIconResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief UISetIconResponse class destructor + **/ + virtual ~UISetIconResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UISetIconResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_ICON_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h new file mode 100644 index 0000000000..24f4d76d89 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.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_HMI_UI_SET_MEDIA_CLOCK_TIMER_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_MEDIA_CLOCK_TIMER_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UISetMediaClockTimerRequest command class + **/ +class UISetMediaClockTimerRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UISetMediaClockTimerRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UISetMediaClockTimerRequest( + 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_handle); + + /** + * @brief UISetMediaClockTimerRequest class destructor + **/ + virtual ~UISetMediaClockTimerRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UISetMediaClockTimerRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_MEDIA_CLOCK_TIMER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_response.h new file mode 100644 index 0000000000..c664bd04f9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_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_HMI_UI_SET_MEDIA_CLOCK_TIMER_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_MEDIA_CLOCK_TIMER_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UISetMediaClockTimerResponse command class + **/ +class UISetMediaClockTimerResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UISetMediaClockTimerResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UISetMediaClockTimerResponse( + 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_handle); + + /** + * @brief UISetMediaClockTimerResponse class destructor + **/ + virtual ~UISetMediaClockTimerResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UISetMediaClockTimerResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_MEDIA_CLOCK_TIMER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_request.h new file mode 100644 index 0000000000..7ba950d530 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_SHOW_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIShowRequest command class + **/ +class UIShowRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UIShowRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UIShowRequest(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_handle); + + /** + * @brief UIShowRequest class destructor + **/ + virtual ~UIShowRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIShowRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_response.h new file mode 100644 index 0000000000..f9f7a61056 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_SHOW_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIShowResponse command class + **/ +class UIShowResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UIShowResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UIShowResponse(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_handle); + + /** + * @brief UIShowResponse class destructor + **/ + virtual ~UIShowResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UIShowResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_request.h new file mode 100644 index 0000000000..3de1b4e775 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_SLIDER_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SLIDER_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ButtonGetCapabilitiesRequest command class + **/ +class UISliderRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UISliderRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UISliderRequest(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_handle); + + /** + * @brief UISliderRequest class destructor + **/ + virtual ~UISliderRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UISliderRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SLIDER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_response.h new file mode 100644 index 0000000000..17d1f8a8ed --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UI_SLIDER_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SLIDER_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UISliderResponse command class + **/ +class UISliderResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UISliderResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UISliderResponse(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_handle); + + /** + * @brief UISliderResponse class destructor + **/ + virtual ~UISliderResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UISliderResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SLIDER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_request.h new file mode 100644 index 0000000000..dc0166e33f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UPDATE_APP_LIST_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_APP_LIST_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UpdateAppListRequest command class + **/ +class UpdateAppListRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UpdateAppListRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UpdateAppListRequest(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_handle); + + /** + * @brief UpdateAppListRequest class destructor + **/ + virtual ~UpdateAppListRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UpdateAppListRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_APP_LIST_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_response.h new file mode 100644 index 0000000000..2e3bb79233 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UPDATE_APP_LIST_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_APP_LIST_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UpdateAppListResponse command class + **/ +class UpdateAppListResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UpdateAppListResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UpdateAppListResponse(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_handle); + + /** + * @brief UpdateAppListResponse class destructor + **/ + virtual ~UpdateAppListResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UpdateAppListResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_APP_LIST_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h new file mode 100644 index 0000000000..c4c9f11e06 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h @@ -0,0 +1,97 @@ +/* + * 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_HMI_UPDATE_DEVICE_LIST_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_DEVICE_LIST_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" +#include "application_manager/event_engine/event_observer.h" +#include "utils/lock.h" +#include "utils/conditional_variable.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UpdateDeviceListRequest command class + **/ +class UpdateDeviceListRequest : public app_mngr::commands::RequestToHMI, + public app_mngr::event_engine::EventObserver { + public: + /** + * @brief UpdateDeviceListRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UpdateDeviceListRequest(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_handle); + + /** + * @brief UpdateDeviceListRequest class destructor + **/ + ~UpdateDeviceListRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief Interface method that is called whenever new event received + * Need to observe OnHMIReady event, to send UpdateDeviceListRequest + * when HMI will be ready + * @param event The received event + */ + virtual void on_event(const app_mngr::event_engine::Event& event); + + /** + * @brief Need to stop execution StopMethod if HMI did not started + */ + virtual bool CleanUp(); + + private: + sync_primitives::Lock wait_hmi_lock; + sync_primitives::ConditionalVariable termination_condition_; + + DISALLOW_COPY_AND_ASSIGN(UpdateDeviceListRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_DEVICE_LIST_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_response.h new file mode 100644 index 0000000000..c33518a545 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UPDATE_DEVICE_LIST_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_DEVICE_LIST_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UpdateDeviceListResponse command class + **/ +class UpdateDeviceListResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UpdateDeviceListResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UpdateDeviceListResponse(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_handle); + + /** + * @brief UpdateDeviceListResponse class destructor + **/ + virtual ~UpdateDeviceListResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UpdateDeviceListResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_DEVICE_LIST_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_request.h new file mode 100644 index 0000000000..e30b045fcb --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_request.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_HMI_UPDATE_SDL_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_SDL_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UpdateSDLRequest command class + **/ +class UpdateSDLRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UpdateSDLRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UpdateSDLRequest(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_handle); + + /** + * @brief UpdateSDLRequest class destructor + **/ + virtual ~UpdateSDLRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UpdateSDLRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_SDL_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_response.h new file mode 100644 index 0000000000..f71921ea3a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_UPDATE_SDL_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_SDL_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UpdateSDLResponse command class + **/ +class UpdateSDLResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UpdateSDLResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UpdateSDLResponse(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_handle); + + /** + * @brief UpdateSDLResponse class destructor + **/ + virtual ~UpdateSDLResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UpdateSDLResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_SDL_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vi_get_vehicle_data_request_template.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vi_get_vehicle_data_request_template.h new file mode 100644 index 0000000000..0c3c63c32c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vi_get_vehicle_data_request_template.h @@ -0,0 +1,83 @@ +/* + * 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_HMI_VI_GET_VEHICLE_DATA_REQUEST_TEMPLATE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_DATA_REQUEST_TEMPLATE_H_ + +#include "application_manager/event_engine/event.h" +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +/** + * @brief VIGetVehicleDataRequestTemplate command class + * + * Template class for sending 1 subscribe thin request + **/ +template <event_engine::Event::EventID eventID> +class VIGetVehicleDataRequestTemplate + : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief VIGetVehicleDataRequestTemplate class constructor + * + * @param message Incoming SmartObject message + **/ + VIGetVehicleDataRequestTemplate( + 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_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + + /** + * @brief Execute command with sending DBus thin request to HMI + **/ + virtual void Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendRequest(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(VIGetVehicleDataRequestTemplate<eventID>); +}; + +} // namespace commands +} // namespace application_manager +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_DATA_REQUEST_TEMPLATE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vi_get_vehicle_data_response_template.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vi_get_vehicle_data_response_template.h new file mode 100644 index 0000000000..e28c55ba12 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vi_get_vehicle_data_response_template.h @@ -0,0 +1,83 @@ +/* + * 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_HMI_VI_GET_VEHICLE_DATA_RESPONSE_TEMPLATE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_DATA_RESPONSE_TEMPLATE_H_ + +#include "application_manager/event_engine/event.h" +#include "application_manager/commands/response_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +/** + * @brief VIGetVehicleDataResponseTemplate command class + **/ +template <event_engine::Event::EventID eventID> +class VIGetVehicleDataResponseTemplate : public ResponseFromHMI { + public: + /** + * @brief VIGetVehicleDataResponseTemplate class constructor + * + * @param message Incoming SmartObject message + **/ + VIGetVehicleDataResponseTemplate( + 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_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + + /** + * @brief Execute command + **/ + virtual void Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event(eventID); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); + } + + private: + DISALLOW_COPY_AND_ASSIGN(VIGetVehicleDataResponseTemplate<eventID>); +}; + +} // namespace commands +} // namespace application_manager +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_DATA_RESPONSE_TEMPLATE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vi_subscribe_vehicle_data_request_template.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vi_subscribe_vehicle_data_request_template.h new file mode 100644 index 0000000000..b74d013a82 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vi_subscribe_vehicle_data_request_template.h @@ -0,0 +1,83 @@ +/* + * 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_HMI_VI_SUBSCRIBE_VEHICLE_DATA_REQUEST_TEMPLATE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_SUBSCRIBE_VEHICLE_DATA_REQUEST_TEMPLATE_H_ + +#include "application_manager/event_engine/event.h" +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +/** + * @brief VISubscriveVehicleDataRequestTemplate command class + * + * Template class for sending 1 subscribe thin request + **/ +template <event_engine::Event::EventID eventID> +class VISubscribeVehicleDataRequestTemplate + : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief VISubscriveVehicleDataRequestTemplate class constructor + * + * @param message Incoming SmartObject message + **/ + VISubscribeVehicleDataRequestTemplate( + 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_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + + /** + * @brief Execute command with sending DBus thin request to HMI + **/ + virtual void Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendRequest(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(VISubscribeVehicleDataRequestTemplate<eventID>); +}; + +} // namespace commands +} // namespace application_manager +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_SUBSCRIBE_VEHICLE_DATA_REQUEST_TEMPLATE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vi_subscribe_vehicle_data_response_template.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vi_subscribe_vehicle_data_response_template.h new file mode 100644 index 0000000000..42dba56345 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vi_subscribe_vehicle_data_response_template.h @@ -0,0 +1,82 @@ +/* + * 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_HMI_VI_SUBSCRIBE_VEHICLE_DATA_RESPONSE_TEMPLATE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_SUBSCRIBE_VEHICLE_DATA_RESPONSE_TEMPLATE_H_ + +#include "application_manager/event_engine/event.h" +#include "application_manager/commands/response_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { +/** + * @brief VISubscriveVehicleDataResponseTemplate command class + **/ +template <event_engine::Event::EventID eventID> +class VISubscribeVehicleDataResponseTemplate : public ResponseFromHMI { + public: + /** + * @brief VISubscriveVehicleDataResponseTemplate class constructor + * + * @param message Incoming SmartObject message + **/ + VISubscribeVehicleDataResponseTemplate( + 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_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + + /** + * @brief Execute command + **/ + virtual void Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event(eventID); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); + } + + private: + DISALLOW_COPY_AND_ASSIGN(VISubscribeVehicleDataResponseTemplate<eventID>); +}; + +} // namespace commands +} // namespace application_manager +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_SUBSCRIBE_VEHICLE_DATA_RESPONSE_TEMPLATE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request_template.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request_template.h new file mode 100644 index 0000000000..2cb5d622b1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request_template.h @@ -0,0 +1,83 @@ +/* + * 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_HMI_VI_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_TEMPLATE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_TEMPLATE_H_ + +#include "application_manager/event_engine/event.h" +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +/** + * @brief VIUnsubscriveVehicleDataRequestTemplate command class + * + * Template class for sending 1 unsubscribe thin request + **/ +template <event_engine::Event::EventID eventID> +class VIUnsubscribeVehicleDataRequestTemplate + : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief VIUnsubscriveVehicleDataRequestTemplate class constructor + * + * @param message Incoming SmartObject message + **/ + VIUnsubscribeVehicleDataRequestTemplate( + 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_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + + /** + * @brief Execute command with sending DBus thin request to HMI + **/ + virtual void Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendRequest(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(VIUnsubscribeVehicleDataRequestTemplate<eventID>); +}; + +} // namespace commands +} // namespace application_manager +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_TEMPLATE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response_template.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response_template.h new file mode 100644 index 0000000000..6138aa59fb --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response_template.h @@ -0,0 +1,84 @@ +/* + * 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_HMI_VI_UNSUBSCRIBE_VEHICLE_DATA_RESPONSE_TEMPLATE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_UNSUBSCRIBE_VEHICLE_DATA_RESPONSE_TEMPLATE_H_ + +#include "application_manager/event_engine/event.h" +#include "application_manager/commands/response_from_hmi.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +/** + * @brief VIUnsubscriveVehicleDataResponseTemplate command class + **/ +template <event_engine::Event::EventID eventID> +class VIUnsubscribeVehicleDataResponseTemplate : public ResponseFromHMI { + public: + /** + * @brief VISubscriveVehicleDataResponseTemplate class constructor + * + * @param message Incoming SmartObject message + **/ + VIUnsubscribeVehicleDataResponseTemplate( + 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_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + + /** + * @brief Execute command + **/ + virtual void Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event(eventID); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); + } + + private: + DISALLOW_COPY_AND_ASSIGN(VIUnsubscribeVehicleDataResponseTemplate<eventID>); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_UNSUBSCRIBE_VEHICLE_DATA_RESPONSE_TEMPLATE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_request.h new file mode 100644 index 0000000000..0abb37adbc --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_VR_ADD_COMMAND_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_ADD_COMMAND_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief VRAddCommandRequest command class + **/ +class VRAddCommandRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief VRAddCommandRequest class constructor + * + * @param message Incoming SmartObject message + **/ + VRAddCommandRequest(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_handle); + + /** + * @brief VRAddCommandRequest class destructor + **/ + virtual ~VRAddCommandRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(VRAddCommandRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_ADD_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_response.h new file mode 100644 index 0000000000..5f9c99a483 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_VR_ADD_COMMAND_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_ADD_COMMAND_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief VRAddCommandResponse command class + **/ +class VRAddCommandResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief VRAddCommandResponse class constructor + * + * @param message Incoming SmartObject message + **/ + VRAddCommandResponse(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_handle); + + /** + * @brief VRAddCommandResponse class destructor + **/ + virtual ~VRAddCommandResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(VRAddCommandResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_ADD_COMMAND_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_request.h new file mode 100644 index 0000000000..4af28cb542 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_request.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_HMI_VR_CHANGE_REGISTRATION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_CHANGE_REGISTRATION_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief VRChangeRegistrationRequest command class + **/ +class VRChangeRegistrationRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief VRChangeRegistrationRequest class constructor + * + * @param message Incoming SmartObject message + **/ + VRChangeRegistrationRequest( + 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_handle); + + /** + * @brief VRChangeRegistrationRequest class destructor + **/ + virtual ~VRChangeRegistrationRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(VRChangeRegistrationRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_CHANGE_REGISTRATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_response.h new file mode 100644 index 0000000000..a80df0968b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_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_HMI_VR_CHANGE_REGISTRATION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_CHANGE_REGISTRATION_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief VRChangeRegistrationResponse command class + **/ +class VRChangeRegistrationResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief VRChangeRegistrationResponse class constructor + * + * @param message Incoming SmartObject message + **/ + VRChangeRegistrationResponse( + 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_handle); + + /** + * @brief VRChangeRegistrationResponse class destructor + **/ + virtual ~VRChangeRegistrationResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(VRChangeRegistrationResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_CHANGE_REGISTRATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h new file mode 100644 index 0000000000..0ed9521ec5 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_VR_DELETE_COMMAND_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_DELETE_COMMAND_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief VRDeleteCommandRequest command class + **/ +class VRDeleteCommandRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief VRDeleteCommandRequest class constructor + * + * @param message Incoming SmartObject message + **/ + VRDeleteCommandRequest(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_handle); + + /** + * @brief VRDeleteCommandRequest class destructor + **/ + virtual ~VRDeleteCommandRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(VRDeleteCommandRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_DELETE_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h new file mode 100644 index 0000000000..63efcab355 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_VR_DELETE_COMMAND_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_DELETE_COMMAND_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief VRDeleteCommandResponse command class + **/ +class VRDeleteCommandResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief VRDeleteCommandResponse class constructor + * + * @param message Incoming SmartObject message + **/ + VRDeleteCommandResponse(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_handle); + + /** + * @brief VRDeleteCommandResponse class destructor + **/ + virtual ~VRDeleteCommandResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(VRDeleteCommandResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_DELETE_COMMAND_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_request.h new file mode 100644 index 0000000000..f8ac83af58 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_VR_GET_CAPABILITIES_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_CAPABILITIES_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief VRGetCapabilitiesRequest command class + **/ +class VRGetCapabilitiesRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief VRGetCapabilitiesRequest class constructor + * + * @param message Incoming SmartObject message + **/ + VRGetCapabilitiesRequest(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_handle); + + /** + * @brief VRGetCapabilitiesRequest class destructor + **/ + virtual ~VRGetCapabilitiesRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(VRGetCapabilitiesRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_CAPABILITIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_response.h new file mode 100644 index 0000000000..9c9bb55b1b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_VR_GET_CAPABILITIES_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_CAPABILITIES_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief VRGetCapabilitiesResponse command class + **/ +class VRGetCapabilitiesResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief VRGetCapabilitiesResponse class constructor + * + * @param message Incoming SmartObject message + **/ + VRGetCapabilitiesResponse(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_handle); + + /** + * @brief VRGetCapabilitiesResponse class destructor + **/ + virtual ~VRGetCapabilitiesResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(VRGetCapabilitiesResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_CAPABILITIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_request.h new file mode 100644 index 0000000000..e764cbef91 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_request.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_VR_GET_LANGUAGE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_LANGUAGE_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief VRGetLanguageRequest command class + **/ +class VRGetLanguageRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief VRGetLanguageRequest class constructor + * + * @param message Incoming SmartObject message + **/ + VRGetLanguageRequest(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_handle); + + /** + * @brief VRGetLanguageRequest class destructor + **/ + virtual ~VRGetLanguageRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(VRGetLanguageRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_LANGUAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_response.h new file mode 100644 index 0000000000..470fe3ebdc --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_VR_GET_LANGUAGE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_LANGUAGE_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief VRGetLanguageResponse command class + **/ +class VRGetLanguageResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief VRGetLanguageResponse class constructor + * + * @param message Incoming SmartObject message + **/ + VRGetLanguageResponse(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_handle); + + /** + * @brief VRGetLanguageResponse class destructor + **/ + virtual ~VRGetLanguageResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(VRGetLanguageResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_LANGUAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h new file mode 100644 index 0000000000..8d9e9e2a61 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.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_HMI_VR_GET_SUPPORTED_LANGUAGES_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_SUPPORTED_LANGUAGES_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief VRGetSupportedLanguagesRequest command class + **/ +class VRGetSupportedLanguagesRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief VRGetSupportedLanguagesRequest class constructor + * + * @param message Incoming SmartObject message + **/ + VRGetSupportedLanguagesRequest( + 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_handle); + + /** + * @brief VRGetSupportedLanguagesRequest class destructor + **/ + virtual ~VRGetSupportedLanguagesRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(VRGetSupportedLanguagesRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_SUPPORTED_LANGUAGES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h new file mode 100644 index 0000000000..735844cd99 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_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_HMI_VR_GET_SUPPORTED_LANGUAGES_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_SUPPORTED_LANGUAGES_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief VRGetSupportedLanguagesResponse command class + **/ +class VRGetSupportedLanguagesResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief VRGetSupportedLanguagesResponse class constructor + * + * @param message Incoming SmartObject message + **/ + VRGetSupportedLanguagesResponse( + 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_handle); + + /** + * @brief VRGetSupportedLanguagesResponse class destructor + **/ + virtual ~VRGetSupportedLanguagesResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(VRGetSupportedLanguagesResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_SUPPORTED_LANGUAGES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h new file mode 100644 index 0000000000..0b580f6c1d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h @@ -0,0 +1,94 @@ +/* + * 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_HMI_VR_IS_READY_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_IS_READY_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief VRIsReadyRequest command class + **/ +class VRIsReadyRequest : public app_mngr::commands::RequestToHMI, + public app_mngr::event_engine::EventObserver { + public: + /** + * @brief VRIsReadyRequest class constructor + * + * @param message Incoming SmartObject message + **/ + VRIsReadyRequest(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_handle); + + /** + * @brief VRIsReadyRequest class destructor + **/ + virtual ~VRIsReadyRequest(); + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + /** + * @brief On event callback + **/ + void on_event(const app_mngr::event_engine::Event& event) OVERRIDE; + + /** + * @brief onTimeOut from requrst Controller + */ + void onTimeOut() OVERRIDE; + + /** + * @brief Send request to HMI for fetching of cappabilities + */ + void SendMessageToHMI(); + + private: + DISALLOW_COPY_AND_ASSIGN(VRIsReadyRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_IS_READY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_response.h new file mode 100644 index 0000000000..42c47f5077 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_response.h @@ -0,0 +1,77 @@ +/* + * 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_HMI_VR_IS_READY_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_IS_READY_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief VRIsReadyResponse command class + **/ +class VRIsReadyResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief VRIsReadyResponse class constructor + * + * @param message Incoming SmartObject message + **/ + VRIsReadyResponse(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_handle); + + /** + * @brief VRIsReadyResponse class destructor + **/ + virtual ~VRIsReadyResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(VRIsReadyResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_IS_READY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_request.h new file mode 100644 index 0000000000..6f206c010f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_request.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_HMI_VR_PERFORM_INTERACTION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_PERFORM_INTERACTION_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief VRPerformInteractionRequest command class + **/ +class VRPerformInteractionRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief VRPerformInteractionRequest class constructor + * + * @param message Incoming SmartObject message + **/ + VRPerformInteractionRequest( + 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_handle); + + /** + * @brief VRPerformInteractionRequest class destructor + **/ + virtual ~VRPerformInteractionRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(VRPerformInteractionRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_PERFORM_INTERACTION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_response.h new file mode 100644 index 0000000000..9e8599419f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_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_HMI_VR_PERFORM_INTERACTION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_PERFORM_INTERACTION_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief TTSPerformInteractionResponse command class + **/ +class VRPerformInteractionResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief TTSPerformInteractionResponse class constructor + * + * @param message Incoming SmartObject message + **/ + VRPerformInteractionResponse( + 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_handle); + + /** + * @brief TTSPerformInteractionResponse class destructor + **/ + virtual ~VRPerformInteractionResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(VRPerformInteractionResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_PERFORM_INTERACTION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_request.h new file mode 100644 index 0000000000..745fb3ec18 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_request.h @@ -0,0 +1,169 @@ +/* + + 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_ADD_COMMAND_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ADD_COMMAND_REQUEST_H_ + +#include <string> + +#include "application_manager/application.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 AddCommandRequest command class + **/ +class AddCommandRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief AddCommandRequest class constructor + * + * @param message Incoming SmartObject message + **/ + AddCommandRequest(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 AddCommandRequest class destructor + **/ + ~AddCommandRequest(); + + /** + * @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 Function is called by RequestController when request execution time + * has exceed it's limit + */ + void onTimeOut() FINAL; + + /** + * @brief Init sets hash update mode for request + */ + bool Init() FINAL; + + private: + /* + * @brief Check if command name doesn't exist in application + * Please see SDLAQ-CRS-407 for more information + * + * @param app Mobile application + * + * @return TRUE on success, otherwise FALSE + */ + bool CheckCommandName(app_mngr::ApplicationConstSharedPtr app); + + /* + * @brief Check if command VR synonyms doesn't exist in application commands + * Please see SDLAQ-CRS-407 for more information + * + * @param app Mobile application + * + * @return TRUE on success, otherwise FALSE + */ + bool CheckCommandVRSynonym(app_mngr::ApplicationConstSharedPtr app); + + /* + * @brief Check if command parent ID exists in submenu map + * + * @param app Mobile application + * + * @return TRUE on success, otherwise FALSE + */ + bool CheckCommandParentId(app_mngr::ApplicationConstSharedPtr app); + + /** + * @brief Removes command from list when HMI sends negative response or + * HMI does not answer on addCommand request. + */ + void RemoveCommand(); + + DISALLOW_COPY_AND_ASSIGN(AddCommandRequest); + + /* + * @brief Check if there some not delivered hmi responses exist + * + * @return true if all responses received + */ + bool IsPendingResponseExist(); + + /** + * @brief Checks add command param + * When type is String there is a check on the contents \t\n \\t \\n + * @return if add command contains \t\n \\t \\n return TRUE, + * FALSE otherwise + */ + bool IsWhiteSpaceExist(); + + inline bool BothSend() const; + + /** + * @brief GenerateMobileResponseInfo generated info for mobile response + * depends from UI and VR responses + * @return info for mobile response + */ + const std::string GenerateMobileResponseInfo(); + bool send_ui_; + bool send_vr_; + + bool is_ui_received_; + bool is_vr_received_; + + std::string ui_info_; + std::string vr_info_; + + hmi_apis::Common_Result::eType ui_result_; + hmi_apis::Common_Result::eType vr_result_; +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ADD_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_response.h new file mode 100644 index 0000000000..fb3f172b0b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_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_ADD_COMMAND_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ADD_COMMAND_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 AddCommandResponse command class + **/ +class AddCommandResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief AddCommandResponse class constructor + * + * @param message Incoming SmartObject message + **/ + AddCommandResponse(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 AddCommandResponse class destructor + **/ + virtual ~AddCommandResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(AddCommandResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ADD_COMMAND_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_request.h new file mode 100644 index 0000000000..37ba9a5990 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_request.h @@ -0,0 +1,97 @@ +/* + + 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_ADD_SUB_MENU_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ADD_SUB_MENU_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 AddSubMenuRequest command class + **/ +class AddSubMenuRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief AddSubMenuRequest class constructor + * + * @param message Incoming SmartObject message + **/ + AddSubMenuRequest(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 AddSubMenuRequest class destructor + **/ + ~AddSubMenuRequest(); + + /** + * @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; + + private: + /* + * @brief Check if submenu name is valid + * + * @return TRUE on success, otherwise FALSE + */ + bool CheckSubMenuName(); + + DISALLOW_COPY_AND_ASSIGN(AddSubMenuRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ADD_SUB_MENU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_response.h new file mode 100644 index 0000000000..253556f899 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_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_ADD_SUB_MENU_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ADD_SUB_MENU_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 AddSubMenuResponse command class + **/ +class AddSubMenuResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief AddSubMenuResponse class constructor + * + * @param message Incoming SmartObject message + **/ + AddSubMenuResponse(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 AddSubMenuResponse class destructor + **/ + virtual ~AddSubMenuResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(AddSubMenuResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ADD_SUB_MENU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h new file mode 100644 index 0000000000..93f716cb65 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h @@ -0,0 +1,110 @@ +/* + + 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_ALERT_MANEUVER_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ALERT_MANEUVER_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/commands/pending.h" +#include "interfaces/MOBILE_API.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief AlertManeuverRequest command class + **/ +class AlertManeuverRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief AlertManeuverRequest class constructor + * + * @param message Incoming SmartObject message + **/ + AlertManeuverRequest(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 AlertManeuverRequest class destructor + **/ + virtual ~AlertManeuverRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + virtual void on_event(const app_mngr::event_engine::Event& event); + + private: + /** + * @brief Prepare parameters for sending to mobile application + * @param result_code contains result code for sending to mobile application + * @param return_info contains resulting info for sending to mobile + * application + * @return result for sending to mobile application. + */ + bool PrepareResponseParameters(mobile_apis::Result::eType& result_code, + std::string& return_info); + /** + * @brief Checks alert maneuver params(ttsChunks, ...). + * When type is String there is a check on the contents \t\n \\t \\n + * @return if alert maneuver contains \t\n \\t \\n return TRUE, + * FALSE otherwise + */ + bool IsWhiteSpaceExist(); + + hmi_apis::Common_Result::eType tts_speak_result_code_; + hmi_apis::Common_Result::eType navi_alert_maneuver_result_code_; + std::string info_navi_; + std::string info_tts_; + app_mngr::commands::Pending pending_requests_; + + DISALLOW_COPY_AND_ASSIGN(AlertManeuverRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ALERT_MANEUVER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_response.h new file mode 100644 index 0000000000..8b21aa64eb --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_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_ALERT_MANEUVER_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ALERT_MANEUVER_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 AlertManeuverResponse command class + **/ +class AlertManeuverResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief AlertManeuverResponse class constructor + * + * @param message Incoming SmartObject message + **/ + AlertManeuverResponse(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 AlertManeuverResponse class destructor + **/ + virtual ~AlertManeuverResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(AlertManeuverResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ALERT_MANEUVER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_request.h new file mode 100644 index 0000000000..e34653daf4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_request.h @@ -0,0 +1,154 @@ +/* + + 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_ALERT_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ALERT_REQUEST_H_ + +#include <string> + +#include "application_manager/commands/command_request_impl.h" +#include "interfaces/MOBILE_API.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief AlertRequest command class + **/ +class AlertRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief AlertRequest class constructor + * + * @param message Incoming SmartObject message + **/ + AlertRequest(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 AlertRequest class destructor + **/ + virtual ~AlertRequest(); + + /** + * @brief Initialize request params + **/ + virtual bool Init(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + void on_event(const app_mngr::event_engine::Event& event); + + protected: + private: + /* + * @brief Checks if request parameters are valid + * @param app_id Id of application requested this RPC + * @returns true if request is valid and should be processed + */ + bool Validate(uint32_t app_id); + /* + * @brief Sends UI Alert request + * + * @param app_id Id of application requested this RPC + */ + void SendAlertRequest(int32_t app_id); + + /* + * @brief Sends TTS Speak request + * + * @param app_id Id of application requested this RPC + * + * @param tts_chunks_exists if tts chunks exists in + * message contains true, otherwise contains false + * + * @param length_tts_chunks contains length of array + * tts chunks. + */ + void SendSpeakRequest(int32_t app_id, + bool tts_chunks_exists, + size_t length_tts_chunks); + + /* + * @brief Tells if there are sent requests without responses + */ + bool HasHmiResponsesToWait(); + + /* + * @brief Check if all strings have valid syntax in request + * + * @return TRUE on success, otherwise FALSE + */ + bool CheckStringsOfAlertRequest(); + + /* + * @brief Prepare result code and result for sending to mobile application + * @param result_code contains result code for sending to mobile application + * @param info contains info for mobile app. + * @return result for sending to mobile application. + */ + bool PrepareResponseParameters(mobile_apis::Result::eType& result_code, + std::string& info); + + bool awaiting_ui_alert_response_; + bool awaiting_tts_speak_response_; + bool awaiting_tts_stop_speaking_response_; + bool is_alert_succeeded_; + bool is_ui_alert_sent_; + hmi_apis::Common_Result::eType alert_result_; + smart_objects::SmartObject alert_response_params_; + hmi_apis::Common_Result::eType tts_speak_result_; + std::string ui_response_info_; + std::string tts_response_info_; + + DISALLOW_COPY_AND_ASSIGN(AlertRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ALERT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_response.h new file mode 100644 index 0000000000..4ae95fb979 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_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_ALERT_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ALERT_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 AlertResponse command class + **/ +class AlertResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief AlertResponse class constructor + * + * @param message Incoming SmartObject message + **/ + AlertResponse(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 AlertResponse class destructor + **/ + virtual ~AlertResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(AlertResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ALERT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_request.h new file mode 100644 index 0000000000..bd5c34ebd1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_request.h @@ -0,0 +1,191 @@ +/* + + 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_CHANGE_REGISTRATION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CHANGE_REGISTRATION_REQUEST_H_ + +#include <strings.h> + +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/commands/pending.h" +#include "utils/macro.h" +#include "utils/custom_string.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +namespace custom_str = utils::custom_string; + +/** + * @brief ChangeRegistrationRequest command class + **/ +class ChangeRegistrationRequest + : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief ChangeRegistrationRequest class constructor + * + * @param message Incoming SmartObject message + **/ + ChangeRegistrationRequest(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 ChangeRegistrationRequest class destructor + **/ + virtual ~ChangeRegistrationRequest(); + + /** + * @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: + /* + * @brief Search for requested language in HMI UI supported languages + * + * @return true if language supported by UI, otherwise false + */ + bool IsLanguageSupportedByUI(const int32_t& hmi_display_lang); + + /* + * @brief Search for requested language in HMI VR supported languages + * + * @return true if language supported by VR, otherwise false + */ + bool IsLanguageSupportedByVR(const int32_t& hmi_display_lang); + + /* + * @brief Search for requested language in HMI TTS supported languages + * + * @return true if language supported by TTS, otherwise false + */ + bool IsLanguageSupportedByTTS(const int32_t& hmi_display_lang); + + /* + * @brief Check if there some not delivered hmi responses exist + * + * @return true if all responses received + */ + bool IsPendingResponseExist(); + + /** + * @brief Checks change_registration params(ttsName, appname, + * ngnMediaScreenAppName, vrSynonyms) on invalid characters. + * + * @return true if command contains \t\n \\t \\n of whitespace otherwise + * returns false. + */ + bool IsWhiteSpaceExist(); + + /** + * @brief Check parameters (name, vr) for + * coincidence with already known parameters of registered applications + * + * @return SUCCESS if there is no coincidence of app.name/VR synonyms, + * otherwise appropriate error code returns + */ + mobile_apis::Result::eType CheckCoincidence(); + + /** + * @brief Checks if requested name is allowed by policy + * @param app_name Application name + * @return true, if allowed, otherwise - false + */ + bool IsNicknameAllowed(const custom_str::CustomString& app_name) const; + + /** + * @brief Prepare result code and result for sending to mobile application + * @param result_code contains result code for sending to mobile application + * @param response_info contains info for sending to mobile application + * @return result for sending to mobile application. + */ + bool PrepareResponseParameters(mobile_apis::Result::eType& result_code, + std::string& ResponseInfo); + + /** + * @brief Predicate for using with CheckCoincidence method to compare with VR + * synonym SO + * + * @return TRUE if there is coincidence of VR, otherwise FALSE + */ + struct CoincidencePredicateVR { + CoincidencePredicateVR(const custom_str::CustomString& newItem) + : newItem_(newItem) {} + + bool operator()(const smart_objects::SmartObject& obj) const { + const custom_str::CustomString& vr_synonym = obj.asCustomString(); + return newItem_.CompareIgnoreCase(vr_synonym); + }; + + const custom_str::CustomString& newItem_; + }; + + app_mngr::commands::Pending pending_requests_; + + hmi_apis::Common_Result::eType ui_result_; + hmi_apis::Common_Result::eType vr_result_; + hmi_apis::Common_Result::eType tts_result_; + std::string ui_response_info_; + std::string vr_response_info_; + std::string tts_response_info_; + + void SendVRRequest(app_mngr::ApplicationSharedPtr app, + smart_objects::SmartObject& msg_params); + + void SendTTSRequest(app_mngr::ApplicationSharedPtr app, + smart_objects::SmartObject& msg_params); + + void SendUIRequest(app_mngr::ApplicationSharedPtr app, + smart_objects::SmartObject& msg_params, + const int32_t hmi_language); + + DISALLOW_COPY_AND_ASSIGN(ChangeRegistrationRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CHANGE_REGISTRATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_response.h new file mode 100644 index 0000000000..4cb8c394c7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_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_CHANGE_REGISTRATION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CHANGE_REGISTRATION_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 ChangeRegistrationResponse command class + **/ +class ChangeRegistrationResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief ChangeRegistrationResponse class constructor + * + * @param message Incoming SmartObject message + **/ + ChangeRegistrationResponse( + 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 ChangeRegistrationResponse class destructor + **/ + virtual ~ChangeRegistrationResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ChangeRegistrationResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CHANGE_REGISTRATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h new file mode 100644 index 0000000000..285b0b10db --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h @@ -0,0 +1,277 @@ +/* + + 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_CREATE_INTERACTION_CHOICE_SET_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_INTERACTION_CHOICE_SET_REQUEST_H_ +#include <map> +#include <string> + +#include "application_manager/application.h" +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/event_engine/event_observer.h" +#include "interfaces/MOBILE_API.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +class Application; + +namespace commands { + +/** + * @brief CreateInteractionChoiceSetRequest command class + **/ +class CreateInteractionChoiceSetRequest + : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief CreateInteractionChoiceSetRequest class constructor + * + * @param message Incoming SmartObject message + **/ + CreateInteractionChoiceSetRequest( + 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 CreateInteractionChoiceSetRequest class destructor + **/ + ~CreateInteractionChoiceSetRequest(); + + /** + * @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 Function is called by RequestController when request execution time + * has exceed it's limit + */ + void onTimeOut() FINAL; + + /** + * @brief Init sets hash update mode for request + */ + bool Init() FINAL; + + private: + /** + * @brief DeleteChoices allows to walk through the sent commands collection + * in order to sent appropriate DeleteCommand request. + */ + void DeleteChoices(); + + /** + * @brief Calls after all responses from HMI were received. + * Terminates request and sends successful response to mobile + * if all responses were SUCCESS or calls DeleteChoices in other case. + */ + void OnAllHMIResponsesReceived(); + + /** + * @brief The VRCommand struct + * Collect minimum information about sent VR commands, for correctly + * processing deleting sent commands if error from HMI received + */ + struct VRCommandInfo { + VRCommandInfo() : cmd_id_(0), succesful_response_received_(false) {} + VRCommandInfo(uint32_t cmd_id) + : cmd_id_(cmd_id), succesful_response_received_(false) {} + uint32_t cmd_id_; + bool succesful_response_received_; + }; + + typedef std::map<uint32_t, VRCommandInfo> SentCommandsMap; + SentCommandsMap sent_commands_map_; + + int32_t choice_set_id_; + size_t expected_chs_count_; + size_t received_chs_count_; + + /** + * @brief Flag for stop sending VR commands to HMI, in case one of responses + * failed + */ + volatile bool error_from_hmi_; + sync_primitives::Lock error_from_hmi_lock_; + + /** + * @brief Flag shows if request already was expired by timeout + */ + volatile bool is_timed_out_; + sync_primitives::Lock is_timed_out_lock_; + + sync_primitives::Lock vr_commands_lock_; + /* + * @brief Sends VR AddCommand request to HMI + * + * @param app_id Application ID + * + */ + void SendVRAddCommandRequests(app_mngr::ApplicationSharedPtr const app); + + /* + * @brief Checks incoming choiseSet params. + * @param app Registred mobile application + * + * @return Mobile result code + */ + mobile_apis::Result::eType CheckChoiceSet( + app_mngr::ApplicationConstSharedPtr app); + + /* + * @brief Predicate for using with CheckChoiceSet method to compare choice ID + *param + * + * return TRUE if there is coincidence of choice ID, otherwise FALSE + */ + struct CoincidencePredicateChoiceID { + CoincidencePredicateChoiceID(const uint32_t newItem) : newItem_(newItem) {} + + bool operator()(smart_objects::SmartObject obj) { + return obj[app_mngr::strings::choice_id].asUInt() == newItem_; + } + + const uint32_t newItem_; + }; + + /* + * @brief Predicate for using with CheckChoiceSet method to compare menu name + *param + * + * return TRUE if there is coincidence of menu name, otherwise FALSE + */ + struct CoincidencePredicateMenuName { + CoincidencePredicateMenuName(const std::string& newItem) + : newItem_(newItem) {} + + bool operator()(smart_objects::SmartObject obj) { + return obj[app_mngr::strings::menu_name].asString() == newItem_; + } + + const std::string& newItem_; + }; + + /* + * @brief Predicate for using with CheckChoiceSet method to compare VR commands + *param + * + * return TRUE if there is coincidence of VR commands, otherwise FALSE + */ + struct CoincidencePredicateVRCommands { + CoincidencePredicateVRCommands(const smart_objects::SmartObject& newItem) + : newItem_(newItem) {} + + bool operator()(smart_objects::SmartObject obj) { + return compareStr(obj, newItem_); + } + + const smart_objects::SmartObject& newItem_; + }; + + /* + * @brief Checks if incoming choice set doesn't has similar VR synonyms. + * + * @param choice1 Choice to compare + * @param choice2 Choice to compare + * + * return Return TRUE if there are similar VR synonyms in choice set, + * otherwise FALSE + */ + bool compareSynonyms( + const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice1, + const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice2); + + /* + * @brief Checks VR synonyms ignoring differences in case. + * + * @param str1 VR synonym to compare + * @param str2 VR synonym to compare + * + * return Return TRUE if there are similar VR synonyms in choice set, + * otherwise FALSE + */ + static bool compareStr( + const NsSmartDeviceLink::NsSmartObjects::SmartObject& str1, + const NsSmartDeviceLink::NsSmartObjects::SmartObject& str2); + + /** + * @brief Checks choice set params(menuName, tertiaryText, ...) + * When type is String there is a check on the contents \t\n \\t \\n + * @param choice_set which must check + * @return if choice_set contains \t\n \\t \\n return TRUE, FALSE otherwise + */ + bool IsWhiteSpaceExist(const smart_objects::SmartObject& choice_set); + + /** + * @brief ProcessHmiError process received error from HMI. + * This function id not thread safe. It should be protected with + * vr_commands_lock_ + * @param vr_result ERROR type + */ + void ProcessHmiError(const hmi_apis::Common_Result::eType vr_result); + + /** + * @brief ProcessSuccesfulHMIResponse process succesful response from HMI\ + * This function id not thread safe. It should be protected with + * vr_commands_lock_ + * @param corr_id correlation id of received response + * @return true if resuest with corr_itd was sent on HMI, false otherwise + */ + bool ProcessSuccesfulHMIResponse(const uint32_t corr_id); + + /** + * @brief CountReceivedVRResponses counts received HMI responses. Updated + * request timeout if not all responses received + * Send response to mobile if all responses received. + */ + void CountReceivedVRResponses(); + + DISALLOW_COPY_AND_ASSIGN(CreateInteractionChoiceSetRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_INTERACTION_CHOICE_SET_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_response.h new file mode 100644 index 0000000000..76718bc2c3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_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_CREATE_INTERACTION_CHOICE_SET_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_INTERACTION_CHOICE_SET_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 CreateInteractionChoiceSetResponse command class + **/ +class CreateInteractionChoiceSetResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief CreateInteractionChoiceSetResponse class constructor + * + * @param message Incoming SmartObject message + **/ + CreateInteractionChoiceSetResponse( + 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 CreateInteractionChoiceSetResponse class destructor + **/ + virtual ~CreateInteractionChoiceSetResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(CreateInteractionChoiceSetResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_INTERACTION_CHOICE_SET_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_request.h new file mode 100644 index 0000000000..a21b1928d0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_request.h @@ -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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_COMMAND_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_COMMAND_REQUEST_H_ + +#include <string> + +#include "application_manager/commands/command_request_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief DeleteCommandRequest command class + **/ +class DeleteCommandRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief DeleteCommandRequest class constructor + * + * @param message Incoming SmartObject message + **/ + DeleteCommandRequest(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 DeleteCommandRequest class destructor + **/ + ~DeleteCommandRequest(); + + /** + * @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; + + private: + DISALLOW_COPY_AND_ASSIGN(DeleteCommandRequest); + + /* + * @brief Check if there some not delivered hmi responses exist + * + * @return true if all responses received + */ + bool IsPendingResponseExist(); + + /* + * @brief Prepare result code and result for sending to mobile application + * @param result_code contains result code for sending to mobile application + * @param info contains info for mobile app. + * @return result for sending to mobile application. + */ + bool PrepareResponseParameters(mobile_apis::Result::eType& result_code, + std::string& info); + + bool is_ui_send_; + bool is_vr_send_; + + bool is_ui_received_; + bool is_vr_received_; + + hmi_apis::Common_Result::eType ui_result_; + hmi_apis::Common_Result::eType vr_result_; + std::string ui_info_; + std::string vr_info_; +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_response.h new file mode 100644 index 0000000000..f81f119792 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_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_DELETE_COMMAND_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_COMMAND_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 DeleteCommandResponse command class + **/ +class DeleteCommandResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief DeleteCommandResponse class constructor + * + * @param message Incoming SmartObject message + **/ + DeleteCommandResponse(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 DeleteCommandResponse class destructor + **/ + virtual ~DeleteCommandResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(DeleteCommandResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_COMMAND_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_request.h new file mode 100644 index 0000000000..02cd0086b6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_request.h @@ -0,0 +1,83 @@ +/* + + 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_DELETE_FILE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_FILE_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +struct AppFile; + +namespace commands { + +/** + * @brief DeleteFileRequest command class + **/ +class DeleteFileRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief DeleteFileRequest class constructor + * + * @param message Incoming SmartObject message + **/ + DeleteFileRequest(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 DeleteFileRequest class destructor + **/ + virtual ~DeleteFileRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(DeleteFileRequest); + + void SendFileRemovedNotification( + const application_manager::AppFile* file) const; +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_FILE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_response.h new file mode 100644 index 0000000000..fbdc70c9bc --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_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_DELETE_FILE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_FILE_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 DeleteFileResponse command class + **/ +class DeleteFileResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief DeleteFileResponse class constructor + * + * @param message Incoming SmartObject message + **/ + DeleteFileResponse(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 DeleteFileResponse class destructor + **/ + virtual ~DeleteFileResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(DeleteFileResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_FILE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_request.h new file mode 100644 index 0000000000..4dec11a67b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_request.h @@ -0,0 +1,95 @@ +/* + + 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_DELETE_INTERACTION_CHOICE_SET_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_INTERACTION_CHOICE_SET_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 DeleteInteractionChoiceSetRequest command class + **/ +class DeleteInteractionChoiceSetRequest + : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief DeleteInteractionChoiceSetRequest class constructor + * + * @param message Incoming SmartObject message + **/ + DeleteInteractionChoiceSetRequest( + 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 DeleteInteractionChoiceSetRequest class destructor + **/ + ~DeleteInteractionChoiceSetRequest(); + + /** + * @brief Execute command + **/ + void Run() FINAL; + + /** + * @brief Init sets hash update mode for request + */ + bool Init() FINAL; + + private: + /* + * @brief Check if requested choice set ID in use by perform interaction + * + * @param app mobile application + */ + bool ChoiceSetInUse(app_mngr::ApplicationConstSharedPtr app); + + void SendVrDeleteCommand(app_mngr::ApplicationSharedPtr app); + + DISALLOW_COPY_AND_ASSIGN(DeleteInteractionChoiceSetRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_INTERACTION_CHOICE_SET_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_response.h new file mode 100644 index 0000000000..0fce16ea9f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_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_DELETE_INTERACTION_CHOICE_SET_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_INTERACTION_CHOICE_SET_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 DeleteInteractionChoiceSetResponse command class + **/ +class DeleteInteractionChoiceSetResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief DeleteInteractionChoiceSetResponse class constructor + * + * @param message Incoming SmartObject message + **/ + DeleteInteractionChoiceSetResponse( + 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 DeleteInteractionChoiceSetResponse class destructor + **/ + virtual ~DeleteInteractionChoiceSetResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(DeleteInteractionChoiceSetResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_INTERACTION_CHOICE_SET_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h new file mode 100644 index 0000000000..c947fda78a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h @@ -0,0 +1,109 @@ +/* + + 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_DELETE_SUB_MENU_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_SUB_MENU_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 DeleteSubMenuRequest command class + **/ +class DeleteSubMenuRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief DeleteSubMenuRequest class constructor + * + * @param message Incoming SmartObject message + **/ + DeleteSubMenuRequest(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 DeleteSubMenuRequest class destructor + **/ + ~DeleteSubMenuRequest(); + + /** + * @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; + + private: + /* + * @brief Deletes VR commands from SDL for corresponding submenu ID + * + * @param app_id Application ID + * + * @return TRUE on success, otherwise FALSE + */ + void DeleteSubMenuVRCommands(app_mngr::ApplicationConstSharedPtr app); + + /* + * @brief Deletes UI commands from SDL for corresponding submenu ID + * + * @param app_id Application ID + * + * @return TRUE on success, otherwise FALSE + */ + void DeleteSubMenuUICommands(app_mngr::ApplicationSharedPtr const app); + + DISALLOW_COPY_AND_ASSIGN(DeleteSubMenuRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_SUB_MENU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_response.h new file mode 100644 index 0000000000..e5b0c58a34 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_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_DELETE_SUB_MENU_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_SUB_MENU_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 ResetGlobalPropertiesResponse command class + **/ +class DeleteSubMenuResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief DeleteSubMenuResponse class constructor + * + * @param message Incoming SmartObject message + **/ + DeleteSubMenuResponse(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 DeleteSubMenuResponse class destructor + **/ + virtual ~DeleteSubMenuResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(DeleteSubMenuResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_SUB_MENU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_request.h new file mode 100644 index 0000000000..3e313602c7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_request.h @@ -0,0 +1,95 @@ +/* + 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_DIAL_NUMBER_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAL_NUMBER_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 DialNumber request command class + **/ +class DialNumberRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * \brief DialNumberRequest class constructor + **/ + DialNumberRequest(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 DialNumberRequest class destructor + **/ + ~DialNumberRequest() OVERRIDE; + + /** + * @brief Initialize request params + **/ + bool Init() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + /** + * @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: + /** + * @brief Removes from number param all characters + * except the + character and digits. + * + */ + void StripNumberParam(std::string& number); + + DISALLOW_COPY_AND_ASSIGN(DialNumberRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAL_NUMBER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_response.h new file mode 100644 index 0000000000..6181231458 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_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_DIAL_NUMBER_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAL_NUMBER_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 DialNumberResponse command class + **/ +class DialNumberResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief DialNumberResponse class constructor + * + * @param message Incoming SmartObject message + **/ + DialNumberResponse(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 DialNumberResponse class destructor + **/ + virtual ~DialNumberResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(DialNumberResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAL_NUMBER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_request.h new file mode 100644 index 0000000000..319a20958e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_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_END_AUDIO_PASS_THRU_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_END_AUDIO_PASS_THRU_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 EndAudioPassThruRequest command class + **/ +class EndAudioPassThruRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief EndAudioPassThruRequest class constructor + * + * @param message Incoming SmartObject message + **/ + EndAudioPassThruRequest(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 EndAudioPassThruRequest class destructor + **/ + virtual ~EndAudioPassThruRequest(); + + /** + * @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(EndAudioPassThruRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_END_AUDIO_PASS_THRU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_response.h new file mode 100644 index 0000000000..e2a667f272 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_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_END_AUDIO_PASS_THRU_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_END_AUDIO_PASS_THRU_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 EndAudioPassThruResponse command class + **/ +class EndAudioPassThruResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief EndAudioPassThruResponse class constructor + * + * @param message Incoming SmartObject message + **/ + EndAudioPassThruResponse(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 EndAudioPassThruResponse class destructor + **/ + virtual ~EndAudioPassThruResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(EndAudioPassThruResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_END_AUDIO_PASS_THRU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/generic_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/generic_response.h new file mode 100644 index 0000000000..b780daaf03 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/generic_response.h @@ -0,0 +1,77 @@ +/* + * 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_GENERIC_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GENERIC_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "application_manager/message.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +class GenericResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * \brief GenericResponse class constructor + **/ + GenericResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manage, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manage, + rpc_service, + hmi_capabilities, + policy_handler) {} + + /** + * \brief GenericResponse class destructor + **/ + virtual ~GenericResponse() {} + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(GenericResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GENERIC_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_request.h new file mode 100644 index 0000000000..b8da061870 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_request.h @@ -0,0 +1,67 @@ +/* + + 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_SYSTEM_CAPABILITY_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_SYSTEM_CAPABILITY_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +class GetSystemCapabilityRequest + : public app_mngr::commands::CommandRequestImpl { + public: + GetSystemCapabilityRequest( + 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); + + virtual ~GetSystemCapabilityRequest(); + + virtual void Run() OVERRIDE; + + virtual void on_event(const app_mngr::event_engine::Event& event); + + private: + DISALLOW_COPY_AND_ASSIGN(GetSystemCapabilityRequest); + +}; // GetSystemCapabilityRequest +} // commands +} // application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_SYSTEM_CAPABILITY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_response.h new file mode 100644 index 0000000000..9fa954c89f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_response.h @@ -0,0 +1,66 @@ +/* + + 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_SYSTEM_CAPABILITY_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_SYSTEM_CAPABILITY_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 { + +class GetSystemCapabilityResponse + : public app_mngr::commands::CommandResponseImpl { + public: + GetSystemCapabilityResponse( + 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); + + virtual ~GetSystemCapabilityResponse(); + + virtual void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(GetSystemCapabilityResponse); + +}; // GetSystemCapabilityResponse +} // commands +} // application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_SYSTEM_CAPABILITY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_request.h new file mode 100644 index 0000000000..7197874475 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_request.h @@ -0,0 +1,81 @@ +/* + * 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_WAY_POINTS_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_WAY_POINTS_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief GetWayPointsRequest command class + **/ +class GetWayPointsRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * \brief GetWayPointsRequest class constructor + **/ + GetWayPointsRequest(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 GetWayPointsRequest class destructor + **/ + virtual ~GetWayPointsRequest(); + + /** + * @brief Execute command + **/ + virtual void Run() OVERRIDE; + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + virtual void on_event(const app_mngr::event_engine::Event& event); + + private: + DISALLOW_COPY_AND_ASSIGN(GetWayPointsRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_response.h new file mode 100644 index 0000000000..bb480a7ac0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_response.h @@ -0,0 +1,76 @@ +/* + * 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_WAY_POINTS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_WAY_POINTS_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 GetWayPointsResponse command class + **/ +class GetWayPointsResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * \brief GetWayPointsResponse class constructor + **/ + GetWayPointsResponse(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 GetWayPointsResponse class destructor + **/ + virtual ~GetWayPointsResponse(); + + /** + * @brief Execute command + **/ + virtual void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(GetWayPointsResponse); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_request.h new file mode 100644 index 0000000000..53d75819f8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_request.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_LIST_FILES_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_LIST_FILES_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 ListFilesRequest command class + **/ +class ListFilesRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief ListFilesRequest class constructor + * + * @param message Incoming SmartObject message + **/ + ListFilesRequest(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 ListFilesRequest class destructor + **/ + virtual ~ListFilesRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ListFilesRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_LIST_FILES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_response.h new file mode 100644 index 0000000000..1b3cdf1b02 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_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_LIST_FILES_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_LIST_FILES_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 ListFilesResponse command class + **/ +class ListFilesResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief ListFilesResponse class constructor + * + * @param message Incoming SmartObject message + **/ + ListFilesResponse(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 ListFilesResponse class destructor + **/ + virtual ~ListFilesResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ListFilesResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_LIST_FILES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_app_interface_unregistered_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_app_interface_unregistered_notification.h new file mode 100644 index 0000000000..ba01d4bb28 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_app_interface_unregistered_notification.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_ON_APP_INTERFACE_UNREGISTERED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_APP_INTERFACE_UNREGISTERED_NOTIFICATION_H_ + +#include "application_manager/commands/command_notification_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnAppInterfaceUnregisteredNotification class + **/ +class OnAppInterfaceUnregisteredNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + /** + * @brief OnAppInterfaceUnregisteredNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnAppInterfaceUnregisteredNotification( + 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 OnAppInterfaceUnregisteredNotification class destructor + **/ + virtual ~OnAppInterfaceUnregisteredNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnAppInterfaceUnregisteredNotification); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_APP_INTERFACE_UNREGISTERED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_audio_pass_thru_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_audio_pass_thru_notification.h new file mode 100644 index 0000000000..e3410bd873 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_audio_pass_thru_notification.h @@ -0,0 +1,82 @@ +/* + + 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_AUDIO_PASS_THRU_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_AUDIO_PASS_THRU_NOTIFICATION_H_ + +#include "application_manager/commands/command_notification_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnAudioPassThruNotification class used to send notification with + *binary data written from + * microphone to mobile device while PerformAudioPassThru is active. + **/ +class OnAudioPassThruNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + /** + * @brief OnAudioPassThruNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnAudioPassThruNotification( + 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 OnAudioPassThruNotification class destructor + **/ + virtual ~OnAudioPassThruNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnAudioPassThruNotification); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_AUDIO_PASS_THRU_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_event_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_event_notification.h new file mode 100644 index 0000000000..6afdc0e1cf --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_event_notification.h @@ -0,0 +1,92 @@ +/* + + 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_BUTTON_EVENT_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_EVENT_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 { + +namespace mobile { + +/** + * @brief OnButtonEventNotification class is used to send notification + * to mobile device that some button was pressed on HMI. + **/ +class OnButtonEventNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + /** + * @brief OnButtonEventNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnButtonEventNotification(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 OnButtonEventNotification class destructor + **/ + virtual ~OnButtonEventNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + /* + * @brief Sends button event notification to mobile device + * + * @param app Application to receive notification + */ + void SendButtonEvent(app_mngr::ApplicationConstSharedPtr app); + + DISALLOW_COPY_AND_ASSIGN(OnButtonEventNotification); +}; + +} // namespace mobile + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_EVENT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_press_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_press_notification.h new file mode 100644 index 0000000000..fe9bc449be --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_press_notification.h @@ -0,0 +1,91 @@ +/* + + 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_BUTTON_PRESS_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_PRESS_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 { + +namespace mobile { + +/** + * @brief OnButtonPressNotification class is used to send notification + * to mobile device that some button was pressed on HMI. + **/ +class OnButtonPressNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + /** + * @brief OnButtonPressNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnButtonPressNotification(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 OnButtonEventCommand class destructor + **/ + virtual ~OnButtonPressNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + /* + * @brief Sends button press notification to mobile device + * + * @param app Application to receive notification + */ + void SendButtonPress(app_mngr::ApplicationConstSharedPtr app); + + DISALLOW_COPY_AND_ASSIGN(OnButtonPressNotification); +}; + +} // namespace mobile +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_PRESS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_command_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_command_notification.h new file mode 100644 index 0000000000..367b280e73 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_command_notification.h @@ -0,0 +1,82 @@ +/* + + 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_COMMAND_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_COMMAND_NOTIFICATION_H_ + +#include "application_manager/commands/command_notification_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +class Application; + +namespace commands { + +/** + * @brief OnCommandNotification class is used to send notification + * to mobile device. + **/ +class OnCommandNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + /** + * @brief OnCommandNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnCommandNotification(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 OnCommandNotification class destructor + **/ + virtual ~OnCommandNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnCommandNotification); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_COMMAND_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_driver_distraction_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_driver_distraction_notification.h new file mode 100644 index 0000000000..82e6097d84 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_driver_distraction_notification.h @@ -0,0 +1,84 @@ +/* + + 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_DRIVER_DISTRACTION_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_DRIVER_DISTRACTION_NOTIFICATION_H_ + +#include "application_manager/commands/command_notification_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +namespace mobile { + +/** + * @brief OnDriverDistractionNotification class + **/ +class OnDriverDistractionNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + /** + * @brief OnDriverDistractionNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnDriverDistractionNotification( + 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 OnDriverDistractionNotification class destructor + **/ + virtual ~OnDriverDistractionNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnDriverDistractionNotification); +}; + +} // namespace mobile + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_DRIVER_DISTRACTION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h new file mode 100644 index 0000000000..76c9cf34c5 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h @@ -0,0 +1,81 @@ +/* + + 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_HASH_CHANGE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_HASH_CHANGE_NOTIFICATION_H_ + +#include "application_manager/commands/command_notification_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { +namespace mobile { + +/** + * @brief OnHashChangeNotification class + **/ +class OnHashChangeNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + /** + * @brief OnHashChangeNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnHashChangeNotification(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 OnHashChangeNotification class destructor + **/ + virtual ~OnHashChangeNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnHashChangeNotification); +}; + +} // namespace mobile +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_HASH_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification.h new file mode 100644 index 0000000000..0e1919676b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification.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_ON_HMI_STATUS_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_HMI_STATUS_NOTIFICATION_H_ + +#include "application_manager/commands/command_notification_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnHMIStatusNotification class + **/ +class OnHMIStatusNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + /** + * @brief OnHMIStatusNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnHMIStatusNotification(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 OnHMIStatusNotification class destructor + **/ + virtual ~OnHMIStatusNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnHMIStatusNotification); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_HMI_STATUS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification_from_mobile.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification_from_mobile.h new file mode 100644 index 0000000000..12e3b54be9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification_from_mobile.h @@ -0,0 +1,82 @@ +/* + + 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_HMI_STATUS_NOTIFICATION_FROM_MOBILE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_HMI_STATUS_NOTIFICATION_FROM_MOBILE_H_ + +#include "application_manager/commands/command_notification_from_mobile_impl.h" +#include "application_manager/application_manager.h" +#include "interfaces/MOBILE_API.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnHMIStatusNotificationFromMobile class + **/ +class OnHMIStatusNotificationFromMobile + : public app_mngr::commands::CommandNotificationFromMobileImpl { + public: + /** + * @brief OnHMIStatusNotificationFromMobile class constructor + * + * @param message Incoming SmartObject message + **/ + OnHMIStatusNotificationFromMobile( + 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 OnHMIStatusNotificationFromMobile class destructor + **/ + virtual ~OnHMIStatusNotificationFromMobile(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnHMIStatusNotificationFromMobile); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_HMI_STATUS_NOTIFICATION_FROM_MOBILE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_keyboard_input_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_keyboard_input_notification.h new file mode 100644 index 0000000000..d34815ff2f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_keyboard_input_notification.h @@ -0,0 +1,83 @@ +/* + + 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_KEYBOARD_INPUT_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_KEYBOARD_INPUT_NOTIFICATION_H_ + +#include "application_manager/commands/command_notification_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +namespace mobile { + +/** + * @brief OnKeyBoardInputNotification class + **/ +class OnKeyBoardInputNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + /** + * @brief OnKeyBoardInputNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnKeyBoardInputNotification( + 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 OnKeyBoardInputNotification class destructor + **/ + virtual ~OnKeyBoardInputNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnKeyBoardInputNotification); +}; + +} // namespace mobile +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_KEYBOARD_INPUT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_language_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_language_change_notification.h new file mode 100644 index 0000000000..b234b93796 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_language_change_notification.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_ON_LANGUAGE_CHANGE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_LANGUAGE_CHANGE_NOTIFICATION_H_ + +#include "application_manager/commands/command_notification_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnLanguageChangeNotification class + **/ +class OnLanguageChangeNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + /** + * @brief OnLanguageChangeNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnLanguageChangeNotification( + 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 OnLanguageChangeNotification class destructor + **/ + virtual ~OnLanguageChangeNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnLanguageChangeNotification); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_LANGUAGE_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_permissions_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_permissions_change_notification.h new file mode 100644 index 0000000000..f586a0d36c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_permissions_change_notification.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_ON_PERMISSIONS_CHANGE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_PERMISSIONS_CHANGE_NOTIFICATION_H_ + +#include "application_manager/commands/command_notification_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnPermissionsChangeNotification class + **/ +class OnPermissionsChangeNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + /** + * @brief OnPermissionsChangeNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnPermissionsChangeNotification( + 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 OnPermissionsChangeNotification class destructor + **/ + virtual ~OnPermissionsChangeNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnPermissionsChangeNotification); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_PERMISSIONS_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h new file mode 100644 index 0000000000..b369ad38f2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h @@ -0,0 +1,93 @@ +/* + 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_SYSTEM_REQUEST_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SYSTEM_REQUEST_NOTIFICATION_H_ + +#include "application_manager/commands/command_notification_impl.h" +#include "policy/policy_table/enums.h" +#include <vector> + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +namespace mobile { + +/** + * @brief OnSystemRequestNotification class + **/ +class OnSystemRequestNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + typedef std::vector<uint8_t> BinaryMessage; + /** + * @brief OnSystemRequestNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnSystemRequestNotification( + 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 OnSystemRequestNotification class destructor + **/ + ~OnSystemRequestNotification() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: +#ifdef PROPRIETARY_MODE + /** + * @brief Adds HTTP header to message + * @param message Message + */ + void AddHeader(BinaryMessage& message) const; + size_t ParsePTString(std::string& pt_string) const; +#endif // PROPRIETARY_MODE + + DISALLOW_COPY_AND_ASSIGN(OnSystemRequestNotification); +}; + +} // namespace mobile +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SYSTEM_REQUEST_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_tbt_client_state_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_tbt_client_state_notification.h new file mode 100644 index 0000000000..39b12fea15 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_tbt_client_state_notification.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_ON_TBT_CLIENT_STATE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_TBT_CLIENT_STATE_NOTIFICATION_H_ + +#include "application_manager/commands/command_notification_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnTBTClientStateNotification class + **/ +class OnTBTClientStateNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + /** + * @brief OnTBTClientStateNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnTBTClientStateNotification( + 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 OnTBTClientStateNotification class destructor + **/ + virtual ~OnTBTClientStateNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnTBTClientStateNotification); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_TBT_CLIENT_STATE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_touch_event_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_touch_event_notification.h new file mode 100644 index 0000000000..858759b793 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_touch_event_notification.h @@ -0,0 +1,82 @@ +/* + + 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_TOUCH_EVENT_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_TOUCH_EVENT_NOTIFICATION_H_ + +#include "application_manager/commands/command_notification_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +namespace mobile { + +/** + * @brief OnTouchEventNotification class + **/ +class OnTouchEventNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + /** + * @brief OnTouchEventNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnTouchEventNotification(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 OnTouchEventNotification class destructor + **/ + virtual ~OnTouchEventNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnTouchEventNotification); +}; + +} // namespace mobile +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_TOUCH_EVENT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_way_point_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_way_point_change_notification.h new file mode 100644 index 0000000000..c379fceb02 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_way_point_change_notification.h @@ -0,0 +1,75 @@ +/* + * 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_WAY_POINT_CHANGE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_WAY_POINT_CHANGE_NOTIFICATION_H_ + +#include "application_manager/commands/command_notification_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +class OnWayPointChangeNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + /** + * @brief OnWayPointChangeNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnWayPointChangeNotification( + 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 OnWayPointChangeNotification class destructor + **/ + virtual ~OnWayPointChangeNotification(); + + /** + * @brief Execute command + **/ + virtual void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(OnWayPointChangeNotification); +}; + +} // namespace commands +} // namespace application_manager +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_WAY_POINT_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h new file mode 100644 index 0000000000..6db222a401 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h @@ -0,0 +1,198 @@ +/* + + 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_PERFORM_AUDIO_PASS_THRU_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_AUDIO_PASS_THRU_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "utils/macro.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief PerformAudioPassThruRequest command class + **/ +class PerformAudioPassThruRequest + : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief PerformAudioPassThruRequest class constructor + * + * @param message Incoming SmartObject message + **/ + PerformAudioPassThruRequest( + 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 PerformAudioPassThruRequest class destructor + **/ + virtual ~PerformAudioPassThruRequest(); + + /** + * @brief Function is called by RequestController when request execution time + * has exceed it's limit + * + */ + virtual void onTimeOut(); + + /** + * @brief Init required by command resources + **/ + bool Init(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + void on_event(const app_mngr::event_engine::Event& event); + + private: + /** + * @brief Prepare result code, result and info for sending to mobile + * @brief Response params + * success for sending to mobile application + * result code for sending to mobile application + * info for sending to mobile application + */ + struct ResponseParams { + bool success; + mobile_apis::Result::eType result_code; + std::string info; + ResponseParams() + : success(false), result_code(mobile_apis::Result::INVALID_ENUM) {} + }; + + ResponseParams response_params_; + + /** + * @brief Prepare result code, result and info for sending to mobile + * application + * @param result_code contains result code for sending to mobile application + * @return result for sending to mobile application. + * @deprecated + */ + DEPRECATED bool PrepareResponseParameters( + mobile_apis::Result::eType& result_code, std::string& info); + /** + * @brief Prepare result code, 'success' result and info for sending + * to mobile application + * @param result_code contains result code for sending to mobile application + * @return result for sending to mobile application. + */ + const ResponseParams& PrepareResponseParameters(); + + /** + * @brief Sends TTS Speak request + */ + void SendSpeakRequest(); + + /** + * @brief Sends UI PerformAudioPassThru request + */ + void SendPerformAudioPassThruRequest(); + + /** + * @brief Sends UI RecordStart notification after TTS Speak response received. + * Indicates that capturing mic data should be started + */ + void SendRecordStartNotification(); + + /** + * @brief Starts microphone recording + */ + void StartMicrophoneRecording(); + + /** + * @brief Checks perform audio pass thru params(initialPrompt, ...). + * When type is String there is a check on the contents \t\n \\t \\n + * @return if perform audio pass thru contains \t\n \\t \\n return TRUE, + * FALSE otherwise + */ + bool IsWhiteSpaceExist(); + + /** + * @brief If is_active_tts_speak_ TRUE - set up to FALSE and send request + * TTS_StopSpeaking to HMI + */ + void FinishTTSSpeak(); + + /* + * @brief Tells if there are sent requests without responses + */ + bool IsWaitingHMIResponse(); + + /** + * @brief Pair of result_code and success for mobile app + */ + typedef std::pair<mobile_apis::Result::eType, bool> AudioPassThruResults; + + /** + * @brief Checks result code from HMI for splitted RPC + * and returns parameter for sending to mobile app in + * audioPassThru communication. + * @param ui_response contains result_code from UI + * @param tts_response contains result_code from TTS + * @return pair of result code (UI error code has precedence than TTS's, + * error_code from TTS is turned to WARNINGS) and + * result for mobile app + */ + AudioPassThruResults PrepareAudioPassThruResultCodeForResponse( + const app_mngr::commands::ResponseInfo& ui_response, + const app_mngr::commands::ResponseInfo& tts_response); + + hmi_apis::Common_Result::eType result_tts_speak_; + hmi_apis::Common_Result::eType result_ui_; + std::string ui_info_; + std::string tts_info_; + + DISALLOW_COPY_AND_ASSIGN(PerformAudioPassThruRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_AUDIO_PASS_THRU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_response.h new file mode 100644 index 0000000000..6654762067 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_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_PERFORM_AUDIO_PASS_THRU_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_AUDIO_PASS_THRU_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 PerformAudioPassThruResponse command class + **/ +class PerformAudioPassThruResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief PerformAudioPassThruResponse class constructor + * + * @param message Incoming SmartObject message + **/ + PerformAudioPassThruResponse( + 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 PerformAudioPassThruResponse class destructor + **/ + virtual ~PerformAudioPassThruResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(PerformAudioPassThruResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_AUDIO_PASS_THRU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h new file mode 100644 index 0000000000..40e706b851 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h @@ -0,0 +1,244 @@ +/* + + 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_PERFORM_INTERACTION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_INTERACTION_REQUEST_H_ + +#include <string> + +#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; + +class Application; + +namespace commands { + +/** + * @brief PerformInteractionRequest command class + **/ +class PerformInteractionRequest + : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief PerformInteractionRequest class constructor + * + * @param message Incoming SmartObject message + **/ + PerformInteractionRequest(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 PerformInteractionRequest class destructor + **/ + virtual ~PerformInteractionRequest(); + + /** + * @brief Initialize request params + **/ + virtual bool Init(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + virtual void on_event(const app_mngr::event_engine::Event& event); + + /* + * @brief Function is called by RequestController when request execution time + * has exceed it's limit + * + */ + virtual void onTimeOut(); + + private: + /** + * @brief Function will be called when VR_OnCommand event + * comes + * @param message which should send to mobile side + * @return true if send response to mobile application otherwise + * return false. + */ + bool ProcessVRResponse(const smart_objects::SmartObject& message, + smart_objects::SmartObject& msg_params); + + /** + * @brief Sends PerformInteraction response to mobile side + * @param message which should send to mobile side + */ + void ProcessUIResponse(const smart_objects::SmartObject& message, + smart_objects::SmartObject& msg_params); + + /* + * @brief Sends UI PerformInteraction request to HMI + * + * @param app_id Application ID + * + */ + void SendUIPerformInteractionRequest( + app_mngr::ApplicationSharedPtr const app); + + /* + * @brief Sends TTS PerformInteraction request to HMI + * + * @param app_id Application ID + * + */ + void SendVRPerformInteractionRequest( + app_mngr::ApplicationSharedPtr const app); + + /* + * @brief Sends UI Show VR help request to HMI + * + * @param app_id Application ID + */ + void SendUIShowVRHelpRequest(app_mngr::ApplicationSharedPtr const app); + + /* + * @brief Checks if incoming choice set doesn't has similar menu names. + * + * @param app_id Application ID + * + * return Return TRUE if there are no similar menu names in choice set, + * otherwise FALSE + */ + bool CheckChoiceSetMenuNames(app_mngr::ApplicationSharedPtr const app); + + /* + * @brief Checks if incoming choice set doesn't has similar VR synonyms. + * + * @param app_id Application ID + * + * return Return TRUE if there are no similar VR synonyms in choice set, + * otherwise FALSE + */ + bool CheckChoiceSetVRSynonyms(app_mngr::ApplicationSharedPtr const app); + + /* + * @brief Checks if request with non-sequential positions of vrHelpItems + * SDLAQ-CRS-466 + * + * @param app_id Application ID + * + * @return TRUE if vrHelpItems positions are sequential, + * otherwise FALSE + */ + bool CheckVrHelpItemPositions(app_mngr::ApplicationSharedPtr const app); + + /* + * @brief Disable PerformInteraction state in application and + * delete VR commands from HMI + */ + void DisablePerformInteraction(); + + /** + * @brief Checks perform interaction params(initialText, initialPrompt, ...). + * When type is String there is a check on the contents \t\n \\t \\n + * @return if perform interaction contains \t\n \\t \\n return TRUE, + * FALSE otherwise + */ + bool IsWhiteSpaceExist(); + + /** + * @brief Send HMI close PopUp and call DisablePerformInteraction + */ + void TerminatePerformInteraction(); + + /** + * @brief Checks parameter ChoiceID from response. + * @param app contains pointer to application + * @param choice_id contains ChoiceID from response. + * @return if ChoiceID from response is correct method returns TRUE + * otherwise returns FALSE. + */ + bool CheckChoiceIDFromResponse(app_mngr::ApplicationSharedPtr app, + int32_t choice_id); + + /** + * @brief Checks for a match of choice ID, in + * choice sets. + * @param app contains pointer to application. + * @param choice_set_id_list_length contains amount + * of choice set ids. + * @param choice_set_id_list array of choice set ids + * @return If request contains several choice sets with + * same choice id returns false, otherwise returns + * true. + */ + bool CheckChoiceIDFromRequest( + app_mngr::ApplicationSharedPtr app, + const size_t choice_set_id_list_length, + const smart_objects::SmartObject& choice_set_id_list) const; + + /** + * @brief Tells if there are sent requests without responses + * @return If there is request without response method returns TRUE + * otherwise returns FALSE + */ + const bool HasHMIResponsesToWait() const; + + /** + * @brief Check UI & VR result codes, send response to mobile + * @param msg_param Message params to send + */ + void SendBothModeResponse(const smart_objects::SmartObject& msg_param); + + mobile_apis::InteractionMode::eType interaction_mode_; + bool ui_response_received_; + bool vr_response_received_; + bool app_pi_was_active_before_; + static uint32_t pi_requests_count_; + hmi_apis::Common_Result::eType vr_result_code_; + hmi_apis::Common_Result::eType ui_result_code_; + std::string ui_info_; + std::string vr_info_; + + DISALLOW_COPY_AND_ASSIGN(PerformInteractionRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_INTERACTION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_response.h new file mode 100644 index 0000000000..6bb9135dcc --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_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_PERFORM_INTERACTION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_INTERACTION_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 PerformInteractionResponse command class + **/ +class PerformInteractionResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief PerformInteractionResponse class constructor + * + * @param message Incoming SmartObject message + **/ + PerformInteractionResponse( + 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 PerformInteractionResponse class destructor + **/ + virtual ~PerformInteractionResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(PerformInteractionResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_INTERACTION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_request.h new file mode 100644 index 0000000000..f82af197b9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_request.h @@ -0,0 +1,86 @@ +/* + + 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_PUT_FILE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PUT_FILE_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "utils/macro.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief PutFileRequest command class + **/ +class PutFileRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief PutFileRequest class constructor + * + * @param message Incoming SmartObject message + **/ + PutFileRequest(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 PutFileRequest class destructor + **/ + virtual ~PutFileRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + int64_t offset_; + std::string sync_file_name_; + int64_t length_; + mobile_apis::FileType::eType file_type_; + bool is_persistent_file_; + + void SendOnPutFileNotification(); + DISALLOW_COPY_AND_ASSIGN(PutFileRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PUT_FILE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_response.h new file mode 100644 index 0000000000..22dbf1b5d5 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_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_PUT_FILE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PUT_FILE_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 PutFileResponse command class + **/ +class PutFileResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief PutFileResponse class constructor + * + * @param message Incoming SmartObject message + **/ + PutFileResponse(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 PutFileResponse class destructor + **/ + virtual ~PutFileResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(PutFileResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PUT_FILE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h new file mode 100644 index 0000000000..9cac2ab34f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h @@ -0,0 +1,230 @@ +/* + + 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_REGISTER_APP_INTERFACE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_REGISTER_APP_INTERFACE_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "utils/macro.h" +#include "utils/custom_string.h" + +namespace policy { +struct DeviceInfo; +} + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +class Application; + +namespace commands { + +namespace custom_str = utils::custom_string; + +/** + * @brief Register app interface request command class + **/ +class RegisterAppInterfaceRequest + : public app_mngr::commands::CommandRequestImpl { + public: + /** + * \brief RegisterAppInterfaceRequest class constructor + **/ + RegisterAppInterfaceRequest( + 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 RegisterAppInterfaceRequest class destructor + **/ + virtual ~RegisterAppInterfaceRequest(); + + /** + * @brief Init required by command resources + **/ + virtual bool Init(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief Prepares and sends RegisterAppInterface response to mobile + * considering application type + **/ + void SendRegisterAppInterfaceResponseToMobile(); + + private: + /** + * @brief The AppicationType enum defines whether application is newly + * registered or existing and being switched over another transport + */ + enum class ApplicationType { + kNewApplication, + kSwitchedApplicationHashOk, + kSwitchedApplicationWrongHashId + }; + + /** + * @brief Prepares and sends RegisterAppInterface response to mobile + * considering application type + * @param app_type Type of application + **/ + void SendRegisterAppInterfaceResponseToMobile(ApplicationType app_type); + + smart_objects::SmartObjectSPtr GetLockScreenIconUrlNotification( + const uint32_t connection_key, app_mngr::ApplicationSharedPtr app); + + /** + * @brief SendChangeRegistration send ChangeRegistration on HMI + * @param function_id interface specific ChangeRegistration + * @param language language of registration + * @param app_id application to change registration + */ + void SendChangeRegistration(const hmi_apis::FunctionID::eType function_id, + const int32_t language, + const uint32_t app_id); + + /** + * @brief SendChangeRegistrationOnHMI send required SendChangeRegistration + * HMI + * @param app application to change registration + */ + void SendChangeRegistrationOnHMI(app_mngr::ApplicationConstSharedPtr app); + + /** + * @brief Sends OnAppRegistered notification to HMI + * + *@param application_impl application with changed HMI status + * + **/ + void SendOnAppRegisteredNotificationToHMI( + const app_mngr::Application& application_impl, + bool resumption = false, + bool need_restore_vr = false); + /* + * @brief Check new ID along with known mobile application ID + * + * return TRUE if ID is known already, otherwise - FALSE + */ + bool IsApplicationWithSameAppIdRegistered(); + + /* + * @brief Check new application parameters (name, tts, vr) for + * coincidence with already known parameters of registered applications + * + * return SUCCESS if there is no coincidence of app.name/TTS/VR synonyms, + * otherwise appropriate error code returns + */ + mobile_apis::Result::eType CheckCoincidence(); + + /* + * @brief Predicate for using with CheckCoincidence method to compare with VR + * synonym SO + * + * return TRUE if there is coincidence of VR, otherwise FALSE + */ + struct CoincidencePredicateVR { + CoincidencePredicateVR(const custom_str::CustomString& newItem) + : newItem_(newItem) {} + + bool operator()(const smart_objects::SmartObject& obj) { + const custom_str::CustomString& vr_synonym = obj.asCustomString(); + return newItem_.CompareIgnoreCase(vr_synonym); + } + const custom_str::CustomString& newItem_; + }; + + /** + * @brief Check request parameters against policy table data + * @return SUCCESS if check ok, otherwise return appropriate error code + */ + mobile_apis::Result::eType CheckWithPolicyData(); + + /** + * @brief Fill DeviceInfo struct with data from request, if any + * @param device_info Struct for device params from request + */ + void FillDeviceInfo(policy::DeviceInfo* device_info); + + /** + * @brief Checks register app interface params(ttsName, ...). + * When type is String there is a check on the contents \t\n \\t \\n + * @return if register app interface contains \t\n \\t \\n return TRUE, + * FALSE otherwise + */ + bool IsWhiteSpaceExist(); + + /** + * @brief Checks vehicle type params (model, year etc.) and in case of absense + * replaces with policy table backup values + * @param vehicle_type VehicleType struct + * @param param Vehicle param + * @param backup_value Backup value + */ + void CheckResponseVehicleTypeParam(smart_objects::SmartObject& vehicle_type, + const std::string& param, + const std::string& backup_value); + /** + * @brief Sends ButtonSubscription notification at start up + * to notify HMI that app subscribed on the custom button by default. + */ + void SendSubscribeCustomButtonNotification(); + + /** + * @brief IsApplicationSwitched checks whether application is switched from + * another transport. If application id is found, but not in reconnection + * list, returns 'already registered' code. Otherwise - proceed with + * switching. + * @return True if application is detected as switched, otherwise false. + */ + bool IsApplicationSwitched(); + + private: + std::string response_info_; + mobile_apis::Result::eType result_code_; + + policy::PolicyHandlerInterface& GetPolicyHandler(); + DISALLOW_COPY_AND_ASSIGN(RegisterAppInterfaceRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_REGISTER_APP_INTERFACE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_response.h new file mode 100644 index 0000000000..d591d67794 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_response.h @@ -0,0 +1,84 @@ +/* + + 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_REGISTER_APP_INTERFACE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_REGISTER_APP_INTERFACE_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 Register app interface request command class + **/ +class RegisterAppInterfaceResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * \brief RegisterAppInterfaceResponse class constructor + **/ + RegisterAppInterfaceResponse( + const app_mngr::commands::MessageSharedPtr& response, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(response, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + + /** + * \brief RegisterAppInterfaceResponse class destructor + **/ + virtual ~RegisterAppInterfaceResponse() {} + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + void SetHeartBeatTimeout(uint32_t connection_key, + const std::string& mobile_app_id); + + DISALLOW_COPY_AND_ASSIGN(RegisterAppInterfaceResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_REGISTER_APP_INTERFACE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_request.h new file mode 100644 index 0000000000..6f7e330bf5 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_request.h @@ -0,0 +1,149 @@ +/* + + 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_RESET_GLOBAL_PROPERTIES_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_RESET_GLOBAL_PROPERTIES_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 ResetGlobalPropertiesRequest command class + **/ +class ResetGlobalPropertiesRequest + : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief ResetGlobalPropertiesRequest class constructor + * + * @param message Incoming SmartObject message + **/ + ResetGlobalPropertiesRequest( + 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 ResetGlobalPropertiesRequest class destructor + **/ + ~ResetGlobalPropertiesRequest(); + + /** + * @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; + + private: + /* + * @brief Sets default value of the HELPPROMT global property + * to the first vrCommand of each Command Menu registered in application + * + * @param app Registered application + * @param is_timeout_promp Flag indicating that timeout prompt + * should be reset + * + * @return TRUE on success, otherwise FALSE + */ + bool ResetHelpPromt(app_mngr::ApplicationSharedPtr app); + + /* + * @brief Sets default value of the TIMEOUTPROMT global property + * to the first vrCommand of each Command Menu registered in application + * + * @param app Registered application + * + * @return TRUE on success, otherwise FALSE + */ + bool ResetTimeoutPromt(application_manager::ApplicationSharedPtr const app); + + /* + * @brief Sets default value of the VRHELPTITLE global property + * to the application name and value of the VRHELPITEMS global property + * to value equal to registered command -1(default command “Help / Cancel”.) + * + * @param app Registered application + * + * @return TRUE on success, otherwise FALSE + */ + bool ResetVrHelpTitleItems( + application_manager::ApplicationSharedPtr const app); + + /* + * @brief Prepare result for sending to mobile application + * @param out_result_code contains result code for sending to mobile + * application + * @param out_response_info contains info for sending to mobile applicaion + * @return result for sending to mobile application. + */ + bool PrepareResponseParameters(mobile_apis::Result::eType& out_result_code, + std::string& out_response_info); + + /* + * @brief Check if there some not delivered hmi responses exist + * + * @return true if all responses received + */ + bool IsPendingResponseExist(); + + DISALLOW_COPY_AND_ASSIGN(ResetGlobalPropertiesRequest); + + hmi_apis::Common_Result::eType ui_result_; + hmi_apis::Common_Result::eType tts_result_; + std::string ui_response_info_; + std::string tts_response_info_; +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_RESET_GLOBAL_PROPERTIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_response.h new file mode 100644 index 0000000000..b33ef41426 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_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_RESET_GLOBAL_PROPERTIES_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_RESET_GLOBAL_PROPERTIES_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 ResetGlobalPropertiesResponse command class + **/ +class ResetGlobalPropertiesResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief ResetGlobalPropertiesResponse class constructor + * + * @param message Incoming SmartObject message + **/ + ResetGlobalPropertiesResponse( + 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 ResetGlobalPropertiesResponse class destructor + **/ + virtual ~ResetGlobalPropertiesResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ResetGlobalPropertiesResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_RESET_GLOBAL_PROPERTIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_request.h new file mode 100644 index 0000000000..a641fa0cd4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_request.h @@ -0,0 +1,90 @@ +/* + + 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_SCROLLABLE_MESSAGE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SCROLLABLE_MESSAGE_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "interfaces/MOBILE_API.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief scrollable message request command class + **/ +class ScrollableMessageRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief ScrollableMessageRequest class constructor + **/ + ScrollableMessageRequest(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 SliderCommand class destructor + **/ + virtual ~ScrollableMessageRequest(); + + /** + * @brief Initialize request params + **/ + virtual bool Init(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + virtual void on_event(const app_mngr::event_engine::Event& event); + + private: + DISALLOW_COPY_AND_ASSIGN(ScrollableMessageRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SCROLLABLE_MESSAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_response.h new file mode 100644 index 0000000000..8bc8a36363 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_response.h @@ -0,0 +1,73 @@ +/* + * 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_SCROLLABLE_MESSAGE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SCROLLABLE_MESSAGE_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "application_manager/message.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +class ScrollableMessageResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * \brief ScrollableMessageResponse class constructor + **/ + ScrollableMessageResponse(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 SpeakResponseCommand class destructor + **/ + virtual ~ScrollableMessageResponse() {} + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ScrollableMessageResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SCROLLABLE_MESSAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_request.h new file mode 100644 index 0000000000..e3ed6ef28b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_request.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_SEND_HAPTIC_DATA_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SEND_HAPTIC_DATA_REQUEST_H_ + +#include <string> +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/application_manager.h" +#include "application_manager/event_engine/event.h" +#include "smart_objects/smart_object.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SendHapticDataRequest command class + **/ +class SendHapticDataRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief SendHapticDataRequest class constructor + * + * @param message Incoming SmartObject message + * @param application_manager Reference of application manager + **/ + SendHapticDataRequest(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 SendHapticDataRequest class destructor + **/ + ~SendHapticDataRequest() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + /** + * @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) OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(SendHapticDataRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SEND_HAPTIC_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h new file mode 100644 index 0000000000..53e8766241 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h @@ -0,0 +1,77 @@ +/* + * 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_SEND_HAPTIC_DATA_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SEND_HAPTIC_DATA_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SendHapticDataResponse command class + **/ +class SendHapticDataResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief SendHapticDataResponse class constructor + * + * @param message Incoming SmartObject message + * @param application_manager Reference of application manager + **/ + SendHapticDataResponse(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 SendHapticDataResponse class destructor + **/ + ~SendHapticDataResponse() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(SendHapticDataResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SEND_HAPTIC_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_request.h new file mode 100644 index 0000000000..6626da4c9d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_request.h @@ -0,0 +1,100 @@ +/* + + 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_SEND_LOCATION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SEND_LOCATION_REQUEST_H_ + +#include <list> +#include "application_manager/commands/command_request_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief send location request command class + */ +class SendLocationRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief SendLocationRquest class constructor + */ + SendLocationRequest(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 SendLocationRquest class destructor + */ + virtual ~SendLocationRequest(); + + /** + * @brief Execute command + */ + virtual void Run(); + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + virtual void on_event(const app_mngr::event_engine::Event& event); + + private: + /** + * @brief CheckFieldsCompatibility checks if fields are compatible with each + * other. + * @return true if compatible, otherwise return false + */ + bool CheckFieldsCompatibility(); + + /** + * @brief Checks sendlocation params(locationName, locationDescription, ...). + * Checks string if it contains \t\n \\t \\n or whitespace + * @return true if string contains invalid characters, otherwise returns false + */ + bool IsWhiteSpaceExist(); + + bool CheckHMICapabilities( + std::vector<hmi_apis::Common_TextFieldName::eType>& fields_names); + DISALLOW_COPY_AND_ASSIGN(SendLocationRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SEND_LOCATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_response.h new file mode 100644 index 0000000000..cb461f9a60 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_response.h @@ -0,0 +1,71 @@ +/* + * 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_SEND_LOCATION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SEND_LOCATION_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "application_manager/message.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +class SendLocationResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief SendLocationResponse class constructor + */ + SendLocationResponse(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 SendLocationResponse class destructor + */ + virtual ~SendLocationResponse(); + + /** + * @brief Execute command + */ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SendLocationResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SEND_LOCATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_request.h new file mode 100644 index 0000000000..1075999af9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_request.h @@ -0,0 +1,116 @@ +/* + + 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_SET_APP_ICON_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_APP_ICON_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 SetIconRequest command class + **/ +class SetAppIconRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief Contains information about the type of image + */ + typedef enum { STATIC = 0, DYNAMIC } ImageType; + + /** + * @brief SetIconRequest class constructor + * + * @param message Incoming SmartObject message + **/ + SetAppIconRequest(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 SetIconRequest class destructor + **/ + virtual ~SetAppIconRequest(); + + /** + * @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: + /** + * @brief Copies file to icon storage + * @param path_to_file Path to icon + */ + void CopyToIconStorage(const std::string& path_to_file) const; + + /** + * @brief Remove oldest icons + * @param storage Path to icons storage + * @param icons_amount Amount of icons to be deleted + */ + void RemoveOldestIcons(const std::string& storage, + const uint32_t icons_amount) const; + + /** + * @brief Checks, if there enough space in storage for icon copy + * @param file_size File size + * @return true, if enough, otherwise - false + */ + bool IsEnoughSpaceForIcon(const uint64_t icon_size) const; + DISALLOW_COPY_AND_ASSIGN(SetAppIconRequest); + + private: + /** + * @brief Checks, if icons saving to configured folder is enabled + */ + bool is_icons_saving_enabled_; +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_APP_ICON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_response.h new file mode 100644 index 0000000000..e4ce0725dc --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_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_SET_APP_ICON_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_APP_ICON_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 SetIconResponse command class + **/ +class SetAppIconResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief SetIconResponse class constructor + * + * @param message Incoming SmartObject message + **/ + SetAppIconResponse(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 SetIconResponse class destructor + **/ + virtual ~SetAppIconResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SetAppIconResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_APP_ICON_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_request.h new file mode 100644 index 0000000000..4bd800988c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_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_SET_DISPLAY_LAYOUT_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_DISPLAY_LAYOUT_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 SetDisplayLayoutRequest command class + **/ +class SetDisplayLayoutRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief SetDisplayLayoutRequest class constructor + * + * @param message Incoming SmartObject message + **/ + SetDisplayLayoutRequest(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 SetDisplayLayoutRequest class destructor + **/ + virtual ~SetDisplayLayoutRequest(); + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + **/ + virtual void on_event(const app_mngr::event_engine::Event& event); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SetDisplayLayoutRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_DISPLAY_LAYOUT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_response.h new file mode 100644 index 0000000000..73f57fc187 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_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_SET_DISPLAY_LAYOUT_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_DISPLAY_LAYOUT_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 SetDisplayLayoutResponse command class + **/ +class SetDisplayLayoutResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief SetDisplayLayoutResponse class constructor + * + * @param message Incoming SmartObject message + **/ + SetDisplayLayoutResponse(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 SetDisplayLayoutResponse class destructor + **/ + virtual ~SetDisplayLayoutResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SetDisplayLayoutResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_DISPLAY_LAYOUT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_request.h new file mode 100644 index 0000000000..7a8abaaad6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_request.h @@ -0,0 +1,166 @@ +/* + 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_SET_GLOBAL_PROPERTIES_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_GLOBAL_PROPERTIES_REQUEST_H_ +#include <string> +#include "application_manager/commands/command_request_impl.h" +#include "utils/macro.h" +#include "application_manager/application.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief Register app interface request command class + **/ +class SetGlobalPropertiesRequest + : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief SetGlobalPropertiesRequest class constructor + * + * @param message Incoming SmartObject message + **/ + SetGlobalPropertiesRequest( + 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 SetGlobalPropertiesRequest class destructor + **/ + ~SetGlobalPropertiesRequest(); + + /** + * @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; + + private: + // Verify correctness VrHelptitle value + static bool ValidateVRHelpTitle( + const smart_objects::SmartObject* const vr_help_so_ptr); + + // prepare UI sending data (VrHelps, Menus, Keyboard) to SmartObject + static void PrepareUIRequestVRHelpData( + const app_mngr::ApplicationSharedPtr app, + const smart_objects::SmartObject& msg_params, + smart_objects::SmartObject& out_params); + + static bool PrepareUIRequestDefaultVRHelpData( + const app_mngr::ApplicationSharedPtr app, + smart_objects::SmartObject& out_params); + + static void PrepareUIRequestMenuAndKeyboardData( + const app_mngr::ApplicationSharedPtr app, + const smart_objects::SmartObject& msg_params, + smart_objects::SmartObject& out_params); + + // Send TTS request to HMI + void SendTTSRequest(const smart_objects::SmartObject& params, + bool use_events); + + // Send UI request to HMI + void SendUIRequest(const smart_objects::SmartObject& params, bool use_events); + + // VRHelp shall contain sequential positions and start from 1 + static bool CheckVrHelpItemsOrder(const smart_objects::SmartObject& vr_help); + + /** + * @brief Check if there some not delivered hmi responses exist + * + * @return true if all responses received + */ + bool IsPendingResponseExist(); + + /** + * @brief Checks if request has at least one parameter + * + * @param params request parameters + * + * @returns true if at least one parameter is present in object + */ + static bool ValidateConditionalMandatoryParameters( + const smart_objects::SmartObject& params); + + /** + * @brief Checks set global properties params(helpPrompt, timeoutPrompt, ...). + * When type is String there is a check on the contents \t\n \\t \\n + * @return if set global properties contains \t\n \\t \\n return TRUE, + * FALSE otherwise + */ + bool IsWhiteSpaceExist(); + + /* + * @brief Prepare result code and result for sending to mobile application + * @param result_code contains result code for sending to mobile application + * @param info contains info for sending to mobile applicaion + * @return result for sending to mobile application. + */ + bool PrepareResponseParameters(mobile_apis::Result::eType& result_code, + std::string& info); + + bool is_ui_send_; + bool is_tts_send_; + + bool is_ui_received_; + bool is_tts_received_; + + hmi_apis::Common_Result::eType ui_result_; + hmi_apis::Common_Result::eType tts_result_; + std::string ui_response_info_; + std::string tts_response_info_; + + DISALLOW_COPY_AND_ASSIGN(SetGlobalPropertiesRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_GLOBAL_PROPERTIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_response.h new file mode 100644 index 0000000000..778dc9b7d7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_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_SET_GLOBAL_PROPERTIES_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_GLOBAL_PROPERTIES_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 Register app interface request command class + **/ +class SetGlobalPropertiesResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief SetGlobalPropertiesResponse class constructor + * + * @param message Incoming SmartObject message + **/ + SetGlobalPropertiesResponse( + 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 SetGlobalPropertiesResponse class destructor + **/ + virtual ~SetGlobalPropertiesResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SetGlobalPropertiesResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_GLOBAL_PROPERTIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_icon_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_icon_request.h new file mode 100644 index 0000000000..f994f06ca3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_icon_request.h @@ -0,0 +1,91 @@ +/* + + 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_SET_ICON_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_ICON_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/application_manager.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SetIconRequest command class + **/ +class SetIconRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief Contains information about the type of image + */ + typedef enum { STATIC = 0, DYNAMIC } ImageType; + + /** + * @brief SetIconRequest class constructor + * + * @param message Incoming SmartObject message + **/ + SetIconRequest(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 SetIconRequest class destructor + **/ + virtual ~SetIconRequest(); + + /** + * @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(SetIconRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_ICON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_icon_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_icon_response.h new file mode 100644 index 0000000000..c83ea3607a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_icon_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_SET_ICON_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_ICON_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "application_manager/application_manager.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SetIconResponse command class + **/ +class SetIconResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief SetIconResponse class constructor + * + * @param message Incoming SmartObject message + **/ + SetIconResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& app_man, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief SetIconResponse class destructor + **/ + virtual ~SetIconResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SetIconResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_ICON_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_request.h new file mode 100644 index 0000000000..ef674f1c38 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_request.h @@ -0,0 +1,86 @@ +/* + + 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_SET_MEDIA_CLOCK_TIMER_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_MEDIA_CLOCK_TIMER_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 SetMediaClockRequest request command class + **/ +class SetMediaClockRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * \brief SetMediaClockRequest class constructor + **/ + SetMediaClockRequest(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 ShowCommand class destructor + **/ + virtual ~SetMediaClockRequest(); + + /** + * @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: + bool isDataValid(); + + DISALLOW_COPY_AND_ASSIGN(SetMediaClockRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_MEDIA_CLOCK_TIMER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_response.h new file mode 100644 index 0000000000..2fb3f25839 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_response.h @@ -0,0 +1,74 @@ +/* + * 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_SET_MEDIA_CLOCK_TIMER_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_MEDIA_CLOCK_TIMER_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "application_manager/message.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +class SetMediaClockTimerResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * \brief SetMediaClockTimerResponse class constructor + **/ + SetMediaClockTimerResponse( + 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 SetMediaClockTimerResponse class destructor + **/ + virtual ~SetMediaClockTimerResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SetMediaClockTimerResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_MEDIA_CLOCK_TIMER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_request.h new file mode 100644 index 0000000000..cadc87cef6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_request.h @@ -0,0 +1,94 @@ +/* + + 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_SHOW_CONSTANT_TBT_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_CONSTANT_TBT_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "interfaces/MOBILE_API.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ShowConstantTBTRequest command class + **/ +class ShowConstantTBTRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief ShowConstantTBTRequest class constructor + * + * @param message Incoming SmartObject message + **/ + ShowConstantTBTRequest(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 ShowConstantTBTRequest class destructor + **/ + virtual ~ShowConstantTBTRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + virtual void on_event(const app_mngr::event_engine::Event& event); + + private: + /** + * @brief Checks show constant TBT params(turnIcon, ...). + * When type is String there is a check on the contents \t\n \\t \\n + * @return if show constant TBT contains \t\n \\t \\n return TRUE, + * FALSE otherwise + */ + bool IsWhiteSpaceExist(); + + DISALLOW_COPY_AND_ASSIGN(ShowConstantTBTRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_CONSTANT_TBT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_response.h new file mode 100644 index 0000000000..4129a7640e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_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_SHOW_CONSTANT_TBT_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_CONSTANT_TBT_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 ShowConstantTBTResponse command class + **/ +class ShowConstantTBTResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief ShowConstantTBTResponse class constructor + * + * @param message Incoming SmartObject message + **/ + ShowConstantTBTResponse(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 ShowConstantTBTResponse class destructor + **/ + virtual ~ShowConstantTBTResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ShowConstantTBTResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_CONSTANT_TBT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_request.h new file mode 100644 index 0000000000..2277a38f11 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_request.h @@ -0,0 +1,103 @@ +/* + + 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_SHOW_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "interfaces/MOBILE_API.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief show request command class + **/ +class ShowRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * \brief ShowRequest class constructor + **/ + ShowRequest(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 ShowRequest class destructor + **/ + virtual ~ShowRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + virtual void on_event(const app_mngr::event_engine::Event& event); + + private: + /* + * @brief Check if all strings have valid syntax in request + * + * @return TRUE on success, otherwise FALSE + */ + bool CheckStringsOfShowRequest(); + + /** + * @brief Handle the conversion of metadata information from the incoming + * mobile json message format to the outgoing hmi json message format + */ + void HandleMetadata(const char* field_id, + int32_t field_index, + smart_objects::SmartObject& msg_params); + + mobile_apis::Result::eType core_result_code_; + std::string core_response_info_; + + DISALLOW_COPY_AND_ASSIGN(ShowRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_response.h new file mode 100644 index 0000000000..c78820a26e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_response.h @@ -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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "application_manager/message.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +class ShowResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * \brief ShowResponse class constructor + **/ + ShowResponse(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 ShowResponse class destructor + **/ + virtual ~ShowResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ShowResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_request.h new file mode 100644 index 0000000000..f1e06e8d8d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_request.h @@ -0,0 +1,96 @@ +/* + + 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_SLIDER_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SLIDER_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 slider request command class + **/ +class SliderRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * \brief SliderRequest class constructor + **/ + SliderRequest(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 SliderRequest class destructor + **/ + virtual ~SliderRequest(); + + /** + * @brief Initialize request params + **/ + virtual bool Init(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + virtual void on_event(const app_mngr::event_engine::Event& event); + + private: + /** + * @brief Checks slider params(sliderHeader, sliderFooter, ...). + * When type is String there is a check on the contents \t\n \\t \\n + * @return if slider contains \t\n \\t \\n return TRUE, FALSE otherwise + */ + bool IsWhiteSpaceExist(); + + DISALLOW_COPY_AND_ASSIGN(SliderRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SLIDER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_response.h new file mode 100644 index 0000000000..2a93103632 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_response.h @@ -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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SLIDER_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SLIDER_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "application_manager/message.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +class SliderResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * \brief SliderResponse class constructor + **/ + SliderResponse(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 SpeakResponseCommand class destructor + **/ + virtual ~SliderResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SliderResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SLIDER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_request.h new file mode 100644 index 0000000000..d6d47bb869 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_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_SPEAK_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SPEAK_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 speak request command class + **/ +class SpeakRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * \brief SpeakRequest class constructor + **/ + SpeakRequest(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 SpeakRequest class destructor + **/ + virtual ~SpeakRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + virtual void on_event(const app_mngr::event_engine::Event& event); + + private: + /* + * @brief Sends Speak response to mobile side + * + * @param message which should send to mobile side + * + */ + void ProcessTTSSpeakResponse(const smart_objects::SmartObject& message); + + /** + * @brief Checks speak param ttsChunks on the contents \t\n \\t \\n + * @return if speak contains \t\n \\t \\n return TRUE, FALSE otherwise + */ + bool IsWhiteSpaceExist(); + + DISALLOW_COPY_AND_ASSIGN(SpeakRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SPEAK_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_response.h new file mode 100644 index 0000000000..30eda07810 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_response.h @@ -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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SPEAK_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SPEAK_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "application_manager/message.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +class SpeakResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * \brief SpeakResponse class constructor + **/ + SpeakResponse(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 SpeakResponse class destructor + **/ + virtual ~SpeakResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SpeakResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SPEAK_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_request.h new file mode 100644 index 0000000000..011c0aa359 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_request.h @@ -0,0 +1,103 @@ +/* + + 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_BUTTON_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_BUTTON_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/application_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SubscribeButtonRequest command class + **/ +class SubscribeButtonRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief SubscribeButtonRequest class constructor + * + * @param message Incoming SmartObject message + **/ + SubscribeButtonRequest(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 SubscribeButtonRequest class destructor + **/ + ~SubscribeButtonRequest(); + + /** + * @brief Execute command + **/ + void Run() FINAL; + + /** + * @brief Init sets hash update mode for request + */ + bool Init() FINAL; + + private: + /** + * @brief Checks if button subscription allowed. In case non-media + * application trying to subscribe on buttons(tune, seek) negative result will + * be returned + * + * @param app Application requested subscription + * @param btn_id Button to be subscribe + * + * @return TRUE on success, otherwise false + **/ + bool IsSubscriptionAllowed(app_mngr::ApplicationSharedPtr app, + const mobile_apis::ButtonName::eType btn_id); + + /** + * @brief Sends ButtonSubscription notification + * to notify HMI that app subscribed on the button. + */ + void SendSubscribeButtonNotification(); + + DISALLOW_COPY_AND_ASSIGN(SubscribeButtonRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_BUTTON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_response.h new file mode 100644 index 0000000000..28e942ec17 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_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_SUBSCRIBE_BUTTON_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_BUTTON_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 SubscribeButtonResponse command class + **/ +class SubscribeButtonResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief SubscribeButtonResponse class constructor + * + * @param message Incoming SmartObject message + **/ + SubscribeButtonResponse(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_handlers); + + /** + * @brief SubscribeButtonResponse class destructor + **/ + virtual ~SubscribeButtonResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SubscribeButtonResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_BUTTON_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h new file mode 100644 index 0000000000..6105f08750 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h @@ -0,0 +1,87 @@ +/* + * 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_WAY_POINTS_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_WAY_POINTS_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SubsribeWayPointsRequest command class + **/ +class SubscribeWayPointsRequest + : public app_mngr::commands::CommandRequestImpl { + public: + /** + * \brief SubscribeWayPointsRequest class constructor + **/ + SubscribeWayPointsRequest(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 SubscribeWayPointsRequest class destructor + **/ + ~SubscribeWayPointsRequest(); + + /** + * @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; + + private: + DISALLOW_COPY_AND_ASSIGN(SubscribeWayPointsRequest); +}; + +} // commands + +} // application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_response.h new file mode 100644 index 0000000000..cd27e96d25 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_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_SUBSCRIBE_WAY_POINTS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_WAY_POINTS_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 SubscribeWayPointsResponse command class + **/ +class SubscribeWayPointsResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * \brief SubscribeWayPointsResponse class constructor + **/ + SubscribeWayPointsResponse( + 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 SubscribeWayPointsResponse class destructor + **/ + virtual ~SubscribeWayPointsResponse(); + + /** + * @brief Execute command + **/ + virtual void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(SubscribeWayPointsResponse); +}; + +} // commands + +} // application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_request.h new file mode 100644 index 0000000000..c34db34506 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_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_SYSTEM_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SYSTEM_REQUEST_H_ + +#include <string> +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/application_manager.h" +#include "application_manager/event_engine/event.h" +#include "smart_objects/smart_object.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SystemRequest command class + **/ +class SystemRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief SystemRequest class constructor + * + * @param message Incoming SmartObject message + **/ + SystemRequest(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 SystemRequest class destructor + **/ + virtual ~SystemRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + virtual void on_event(const app_mngr::event_engine::Event& event); + + private: + /** + * @brief Validates data coming within QueryApps response + * @param data Data + * @return true, if data is valid, otherwise - false + */ + bool ValidateQueryAppData(smart_objects::SmartObject& data) const; + + private: + static uint32_t index; + std::string processing_file_; + DISALLOW_COPY_AND_ASSIGN(SystemRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SYSTEM_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_response.h new file mode 100644 index 0000000000..afbd557d12 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_response.h @@ -0,0 +1,77 @@ +/* + + 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_SYSTEM_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SYSTEM_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SystemResponse command class + **/ +class SystemResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief SystemResponse class constructor + * + * @param message Incoming SmartObject message + **/ + SystemResponse(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 SystemResponse class destructor + **/ + virtual ~SystemResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SystemResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SYSTEM_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_request.h new file mode 100644 index 0000000000..172f934a15 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_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_UNREGISTER_APP_INTERFACE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNREGISTER_APP_INTERFACE_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 Unregister app interface request command class + **/ +class UnregisterAppInterfaceRequest + : public app_mngr::commands::CommandRequestImpl { + public: + /** + * \brief UnregisterAppInterfaceRequest class constructor + **/ + UnregisterAppInterfaceRequest( + 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) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + + /** + * \brief UnregisterAppInterfaceRequest class destructor + **/ + virtual ~UnregisterAppInterfaceRequest() {} + + /** + * @brief Execute command + **/ + virtual void Run(); + // virtual void cleanUp() = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(UnregisterAppInterfaceRequest); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNREGISTER_APP_INTERFACE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_response.h new file mode 100644 index 0000000000..13d8b549e8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_response.h @@ -0,0 +1,81 @@ +/* + + 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_UNREGISTER_APP_INTERFACE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNREGISTER_APP_INTERFACE_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 Unregister app interface request command class + **/ +class UnregisterAppInterfaceResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * \brief UnregisterAppInterfaceResponse class constructor + **/ + UnregisterAppInterfaceResponse( + const app_mngr::commands::MessageSharedPtr& response, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(response, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + + /** + * \brief UnregisterAppInterfaceResponse class destructor + **/ + virtual ~UnregisterAppInterfaceResponse() {} + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UnregisterAppInterfaceResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNREGISTER_APP_INTERFACE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h new file mode 100644 index 0000000000..8cbaafbfe1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h @@ -0,0 +1,89 @@ +/* + + 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_BUTTON_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_BUTTON_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 UnsubscribeButtonRequest command class + **/ +class UnsubscribeButtonRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief UnsubscribeButtonRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UnsubscribeButtonRequest(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 UnsubscribeButtonRequest class destructor + **/ + ~UnsubscribeButtonRequest() FINAL; + + /** + * @brief Execute command + **/ + void Run() FINAL; + + /** + * @brief Init sets hash update mode for request + */ + bool Init() FINAL; + + private: + /** + * @brief Sends ButtonSubscription notification + * to notify HMI that app unsubscribed from the button. + */ + void SendUnsubscribeButtonNotification(); + + DISALLOW_COPY_AND_ASSIGN(UnsubscribeButtonRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_BUTTON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_response.h new file mode 100644 index 0000000000..1db067acce --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_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_UNSUBSCRIBE_BUTTON_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_BUTTON_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 UnsubscribeButtonResponse command class + **/ +class UnsubscribeButtonResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief UnsubscribeButtonResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UnsubscribeButtonResponse(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 UnsubscribeButtonResponse class destructor + **/ + virtual ~UnsubscribeButtonResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UnsubscribeButtonResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_BUTTON_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h new file mode 100644 index 0000000000..b7b87f8b51 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h @@ -0,0 +1,86 @@ +/* + * 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_WAY_POINTS_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_WAY_POINTS_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +class UnSubscribeWayPointsRequest + : public app_mngr::commands::CommandRequestImpl { + public: + /** + * \brief UnSubscribeWayPointsRequest class constructor + **/ + UnSubscribeWayPointsRequest( + 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 UnSubscribeWayPointsRequest class destructor + **/ + ~UnSubscribeWayPointsRequest(); + + /** + * @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; + + private: + DISALLOW_COPY_AND_ASSIGN(UnSubscribeWayPointsRequest); +}; + +} // commands + +} // application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_response.h new file mode 100644 index 0000000000..c578bf9f99 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_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_UNSUBSCRIBE_WAY_POINTS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_WAY_POINTS_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 UnsubscribeWayPointsResponse command class + **/ +class UnsubscribeWayPointsResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * \brief UnsubscribeWayPointsResponse class constructor + **/ + UnsubscribeWayPointsResponse( + 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 UnsubscribeWayPointsResponse class destructor + **/ + virtual ~UnsubscribeWayPointsResponse(); + + /** + * @brief Execute command + **/ + virtual void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(UnsubscribeWayPointsResponse); +}; + +} // commands + +} // application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_request.h new file mode 100644 index 0000000000..8766339f96 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_request.h @@ -0,0 +1,102 @@ +/* + + 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_UPDATE_TURN_LIST_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UPDATE_TURN_LIST_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "interfaces/MOBILE_API.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UpdateTurnListRequest command class + **/ +class UpdateTurnListRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief UpdateTurnListRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UpdateTurnListRequest(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 UpdateTurnListRequest class destructor + **/ + virtual ~UpdateTurnListRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + virtual void on_event(const app_mngr::event_engine::Event& event); + + private: + /** + * @brief check correct parameter turnList + * + * @return TRUE if turnList is correct, + * otherwise FALSE + */ + bool CheckTurnListArray(); + + /** + * @brief Checks update turn list param + * When type is String there is a check on the contents \t\n \\t \\n + * @return if update turn list contains \t\n \\t \\n return TRUE, + * FALSE otherwise + */ + bool IsWhiteSpaceExist(); + + DISALLOW_COPY_AND_ASSIGN(UpdateTurnListRequest); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UPDATE_TURN_LIST_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_response.h new file mode 100644 index 0000000000..59d3bf0b2c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_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_UPDATE_TURN_LIST_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UPDATE_TURN_LIST_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 UpdateTurnListResponse command class + **/ +class UpdateTurnListResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief UpdateTurnListResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UpdateTurnListResponse(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 UpdateTurnListResponse class destructor + **/ + virtual ~UpdateTurnListResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UpdateTurnListResponse); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UPDATE_TURN_LIST_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/hmi_command_factory.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/hmi_command_factory.h new file mode 100644 index 0000000000..eee454fb00 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/hmi_command_factory.h @@ -0,0 +1,75 @@ +/* + 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_HMI_COMMAND_FACTORY_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_HMI_COMMAND_FACTORY_H_ + +#include "application_manager/command_factory.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +/** + * @brief Factory class for HMI command creation + **/ +class HMICommandFactory : public app_mngr::CommandFactory { + public: + HMICommandFactory(app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + app_mngr::CommandSharedPtr CreateCommand( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::commands::Command::CommandSource source) OVERRIDE; + + bool IsAbleToProcess( + const int32_t, + const application_manager::commands::Command::CommandSource) + const OVERRIDE; + + private: + app_mngr::CommandCreator& get_creator_factory( + hmi_apis::FunctionID::eType id, + hmi_apis::messageType::eType message_type, + app_mngr::commands::Command::CommandSource source) const; + + app_mngr::ApplicationManager& application_manager_; + app_mngr::rpc_service::RPCService& rpc_service_; + app_mngr::HMICapabilities& hmi_capabilities_; + policy::PolicyHandlerInterface& policy_handler_; + DISALLOW_COPY_AND_ASSIGN(HMICommandFactory); +}; + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_HMI_COMMAND_FACTORY_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/mobile_command_factory.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/mobile_command_factory.h new file mode 100644 index 0000000000..f0840dde41 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/mobile_command_factory.h @@ -0,0 +1,75 @@ +/* + 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_MOBILE_COMMAND_FACTORY_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_MOBILE_COMMAND_FACTORY_H_ + +#include "application_manager/command_factory.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; +/** + * @brief Factory class for mobile command creation + **/ +class MobileCommandFactory : public app_mngr::CommandFactory { + public: + MobileCommandFactory(app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + app_mngr::CommandSharedPtr CreateCommand( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::commands::Command::CommandSource source) OVERRIDE; + + bool IsAbleToProcess( + const int32_t, + const application_manager::commands::Command::CommandSource) + const OVERRIDE; + + private: + app_mngr::CommandCreator& get_creator_factory( + mobile_apis::FunctionID::eType id, + mobile_apis::messageType::eType message_type, + app_mngr::commands::Command::CommandSource source) const; + + app_mngr::ApplicationManager& application_manager_; + app_mngr::rpc_service::RPCService& rpc_service_; + app_mngr::HMICapabilities& hmi_capabilities_; + policy::PolicyHandlerInterface& policy_handler_; + DISALLOW_COPY_AND_ASSIGN(MobileCommandFactory); +}; + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_MOBILE_COMMAND_FACTORY_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_command_factory.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_command_factory.h new file mode 100644 index 0000000000..5b5f0ae49f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_command_factory.h @@ -0,0 +1,73 @@ +/* + 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_SDL_COMMAND_FACTORY_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_SDL_COMMAND_FACTORY_H + +#include <memory> +#include "application_manager/application_manager.h" +#include "application_manager/command_factory.h" +#include "sdl_rpc_plugin/hmi_command_factory.h" +#include "sdl_rpc_plugin/mobile_command_factory.h" +#include "application_manager/rpc_service.h" +#include "application_manager/hmi_capabilities.h" +#include "application_manager/policies/policy_handler_interface.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +class SDLCommandFactory : public app_mngr::CommandFactory { + public: + SDLCommandFactory(app_mngr::ApplicationManager& app_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + app_mngr::CommandSharedPtr CreateCommand( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::commands::Command::CommandSource source) OVERRIDE; + + bool IsAbleToProcess( + const int32_t, + const application_manager::commands::Command::CommandSource) + const OVERRIDE; + + private: + app_mngr::ApplicationManager& app_manager_; + app_mngr::rpc_service::RPCService& rpc_service_; + app_mngr::HMICapabilities& hmi_capabilities_; + policy::PolicyHandlerInterface& policy_handler_; + std::unique_ptr<HMICommandFactory> hmi_command_factory_; + std::unique_ptr<MobileCommandFactory> mobile_command_factory_; +}; +} +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_SDL_COMMAND_FACTORY_H diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h new file mode 100644 index 0000000000..6ae3a0b6bc --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h @@ -0,0 +1,68 @@ +/* + 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_SDL_RPC_PLUGIN_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_SDL_RPC_PLUGIN_H +#include "application_manager/plugin_manager/rpc_plugin.h" +#include "application_manager/command_factory.h" + +namespace sdl_rpc_plugin { +namespace plugins = application_manager::plugin_manager; +class SDLRPCPlugin : public plugins::RPCPlugin { + // RPCPlugin interface + public: + bool Init(application_manager::ApplicationManager& app_manager, + application_manager::rpc_service::RPCService& rpc_service, + application_manager::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) OVERRIDE; + + bool IsAbleToProcess( + const int32_t function_id, + const application_manager::commands::Command::CommandSource + message_source) OVERRIDE; + std::string PluginName() OVERRIDE; + + application_manager::CommandFactory& GetCommandFactory() OVERRIDE; + void OnPolicyEvent( + application_manager::plugin_manager::PolicyEvent event) OVERRIDE; + void OnApplicationEvent( + application_manager::plugin_manager::ApplicationEvent event, + application_manager::ApplicationSharedPtr application) OVERRIDE; + + private: + std::unique_ptr<application_manager::CommandFactory> command_factory_; +}; +} + +extern "C" application_manager::plugin_manager::RPCPlugin* Create(); + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_SDL_RPC_PLUGIN_H diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_request.cc new file mode 100644 index 0000000000..19d01b594f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_request.cc @@ -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. + */ + +#include "sdl_rpc_plugin/commands/hmi/activate_app_request.h" + +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +ActivateAppRequest::ActivateAppRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +ActivateAppRequest::~ActivateAppRequest() { + LOG4CXX_TRACE(logger_, "~ActivateAppRequest"); +} + +void ActivateAppRequest::Run() { + LOG4CXX_TRACE(logger_, "enter " << correlation_id()); + uint32_t app_id = RequestToHMI::application_id(); + application_manager_.set_application_id(correlation_id(), app_id); +#ifdef ENABLE_LOG + if ((*message_)[strings::msg_params].keyExists( + strings::activate_app_hmi_level)) { + mobile_apis::HMILevel::eType requested_hmi_level = + static_cast<mobile_apis::HMILevel::eType>( + (*message_)[strings::msg_params][strings::activate_app_hmi_level] + .asInt()); + LOG4CXX_TRACE(logger_, "requested_hmi_level = " << requested_hmi_level); + } +#endif + SendRequest(); + LOG4CXX_TRACE(logger_, "exit"); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_response.cc new file mode 100644 index 0000000000..d7e38c5d5b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_response.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/activate_app_response.h" + +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +ActivateAppResponse::ActivateAppResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +ActivateAppResponse::~ActivateAppResponse() {} + +void ActivateAppResponse::Run() { + LOG4CXX_TRACE(logger_, "enter"); + event_engine::Event event( + hmi_apis::FunctionID::BasicCommunication_ActivateApp); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); + LOG4CXX_TRACE(logger_, "exit"); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/add_statistics_info_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/add_statistics_info_notification.cc new file mode 100644 index 0000000000..3e46bd353a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/add_statistics_info_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/add_statistics_info_notification.h" +#include "application_manager/policies/policy_handler.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +AddStatisticsInfoNotification::AddStatisticsInfoNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +AddStatisticsInfoNotification::~AddStatisticsInfoNotification() {} + +void AddStatisticsInfoNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + int type = (*message_)[strings::msg_params][hmi_notification::statistic_type] + .asInt(); + + policy_handler_.AddStatisticsInfo(type); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_request.cc new file mode 100644 index 0000000000..b227dd79dc --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/allow_all_apps_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +AllowAllAppsRequest::AllowAllAppsRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +AllowAllAppsRequest::~AllowAllAppsRequest() {} + +void AllowAllAppsRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_response.cc new file mode 100644 index 0000000000..2fdf29a7dd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_response.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/allow_all_apps_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +AllowAllAppsResponse::AllowAllAppsResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +AllowAllAppsResponse::~AllowAllAppsResponse() {} + +void AllowAllAppsResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + application_manager_.SetAllAppsAllowed( + (*message_)[strings::msg_params][hmi_response::allowed].asBool()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_request.cc new file mode 100644 index 0000000000..0c6e5145c7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/allow_app_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +AllowAppRequest::AllowAppRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +AllowAppRequest::~AllowAppRequest() {} + +void AllowAppRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_response.cc new file mode 100644 index 0000000000..4853c3764a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_response.cc @@ -0,0 +1,73 @@ +/* + * 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/hmi/allow_app_response.h" + +#include "application_manager/application_impl.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +AllowAppResponse::AllowAppResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +AllowAppResponse::~AllowAppResponse() {} + +void AllowAppResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + uint32_t connection_key = + (*message_)[strings::params][strings::connection_key].asInt(); + + ApplicationSharedPtr app = application_manager_.application(connection_key); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + app->set_app_allowed( + (*message_)[strings::msg_params][hmi_response::allowed].asBool()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_request.cc new file mode 100644 index 0000000000..fb87612e19 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_request.cc @@ -0,0 +1,58 @@ +/* + * 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 + * distribut wiion. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 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/hmi/basic_communication_get_system_time_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +BasicCommunicationGetSystemTimeRequest::BasicCommunicationGetSystemTimeRequest( + 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) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +void BasicCommunicationGetSystemTimeRequest::onTimeOut() { + LOG4CXX_AUTO_TRACE(logger_); + application_manager_.protocol_handler().NotifyOnFailedHandshake(); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_response.cc new file mode 100644 index 0000000000..c067debf36 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_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 "sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h" +#include "utils/logger.h" + +CREATE_LOGGERPTR_GLOBAL(logger_, "Commands") + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +BasicCommunicationGetSystemTimeResponse:: + BasicCommunicationGetSystemTimeResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +void BasicCommunicationGetSystemTimeResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event( + hmi_apis::FunctionID::BasicCommunication_GetSystemTime); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_on_awake_sdl.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_on_awake_sdl.cc new file mode 100644 index 0000000000..0c39389116 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_on_awake_sdl.cc @@ -0,0 +1,82 @@ +/* + * 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/hmi/basic_communication_on_awake_sdl.h" +#include "application_manager/message_helper.h" +#include "application_manager/resumption/resume_ctrl.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnAwakeSDLNotification::OnAwakeSDLNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnAwakeSDLNotification::~OnAwakeSDLNotification() {} + +void OnAwakeSDLNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + if (!application_manager_.resume_controller().is_suspended()) { + return; + } + + { + DataAccessor<ApplicationSet> accessor = application_manager_.applications(); + ApplicationSetIt itBegin = accessor.GetData().begin(); + ApplicationSetIt itEnd = accessor.GetData().end(); + for (; itBegin != itEnd; ++itBegin) { + const ApplicationSharedPtr app = *itBegin; + if (app && app->IsHashChangedDuringSuspend()) { + MessageHelper::SendHashUpdateNotification(app->app_id(), + application_manager_); + app->SetHashChangedDuringSuspend(false); + } + } + } + + application_manager_.resume_controller().OnAwake(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_request.cc new file mode 100644 index 0000000000..04e44a6979 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_request.cc @@ -0,0 +1,61 @@ +/* + * 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/hmi/basic_communication_system_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +BasicCommunicationSystemRequest::BasicCommunicationSystemRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +BasicCommunicationSystemRequest::~BasicCommunicationSystemRequest() {} + +void BasicCommunicationSystemRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_response.cc new file mode 100644 index 0000000000..5f8221fdbe --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_response.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/basic_communication_system_response.h" +#include "application_manager/event_engine/event.h" + +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +BasicCommunicationSystemResponse::BasicCommunicationSystemResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +BasicCommunicationSystemResponse::~BasicCommunicationSystemResponse() {} + +void BasicCommunicationSystemResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event( + hmi_apis::FunctionID::BasicCommunication_SystemRequest); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_request.cc new file mode 100644 index 0000000000..cf2fbd9761 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_request.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 "sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h" +#include "utils/logger.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +ButtonGetCapabilitiesRequest::ButtonGetCapabilitiesRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +ButtonGetCapabilitiesRequest::~ButtonGetCapabilitiesRequest() {} + +void ButtonGetCapabilitiesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_response.cc new file mode 100644 index 0000000000..863e179040 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_response.cc @@ -0,0 +1,77 @@ +/* + * 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/hmi/button_get_capabilities_response.h" + +#include "utils/logger.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +ButtonGetCapabilitiesResponse::ButtonGetCapabilitiesResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +ButtonGetCapabilitiesResponse::~ButtonGetCapabilitiesResponse() {} + +void ButtonGetCapabilitiesResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + const hmi_apis::Common_Result::eType code = + static_cast<hmi_apis::Common_Result::eType>( + (*message_)[strings::params][hmi_response::code].asInt()); + + if (hmi_apis::Common_Result::SUCCESS != code) { + LOG4CXX_ERROR(logger_, "Error is returned. Capabilities won't be updated."); + return; + } + + HMICapabilities& hmi_capabilities = hmi_capabilities_; + + hmi_capabilities.set_button_capabilities( + (*message_)[strings::msg_params][hmi_response::capabilities]); + + hmi_capabilities.set_preset_bank_capabilities( + (*message_)[strings::msg_params][hmi_response::preset_bank_capabilities]); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_request.cc new file mode 100644 index 0000000000..84a47b9deb --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_request.cc @@ -0,0 +1,61 @@ +/* + * 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/hmi/close_popup_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +ClosePopupRequest::ClosePopupRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +ClosePopupRequest::~ClosePopupRequest() {} + +void ClosePopupRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_response.cc new file mode 100644 index 0000000000..25396af337 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_response.cc @@ -0,0 +1,61 @@ +/* + * 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/hmi/close_popup_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +ClosePopupResponse::ClosePopupResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +ClosePopupResponse::~ClosePopupResponse() {} + +void ClosePopupResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // TODO(VS): Process response from HMI +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_request.cc new file mode 100644 index 0000000000..0e09c14650 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/decrypt_certificate_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +DecryptCertificateRequest::DecryptCertificateRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +void DecryptCertificateRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + const uint32_t correlation_id = RequestToHMI::correlation_id(); + const uint32_t app_id = RequestToHMI::application_id(); + application_manager_.set_application_id(correlation_id, app_id); + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_response.cc new file mode 100644 index 0000000000..694298ed91 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_response.cc @@ -0,0 +1,68 @@ +/* + * 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/hmi/decrypt_certificate_response.h" + +#include "application_manager/policies/policy_handler.h" +#ifdef EXTERNAL_PROPRIETARY_MODE +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +DecryptCertificateResponse::DecryptCertificateResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +DecryptCertificateResponse::~DecryptCertificateResponse() {} + +void DecryptCertificateResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + const hmi_apis::Common_Result::eType code = + static_cast<hmi_apis::Common_Result::eType>( + (*message_)[strings::params][hmi_response::code].asInt()); + + const bool is_succeeded = hmi_apis::Common_Result::SUCCESS == code; + + policy_handler_.OnCertificateDecrypted(is_succeeded); +} + +} // namespace commands +} // namespace application_manager +#endif // EXTERNAL_PROPRIETARY_MODE diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_request.cc new file mode 100644 index 0000000000..63f5c2e815 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_request.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 "sdl_rpc_plugin/commands/hmi/dial_number_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace hmi { + +DialNumberRequest::DialNumberRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +DialNumberRequest::~DialNumberRequest() {} + +void DialNumberRequest::Run() { + SendRequest(); +} + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_response.cc new file mode 100644 index 0000000000..6d37ece2bf --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_response.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/dial_number_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace hmi { + +DialNumberResponse::DialNumberResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +DialNumberResponse::~DialNumberResponse() {} + +void DialNumberResponse::Run() { + event_engine::Event event( + hmi_apis::FunctionID::BasicCommunication_DialNumber); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_request.cc new file mode 100644 index 0000000000..c06c90973d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_request.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 "sdl_rpc_plugin/commands/hmi/get_system_info_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +GetSystemInfoRequest::GetSystemInfoRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +GetSystemInfoRequest::~GetSystemInfoRequest() {} + +void GetSystemInfoRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + uint32_t correlation_id = RequestToHMI::correlation_id(); + uint32_t app_id = RequestToHMI::application_id(); + application_manager_.set_application_id(correlation_id, app_id); + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc new file mode 100644 index 0000000000..aef428b39f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc @@ -0,0 +1,93 @@ +/* + * 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/hmi/get_system_info_response.h" +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +GetSystemInfoResponse::GetSystemInfoResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +GetSystemInfoResponse::~GetSystemInfoResponse() {} + +void GetSystemInfoResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + const hmi_apis::Common_Result::eType code = + static_cast<hmi_apis::Common_Result::eType>( + (*message_)[strings::params][hmi_response::code].asInt()); + + const SystemInfo& info = GetSystemInfo(code); + + // We have to set preloaded flag as false in policy table on any response + // of GetSystemInfo (SDLAQ-CRS-2365) + policy_handler_.OnGetSystemInfo( + info.ccpu_version, info.wers_country_code, info.language); +} + +const SystemInfo GetSystemInfoResponse::GetSystemInfo( + const hmi_apis::Common_Result::eType code) const { + SystemInfo info; + + if (hmi_apis::Common_Result::SUCCESS != code) { + LOG4CXX_WARN(logger_, "GetSystemError returns an error code " << code); + return info; + } + info.ccpu_version = + (*message_)[strings::msg_params]["ccpu_version"].asString(); + + info.wers_country_code = + (*message_)[strings::msg_params]["wersCountryCode"].asString(); + + const uint32_t lang_code = + (*message_)[strings::msg_params]["language"].asUInt(); + info.language = application_manager::MessageHelper::CommonLanguageToString( + static_cast<hmi_apis::Common_Language::eType>(lang_code)); + + hmi_capabilities_.set_ccpu_version(info.ccpu_version); + + return info; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls.cc new file mode 100644 index 0000000000..52b95d3fa3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls.cc @@ -0,0 +1,230 @@ +/* + * 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/hmi/get_urls.h" +#include "application_manager/message.h" +#include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" +#include "application_manager/policies/policy_handler.h" +#include "utils/helpers.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +GetUrls::GetUrls(const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +GetUrls::~GetUrls() {} + +void GetUrls::Run() { + LOG4CXX_AUTO_TRACE(logger_); + namespace Common_Result = hmi_apis::Common_Result; + using policy::EndpointUrls; + + if (!policy_handler_.PolicyEnabled()) { + SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE); + return; + } + + const uint32_t service_to_check = + (*message_)[strings::msg_params][hmi_request::service].asUInt(); + + EndpointUrls endpoints; + policy_handler_.GetUpdateUrls(service_to_check, endpoints); + + if (endpoints.empty()) { + LOG4CXX_ERROR(logger_, "No URLs for service " << service_to_check); + SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE); + return; + } + +#ifdef PROPRIETARY_MODE + const uint32_t policy_service = 7u; + + if (policy_service == service_to_check) { + ProcessPolicyServiceURLs(endpoints); + return; + } +#endif // PROPRIETARY_MODE + + ProcessServiceURLs(endpoints); +} + +void GetUrls::ProcessServiceURLs(const policy::EndpointUrls& endpoints) { + namespace Common_Result = hmi_apis::Common_Result; + using smart_objects::SmartObject; + + (*message_)[strings::msg_params].erase(hmi_request::service); + SmartObject& urls = (*message_)[strings::msg_params][hmi_response::urls]; + + size_t index = 0; + for (size_t e = 0; e < endpoints.size(); ++e) { + ApplicationSharedPtr app = + application_manager_.application_by_policy_id(endpoints[e].app_id); + +#ifndef PROPRIETARY_MODE + bool registered_not_default = false; + if (policy::kDefaultId != endpoints[e].app_id) { + if (!app) { + LOG4CXX_ERROR(logger_, + "Can't find application with policy id " + << endpoints[e].app_id + << " URLs adding for this application is skipped."); + continue; + } + registered_not_default = true; + } +#endif // EXTERNAL_PROPRIETARY_MODE || HTTP + for (size_t u = 0; u < endpoints[e].url.size(); ++u, ++index) { + const std::string& app_url = endpoints[e].url[u]; + SmartObject& service_info = urls[index]; + + service_info[strings::url] = app_url; +#ifndef PROPRIETARY_MODE + if (registered_not_default) { + service_info[strings::app_id] = app->hmi_app_id(); + } +#else // EXTERNAL_PROPRIETARY_MODE || HTTP + service_info[hmi_response::policy_app_id] = endpoints[e].app_id; +#endif + } + } + SendResponseToHMI(Common_Result::SUCCESS); +} + +void GetUrls::SendResponseToHMI(hmi_apis::Common_Result::eType result) { + (*message_)[strings::params][strings::message_type] = MessageType::kResponse; + (*message_)[strings::params][hmi_response::code] = result; + rpc_service_.ManageHMICommand(message_); +} + +#ifdef PROPRIETARY_MODE +struct PolicyAppIdComparator { + PolicyAppIdComparator(const std::string& policy_app_id) + : policy_app_id_(policy_app_id) {} + + bool operator()(const policy::EndpointData& data) { + return data.app_id == policy_app_id_; + } + std::string policy_app_id_; +}; + +void FillSODefaultUrls(smart_objects::SmartObject& urls, + const policy::EndpointUrls& endpoints) { + using smart_objects::SmartObject; + PolicyAppIdComparator comparator(policy::kDefaultId); + policy::EndpointUrls::const_iterator it = + std::find_if(endpoints.begin(), endpoints.end(), comparator); + if (it == endpoints.end()) { + return; + } + SmartObject service_info = SmartObject(smart_objects::SmartType_Map); + for (size_t i = 0; i < (*it).url.size(); ++i) { + service_info[strings::url] = (*it).url[i]; + urls[i] = service_info; + } +} + +void GetUrls::ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace smart_objects; + using namespace application_manager; + using namespace strings; + using namespace hmi_apis; + + const uint32_t app_id_to_send_to = policy_handler_.GetAppIdForSending(); + + if (!app_id_to_send_to) { + LOG4CXX_ERROR(logger_, + "There are no available applications for processing."); + SmartObject urls(SmartType_Array); + FillSODefaultUrls(urls, endpoints); + if (!urls.empty()) { + (*message_)[msg_params][hmi_response::urls] = urls; + } + (*message_).erase(hmi_request::service); + SendResponseToHMI(Common_Result::SUCCESS); + return; + } + + ApplicationSharedPtr app = + application_manager_.application(app_id_to_send_to); + + if (!app.valid()) { + LOG4CXX_WARN(logger_, + "There is no registered application with " + "connection key '" + << app_id_to_send_to << "'"); + SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE); + return; + } + + SmartObject& object = *message_; + object[msg_params].erase(hmi_request::service); + object[msg_params][hmi_response::urls] = SmartObject(SmartType_Array); + SmartObject& urls = object[msg_params][hmi_response::urls]; + const std::string mobile_app_id = app->policy_app_id(); + + size_t index = 0; + for (size_t i = 0; i < endpoints.size(); ++i) { + using namespace helpers; + + const bool to_add = Compare<std::string, EQ, ONE>( + endpoints[i].app_id, mobile_app_id, policy::kDefaultId); + const bool is_default = policy::kDefaultId == endpoints[i].app_id; + + if (to_add) { + for (size_t k = 0; k < endpoints[i].url.size(); ++k) { + if (!is_default) { + urls[index][strings::app_id] = app_id_to_send_to; + } + urls[index][strings::url] = endpoints[i].url[k]; + ++index; + } + } + } + SendResponseToHMI(Common_Result::SUCCESS); + return; +} +#endif // PROPRIETARY_MODE + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls_response.cc new file mode 100644 index 0000000000..57c925e08f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls_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 "sdl_rpc_plugin/commands/hmi/get_urls_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +GetUrlsResponse::GetUrlsResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +GetUrlsResponse::~GetUrlsResponse() {} + +void GetUrlsResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; + (*message_)[strings::params][strings::protocol_version] = protocol_version_; + + rpc_service_.SendMessageToHMI(message_); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_request.cc new file mode 100644 index 0000000000..39f7e61c06 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/mixing_audio_supported_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +MixingAudioSupportedRequest::MixingAudioSupportedRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +MixingAudioSupportedRequest::~MixingAudioSupportedRequest() {} + +void MixingAudioSupportedRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_response.cc new file mode 100644 index 0000000000..26fa967844 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_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 "sdl_rpc_plugin/commands/hmi/mixing_audio_supported_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +MixingAudioSupportedResponse::MixingAudioSupportedResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +MixingAudioSupportedResponse::~MixingAudioSupportedResponse() {} + +void MixingAudioSupportedResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + hmi_capabilities_.set_attenuated_supported( + (*message_)[strings::msg_params][hmi_response::attenuated_supported] + .asBool()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_request.cc new file mode 100644 index 0000000000..ae3695b68e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/navi_alert_maneuver_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviAlertManeuverRequest::NaviAlertManeuverRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +NaviAlertManeuverRequest::~NaviAlertManeuverRequest() {} + +void NaviAlertManeuverRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_response.cc new file mode 100644 index 0000000000..6a6307038a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_response.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/navi_alert_maneuver_response.h" +#include "application_manager/event_engine/event.h" + +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviAlertManeuverResponse::NaviAlertManeuverResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +NaviAlertManeuverResponse::~NaviAlertManeuverResponse() {} + +void NaviAlertManeuverResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::Navigation_AlertManeuver); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc new file mode 100644 index 0000000000..a9698d36ab --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc @@ -0,0 +1,192 @@ +/* + * 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/hmi/navi_audio_start_stream_request.h" + +#include "application_manager/message_helper.h" +#include "protocol_handler/protocol_handler.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +AudioStartStreamRequest::AudioStartStreamRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) + , EventObserver(application_manager.event_dispatcher()) + , retry_number_(0) { + LOG4CXX_AUTO_TRACE(logger_); + std::pair<uint32_t, int32_t> stream_retry = + application_manager_.get_settings().start_stream_retry_amount(); + default_timeout_ = stream_retry.second; + retry_number_ = stream_retry.first; + LOG4CXX_DEBUG(logger_, + "default_timeout_ = " << default_timeout_ + << "; retry_number_ = " << retry_number_); +} + +AudioStartStreamRequest::~AudioStartStreamRequest() { + // see comment in NaviStartStreamRequest + unsubscribe_from_event(hmi_apis::FunctionID::Navigation_StartAudioStream); +} + +void AudioStartStreamRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + if (!app_mngr::commands::CheckAvailabilityHMIInterfaces( + application_manager_, HmiInterfaces::HMI_INTERFACE_Navigation)) { + LOG4CXX_INFO(logger_, "Interface Navi is not supported by system"); + return; + } + ApplicationSharedPtr app = + application_manager_.application_by_hmi_app(application_id()); + if (!app) { + LOG4CXX_ERROR(logger_, + "Applcation with hmi_app_id " << application_id() + << " does not exist"); + return; + } + SetAllowedToTerminate(false); + subscribe_on_event(hmi_apis::FunctionID::Navigation_StartAudioStream, + correlation_id()); + app->set_audio_streaming_allowed(true); + SendRequest(); +} + +void AudioStartStreamRequest::on_event(const event_engine::Event& event) { + using namespace protocol_handler; + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = + application_manager_.application_by_hmi_app(application_id()); + if (!app) { + LOG4CXX_ERROR(logger_, + "StartAudioStreamRequest aborted. Application not found"); + return; + } + + const smart_objects::SmartObject& message = event.smart_object(); + switch (event.id()) { + case hmi_apis::FunctionID::Navigation_StartAudioStream: { + LOG4CXX_DEBUG(logger_, "Received StartStream event"); + + const hmi_apis::Common_Result::eType code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + if (hmi_apis::Common_Result::SUCCESS == code) { + LOG4CXX_INFO(logger_, "StartAudioStream response SUCCESS"); + if (application_manager_.HMILevelAllowsStreaming(app->app_id(), + ServiceType::kAudio)) { + app->set_audio_streaming_approved(true); + } else { + LOG4CXX_WARN( + logger_, + "StartAudioStreamRequest aborted. Application can not stream"); + } + application_manager_.TerminateRequest( + connection_key(), correlation_id(), function_id()); + break; + } + if (hmi_apis::Common_Result::REJECTED == code) { + LOG4CXX_INFO(logger_, "StartAudioStream response REJECTED"); + RetryStartSession(); + break; + } + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +void AudioStartStreamRequest::onTimeOut() { + LOG4CXX_AUTO_TRACE(logger_); + RetryStartSession(); +} + +void AudioStartStreamRequest::RetryStartSession() { + LOG4CXX_AUTO_TRACE(logger_); + + application_manager_.TerminateRequest( + connection_key(), correlation_id(), function_id()); + + ApplicationSharedPtr app = + application_manager_.application_by_hmi_app(application_id()); + if (!app) { + LOG4CXX_ERROR(logger_, + "StartAudioStreamRequest aborted. Application not found"); + return; + } + + if (!app->audio_streaming_allowed()) { + LOG4CXX_WARN(logger_, "Audio streaming not allowed"); + return; + } + + if (app->audio_streaming_approved()) { + LOG4CXX_INFO(logger_, + "AudioStartStream retry sequence stopped. " + << "SUCCESS received"); + app->set_audio_stream_retry_number(0); + return; + } + + uint32_t curr_retry_number = app->audio_stream_retry_number(); + LOG4CXX_DEBUG( + logger_, "Retry number " << curr_retry_number << " of " << retry_number_); + + if (curr_retry_number < retry_number_) { + LOG4CXX_DEBUG(logger_, "Send AudioStartStream retry"); + MessageHelper::SendAudioStartStream(app->app_id(), application_manager_); + app->set_audio_stream_retry_number(++curr_retry_number); + } else { + LOG4CXX_DEBUG(logger_, + "Audio start stream retry sequence stopped. " + << "Attempts expired."); + + application_manager_.EndNaviServices(app->app_id()); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_response.cc new file mode 100644 index 0000000000..362a46cc19 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_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 "sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +AudioStartStreamResponse::AudioStartStreamResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +AudioStartStreamResponse::~AudioStartStreamResponse() {} + +void AudioStartStreamResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::Navigation_StartAudioStream); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_request.cc new file mode 100644 index 0000000000..ba2b8c8157 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_request.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 "sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +AudioStopStreamRequest::AudioStopStreamRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +AudioStopStreamRequest::~AudioStopStreamRequest() {} + +void AudioStopStreamRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + if (!app_mngr::commands::CheckAvailabilityHMIInterfaces( + application_manager_, HmiInterfaces::HMI_INTERFACE_Navigation)) { + LOG4CXX_INFO(logger_, "Interface Navi is not supported by system"); + return; + } + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_response.cc new file mode 100644 index 0000000000..87ddc81696 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_response.cc @@ -0,0 +1,59 @@ +/* + * 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/hmi/navi_audio_stop_stream_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +AudioStopStreamResponse::AudioStopStreamResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +AudioStopStreamResponse::~AudioStopStreamResponse() {} + +void AudioStopStreamResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_request.cc new file mode 100644 index 0000000000..77ef3e3369 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/navi_get_way_points_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviGetWayPointsRequest::NaviGetWayPointsRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +NaviGetWayPointsRequest::~NaviGetWayPointsRequest() {} + +void NaviGetWayPointsRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_response.cc new file mode 100644 index 0000000000..0aad5e5724 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_response.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/navi_get_way_points_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviGetWayPointsResponse::NaviGetWayPointsResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +NaviGetWayPointsResponse::~NaviGetWayPointsResponse() {} + +void NaviGetWayPointsResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::Navigation_GetWayPoints); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_request.cc new file mode 100644 index 0000000000..781b8d3045 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_request.cc @@ -0,0 +1,87 @@ +/* + * 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/hmi/navi_is_ready_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviIsReadyRequest::NaviIsReadyRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) + , EventObserver(application_manager.event_dispatcher()) {} + +NaviIsReadyRequest::~NaviIsReadyRequest() {} + +void NaviIsReadyRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + subscribe_on_event(hmi_apis::FunctionID::Navigation_IsReady, + correlation_id()); + SendRequest(); +} + +void NaviIsReadyRequest::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::Navigation_IsReady: { + LOG4CXX_DEBUG(logger_, "Received Navigation_IsReady event"); + unsubscribe_from_event(hmi_apis::FunctionID::Navigation_IsReady); + const bool is_available = app_mngr::commands::ChangeInterfaceState( + application_manager_, + message, + HmiInterfaces::HMI_INTERFACE_Navigation); + + HMICapabilities& hmi_capabilities = hmi_capabilities_; + hmi_capabilities.set_is_navi_cooperating(is_available); + 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/hmi/navi_is_ready_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_response.cc new file mode 100644 index 0000000000..b4e64e2a3e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_response.cc @@ -0,0 +1,61 @@ +/* + * 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/hmi/navi_is_ready_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviIsReadyResponse::NaviIsReadyResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +NaviIsReadyResponse::~NaviIsReadyResponse() {} + +void NaviIsReadyResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event(hmi_apis::FunctionID::Navigation_IsReady); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_request.cc new file mode 100644 index 0000000000..a10f61310d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/navi_send_location_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviSendLocationRequest::NaviSendLocationRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +NaviSendLocationRequest::~NaviSendLocationRequest() {} + +void NaviSendLocationRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_response.cc new file mode 100644 index 0000000000..f93e2e17c3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_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 "sdl_rpc_plugin/commands/hmi/navi_send_location_response.h" +#include "application_manager/event_engine/event.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviSendLocationResponse::NaviSendLocationResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +NaviSendLocationResponse::~NaviSendLocationResponse() {} + +void NaviSendLocationResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::Navigation_SendLocation); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_request.cc new file mode 100644 index 0000000000..5e4426bd20 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_request.cc @@ -0,0 +1,156 @@ +/* + * 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 names of the copyright holders nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 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/hmi/navi_set_video_config_request.h" +#include <string> +#include <vector> + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviSetVideoConfigRequest::NaviSetVideoConfigRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) + , EventObserver(application_manager.event_dispatcher()) {} + +NaviSetVideoConfigRequest::~NaviSetVideoConfigRequest() {} + +void NaviSetVideoConfigRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + if (!app_mngr::commands::CheckAvailabilityHMIInterfaces( + application_manager_, HmiInterfaces::HMI_INTERFACE_Navigation)) { + LOG4CXX_WARN(logger_, "HMI interface Navigation is not supported"); + return; + } + + ApplicationSharedPtr app = + application_manager_.application_by_hmi_app(application_id()); + if (!app) { + LOG4CXX_ERROR(logger_, + "Application with hmi_app_id " << application_id() + << "does not exist"); + return; + } + + subscribe_on_event(hmi_apis::FunctionID::Navigation_SetVideoConfig, + correlation_id()); + SendRequest(); +} + +void NaviSetVideoConfigRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = + application_manager_.application_by_hmi_app(application_id()); + if (!app) { + LOG4CXX_ERROR(logger_, + "Application is not found, abort NaviSetVideoConfigRequest"); + return; + } + + const smart_objects::SmartObject& message = event.smart_object(); + switch (event.id()) { + case hmi_apis::FunctionID::Navigation_SetVideoConfig: { + const hmi_apis::Common_Result::eType code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + bool result = false; + std::vector<std::string> rejected_params; + + if (code == hmi_apis::Common_Result::SUCCESS) { + LOG4CXX_DEBUG(logger_, "Received SetVideoConfig success response"); + result = true; + } else { + LOG4CXX_DEBUG(logger_, + "Received SetVideoConfig failure response (" << event.id() + << ")"); + result = false; + if (message[strings::msg_params].keyExists(strings::rejected_params)) { + const smart_objects::SmartArray* list = + message[strings::msg_params][strings::rejected_params].asArray(); + if (list != NULL) { + for (unsigned int i = 0; i < list->size(); i++) { + const std::string& param = (*list)[i].asString(); + // Make sure that we actually sent the parameter in the request + if ((*message_)[strings::msg_params].keyExists(strings::config) && + (*message_)[strings::msg_params][strings::config].keyExists( + param)) { + rejected_params.push_back(param); + } + } + } + } + } + application_manager_.OnStreamingConfigured( + app->app_id(), + protocol_handler::ServiceType::kMobileNav, + result, + rejected_params); + break; + } + default: + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + break; + } +} + +void NaviSetVideoConfigRequest::onTimeOut() { + LOG4CXX_WARN(logger_, "Timed out while waiting for SetVideoConfig response"); + + ApplicationSharedPtr app = + application_manager_.application_by_hmi_app(application_id()); + if (!app) { + LOG4CXX_ERROR(logger_, "Application is not found"); + return; + } + + std::vector<std::string> empty; + application_manager_.OnStreamingConfigured( + app->app_id(), protocol_handler::ServiceType::kMobileNav, false, empty); + + application_manager_.TerminateRequest( + connection_key(), correlation_id(), function_id()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_response.cc new file mode 100644 index 0000000000..c5f1c5307f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_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 names of the copyright holders nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 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/hmi/navi_set_video_config_response.h" +#include "application_manager/event_engine/event.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviSetVideoConfigResponse::NaviSetVideoConfigResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +NaviSetVideoConfigResponse::~NaviSetVideoConfigResponse() {} + +void NaviSetVideoConfigResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::Navigation_SetVideoConfig); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_request.cc new file mode 100644 index 0000000000..22d604ab0d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/navi_show_constant_tbt_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviShowConstantTBTRequest::NaviShowConstantTBTRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +NaviShowConstantTBTRequest::~NaviShowConstantTBTRequest() {} + +void NaviShowConstantTBTRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_response.cc new file mode 100644 index 0000000000..d2ff26b645 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_response.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/navi_show_constant_tbt_response.h" +#include "application_manager/event_engine/event.h" + +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviShowConstantTBTResponse::NaviShowConstantTBTResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +NaviShowConstantTBTResponse::~NaviShowConstantTBTResponse() {} + +void NaviShowConstantTBTResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::Navigation_ShowConstantTBT); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc new file mode 100644 index 0000000000..f3d971acba --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc @@ -0,0 +1,193 @@ +/* + * 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/hmi/navi_start_stream_request.h" + +#include "application_manager/message_helper.h" +#include "protocol_handler/protocol_handler.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviStartStreamRequest::NaviStartStreamRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) + , EventObserver(application_manager.event_dispatcher()) + , retry_number_(0) { + LOG4CXX_AUTO_TRACE(logger_); + std::pair<uint32_t, int32_t> stream_retry = + application_manager_.get_settings().start_stream_retry_amount(); + default_timeout_ = stream_retry.second; + retry_number_ = stream_retry.first; + LOG4CXX_DEBUG(logger_, + "default_timeout_ = " << default_timeout_ + << "; retry_number_ = " << retry_number_); +} + +NaviStartStreamRequest::~NaviStartStreamRequest() { + // unsubscribe_from_all_events() in EventObserver's destructor isn't enough; + // we must unsubscribe before this NaviStartStreamRequest instance is removed + unsubscribe_from_event(hmi_apis::FunctionID::Navigation_StartStream); +} + +void NaviStartStreamRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + if (!app_mngr::commands::CheckAvailabilityHMIInterfaces( + application_manager_, HmiInterfaces::HMI_INTERFACE_Navigation)) { + LOG4CXX_INFO(logger_, "Interface Navi is not supported by system"); + return; + } + ApplicationSharedPtr app = + application_manager_.application_by_hmi_app(application_id()); + if (!app) { + LOG4CXX_ERROR(logger_, + "Applcation with hmi_app_id " << application_id() + << "does not exist"); + return; + } + SetAllowedToTerminate(false); + subscribe_on_event(hmi_apis::FunctionID::Navigation_StartStream, + correlation_id()); + app->set_video_streaming_allowed(true); + SendRequest(); +} + +void NaviStartStreamRequest::on_event(const event_engine::Event& event) { + using namespace protocol_handler; + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = + application_manager_.application_by_hmi_app(application_id()); + if (!app) { + LOG4CXX_ERROR(logger_, + "NaviStartStreamRequest aborted. Application not found"); + return; + } + + const smart_objects::SmartObject& message = event.smart_object(); + switch (event.id()) { + case hmi_apis::FunctionID::Navigation_StartStream: { + LOG4CXX_DEBUG(logger_, "Received StartStream event"); + + const hmi_apis::Common_Result::eType code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + if (hmi_apis::Common_Result::SUCCESS == code) { + LOG4CXX_INFO(logger_, "NaviStartStreamResponse SUCCESS"); + if (application_manager_.HMILevelAllowsStreaming( + app->app_id(), ServiceType::kMobileNav)) { + app->set_video_streaming_approved(true); + } else { + LOG4CXX_DEBUG( + logger_, + "NaviStartStreamRequest aborted. Application can not stream"); + } + application_manager_.TerminateRequest( + connection_key(), correlation_id(), function_id()); + break; + } + if (hmi_apis::Common_Result::REJECTED == code) { + LOG4CXX_INFO(logger_, "StartStream response REJECTED "); + RetryStartSession(); + break; + } + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +void NaviStartStreamRequest::onTimeOut() { + LOG4CXX_AUTO_TRACE(logger_); + RetryStartSession(); +} + +void NaviStartStreamRequest::RetryStartSession() { + LOG4CXX_AUTO_TRACE(logger_); + + application_manager_.TerminateRequest( + connection_key(), correlation_id(), function_id()); + + ApplicationSharedPtr app = + application_manager_.application_by_hmi_app(application_id()); + if (!app) { + LOG4CXX_ERROR(logger_, + "NaviStartStreamRequest aborted. Application not found"); + return; + } + + if (!app->video_streaming_allowed()) { + LOG4CXX_WARN(logger_, "Video streaming not allowed"); + return; + } + + if (app->video_streaming_approved()) { + LOG4CXX_INFO(logger_, + "NaviStartStream retry sequence stopped. " + << "SUCCESS received"); + app->set_video_stream_retry_number(0); + return; + } + + uint32_t curr_retry_number = app->video_stream_retry_number(); + LOG4CXX_DEBUG( + logger_, "Retry number " << curr_retry_number << " of " << retry_number_); + + if (curr_retry_number < retry_number_) { + LOG4CXX_DEBUG(logger_, "Send NaviStartStream retry"); + MessageHelper::SendNaviStartStream(app->app_id(), application_manager_); + app->set_video_stream_retry_number(++curr_retry_number); + } else { + LOG4CXX_DEBUG(logger_, + "NaviStartStream retry sequence stopped. " + << "Attempts expired"); + + application_manager_.EndNaviServices(app->app_id()); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_response.cc new file mode 100644 index 0000000000..f09a334f51 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_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 "sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviStartStreamResponse::NaviStartStreamResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +NaviStartStreamResponse::~NaviStartStreamResponse() {} + +void NaviStartStreamResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::Navigation_StartStream); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_request.cc new file mode 100644 index 0000000000..3e27692d62 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_request.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 "sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviStopStreamRequest::NaviStopStreamRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +NaviStopStreamRequest::~NaviStopStreamRequest() {} + +void NaviStopStreamRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + if (!app_mngr::commands::CheckAvailabilityHMIInterfaces( + application_manager_, HmiInterfaces::HMI_INTERFACE_Navigation)) { + LOG4CXX_INFO(logger_, "Interface Navi is not supported by system"); + return; + } + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_response.cc new file mode 100644 index 0000000000..61b8d5a1e2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_response.cc @@ -0,0 +1,59 @@ +/* + * 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/hmi/navi_stop_stream_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviStopStreamResponse::NaviStopStreamResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +NaviStopStreamResponse::~NaviStopStreamResponse() {} + +void NaviStopStreamResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_request.cc new file mode 100644 index 0000000000..a4445ebce8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/navi_subscribe_way_points_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviSubscribeWayPointsRequest::NaviSubscribeWayPointsRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +NaviSubscribeWayPointsRequest::~NaviSubscribeWayPointsRequest() {} + +void NaviSubscribeWayPointsRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_response.cc new file mode 100644 index 0000000000..ae5f236f6f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_response.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/navi_subscribe_way_points_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviSubscribeWayPointsResponse::NaviSubscribeWayPointsResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +NaviSubscribeWayPointsResponse::~NaviSubscribeWayPointsResponse() {} + +void NaviSubscribeWayPointsResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event( + hmi_apis::FunctionID::Navigation_SubscribeWayPoints); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_request.cc new file mode 100644 index 0000000000..e7d416bc61 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/navi_unsubscribe_way_points_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviUnSubscribeWayPointsRequest::NaviUnSubscribeWayPointsRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +NaviUnSubscribeWayPointsRequest::~NaviUnSubscribeWayPointsRequest() {} + +void NaviUnSubscribeWayPointsRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_response.cc new file mode 100644 index 0000000000..c084bd52d3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_response.cc @@ -0,0 +1,68 @@ +/* + * 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/hmi/navi_unsubscribe_way_points_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviUnsubscribeWayPointsResponse::NaviUnsubscribeWayPointsResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +NaviUnsubscribeWayPointsResponse::~NaviUnsubscribeWayPointsResponse() {} + +void NaviUnsubscribeWayPointsResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event( + hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_request.cc new file mode 100644 index 0000000000..9c507c3637 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/navi_update_turn_list_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviUpdateTurnListRequest::NaviUpdateTurnListRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +NaviUpdateTurnListRequest::~NaviUpdateTurnListRequest() {} + +void NaviUpdateTurnListRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_response.cc new file mode 100644 index 0000000000..eb232e6d01 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_response.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/navi_update_turn_list_response.h" +#include "application_manager/event_engine/event.h" + +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +NaviUpdateTurnListResponse::NaviUpdateTurnListResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +NaviUpdateTurnListResponse::~NaviUpdateTurnListResponse() {} + +void NaviUpdateTurnListResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::Navigation_UpdateTurnList); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_allow_sdl_functionality_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_allow_sdl_functionality_notification.cc new file mode 100644 index 0000000000..398c2dac30 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_allow_sdl_functionality_notification.cc @@ -0,0 +1,69 @@ +/* + * 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/hmi/on_allow_sdl_functionality_notification.h" +#include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnAllowSDLFunctionalityNotification::OnAllowSDLFunctionalityNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnAllowSDLFunctionalityNotification::~OnAllowSDLFunctionalityNotification() {} + +void OnAllowSDLFunctionalityNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + std::string device_id; + if ((*message_)[strings::msg_params].keyExists("device")) { + device_id = (*message_)[strings::msg_params]["device"]["id"].asString(); + } + policy_handler_.OnAllowSDLFunctionalityNotification( + (*message_)[strings::msg_params][hmi_response::allowed].asBool(), + device_id); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_activated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_activated_notification.cc new file mode 100644 index 0000000000..189596c58a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_activated_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_app_activated_notification.h" + +#include "application_manager/message_helper.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnAppActivatedNotification::OnAppActivatedNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnAppActivatedNotification::~OnAppActivatedNotification() {} + +void OnAppActivatedNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event( + hmi_apis::FunctionID::BasicCommunication_OnAppActivated); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_deactivated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_deactivated_notification.cc new file mode 100644 index 0000000000..ee45f9bf1e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_deactivated_notification.cc @@ -0,0 +1,69 @@ +/* + * 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/hmi/on_app_deactivated_notification.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 { + +OnAppDeactivatedNotification::OnAppDeactivatedNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnAppDeactivatedNotification::~OnAppDeactivatedNotification() {} + +void OnAppDeactivatedNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event( + hmi_apis::FunctionID::BasicCommunication_OnAppDeactivated); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_changed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_changed_notification.cc new file mode 100644 index 0000000000..e13299ece7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_changed_notification.cc @@ -0,0 +1,61 @@ +/* + * 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/hmi/on_app_permission_changed_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnAppPermissionChangedNotification::OnAppPermissionChangedNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnAppPermissionChangedNotification::~OnAppPermissionChangedNotification() {} + +void OnAppPermissionChangedNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_consent_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_consent_notification.cc new file mode 100644 index 0000000000..839c16ca08 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_consent_notification.cc @@ -0,0 +1,183 @@ + +/** + * 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/hmi/on_app_permission_consent_notification.h" +#include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler.h" +#include "application_manager/message_helper.h" +#include <algorithm> +#include <functional> +#include <string> +#include "policy/policy_types.h" +#include "smart_objects/smart_object.h" +#include "utils/make_shared.h" + +namespace { + +/** + * @brief Converts SmartObject data to group permission status and appends to + * collection + */ +struct PermissionsAppender + : public std::unary_function<void, + const smart_objects::SmartArray::value_type&> { + PermissionsAppender(policy::PermissionConsent& consents) + : allowed_key_(application_manager::hmi_response::allowed) + , consents_(consents) {} + void operator()(const smart_objects::SmartArray::value_type& item) const { + using namespace policy; + using namespace application_manager; + + FunctionalGroupPermission permissions; + + permissions.group_id = static_cast<int32_t>(item[strings::id].asInt()); + permissions.group_alias = item[strings::name].asString(); + + if (item.keyExists(allowed_key_)) { + permissions.state = + item[allowed_key_].asBool() ? kGroupAllowed : kGroupDisallowed; + } + + consents_.group_permissions.push_back(permissions); + } + + private: + const std::string allowed_key_; + policy::PermissionConsent& consents_; +}; + +#ifdef EXTERNAL_PROPRIETARY_MODE +/** + * @brief Converts SmartObject data to customer connectivity status item and + * appends to collection + */ +struct ExternalConsentStatusAppender + : std::unary_function<void, const smart_objects::SmartArray::value_type&> { + ExternalConsentStatusAppender( + policy::ExternalConsentStatus& external_consent_status) + : external_consent_status_(external_consent_status) {} + void operator()(const smart_objects::SmartArray::value_type& item) const { + using namespace policy; + using namespace hmi_apis; + using namespace application_manager; + + ExternalConsentStatusItem status_item( + static_cast<uint32_t>(item[strings::entity_type].asUInt()), + static_cast<uint32_t>(item[strings::entity_id].asUInt()), + static_cast<Common_EntityStatus::eType>( + item[strings::status].asUInt()) == Common_EntityStatus::ON + ? policy::kStatusOn + : policy::kStatusOff); + + external_consent_status_.insert(status_item); + } + + private: + policy::ExternalConsentStatus& external_consent_status_; +}; +#endif +} // namespace + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnAppPermissionConsentNotification::OnAppPermissionConsentNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnAppPermissionConsentNotification::~OnAppPermissionConsentNotification() {} + +void OnAppPermissionConsentNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; + + uint32_t connection_key = 0; + + policy::PermissionConsent permission_consent; + + // If user defined group permissions for specific app + if (msg_params.keyExists(strings::app_id)) { + connection_key = msg_params[strings::app_id].asUInt(); + } + + if (msg_params.keyExists(strings::consented_functions)) { + const smart_objects::SmartArray* user_consent = + msg_params[strings::consented_functions].asArray(); + + smart_objects::SmartArray::const_iterator it = user_consent->begin(); + smart_objects::SmartArray::const_iterator it_end = user_consent->end(); + for (; it != it_end; ++it) { + policy::FunctionalGroupPermission permissions; + permissions.group_id = (*it)["id"].asInt(); + permissions.group_alias = (*it)["name"].asString(); + if ((*it).keyExists("allowed")) { + permissions.state = (*it)["allowed"].asBool() + ? policy::kGroupAllowed + : policy::kGroupDisallowed; + } else { + permissions.state = policy::kGroupUndefined; + } + + permission_consent.group_permissions.push_back(permissions); + } + + permission_consent.consent_source = msg_params[strings::source].asString(); + } +#ifdef EXTERNAL_PROPRIETARY_MODE + policy::ExternalConsentStatus external_consent_status; + if (msg_params.keyExists(strings::external_consent_status)) { + const smart_objects::SmartArray* system_external_consent_status = + msg_params[strings::external_consent_status].asArray(); + ExternalConsentStatusAppender status_appender(external_consent_status); + std::for_each(system_external_consent_status->begin(), + system_external_consent_status->end(), + status_appender); + } + policy_handler_.OnAppPermissionConsent( + connection_key, permission_consent, external_consent_status); +#else + policy_handler_.OnAppPermissionConsent(connection_key, permission_consent); +#endif +} +} // commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_registered_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_registered_notification.cc new file mode 100644 index 0000000000..24c5a94272 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_registered_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_app_registered_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnAppRegisteredNotification::OnAppRegisteredNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnAppRegisteredNotification::~OnAppRegisteredNotification() {} + +void OnAppRegisteredNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + // SDL must notify system about app registration before any dependent actions + // will be started + SendNotification(); + event_engine::Event event( + hmi_apis::FunctionID::BasicCommunication_OnAppRegistered); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_unregistered_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_unregistered_notification.cc new file mode 100644 index 0000000000..001b9fa5e0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_unregistered_notification.cc @@ -0,0 +1,76 @@ +/* + * 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/hmi/on_app_unregistered_notification.h" + +#include "application_manager/event_engine/event.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnAppUnregisteredNotification::OnAppUnregisteredNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnAppUnregisteredNotification::~OnAppUnregisteredNotification() {} + +bool OnAppUnregisteredNotification::Init() { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, "Replacement of hmi id is skipped."); + return true; +} + +void OnAppUnregisteredNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // sending event for delete VRCommand on PerformInteraction + event_engine::Event event( + hmi_apis::FunctionID::BasicCommunication_OnAppUnregistered); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); + + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_audio_data_streaming_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_audio_data_streaming_notification.cc new file mode 100644 index 0000000000..e2cd6d2cbf --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_audio_data_streaming_notification.cc @@ -0,0 +1,61 @@ +/* + * 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/hmi/on_audio_data_streaming_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnAudioDataStreamingNotification::OnAudioDataStreamingNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnAudioDataStreamingNotification::~OnAudioDataStreamingNotification() {} + +void OnAudioDataStreamingNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_event_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_event_notification.cc new file mode 100644 index 0000000000..1f052b865b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_event_notification.cc @@ -0,0 +1,70 @@ +/* + * 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/hmi/on_button_event_notification.h" + +#include "application_manager/application_impl.h" +#include "utils/logger.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace hmi { + +OnButtonEventNotification::OnButtonEventNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +void OnButtonEventNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::OnButtonEventID); + + SendNotificationToMobile(message_); +} + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_press_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_press_notification.cc new file mode 100644 index 0000000000..6c5d8f5a43 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_press_notification.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 "sdl_rpc_plugin/commands/hmi/on_button_press_notification.h" + +#include "application_manager/application_impl.h" +#include "utils/logger.h" +#include "application_manager/event_engine/event.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace hmi { + +OnButtonPressNotification::OnButtonPressNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +void OnButtonPressNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event(hmi_apis::FunctionID::Buttons_OnButtonPress); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); + (*message_)[strings::params][strings::function_id] = + static_cast<int>(mobile_apis::FunctionID::eType::OnButtonPressID); + SendNotificationToMobile(message_); +} + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_subscription_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_subscription_notification.cc new file mode 100644 index 0000000000..70ff1c3fad --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_subscription_notification.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/on_button_subscription_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace hmi { + +OnButtonSubscriptionNotification::OnButtonSubscriptionNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnButtonSubscriptionNotification::~OnButtonSubscriptionNotification() {} + +void OnButtonSubscriptionNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendNotification(); +} + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_chosen_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_chosen_notification.cc new file mode 100644 index 0000000000..2c4f9a1ccc --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_chosen_notification.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/on_device_chosen_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnDeviceChosenNotification::OnDeviceChosenNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnDeviceChosenNotification::~OnDeviceChosenNotification() {} + +void OnDeviceChosenNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + if ((*message_)[strings::msg_params].keyExists(strings::device_info)) { + application_manager_.ConnectToDevice( + (*message_)[strings::msg_params][strings::device_info][strings::id] + .asString()); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc new file mode 100644 index 0000000000..307dccd09b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc @@ -0,0 +1,124 @@ +/* + * 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 <algorithm> +#include "sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h" +#include "application_manager/application_manager.h" +#include "application_manager/message_helper.h" +#include "interfaces/HMI_API.h" +#include "encryption/hashing.h" + +namespace { +// TODO(AOleynik) : replace this !!! +void check_zero(const char& a, const char& b, std::string& bt_mac) { + if ('0' != a && '0' == b) { + bt_mac.push_back(a); + bt_mac.push_back(b); + } else if ('0' == a) { + bt_mac.push_back(b); + } else { + bt_mac.push_back(a); + bt_mac.push_back(b); + } +} + +std::string convert_to_bt_mac(std::string& deviceInternalId) { + std::transform(deviceInternalId.begin(), + deviceInternalId.end(), + deviceInternalId.begin(), + ::tolower); + + std::string bt_mac; + check_zero(deviceInternalId[10], deviceInternalId[11], bt_mac); + bt_mac.push_back(':'); + check_zero(deviceInternalId[8], deviceInternalId[9], bt_mac); + bt_mac.push_back(':'); + check_zero(deviceInternalId[6], deviceInternalId[7], bt_mac); + bt_mac.push_back(':'); + check_zero(deviceInternalId[4], deviceInternalId[5], bt_mac); + bt_mac.push_back(':'); + check_zero(deviceInternalId[2], deviceInternalId[3], bt_mac); + bt_mac.push_back(':'); + check_zero(deviceInternalId[0], deviceInternalId[1], bt_mac); + + return bt_mac; +} +} + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnDeviceStateChangedNotification::OnDeviceStateChangedNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnDeviceStateChangedNotification::~OnDeviceStateChangedNotification() {} + +void OnDeviceStateChangedNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + if ((*message_)[strings::msg_params]["deviceState"] == + hmi_apis::Common_DeviceState::UNPAIRED) { + // It is expected, that "deviceInternalId" is the device MAC address in + // form XXXXXXXXXX + std::string device_id = + (*message_)[strings::msg_params]["deviceInternalId"].asString(); + if (device_id.empty()) { + if ((*message_)[strings::msg_params].keyExists("deviceId")) { + device_id = + (*message_)[strings::msg_params]["deviceId"]["id"].asString(); + } + } else { + // Policy uses hashed MAC address as device_id + LOG4CXX_DEBUG(logger_, "Device_id from HMI: " << device_id); + std::string bt_mac = convert_to_bt_mac(device_id); + LOG4CXX_DEBUG(logger_, "Device_id as BT MAC: " << bt_mac); + device_id = encryption::MakeHash(bt_mac); + LOG4CXX_DEBUG(logger_, "Device_id hashed as BT MAC : " << device_id); + } + policy_handler_.RemoveDevice(device_id); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc new file mode 100644 index 0000000000..16ca48a2d4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc @@ -0,0 +1,143 @@ +/* + * 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 <set> +#include "sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h" + +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" +#include "utils/make_shared.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace hmi { + +namespace { +struct OnDriverDistractionProcessor { + OnDriverDistractionProcessor( + OnDriverDistractionNotification& command, + smart_objects::SmartObjectSPtr on_driver_distraction_so, + ApplicationManager& application_manager) + : command_(command) + , on_driver_distraction_so_(on_driver_distraction_so) + , application_manager_(application_manager) + , stringified_function_id_(MessageHelper::StringifiedFunctionID( + mobile_api::FunctionID::OnDriverDistractionID)) {} + + void operator()(ApplicationSharedPtr application) { + if (application) { + (*on_driver_distraction_so_)[strings::params][strings::connection_key] = + application->app_id(); + const RPCParams params; + policy::CheckPermissionResult result; + application_manager_.GetPolicyHandler().CheckPermissions( + application, stringified_function_id_, params, result); + if (result.hmi_level_permitted != policy::kRpcAllowed) { + MobileMessageQueue messages; + application->SwapMobileMessageQueue(messages); + messages.erase( + std::remove_if( + messages.begin(), + messages.end(), + [this](smart_objects::SmartObjectSPtr message) { + return (*message)[strings::params][strings::function_id] + .asString() == stringified_function_id_; + }), + messages.end()); + application->PushMobileMessage(on_driver_distraction_so_); + return; + } + command_.SendNotificationToMobile(on_driver_distraction_so_); + } + } + + private: + OnDriverDistractionNotification& command_; + smart_objects::SmartObjectSPtr on_driver_distraction_so_; + ApplicationManager& application_manager_; + std::string stringified_function_id_; +}; +} + +OnDriverDistractionNotification::OnDriverDistractionNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnDriverDistractionNotification::~OnDriverDistractionNotification() {} + +void OnDriverDistractionNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + const hmi_apis::Common_DriverDistractionState::eType state = + static_cast<hmi_apis::Common_DriverDistractionState::eType>( + (*message_)[strings::msg_params][hmi_notification::state].asInt()); + application_manager_.set_driver_distraction_state(state); + + smart_objects::SmartObjectSPtr on_driver_distraction = + utils::MakeShared<smart_objects::SmartObject>(); + + if (!on_driver_distraction) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + (*on_driver_distraction)[strings::params][strings::function_id] = + mobile_api::FunctionID::OnDriverDistractionID; + (*on_driver_distraction)[strings::params][strings::message_type] = + static_cast<int32_t>(application_manager::MessageType::kNotification); + (*on_driver_distraction)[strings::msg_params][mobile_notification::state] = + state; + + const ApplicationSet applications = + application_manager_.applications().GetData(); + + OnDriverDistractionProcessor processor( + *this, on_driver_distraction, application_manager_); + std::for_each(applications.begin(), applications.end(), processor); +} + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_event_changed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_event_changed_notification.cc new file mode 100644 index 0000000000..cd3f2c23e6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_event_changed_notification.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 "sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnEventChangedNotification::OnEventChangedNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnEventChangedNotification::~OnEventChangedNotification() {} + +void OnEventChangedNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event( + hmi_apis::FunctionID::BasicCommunication_OnEventChanged); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_all_applications_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_all_applications_notification.cc new file mode 100644 index 0000000000..9131bf7392 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_all_applications_notification.cc @@ -0,0 +1,124 @@ +/* + * 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/hmi/on_exit_all_applications_notification.h" + +#include <sys/types.h> +#include <unistd.h> +#include <signal.h> + +#include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" +#include "application_manager/resumption/resume_ctrl.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnExitAllApplicationsNotification::OnExitAllApplicationsNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnExitAllApplicationsNotification::~OnExitAllApplicationsNotification() {} + +void OnExitAllApplicationsNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + const hmi_apis::Common_ApplicationsCloseReason::eType reason = + static_cast<hmi_apis::Common_ApplicationsCloseReason::eType>( + (*message_)[strings::msg_params][hmi_request::reason].asInt()); + LOG4CXX_DEBUG(logger_, "Reason " << reason); + + mobile_api::AppInterfaceUnregisteredReason::eType mob_reason = + mobile_api::AppInterfaceUnregisteredReason::INVALID_ENUM; + + switch (reason) { + case hmi_apis::Common_ApplicationsCloseReason::IGNITION_OFF: { + mob_reason = mobile_api::AppInterfaceUnregisteredReason::IGNITION_OFF; + break; + } + case hmi_apis::Common_ApplicationsCloseReason::MASTER_RESET: { + mob_reason = mobile_api::AppInterfaceUnregisteredReason::MASTER_RESET; + break; + } + case hmi_apis::Common_ApplicationsCloseReason::FACTORY_DEFAULTS: { + mob_reason = mobile_api::AppInterfaceUnregisteredReason::FACTORY_DEFAULTS; + break; + } + case hmi_apis::Common_ApplicationsCloseReason::SUSPEND: { + application_manager_.resume_controller().OnSuspend(); + SendOnSDLPersistenceComplete(); + return; + } + default: { + LOG4CXX_ERROR(logger_, "Unknown Application close reason" << reason); + return; + } + } + + application_manager_.SetUnregisterAllApplicationsReason(mob_reason); + + if (mobile_api::AppInterfaceUnregisteredReason::MASTER_RESET == mob_reason || + mobile_api::AppInterfaceUnregisteredReason::FACTORY_DEFAULTS == + mob_reason) { + application_manager_.HeadUnitReset(mob_reason); + } + kill(getpid(), SIGINT); +} + +void OnExitAllApplicationsNotification::SendOnSDLPersistenceComplete() { + LOG4CXX_AUTO_TRACE(logger_); + + smart_objects::SmartObjectSPtr message = + new smart_objects::SmartObject(smart_objects::SmartType_Map); + (*message)[strings::params][strings::function_id] = + hmi_apis::FunctionID::BasicCommunication_OnSDLPersistenceComplete; + (*message)[strings::params][strings::message_type] = + MessageType::kNotification; + (*message)[strings::params][strings::correlation_id] = + application_manager_.GetNextHMICorrelationID(); + + rpc_service_.ManageHMICommand(message); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc new file mode 100644 index 0000000000..d2a149bf94 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc @@ -0,0 +1,125 @@ +/* + * 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/hmi/on_exit_application_notification.h" + +#include "application_manager/application_impl.h" +#include "application_manager/state_controller.h" +#include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnExitApplicationNotification::OnExitApplicationNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnExitApplicationNotification::~OnExitApplicationNotification() {} + +void OnExitApplicationNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + using namespace mobile_apis; + using namespace hmi_apis; + + uint32_t app_id = (*message_)[strings::msg_params][strings::app_id].asUInt(); + ApplicationSharedPtr app_impl = application_manager_.application(app_id); + + if (!(app_impl.valid())) { + LOG4CXX_ERROR(logger_, "Application does not exist"); + return; + } + + auto on_app_exit = [app_impl](plugin_manager::RPCPlugin& plugin) { + plugin.OnApplicationEvent(plugin_manager::kApplicationExit, app_impl); + }; + + application_manager_.GetPluginManager().ForEachPlugin(on_app_exit); + + Common_ApplicationExitReason::eType reason; + reason = static_cast<Common_ApplicationExitReason::eType>( + (*message_)[strings::msg_params][strings::reason].asInt()); + + switch (reason) { + case Common_ApplicationExitReason::DRIVER_DISTRACTION_VIOLATION: { + break; + } + case Common_ApplicationExitReason::USER_EXIT: { + break; + } + case Common_ApplicationExitReason::UNAUTHORIZED_TRANSPORT_REGISTRATION: { + rpc_service_.ManageMobileCommand( + MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + app_id, AppInterfaceUnregisteredReason::APP_UNAUTHORIZED), + SOURCE_SDL); + // HMI rejects registration for navi application + application_manager_.UnregisterApplication(app_id, Result::SUCCESS); + return; + } + case Common_ApplicationExitReason::UNSUPPORTED_HMI_RESOURCE: { + rpc_service_.ManageMobileCommand( + MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + app_id, AppInterfaceUnregisteredReason::UNSUPPORTED_HMI_RESOURCE), + SOURCE_SDL); + application_manager_.UnregisterApplication(app_id, Result::SUCCESS); + return; + } + default: { + LOG4CXX_WARN(logger_, "Unhandled reason"); + return; + } + } + + application_manager_.state_controller().SetRegularState( + app_impl, + HMILevel::HMI_NONE, + AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, + false); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_file_removed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_file_removed_notification.cc new file mode 100644 index 0000000000..ec680c667d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_file_removed_notification.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/on_file_removed_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnFileRemovedNotification::OnFileRemovedNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnFileRemovedNotification::~OnFileRemovedNotification() {} + +void OnFileRemovedNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_find_applications.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_find_applications.cc new file mode 100644 index 0000000000..c74dd70c84 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_find_applications.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/on_find_applications.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnFindApplications::OnFindApplications( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnFindApplications::~OnFindApplications() {} + +void OnFindApplications::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // TODO(PV): add UpdateAppsOnDevice to ApplicationManager +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc new file mode 100644 index 0000000000..9ff1851e3f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/on_ignition_cycle_over_notification.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnIgnitionCycleOverNotification::OnIgnitionCycleOverNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnIgnitionCycleOverNotification::~OnIgnitionCycleOverNotification() {} + +void OnIgnitionCycleOverNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + policy_handler_.OnIgnitionCycleOver(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_tbt_client_state_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_tbt_client_state_notification.cc new file mode 100644 index 0000000000..20f20ece08 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_tbt_client_state_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_navi_tbt_client_state_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnNaviTBTClientStateNotification::OnNaviTBTClientStateNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnNaviTBTClientStateNotification::~OnNaviTBTClientStateNotification() {} + +void OnNaviTBTClientStateNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::OnTBTClientStateID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc new file mode 100644 index 0000000000..fa8819ca5b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.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 "sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnNaviWayPointChangeNotification::OnNaviWayPointChangeNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& app_man, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI( + message, app_man, rpc_service, hmi_capabilities, policy_handle) {} + +OnNaviWayPointChangeNotification::~OnNaviWayPointChangeNotification() {} + +void OnNaviWayPointChangeNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::OnWayPointChangeID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc new file mode 100644 index 0000000000..e069bea740 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc @@ -0,0 +1,60 @@ +/* + * 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/hmi/on_policy_update.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +OnPolicyUpdate::OnPolicyUpdate( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnPolicyUpdate::~OnPolicyUpdate() {} + +void OnPolicyUpdate::Run() { + LOG4CXX_AUTO_TRACE(logger_); + policy_handler_.OnPTExchangeNeeded(); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_put_file_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_put_file_notification.cc new file mode 100644 index 0000000000..1524aa9ea2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_put_file_notification.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/on_put_file_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnPutFileNotification::OnPutFileNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnPutFileNotification::~OnPutFileNotification() {} + +void OnPutFileNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ready_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ready_notification.cc new file mode 100644 index 0000000000..76c9115662 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ready_notification.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 "sdl_rpc_plugin/commands/hmi/on_ready_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnReadyNotification::OnReadyNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnReadyNotification::~OnReadyNotification() {} + +void OnReadyNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + application_manager_.OnHMIStartedCooperation(); + event_engine::Event event(hmi_apis::FunctionID::BasicCommunication_OnReady); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc new file mode 100644 index 0000000000..1eaef0b5e1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc @@ -0,0 +1,77 @@ +/* + * 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 <string> +#include "sdl_rpc_plugin/commands/hmi/on_received_policy_update.h" +#include "application_manager/application_manager.h" +#include "utils/file_system.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnReceivedPolicyUpdate::OnReceivedPolicyUpdate( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnReceivedPolicyUpdate::~OnReceivedPolicyUpdate() {} + +void OnReceivedPolicyUpdate::Run() { + LOG4CXX_AUTO_TRACE(logger_); +#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) + const std::string& file_path = + (*message_)[strings::msg_params][hmi_notification::policyfile].asString(); + policy::BinaryMessage file_content; + if (!file_system::ReadBinaryFile(file_path, file_content)) { + LOG4CXX_ERROR(logger_, "Failed to read Update file."); + return; + } + policy_handler_.ReceiveMessageFromSDK(file_path, file_content); +#else + LOG4CXX_WARN(logger_, + "This RPC is part of extended policy flow." + "Please re-build with extended policy mode enabled."); +#endif +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_record_start_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_record_start_notification.cc new file mode 100644 index 0000000000..60699e5b9c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_record_start_notification.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/on_record_start_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnRecordStartdNotification::OnRecordStartdNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnRecordStartdNotification::~OnRecordStartdNotification() {} + +void OnRecordStartdNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_resume_audio_source_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_resume_audio_source_notification.cc new file mode 100644 index 0000000000..9f8a713ffe --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_resume_audio_source_notification.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/on_resume_audio_source_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnResumeAudioSourceNotification::OnResumeAudioSourceNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnResumeAudioSourceNotification::~OnResumeAudioSourceNotification() {} + +void OnResumeAudioSourceNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_close_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_close_notification.cc new file mode 100644 index 0000000000..65879edce6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_close_notification.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/on_sdl_close_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnSDLCloseNotification::OnSDLCloseNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnSDLCloseNotification::~OnSDLCloseNotification() {} + +void OnSDLCloseNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_consent_needed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_consent_needed_notification.cc new file mode 100644 index 0000000000..cf8feb4ca1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_consent_needed_notification.cc @@ -0,0 +1,62 @@ + +/** + * 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/hmi/on_sdl_consent_needed_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnSDLConsentNeededNotification::OnSDLConsentNeededNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnSDLConsentNeededNotification::~OnSDLConsentNeededNotification() {} + +void OnSDLConsentNeededNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_persistence_complete_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_persistence_complete_notification.cc new file mode 100644 index 0000000000..0ac4afd4d2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_persistence_complete_notification.cc @@ -0,0 +1,61 @@ +/* + * 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/hmi/on_sdl_persistence_complete_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnSDLPersistenceCompleteNotification::OnSDLPersistenceCompleteNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnSDLPersistenceCompleteNotification::~OnSDLPersistenceCompleteNotification() {} + +void OnSDLPersistenceCompleteNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_start_device_discovery.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_start_device_discovery.cc new file mode 100644 index 0000000000..2cee7926bd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_start_device_discovery.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/on_start_device_discovery.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnStartDeviceDiscovery::OnStartDeviceDiscovery( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnStartDeviceDiscovery::~OnStartDeviceDiscovery() {} + +void OnStartDeviceDiscovery::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + application_manager_.StartDevicesDiscovery(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_status_update_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_status_update_notification.cc new file mode 100644 index 0000000000..4cb01e7e90 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_status_update_notification.cc @@ -0,0 +1,61 @@ +/* + * 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/hmi/on_status_update_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnStatusUpdateNotification::OnStatusUpdateNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnStatusUpdateNotification::~OnStatusUpdateNotification() {} + +void OnStatusUpdateNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_context_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_context_notification.cc new file mode 100644 index 0000000000..242fb1d8cd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_context_notification.cc @@ -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. + */ + +#include "sdl_rpc_plugin/commands/hmi/on_system_context_notification.h" + +#include "application_manager/application_impl.h" +#include "application_manager/state_controller.h" +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +OnSystemContextNotification::OnSystemContextNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnSystemContextNotification::~OnSystemContextNotification() {} + +void OnSystemContextNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + mobile_api::SystemContext::eType system_context = + static_cast<mobile_api::SystemContext::eType>( + (*message_)[strings::msg_params][hmi_notification::system_context] + .asInt()); + + ApplicationSharedPtr app; + if ((mobile_api::SystemContext::SYSCTXT_VRSESSION == system_context) || + (mobile_api::SystemContext::SYSCTXT_MENU == system_context) || + (mobile_api::SystemContext::SYSCTXT_HMI_OBSCURED == system_context)) { + app = application_manager_.active_application(); + } else if ((mobile_api::SystemContext::SYSCTXT_ALERT == system_context) || + (mobile_api::SystemContext::SYSCTXT_MAIN == system_context)) { + if ((*message_)[strings::msg_params].keyExists(strings::app_id)) { + app = application_manager_.application( + (*message_)[strings::msg_params][strings::app_id].asUInt()); + } + } + + if (app && mobile_api::SystemContext::INVALID_ENUM != system_context) { + application_manager_.state_controller().SetRegularState(app, + system_context); + } else { + LOG4CXX_ERROR(logger_, "Application does not exist"); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc new file mode 100644 index 0000000000..5591d59355 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_system_error_notification.h" +#include "application_manager/application_manager.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnSystemErrorNotification::OnSystemErrorNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnSystemErrorNotification::~OnSystemErrorNotification() {} + +void OnSystemErrorNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + const int code = + (*message_)[strings::msg_params][hmi_notification::error].asInt(); + + policy_handler_.OnSystemError(code); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc new file mode 100644 index 0000000000..11b2471294 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc @@ -0,0 +1,69 @@ +/* + * 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/hmi/on_system_info_changed_notification.h" +#include "application_manager/application_manager.h" +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnSystemInfoChangedNotification::OnSystemInfoChangedNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnSystemInfoChangedNotification::~OnSystemInfoChangedNotification() {} + +void OnSystemInfoChangedNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + uint32_t lang_code = + (*message_)[strings::msg_params][strings::language].asUInt(); + const std::string language = + application_manager::MessageHelper::CommonLanguageToString( + static_cast<hmi_apis::Common_Language::eType>(lang_code)); + + policy_handler_.OnSystemInfoChanged(language); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_request_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_request_notification.cc new file mode 100644 index 0000000000..cfb860a1c7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_request_notification.cc @@ -0,0 +1,124 @@ +/* + * 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 "application_manager/application_impl.h" + +#include "sdl_rpc_plugin/commands/hmi/on_system_request_notification.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "interfaces/MOBILE_API.h" +#include "utils/macro.h" + +using policy::PolicyHandlerInterface; + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnSystemRequestNotification::OnSystemRequestNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnSystemRequestNotification::~OnSystemRequestNotification() {} + +void OnSystemRequestNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + smart_objects::SmartObject& params = (*message_)[strings::params]; + smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; + + params[strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnSystemRequestID); + + // According to HMI API, this should be HMI unique id, but during processing + // messages from HMI this param is replaced by connection key, so below it + // will be treated as connection key + ApplicationSharedPtr app; + if (msg_params.keyExists(strings::app_id)) { + const uint32_t app_id = msg_params[strings::app_id].asUInt(); + LOG4CXX_DEBUG(logger_, "Received OnSystemRequest for appID " << app_id); + LOG4CXX_DEBUG(logger_, "Searching app to send OnSystemRequest by appID."); + app = application_manager_.application(app_id); + } else { + LOG4CXX_DEBUG(logger_, + "Received OnSystemRequest without appID." + " One of registered apps will be used."); + LOG4CXX_DEBUG(logger_, "Searching registered app to send OnSystemRequest."); + const PolicyHandlerInterface& policy_handler = policy_handler_; + const uint32_t selected_app_id = policy_handler.GetAppIdForSending(); + if (0 == selected_app_id) { + LOG4CXX_WARN(logger_, + "Can't select application to forward OnSystemRequest."); + return; + } + app = application_manager_.application(selected_app_id); + } + + if (!app.valid()) { + LOG4CXX_WARN(logger_, + "No valid application found to forward OnSystemRequest."); + return; + } + + std::string device_mac; + application_manager_.connection_handler() + .get_session_observer() + .GetDataOnDeviceID(app->device(), NULL, NULL, &device_mac, NULL); + + if (policy::kDeviceAllowed != + policy_handler_.GetUserConsentForDevice(device_mac)) { + LOG4CXX_WARN(logger_, + "Application " + << app->policy_app_id() + << " is registered from non-consented device." + "Can't forward notification to application."); + return; + } + + LOG4CXX_DEBUG(logger_, + "Sending request with application id " << app->policy_app_id()); + + params[strings::connection_key] = app->app_id(); + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_time_ready_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_time_ready_notification.cc new file mode 100644 index 0000000000..b5fd1a007e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_time_ready_notification.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/on_system_time_ready_notification.h" + +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnSystemTimeReadyNotification::OnSystemTimeReadyNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& app_man, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : NotificationFromHMI( + message, app_man, rpc_service, hmi_capabilities, policy_handler) {} + +OnSystemTimeReadyNotification::~OnSystemTimeReadyNotification() {} + +void OnSystemTimeReadyNotification::Run() { + event_engine::Event event( + hmi_apis::FunctionID::BasicCommunication_OnSystemTimeReady); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_language_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_language_change_notification.cc new file mode 100644 index 0000000000..5b5cfeefb1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_language_change_notification.cc @@ -0,0 +1,103 @@ +/* + * 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/hmi/on_tts_language_change_notification.h" + +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnTTSLanguageChangeNotification::OnTTSLanguageChangeNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnTTSLanguageChangeNotification::~OnTTSLanguageChangeNotification() {} + +void OnTTSLanguageChangeNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + HMICapabilities& hmi_capabilities = hmi_capabilities_; + + hmi_capabilities.set_active_tts_language( + static_cast<hmi_apis::Common_Language::eType>( + (*message_)[strings::msg_params][strings::language].asInt())); + + /* need to clarify, because unchanged VR + cause WRONG_LANGUAGE on Register */ + hmi_capabilities.set_active_vr_language( + static_cast<hmi_apis::Common_Language::eType>( + (*message_)[strings::msg_params][strings::language].asInt())); + + (*message_)[strings::msg_params][strings::hmi_display_language] = + hmi_capabilities.active_ui_language(); + + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID); + + const ApplicationSet& accessor = + application_manager_.applications().GetData(); + ApplicationSetIt it = accessor.begin(); + for (; accessor.end() != it;) { + ApplicationSharedPtr app = *it++; + (*message_)[strings::params][strings::connection_key] = app->app_id(); + SendNotificationToMobile(message_); + + if (static_cast<int>(app->language()) != + (*message_)[strings::msg_params][strings::language].asInt()) { + rpc_service_.ManageMobileCommand( + MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + app->app_id(), + mobile_api::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE), + SOURCE_SDL); + application_manager_.UnregisterApplication( + app->app_id(), mobile_apis::Result::SUCCESS, false); + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_reset_timeout_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_reset_timeout_notification.cc new file mode 100644 index 0000000000..701dbe0538 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_reset_timeout_notification.cc @@ -0,0 +1,69 @@ +/* + * 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/hmi/on_tts_reset_timeout_notification.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace hmi { + +OnTTSResetTimeoutNotification::OnTTSResetTimeoutNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnTTSResetTimeoutNotification::~OnTTSResetTimeoutNotification() {} + +void OnTTSResetTimeoutNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::TTS_OnResetTimeout); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_started_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_started_notification.cc new file mode 100644 index 0000000000..34ba82df1d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_started_notification.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 "sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnTTSStartedNotification::OnTTSStartedNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnTTSStartedNotification::~OnTTSStartedNotification() {} + +void OnTTSStartedNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event(hmi_apis::FunctionID::TTS_Started); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_stopped_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_stopped_notification.cc new file mode 100644 index 0000000000..0935a36848 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_stopped_notification.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/on_tts_stopped_notification.h" + +#include "application_manager/event_engine/event.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnTTSStoppedNotification::OnTTSStoppedNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnTTSStoppedNotification::~OnTTSStoppedNotification() {} + +void OnTTSStoppedNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::TTS_Stopped); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_command_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_command_notification.cc new file mode 100644 index 0000000000..21cf0d9628 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_command_notification.cc @@ -0,0 +1,68 @@ +/* + * 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/hmi/on_ui_command_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnUICommandNotification::OnUICommandNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnUICommandNotification::~OnUICommandNotification() {} + +void OnUICommandNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnCommandID); + + (*message_)[strings::msg_params][strings::trigger_source] = + static_cast<int32_t>(mobile_apis::TriggerSource::TS_MENU); + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_keyboard_input_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_keyboard_input_notification.cc new file mode 100644 index 0000000000..fbdd4fce2b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_keyboard_input_notification.cc @@ -0,0 +1,70 @@ +/* + * 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/hmi/on_ui_keyboard_input_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace hmi { + +OnUIKeyBoardInputNotification::OnUIKeyBoardInputNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnUIKeyBoardInputNotification::~OnUIKeyBoardInputNotification() {} + +void OnUIKeyBoardInputNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + mobile_apis::FunctionID::OnKeyboardInputID; + SendNotificationToMobile(message_); +} + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_language_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_language_change_notification.cc new file mode 100644 index 0000000000..3bf5a5aed4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_language_change_notification.cc @@ -0,0 +1,102 @@ +/* + * 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/hmi/on_ui_language_change_notification.h" + +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnUILanguageChangeNotification::OnUILanguageChangeNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnUILanguageChangeNotification::~OnUILanguageChangeNotification() {} + +void OnUILanguageChangeNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + HMICapabilities& hmi_capabilities = hmi_capabilities_; + + hmi_capabilities.set_active_ui_language( + static_cast<hmi_apis::Common_Language::eType>( + (*message_)[strings::msg_params][strings::language].asInt())); + + (*message_)[strings::msg_params][strings::hmi_display_language] = + (*message_)[strings::msg_params][strings::language]; + + (*message_)[strings::msg_params][strings::language] = + hmi_capabilities.active_vr_language(); + + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID); + + const ApplicationSet& accessor = + application_manager_.applications().GetData(); + + ApplicationSetConstIt it = accessor.begin(); + for (; accessor.end() != it;) { + ApplicationSharedPtr app = *it++; + (*message_)[strings::params][strings::connection_key] = app->app_id(); + SendNotificationToMobile(message_); + + if (app->ui_language() != + (*message_)[strings::msg_params][strings::hmi_display_language] + .asInt()) { + rpc_service_.ManageMobileCommand( + MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + app->app_id(), + mobile_api::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE), + SOURCE_SDL); + application_manager_.UnregisterApplication( + app->app_id(), mobile_apis::Result::SUCCESS, false); + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_reset_timeout_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_reset_timeout_notification.cc new file mode 100644 index 0000000000..953932cdb6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_reset_timeout_notification.cc @@ -0,0 +1,70 @@ +/* + * 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/hmi/on_ui_reset_timeout_notification.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace hmi { + +OnUIResetTimeoutNotification::OnUIResetTimeoutNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnUIResetTimeoutNotification::~OnUIResetTimeoutNotification() {} + +void OnUIResetTimeoutNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_OnResetTimeout); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_touch_event_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_touch_event_notification.cc new file mode 100644 index 0000000000..e5b321e1ff --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_touch_event_notification.cc @@ -0,0 +1,70 @@ +/* + * 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/hmi/on_ui_touch_event_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace hmi { + +OnUITouchEventNotification::OnUITouchEventNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnUITouchEventNotification::~OnUITouchEventNotification() {} + +void OnUITouchEventNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + mobile_apis::FunctionID::OnTouchEventID; + SendNotificationToMobile(message_); +} + +} // namespace hmi + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_update_device_list.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_update_device_list.cc new file mode 100644 index 0000000000..2a5e6ba797 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_update_device_list.cc @@ -0,0 +1,59 @@ +/* + * 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/hmi/on_update_device_list.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnUpdateDeviceList::OnUpdateDeviceList( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnUpdateDeviceList::~OnUpdateDeviceList() {} + +void OnUpdateDeviceList::Run() { + LOG4CXX_AUTO_TRACE(logger_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_acc_pedal_position_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_acc_pedal_position_notification.cc new file mode 100644 index 0000000000..c8ecba458a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_acc_pedal_position_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_acc_pedal_position_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVIAccPedalPositionNotification::OnVIAccPedalPositionNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVIAccPedalPositionNotification::~OnVIAccPedalPositionNotification() {} + +void OnVIAccPedalPositionNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_belt_status_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_belt_status_notification.cc new file mode 100644 index 0000000000..ee909d19dc --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_belt_status_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_belt_status_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVIBeltStatusNotification::OnVIBeltStatusNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVIBeltStatusNotification::~OnVIBeltStatusNotification() {} + +void OnVIBeltStatusNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_body_information_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_body_information_notification.cc new file mode 100644 index 0000000000..f0386646ce --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_body_information_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_body_information_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVIBodyInformationNotification::OnVIBodyInformationNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVIBodyInformationNotification::~OnVIBodyInformationNotification() {} + +void OnVIBodyInformationNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_device_status_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_device_status_notification.cc new file mode 100644 index 0000000000..549c73065a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_device_status_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_device_status_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVIDeviceStatusNotification::OnVIDeviceStatusNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVIDeviceStatusNotification::~OnVIDeviceStatusNotification() {} + +void OnVIDeviceStatusNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_driver_braking_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_driver_braking_notification.cc new file mode 100644 index 0000000000..23f0d37068 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_driver_braking_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_driver_braking_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVIDriverBrakingNotification::OnVIDriverBrakingNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVIDriverBrakingNotification::~OnVIDriverBrakingNotification() {} + +void OnVIDriverBrakingNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_engine_torque_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_engine_torque_notification.cc new file mode 100644 index 0000000000..735a225225 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_engine_torque_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_engine_torque_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVIEngineTorqueNotification::OnVIEngineTorqueNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVIEngineTorqueNotification::~OnVIEngineTorqueNotification() {} + +void OnVIEngineTorqueNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_external_temperature_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_external_temperature_notification.cc new file mode 100644 index 0000000000..0b4bfa893f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_external_temperature_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_external_temperature_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVIExternalTemperatureNotification::OnVIExternalTemperatureNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVIExternalTemperatureNotification::~OnVIExternalTemperatureNotification() {} + +void OnVIExternalTemperatureNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_notification.cc new file mode 100644 index 0000000000..a5e84f1108 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_fuel_level_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVIFuelLevelNotification::OnVIFuelLevelNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVIFuelLevelNotification::~OnVIFuelLevelNotification() {} + +void OnVIFuelLevelNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_state_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_state_notification.cc new file mode 100644 index 0000000000..950b5a36f1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_state_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_fuel_level_state_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVIFuelLevelStateNotification::OnVIFuelLevelStateNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVIFuelLevelStateNotification::~OnVIFuelLevelStateNotification() {} + +void OnVIFuelLevelStateNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_gps_data_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_gps_data_notification.cc new file mode 100644 index 0000000000..0d94194f76 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_gps_data_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_gps_data_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVIGpsDataNotification::OnVIGpsDataNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVIGpsDataNotification::~OnVIGpsDataNotification() {} + +void OnVIGpsDataNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_head_lamp_status_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_head_lamp_status_notification.cc new file mode 100644 index 0000000000..80edb88e38 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_head_lamp_status_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_head_lamp_status_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVIHeadLampStatusNotification::OnVIHeadLampStatusNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVIHeadLampStatusNotification::~OnVIHeadLampStatusNotification() {} + +void OnVIHeadLampStatusNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_instant_fuel_consumption_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_instant_fuel_consumption_notification.cc new file mode 100644 index 0000000000..a2b0b1a8fd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_instant_fuel_consumption_notification.cc @@ -0,0 +1,68 @@ +/* + * 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/hmi/on_vi_instant_fuel_consumption_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVIInstantFuelConsumptionNotification::OnVIInstantFuelConsumptionNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVIInstantFuelConsumptionNotification:: + ~OnVIInstantFuelConsumptionNotification() {} + +void OnVIInstantFuelConsumptionNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_my_key_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_my_key_notification.cc new file mode 100644 index 0000000000..5e3555bbc4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_my_key_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_my_key_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVIMyKeyNotification::OnVIMyKeyNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVIMyKeyNotification::~OnVIMyKeyNotification() {} + +void OnVIMyKeyNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_odometer_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_odometer_notification.cc new file mode 100644 index 0000000000..1dbef77fa3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_odometer_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_odometer_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVIOdometerNotification::OnVIOdometerNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVIOdometerNotification::~OnVIOdometerNotification() {} + +void OnVIOdometerNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_prndl_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_prndl_notification.cc new file mode 100644 index 0000000000..d4ae93b324 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_prndl_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_prndl_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVIPrndlNotification::OnVIPrndlNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVIPrndlNotification::~OnVIPrndlNotification() {} + +void OnVIPrndlNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_rpm_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_rpm_notification.cc new file mode 100644 index 0000000000..77f694c92e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_rpm_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_rpm_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVIRpmNotification::OnVIRpmNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVIRpmNotification::~OnVIRpmNotification() {} + +void OnVIRpmNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_speed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_speed_notification.cc new file mode 100644 index 0000000000..e5860c9eec --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_speed_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_speed_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVISpeedNotification::OnVISpeedNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVISpeedNotification::~OnVISpeedNotification() {} + +void OnVISpeedNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_steering_wheel_angle_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_steering_wheel_angle_notification.cc new file mode 100644 index 0000000000..db591d9da3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_steering_wheel_angle_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_steering_wheel_angle_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVISteeringWheelAngleNotification::OnVISteeringWheelAngleNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVISteeringWheelAngleNotification::~OnVISteeringWheelAngleNotification() {} + +void OnVISteeringWheelAngleNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_tire_pressure_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_tire_pressure_notification.cc new file mode 100644 index 0000000000..b5c7e18803 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_tire_pressure_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_tire_pressure_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVITirePressureNotification::OnVITirePressureNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVITirePressureNotification::~OnVITirePressureNotification() {} + +void OnVITirePressureNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_vin_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_vin_notification.cc new file mode 100644 index 0000000000..323fe5b885 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_vin_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_vin_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVIVinNotification::OnVIVinNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVIVinNotification::~OnVIVinNotification() {} + +void OnVIVinNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_wiper_status_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_wiper_status_notification.cc new file mode 100644 index 0000000000..6a3b863e7c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_wiper_status_notification.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/on_vi_wiper_status_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVIWiperStatusNotification::OnVIWiperStatusNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVIWiperStatusNotification::~OnVIWiperStatusNotification() {} + +void OnVIWiperStatusNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_video_data_streaming_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_video_data_streaming_notification.cc new file mode 100644 index 0000000000..701dee5385 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_video_data_streaming_notification.cc @@ -0,0 +1,62 @@ + +/* + * 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/hmi/on_video_data_streaming_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVideoDataStreamingNotification::OnVideoDataStreamingNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVideoDataStreamingNotification::~OnVideoDataStreamingNotification() {} + +void OnVideoDataStreamingNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc new file mode 100644 index 0000000000..386ef1d1c7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc @@ -0,0 +1,113 @@ +/* + * 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/hmi/on_vr_command_notification.h" + +#include "application_manager/policies/policy_handler.h" +#include "application_manager/message_helper.h" +#include "application_manager/state_controller.h" + +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" +#include "application_manager/event_engine/event.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVRCommandNotification::OnVRCommandNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVRCommandNotification::~OnVRCommandNotification() {} + +void OnVRCommandNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + const uint32_t cmd_id = + (*message_)[strings::msg_params][strings::cmd_id].asUInt(); + uint32_t max_cmd_id = application_manager_.get_settings().max_cmd_id(); + + // Check if this is one of standart VR commands (i.e. "Help") + if (cmd_id > max_cmd_id + 1) { + LOG4CXX_INFO(logger_, "Switched App"); + const uint32_t app_id = cmd_id - max_cmd_id; + ApplicationSharedPtr app = application_manager_.application(app_id); + if (app) { + application_manager_.state_controller().SetRegularState( + app, mobile_apis::HMILevel::HMI_FULL, true); + } else { + LOG4CXX_ERROR(logger_, "Unable to find appication " << app_id); + } + return; + } + + // Check if this is "Help" + if (cmd_id == max_cmd_id + 1) { + return; + } + const uint32_t app_id = + (*message_)[strings::msg_params][strings::app_id].asUInt(); + ApplicationSharedPtr app = application_manager_.application(app_id); + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + /* check if perform interaction is active + * if it is active we should sent to HMI DeleteCommand request + * and PerformInterActionResponse to mobile + */ + if (0 != app->is_perform_interaction_active()) { + event_engine::Event event(hmi_apis::FunctionID::VR_OnCommand); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); + } else { + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnCommandID); + + (*message_)[strings::msg_params][strings::trigger_source] = + static_cast<int32_t>(mobile_apis::TriggerSource::TS_VR); + SendNotificationToMobile(message_); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_language_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_language_change_notification.cc new file mode 100644 index 0000000000..6a58ab9ffa --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_language_change_notification.cc @@ -0,0 +1,101 @@ +/* + * 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/hmi/on_vr_language_change_notification.h" + +#include "application_manager/application_impl.h" +#include "application_manager/state_controller.h" +#include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVRLanguageChangeNotification::OnVRLanguageChangeNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVRLanguageChangeNotification::~OnVRLanguageChangeNotification() {} + +void OnVRLanguageChangeNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + HMICapabilities& hmi_capabilities = hmi_capabilities_; + + hmi_capabilities.set_active_vr_language( + static_cast<hmi_apis::Common_Language::eType>( + (*message_)[strings::msg_params][strings::language].asInt())); + + (*message_)[strings::msg_params][strings::hmi_display_language] = + hmi_capabilities.active_ui_language(); + + (*message_)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID); + + const ApplicationSet& accessor = + application_manager_.applications().GetData(); + + ApplicationSetConstIt it = accessor.begin(); + for (; accessor.end() != it;) { + ApplicationSharedPtr app = *it++; + (*message_)[strings::params][strings::connection_key] = app->app_id(); + SendNotificationToMobile(message_); + if (static_cast<int32_t>(app->language()) != + (*message_)[strings::msg_params][strings::language].asInt()) { + application_manager_.state_controller().SetRegularState( + app, mobile_api::HMILevel::HMI_NONE, false); + + rpc_service_.ManageMobileCommand( + MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + app->app_id(), + mobile_api::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE), + SOURCE_SDL); + application_manager_.UnregisterApplication( + app->app_id(), mobile_apis::Result::SUCCESS, false); + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_started_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_started_notification.cc new file mode 100644 index 0000000000..04eb9a9ed0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_started_notification.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 "sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVRStartedNotification::OnVRStartedNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVRStartedNotification::~OnVRStartedNotification() {} + +void OnVRStartedNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::VR_Started); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_stopped_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_stopped_notification.cc new file mode 100644 index 0000000000..8fea5ddd1c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_stopped_notification.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 "sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnVRStoppedNotification::OnVRStoppedNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnVRStoppedNotification::~OnVRStoppedNotification() {} + +void OnVRStoppedNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::VR_Stopped); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_request.cc new file mode 100644 index 0000000000..5947454517 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/rc_get_capabilities_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +RCGetCapabilitiesRequest::RCGetCapabilitiesRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +RCGetCapabilitiesRequest::~RCGetCapabilitiesRequest() {} + +void RCGetCapabilitiesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_response.cc new file mode 100644 index 0000000000..b14c28426c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_response.cc @@ -0,0 +1,69 @@ +/* + * 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/hmi/rc_get_capabilities_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +RCGetCapabilitiesResponse::RCGetCapabilitiesResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +RCGetCapabilitiesResponse::~RCGetCapabilitiesResponse() {} + +void RCGetCapabilitiesResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + HMICapabilities& hmi_capabilities = hmi_capabilities_; + bool capability_exists = + (*message_)[strings::msg_params].keyExists(strings::rc_capability); + + if (capability_exists) { + hmi_capabilities.set_rc_capability( + (*message_)[strings::msg_params][strings::rc_capability]); + } + hmi_capabilities.set_rc_supported(capability_exists); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_request.cc new file mode 100644 index 0000000000..4b3d303089 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_request.cc @@ -0,0 +1,108 @@ +/* + * 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/hmi/rc_is_ready_request.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +RCIsReadyRequest::RCIsReadyRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) + , EventObserver(application_manager.event_dispatcher()) {} + +RCIsReadyRequest::~RCIsReadyRequest() {} + +void RCIsReadyRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + subscribe_on_event(hmi_apis::FunctionID::RC_IsReady, correlation_id()); + SendRequest(); +} + +void RCIsReadyRequest::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::RC_IsReady: { + LOG4CXX_DEBUG(logger_, "Received RC_IsReady event"); + unsubscribe_from_event(hmi_apis::FunctionID::RC_IsReady); + const bool is_available = app_mngr::commands::ChangeInterfaceState( + application_manager_, message, HmiInterfaces::HMI_INTERFACE_RC); + + HMICapabilities& hmi_capabilities = hmi_capabilities_; + hmi_capabilities.set_is_rc_cooperating(is_available); + if (!is_available) { + hmi_capabilities.set_rc_supported(false); + } + + if (!app_mngr::commands::CheckAvailabilityHMIInterfaces( + application_manager_, HmiInterfaces::HMI_INTERFACE_RC)) { + LOG4CXX_INFO(logger_, + "HmiInterfaces::HMI_INTERFACE_RC isn't available"); + return; + } + SendMessageToHMI(); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +void RCIsReadyRequest::onTimeOut() { + // Note(dtrunov): According to new requirment APPLINK-27956 + SendMessageToHMI(); +} + +void RCIsReadyRequest::SendMessageToHMI() { + utils::SharedPtr<smart_objects::SmartObject> get_capabilities( + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::RC_GetCapabilities, application_manager_)); + rpc_service_.ManageHMICommand(get_capabilities); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_response.cc new file mode 100644 index 0000000000..7534567204 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_response.cc @@ -0,0 +1,61 @@ +/* + * 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/hmi/rc_is_ready_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +RCIsReadyResponse::RCIsReadyResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +RCIsReadyResponse::~RCIsReadyResponse() {} + +void RCIsReadyResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event(hmi_apis::FunctionID::RC_IsReady); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc new file mode 100644 index 0000000000..f89ae1f697 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc @@ -0,0 +1,294 @@ +/* + * 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/hmi/sdl_activate_app_request.h" +#include "application_manager/state_controller.h" +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace { +struct ProtoV4AppsOnDevice : std::unary_function<ApplicationSharedPtr, bool> { + connection_handler::DeviceHandle handle_; + ProtoV4AppsOnDevice(const connection_handler::DeviceHandle handle) + : handle_(handle) {} + bool operator()(const ApplicationSharedPtr app) const { + return app + ? handle_ == app->device() && + Message::is_sufficient_version( + protocol_handler::MajorProtocolVersion:: + PROTOCOL_VERSION_4, + app->protocol_version()) + : false; + } +}; + +struct ForegroundApp + : std::unary_function<SDLActivateAppRequest::V4ProtoApps::value_type, + bool> { + bool operator()( + const SDLActivateAppRequest::V4ProtoApps::value_type ptr) const { + return ptr ? ptr->is_foreground() : false; + } +}; + +struct SendLaunchApp + : std::unary_function<SDLActivateAppRequest::V4ProtoApps::value_type, + void> { + ApplicationConstSharedPtr app_to_launch_; + ApplicationManager& application_manager_; + SendLaunchApp(ApplicationConstSharedPtr app_to_launch, ApplicationManager& am) + : app_to_launch_(app_to_launch), application_manager_(am) {} + void operator()( + const SDLActivateAppRequest::V4ProtoApps::value_type ptr) const { + MessageHelper::SendLaunchApp((*ptr).app_id(), + app_to_launch_->SchemaUrl(), + app_to_launch_->PackageName(), + application_manager_); + return; + } +}; +} + +SDLActivateAppRequest::SDLActivateAppRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +SDLActivateAppRequest::~SDLActivateAppRequest() {} + +uint32_t SDLActivateAppRequest::app_id() const { + using namespace strings; + if (!(*message_).keyExists(msg_params)) { + LOG4CXX_DEBUG(logger_, msg_params << " section is absent in the message."); + return 0; + } + if (!(*message_)[msg_params].keyExists(strings::app_id)) { + LOG4CXX_DEBUG(logger_, + strings::app_id << " section is absent in the message."); + return 0; + } + return (*message_)[msg_params][strings::app_id].asUInt(); +} + +#ifdef EXTERNAL_PROPRIETARY_MODE +void SDLActivateAppRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + using namespace hmi_apis::FunctionID; + + if (application_manager_.state_controller().IsStateActive( + HmiState::STATE_ID_DEACTIVATE_HMI)) { + LOG4CXX_DEBUG(logger_, + "DeactivateHmi state is active. " + "Sends response with result code REJECTED"); + SendErrorResponse(correlation_id(), + static_cast<eType>(function_id()), + hmi_apis::Common_Result::REJECTED, + "HMIDeactivate is active"); + } else { + const uint32_t application_id = app_id(); + policy_handler_.OnActivateApp(application_id, correlation_id()); + } +} + +#else // EXTERNAL_PROPRIETARY_MODE +void SDLActivateAppRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + using namespace hmi_apis::FunctionID; + using namespace hmi_apis::Common_Result; + + const uint32_t application_id = app_id(); + + ApplicationConstSharedPtr app_to_activate = + application_manager_.application(application_id); + + if (!app_to_activate) { + LOG4CXX_WARN( + logger_, + "Can't find application within regular apps: " << application_id); + + // Here is the hack - in fact SDL gets hmi_app_id in appID field and + // replaces it with connection_key only for normally registered apps, but + // for apps_to_be_registered (waiting) it keeps original value (hmi_app_id) + // so method does lookup for hmi_app_id + app_to_activate = + application_manager_.WaitingApplicationByID(application_id); + + if (!app_to_activate) { + LOG4CXX_WARN( + logger_, + "Can't find application within waiting apps: " << application_id); + return; + } + } + + LOG4CXX_DEBUG(logger_, + "Found application to activate. Application id is " + << app_to_activate->app_id()); + + if (application_manager_.state_controller().IsStateActive( + HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) { + LOG4CXX_WARN(logger_, + "DeactivateHmi state is active. " + "Sends response with result code REJECTED"); + SendErrorResponse(correlation_id(), + static_cast<hmi_apis::FunctionID::eType>(function_id()), + hmi_apis::Common_Result::REJECTED, + "HMIDeactivate is active"); + return; + } + + if (app_to_activate->IsRegistered()) { + LOG4CXX_DEBUG(logger_, "Application is registered. Activating."); + policy_handler_.OnActivateApp(application_id, correlation_id()); + return; + } + + connection_handler::DeviceHandle device_handle = app_to_activate->device(); + ApplicationSharedPtr foreground_v4_app = get_foreground_app(device_handle); + V4ProtoApps v4_proto_apps = get_v4_proto_apps(device_handle); + + if (!foreground_v4_app && v4_proto_apps.empty()) { + LOG4CXX_ERROR(logger_, + "Can't find regular foreground app with the same " + "connection id:" + << device_handle); + SendErrorResponse( + correlation_id(), SDL_ActivateApp, NO_APPS_REGISTERED, ""); + return; + } + + LOG4CXX_DEBUG(logger_, + "Application is not registered yet. " + "Sending launch request."); + + if (foreground_v4_app) { + LOG4CXX_DEBUG(logger_, "Sending request to foreground application."); + MessageHelper::SendLaunchApp(foreground_v4_app->app_id(), + app_to_activate->SchemaUrl(), + app_to_activate->PackageName(), + application_manager_); + } else { + LOG4CXX_DEBUG(logger_, + "No preffered (foreground) application is found. " + "Sending request to all v4 applications."); + std::for_each(v4_proto_apps.begin(), + v4_proto_apps.end(), + SendLaunchApp(app_to_activate, application_manager_)); + } + + subscribe_on_event(BasicCommunication_OnAppRegistered); +} + +#endif // EXTERNAL_PROPRIETARY_MODE +void SDLActivateAppRequest::onTimeOut() { + using namespace hmi_apis::FunctionID; + using namespace hmi_apis::Common_Result; + using namespace application_manager; + unsubscribe_from_event(BasicCommunication_OnAppRegistered); + SendErrorResponse( + correlation_id(), SDL_ActivateApp, APPLICATION_NOT_REGISTERED, ""); +} + +void SDLActivateAppRequest::on_event(const event_engine::Event& event) { + using namespace hmi_apis::FunctionID; + if (event.id() != BasicCommunication_OnAppRegistered) { + return; + } + unsubscribe_from_event(BasicCommunication_OnAppRegistered); + + // Have to use HMI app id from event, since HMI app id from original request + // message will be changed after app, initially requested for launch via + // SDL.ActivateApp, will be registered + const uint32_t hmi_application_id = hmi_app_id(event.smart_object()); + + ApplicationSharedPtr app = + application_manager_.application_by_hmi_app(hmi_application_id); + if (!app) { + LOG4CXX_ERROR( + logger_, "Application not found by HMI app id: " << hmi_application_id); + return; + } + policy_handler_.OnActivateApp(app->app_id(), correlation_id()); +} + +uint32_t SDLActivateAppRequest::hmi_app_id( + const smart_objects::SmartObject& so) const { + using namespace strings; + if (!so.keyExists(params)) { + LOG4CXX_DEBUG(logger_, params << " section is absent in the message."); + return 0; + } + if (!so[msg_params].keyExists(application)) { + LOG4CXX_DEBUG(logger_, application << " section is absent in the message."); + return 0; + } + if (so[msg_params][application].keyExists(strings::app_id)) { + LOG4CXX_DEBUG(logger_, + strings::app_id << " section is absent in the message."); + return 0; + } + return so[msg_params][application][strings::app_id].asUInt(); +} + +SDLActivateAppRequest::V4ProtoApps SDLActivateAppRequest::get_v4_proto_apps( + const connection_handler::DeviceHandle handle) const { + const ApplicationSet app_list = application_manager_.applications().GetData(); + V4ProtoApps v4_proto_apps; + std::copy_if(app_list.begin(), + app_list.end(), + std::back_inserter(v4_proto_apps), + ProtoV4AppsOnDevice(handle)); + return v4_proto_apps; +} + +ApplicationSharedPtr SDLActivateAppRequest::get_foreground_app( + const connection_handler::DeviceHandle handle) const { + V4ProtoApps v4_proto_apps = get_v4_proto_apps(handle); + V4ProtoApps::iterator foreground_app = + std::find_if(v4_proto_apps.begin(), v4_proto_apps.end(), ForegroundApp()); + return foreground_app != v4_proto_apps.end() ? *foreground_app + : ApplicationSharedPtr(); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_response.cc new file mode 100644 index 0000000000..3262b12759 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_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 "sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SDLActivateAppResponse::SDLActivateAppResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +SDLActivateAppResponse::~SDLActivateAppResponse() {} + +void SDLActivateAppResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; + (*message_)[strings::params][strings::protocol_version] = protocol_version_; + + rpc_service_.SendMessageToHMI(message_); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc new file mode 100644 index 0000000000..6b983d566a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/sdl_get_list_of_permissions_request.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SDLGetListOfPermissionsRequest::SDLGetListOfPermissionsRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +SDLGetListOfPermissionsRequest::~SDLGetListOfPermissionsRequest() {} + +void SDLGetListOfPermissionsRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + uint32_t connection_key = 0; + if ((*message_)[strings::msg_params].keyExists(strings::app_id)) { + connection_key = (*message_)[strings::msg_params][strings::app_id].asUInt(); + } + policy_handler_.OnGetListOfPermissions( + connection_key, + (*message_)[strings::params][strings::correlation_id].asUInt()); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_response.cc new file mode 100644 index 0000000000..784b4922d4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_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 "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SDLGetListOfPermissionsResponse::SDLGetListOfPermissionsResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +SDLGetListOfPermissionsResponse::~SDLGetListOfPermissionsResponse() {} + +void SDLGetListOfPermissionsResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; + (*message_)[strings::params][strings::protocol_version] = protocol_version_; + + rpc_service_.SendMessageToHMI(message_); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc new file mode 100644 index 0000000000..9a6c0fd520 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/sdl_get_status_update_request.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SDLGetStatusUpdateRequest::SDLGetStatusUpdateRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +SDLGetStatusUpdateRequest::~SDLGetStatusUpdateRequest() {} + +void SDLGetStatusUpdateRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + policy_handler_.OnGetStatusUpdate( + (*message_)[strings::params][strings::correlation_id].asUInt()); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_response.cc new file mode 100644 index 0000000000..8fc85da481 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_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 "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SDLGetStatusUpdateResponse::SDLGetStatusUpdateResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +SDLGetStatusUpdateResponse::~SDLGetStatusUpdateResponse() {} + +void SDLGetStatusUpdateResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; + (*message_)[strings::params][strings::protocol_version] = protocol_version_; + + rpc_service_.SendMessageToHMI(message_); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc new file mode 100644 index 0000000000..ab8ec4e3d9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc @@ -0,0 +1,96 @@ +/* + * 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/hmi/sdl_get_user_friendly_message_request.h" +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SDLGetUserFriendlyMessageRequest::SDLGetUserFriendlyMessageRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +SDLGetUserFriendlyMessageRequest::~SDLGetUserFriendlyMessageRequest() {} + +void SDLGetUserFriendlyMessageRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + const std::string messageCodes = "messageCodes"; + if (!(*message_)[strings::msg_params].keyExists(messageCodes)) { + LOG4CXX_WARN(logger_, + "Mandatory parameter '" + messageCodes + "'' is missing"); + return; + } + smart_objects::SmartArray* msg = + (*message_)[strings::msg_params][messageCodes].asArray(); + + std::vector<std::string> msg_codes; + + smart_objects::SmartArray::const_iterator it = msg->begin(); + smart_objects::SmartArray::const_iterator it_end = msg->end(); + for (; it != it_end; ++it) { + msg_codes.push_back((*it).asString()); + } + + std::string required_language; + if ((*message_)[strings::msg_params].keyExists(strings::language)) { + uint32_t lang_code = + (*message_)[strings::msg_params][strings::language].asUInt(); + required_language = + application_manager::MessageHelper::CommonLanguageToString( + static_cast<hmi_apis::Common_Language::eType>(lang_code)); + } else { + hmi_apis::Common_Language::eType ui_language = + hmi_capabilities_.active_ui_language(); + + required_language = + application_manager::MessageHelper::CommonLanguageToString(ui_language); + } + + policy_handler_.OnGetUserFriendlyMessage( + msg_codes, + required_language, + (*message_)[strings::params][strings::correlation_id].asInt()); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_response.cc new file mode 100644 index 0000000000..c5b3450723 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_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 "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SDLGetUserFriendlyMessageResponse::SDLGetUserFriendlyMessageResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +SDLGetUserFriendlyMessageResponse::~SDLGetUserFriendlyMessageResponse() {} + +void SDLGetUserFriendlyMessageResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; + (*message_)[strings::params][strings::protocol_version] = protocol_version_; + + rpc_service_.SendMessageToHMI(message_); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update.cc new file mode 100644 index 0000000000..aef2e286d7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/sdl_policy_update.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SDLPolicyUpdate::SDLPolicyUpdate( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +SDLPolicyUpdate::~SDLPolicyUpdate() {} + +void SDLPolicyUpdate::Run() { + LOG4CXX_AUTO_TRACE(logger_); +#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) + SendRequest(); +#else + LOG4CXX_WARN(logger_, + "This RPC is part of extended policy flow." + "Please re-build with extended policy mode enabled."); +#endif +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update_response.cc new file mode 100644 index 0000000000..d16fc578ab --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update_response.cc @@ -0,0 +1,59 @@ +/* + * 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/hmi/sdl_policy_update_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { +SDLPolicyUpdateResponse::SDLPolicyUpdateResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +SDLPolicyUpdateResponse::~SDLPolicyUpdateResponse() {} + +void SDLPolicyUpdateResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + // TODO(PV): add some logic here +} +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_request.cc new file mode 100644 index 0000000000..163d749426 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/tts_change_registration_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +TTSChangeRegistrationRequest::TTSChangeRegistrationRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +TTSChangeRegistrationRequest::~TTSChangeRegistrationRequest() {} + +void TTSChangeRegistrationRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_response.cc new file mode 100644 index 0000000000..2c28d615d3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_response.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/tts_change_registration_response.h" +#include "application_manager/event_engine/event.h" + +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +TTSChangeRegistratioResponse::TTSChangeRegistratioResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +TTSChangeRegistratioResponse::~TTSChangeRegistratioResponse() {} + +void TTSChangeRegistratioResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::TTS_ChangeRegistration); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_request.cc new file mode 100644 index 0000000000..49623e01d7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/tts_get_capabilities_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +TTSGetCapabilitiesRequest::TTSGetCapabilitiesRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +TTSGetCapabilitiesRequest::~TTSGetCapabilitiesRequest() {} + +void TTSGetCapabilitiesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_response.cc new file mode 100644 index 0000000000..1cef3daf15 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_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 "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +TTSGetCapabilitiesResponse::TTSGetCapabilitiesResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +TTSGetCapabilitiesResponse::~TTSGetCapabilitiesResponse() {} + +void TTSGetCapabilitiesResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + HMICapabilities& hmi_capabilities = hmi_capabilities_; + if ((*message_)[strings::msg_params].keyExists( + hmi_response::speech_capabilities)) { + hmi_capabilities.set_speech_capabilities( + (*message_)[strings::msg_params][hmi_response::speech_capabilities]); + } + if ((*message_)[strings::msg_params].keyExists( + hmi_response::prerecorded_speech_capabilities)) { + hmi_capabilities.set_prerecorded_speech( + (*message_)[strings::msg_params] + [hmi_response::prerecorded_speech_capabilities]); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_request.cc new file mode 100644 index 0000000000..5533537b33 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/tts_get_language_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +TTSGetLanguageRequest::TTSGetLanguageRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +TTSGetLanguageRequest::~TTSGetLanguageRequest() {} + +void TTSGetLanguageRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_response.cc new file mode 100644 index 0000000000..ac423a2bf3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_response.cc @@ -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. + */ +#include "sdl_rpc_plugin/commands/hmi/tts_get_language_response.h" + +#include "application_manager/event_engine/event.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +TTSGetLanguageResponse::TTSGetLanguageResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +TTSGetLanguageResponse::~TTSGetLanguageResponse() {} + +void TTSGetLanguageResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + using namespace hmi_apis; + + Common_Language::eType language = Common_Language::INVALID_ENUM; + + if ((*message_).keyExists(strings::msg_params) && + (*message_)[strings::msg_params].keyExists(hmi_response::language)) { + language = static_cast<Common_Language::eType>( + (*message_)[strings::msg_params][hmi_response::language].asInt()); + } + + hmi_capabilities_.set_active_tts_language(language); + + LOG4CXX_DEBUG(logger_, + "Raising event for function_id " << function_id() + << " and correlation_id " + << correlation_id()); + event_engine::Event event(FunctionID::TTS_GetLanguage); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_request.cc new file mode 100644 index 0000000000..8b87b9c6ea --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/tts_get_supported_languages_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +TTSGetSupportedLanguagesRequest::TTSGetSupportedLanguagesRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +TTSGetSupportedLanguagesRequest::~TTSGetSupportedLanguagesRequest() {} + +void TTSGetSupportedLanguagesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_response.cc new file mode 100644 index 0000000000..a4e97d9d70 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_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 "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_response.h" + +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +TTSGetSupportedLanguagesResponse::TTSGetSupportedLanguagesResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +TTSGetSupportedLanguagesResponse::~TTSGetSupportedLanguagesResponse() {} + +void TTSGetSupportedLanguagesResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + const hmi_apis::Common_Result::eType code = + static_cast<hmi_apis::Common_Result::eType>( + (*message_)[strings::params][hmi_response::code].asInt()); + + if (hmi_apis::Common_Result::SUCCESS == code) { + HMICapabilities& hmi_capabilities = hmi_capabilities_; + + hmi_capabilities.set_tts_supported_languages( + (*message_)[strings::msg_params][hmi_response::languages]); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_request.cc new file mode 100644 index 0000000000..32d3cba48a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_request.cc @@ -0,0 +1,115 @@ +/* + * 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/hmi/tts_is_ready_request.h" +#include "application_manager/rpc_service.h" +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +TTSIsReadyRequest::TTSIsReadyRequest( + const app_mngr::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) + , EventObserver(application_manager.event_dispatcher()) {} + +TTSIsReadyRequest::~TTSIsReadyRequest() {} + +void TTSIsReadyRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + subscribe_on_event(hmi_apis::FunctionID::TTS_IsReady, correlation_id()); + SendRequest(); +} + +void TTSIsReadyRequest::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::TTS_IsReady: { + LOG4CXX_DEBUG(logger_, "Received TTS_IsReady event"); + unsubscribe_from_event(hmi_apis::FunctionID::TTS_IsReady); + const bool is_available = app_mngr::commands::ChangeInterfaceState( + application_manager_, message, HmiInterfaces::HMI_INTERFACE_TTS); + HMICapabilities& hmi_capabilities = hmi_capabilities_; + hmi_capabilities.set_is_tts_cooperating(is_available); + if (!app_mngr::commands::CheckAvailabilityHMIInterfaces( + application_manager_, HmiInterfaces::HMI_INTERFACE_TTS)) { + LOG4CXX_INFO(logger_, + "HmiInterfaces::HMI_INTERFACE_TTS isn't available"); + return; + } + SendMessageToHMI(); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +void TTSIsReadyRequest::onTimeOut() { + // Note(dtrunov): According to new requirment APPLINK-27956 + SendMessageToHMI(); +} + +void TTSIsReadyRequest::SendMessageToHMI() { + utils::SharedPtr<smart_objects::SmartObject> get_language( + MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::TTS_GetLanguage, + application_manager_)); + HMICapabilities& hmi_capabilities = hmi_capabilities_; + hmi_capabilities.set_handle_response_for(*get_language); + rpc_service_.ManageHMICommand(get_language); + utils::SharedPtr<smart_objects::SmartObject> get_all_languages( + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::TTS_GetSupportedLanguages, + application_manager_)); + rpc_service_.ManageHMICommand(get_all_languages); + utils::SharedPtr<smart_objects::SmartObject> get_capabilities( + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::TTS_GetCapabilities, application_manager_)); + rpc_service_.ManageHMICommand(get_capabilities); +} +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_response.cc new file mode 100644 index 0000000000..c7d634bee2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_response.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/tts_is_ready_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +TTSIsReadyResponse::TTSIsReadyResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +TTSIsReadyResponse::~TTSIsReadyResponse() {} + +void TTSIsReadyResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event(hmi_apis::FunctionID::TTS_IsReady); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_request.cc new file mode 100644 index 0000000000..8c7443d465 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/tts_set_global_properties_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +TTSSetGlobalPropertiesRequest::TTSSetGlobalPropertiesRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +TTSSetGlobalPropertiesRequest::~TTSSetGlobalPropertiesRequest() {} + +void TTSSetGlobalPropertiesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_response.cc new file mode 100644 index 0000000000..dae06d75f9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_response.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/tts_set_global_properties_response.h" +#include "application_manager/event_engine/event.h" + +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +TTSSetGlobalPropertiesResponse::TTSSetGlobalPropertiesResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +TTSSetGlobalPropertiesResponse::~TTSSetGlobalPropertiesResponse() {} + +void TTSSetGlobalPropertiesResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_request.cc new file mode 100644 index 0000000000..96b93b724f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/tts_speak_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +TTSSpeakRequest::TTSSpeakRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +TTSSpeakRequest::~TTSSpeakRequest() {} + +void TTSSpeakRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_response.cc new file mode 100644 index 0000000000..cb2346083b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_response.cc @@ -0,0 +1,67 @@ +/* + * 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/hmi/tts_speak_response.h" +#include "application_manager/event_engine/event.h" + +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +TTSSpeakResponse::TTSSpeakResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +TTSSpeakResponse::~TTSSpeakResponse() {} + +void TTSSpeakResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::TTS_Speak); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_request.cc new file mode 100644 index 0000000000..25a05f085b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/tts_stop_speaking_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +TTSStopSpeakingRequest::TTSStopSpeakingRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +TTSStopSpeakingRequest::~TTSStopSpeakingRequest() {} + +void TTSStopSpeakingRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_response.cc new file mode 100644 index 0000000000..a2620c1340 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_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 "sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h" + +#include "application_manager/event_engine/event.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +TTSStopSpeakingResponse::TTSStopSpeakingResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +TTSStopSpeakingResponse::~TTSStopSpeakingResponse() {} + +void TTSStopSpeakingResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::TTS_StopSpeaking); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_request.cc new file mode 100644 index 0000000000..749b3ad56b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/ui_add_command_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIAddCommandRequest::UIAddCommandRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIAddCommandRequest::~UIAddCommandRequest() {} + +void UIAddCommandRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_response.cc new file mode 100644 index 0000000000..266dffd225 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_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 "sdl_rpc_plugin/commands/hmi/ui_add_command_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIAddCommandResponse::UIAddCommandResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIAddCommandResponse::~UIAddCommandResponse() {} + +void UIAddCommandResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_AddCommand); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_request.cc new file mode 100644 index 0000000000..de338d4670 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/ui_add_submenu_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIAddSubmenuRequest::UIAddSubmenuRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIAddSubmenuRequest::~UIAddSubmenuRequest() {} + +void UIAddSubmenuRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_response.cc new file mode 100644 index 0000000000..85e600c87d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_response.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/ui_add_submenu_response.h" +#include "application_manager/event_engine/event.h" + +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIAddSubmenuResponse::UIAddSubmenuResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIAddSubmenuResponse::~UIAddSubmenuResponse() {} + +void UIAddSubmenuResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_AddSubMenu); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_request.cc new file mode 100644 index 0000000000..ae5f861ba6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/ui_alert_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIAlertRequest::UIAlertRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIAlertRequest::~UIAlertRequest() {} + +void UIAlertRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_response.cc new file mode 100644 index 0000000000..3076eabc4c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_response.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/ui_alert_response.h" +#include "application_manager/event_engine/event.h" + +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIAlertResponse::UIAlertResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIAlertResponse::~UIAlertResponse() {} + +void UIAlertResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_Alert); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_request.cc new file mode 100644 index 0000000000..d109987009 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/ui_change_registration_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIChangeRegistrationRequest::UIChangeRegistrationRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIChangeRegistrationRequest::~UIChangeRegistrationRequest() {} + +void UIChangeRegistrationRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_response.cc new file mode 100644 index 0000000000..6557269e49 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_response.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/ui_change_registration_response.h" +#include "application_manager/event_engine/event.h" + +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIChangeRegistratioResponse::UIChangeRegistratioResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIChangeRegistratioResponse::~UIChangeRegistratioResponse() {} + +void UIChangeRegistratioResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_ChangeRegistration); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_request.cc new file mode 100644 index 0000000000..9e52f5fc18 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/ui_delete_command_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIDeleteCommandRequest::UIDeleteCommandRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIDeleteCommandRequest::~UIDeleteCommandRequest() {} + +void UIDeleteCommandRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_response.cc new file mode 100644 index 0000000000..a8f5b59d39 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_response.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/ui_delete_command_response.h" +#include "application_manager/event_engine/event.h" + +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIDeleteCommandResponse::UIDeleteCommandResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIDeleteCommandResponse::~UIDeleteCommandResponse() {} + +void UIDeleteCommandResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_DeleteCommand); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_request.cc new file mode 100644 index 0000000000..1b84df8bed --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/ui_delete_submenu_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIDeleteSubmenuRequest::UIDeleteSubmenuRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIDeleteSubmenuRequest::~UIDeleteSubmenuRequest() {} + +void UIDeleteSubmenuRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_response.cc new file mode 100644 index 0000000000..ec4025bea1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_response.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/ui_delete_submenu_response.h" +#include "application_manager/event_engine/event.h" + +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIDeleteSubmenuResponse::UIDeleteSubmenuResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIDeleteSubmenuResponse::~UIDeleteSubmenuResponse() {} + +void UIDeleteSubmenuResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_DeleteSubMenu); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_request.cc new file mode 100644 index 0000000000..fe11185c62 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/ui_end_audio_pass_thru_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIEndAudioPassThruRequest::UIEndAudioPassThruRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +UIEndAudioPassThruRequest::~UIEndAudioPassThruRequest() {} + +void UIEndAudioPassThruRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_response.cc new file mode 100644 index 0000000000..3a6d4efbe4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_response.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/ui_end_audio_pass_thru_response.h" +#include "application_manager/event_engine/event.h" + +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIEndAudioPassThruResponse::UIEndAudioPassThruResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIEndAudioPassThruResponse::~UIEndAudioPassThruResponse() {} + +void UIEndAudioPassThruResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_EndAudioPassThru); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_request.cc new file mode 100644 index 0000000000..3bd56a0682 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/ui_get_capabilities_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIGetCapabilitiesRequest::UIGetCapabilitiesRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIGetCapabilitiesRequest::~UIGetCapabilitiesRequest() {} + +void UIGetCapabilitiesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc new file mode 100644 index 0000000000..cd5f3c9a42 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.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 "sdl_rpc_plugin/commands/hmi/ui_get_capabilities_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIGetCapabilitiesResponse::UIGetCapabilitiesResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIGetCapabilitiesResponse::~UIGetCapabilitiesResponse() {} + +void UIGetCapabilitiesResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + HMICapabilities& hmi_capabilities = hmi_capabilities_; + + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + if (msg_params.keyExists(hmi_response::display_capabilities)) { + hmi_capabilities.set_display_capabilities( + msg_params[hmi_response::display_capabilities]); + } + + if (msg_params.keyExists(hmi_response::hmi_zone_capabilities)) { + hmi_capabilities.set_hmi_zone_capabilities( + msg_params[hmi_response::hmi_zone_capabilities]); + } + + if (msg_params.keyExists(hmi_response::soft_button_capabilities)) { + hmi_capabilities.set_soft_button_capabilities( + msg_params[hmi_response::soft_button_capabilities]); + } + + if (msg_params.keyExists(strings::audio_pass_thru_capabilities)) { + hmi_capabilities.set_audio_pass_thru_capabilities( + msg_params[strings::audio_pass_thru_capabilities]); + } + + if (msg_params.keyExists(strings::hmi_capabilities)) { + if (msg_params[strings::hmi_capabilities].keyExists(strings::navigation)) { + hmi_capabilities.set_navigation_supported( + msg_params[strings::hmi_capabilities][strings::navigation].asBool()); + } + if (msg_params[strings::hmi_capabilities].keyExists(strings::phone_call)) { + hmi_capabilities.set_phone_call_supported( + msg_params[strings::hmi_capabilities][strings::phone_call].asBool()); + } + if (msg_params[strings::hmi_capabilities].keyExists( + strings::video_streaming)) { + hmi_capabilities.set_video_streaming_supported( + msg_params[strings::hmi_capabilities][strings::video_streaming] + .asBool()); + } + } + + if (msg_params.keyExists(strings::system_capabilities)) { + if (msg_params[strings::system_capabilities].keyExists( + strings::navigation_capability)) { + hmi_capabilities.set_navigation_capability( + msg_params[strings::system_capabilities] + [strings::navigation_capability]); + } + if (msg_params[strings::system_capabilities].keyExists( + strings::phone_capability)) { + hmi_capabilities.set_phone_capability( + msg_params[strings::system_capabilities][strings::phone_capability]); + } + if (msg_params[strings::system_capabilities].keyExists( + strings::video_streaming_capability)) { + hmi_capabilities.set_video_streaming_capability( + msg_params[strings::system_capabilities] + [strings::video_streaming_capability]); + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_request.cc new file mode 100644 index 0000000000..8acba42493 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/ui_get_language_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIGetLanguageRequest::UIGetLanguageRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIGetLanguageRequest::~UIGetLanguageRequest() {} + +void UIGetLanguageRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_response.cc new file mode 100644 index 0000000000..27e46e52b4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_response.cc @@ -0,0 +1,81 @@ +/* + * 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/hmi/ui_get_language_response.h" + +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIGetLanguageResponse::UIGetLanguageResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIGetLanguageResponse::~UIGetLanguageResponse() {} + +void UIGetLanguageResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + using namespace hmi_apis; + + Common_Language::eType language = Common_Language::INVALID_ENUM; + + if ((*message_).keyExists(strings::msg_params) && + (*message_)[strings::msg_params].keyExists(hmi_response::language)) { + language = static_cast<Common_Language::eType>( + (*message_)[strings::msg_params][hmi_response::language].asInt()); + } + + hmi_capabilities_.set_active_ui_language(language); + + LOG4CXX_DEBUG(logger_, + "Raising event for function_id " << function_id() + << " and correlation_id " + << correlation_id()); + event_engine::Event event(FunctionID::UI_GetLanguage); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_request.cc new file mode 100644 index 0000000000..2f8ef12a25 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/ui_get_supported_languages_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIGetSupportedLanguagesRequest::UIGetSupportedLanguagesRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIGetSupportedLanguagesRequest::~UIGetSupportedLanguagesRequest() {} + +void UIGetSupportedLanguagesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_response.cc new file mode 100644 index 0000000000..d20dd8545f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_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 "sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_response.h" + +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIGetSupportedLanguagesResponse::UIGetSupportedLanguagesResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIGetSupportedLanguagesResponse::~UIGetSupportedLanguagesResponse() {} + +void UIGetSupportedLanguagesResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + const hmi_apis::Common_Result::eType code = + static_cast<hmi_apis::Common_Result::eType>( + (*message_)[strings::params][hmi_response::code].asInt()); + + if (hmi_apis::Common_Result::SUCCESS == code) { + HMICapabilities& hmi_capabilities = hmi_capabilities_; + + hmi_capabilities.set_ui_supported_languages( + (*message_)[strings::msg_params][hmi_response::languages]); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_request.cc new file mode 100644 index 0000000000..3b2c77f16e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_request.cc @@ -0,0 +1,115 @@ +/* + * 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/hmi/ui_is_ready_request.h" +#include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIIsReadyRequest::UIIsReadyRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) + , EventObserver(application_manager.event_dispatcher()) {} + +UIIsReadyRequest::~UIIsReadyRequest() {} + +void UIIsReadyRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + subscribe_on_event(hmi_apis::FunctionID::UI_IsReady, correlation_id()); + SendRequest(); +} + +void UIIsReadyRequest::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::UI_IsReady: { + LOG4CXX_DEBUG(logger_, "Received UI_IsReady event"); + unsubscribe_from_event(hmi_apis::FunctionID::UI_IsReady); + const bool is_available = app_mngr::commands::ChangeInterfaceState( + application_manager_, message, HmiInterfaces::HMI_INTERFACE_UI); + HMICapabilities& hmi_capabilities = hmi_capabilities_; + hmi_capabilities.set_is_ui_cooperating(is_available); + if (!app_mngr::commands::CheckAvailabilityHMIInterfaces( + application_manager_, HmiInterfaces::HMI_INTERFACE_UI)) { + LOG4CXX_INFO(logger_, + "HmiInterfaces::HMI_INTERFACE_UI isn't available"); + return; + } + SendMessageToHMI(); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +void UIIsReadyRequest::onTimeOut() { + // Note(dtrunov): According to new requirment APPLINK-27956 + SendMessageToHMI(); +} + +void UIIsReadyRequest::SendMessageToHMI() { + utils::SharedPtr<smart_objects::SmartObject> get_language( + MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::UI_GetLanguage, + application_manager_)); + HMICapabilities& hmi_capabilities = hmi_capabilities_; + hmi_capabilities.set_handle_response_for(*get_language); + rpc_service_.ManageHMICommand(get_language); + utils::SharedPtr<smart_objects::SmartObject> get_all_languages( + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::UI_GetSupportedLanguages, + application_manager_)); + rpc_service_.ManageHMICommand(get_all_languages); + utils::SharedPtr<smart_objects::SmartObject> get_capabilities( + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::UI_GetCapabilities, application_manager_)); + rpc_service_.ManageHMICommand(get_capabilities); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_response.cc new file mode 100644 index 0000000000..e25e8ee8ab --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_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 "sdl_rpc_plugin/commands/hmi/ui_is_ready_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIIsReadyResponse::UIIsReadyResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIIsReadyResponse::~UIIsReadyResponse() {} + +void UIIsReadyResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_IsReady); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_request.cc new file mode 100644 index 0000000000..cca89e3073 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/ui_perform_audio_pass_thru_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIPerformAudioPassThruRequest::UIPerformAudioPassThruRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIPerformAudioPassThruRequest::~UIPerformAudioPassThruRequest() {} + +void UIPerformAudioPassThruRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_response.cc new file mode 100644 index 0000000000..057448ab33 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_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 "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIPerformAudioPassThruResponse::UIPerformAudioPassThruResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIPerformAudioPassThruResponse::~UIPerformAudioPassThruResponse() {} + +void UIPerformAudioPassThruResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_PerformAudioPassThru); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_request.cc new file mode 100644 index 0000000000..d5696a39e7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/ui_perform_interaction_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIPerformInteractionRequest::UIPerformInteractionRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIPerformInteractionRequest::~UIPerformInteractionRequest() {} + +void UIPerformInteractionRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_response.cc new file mode 100644 index 0000000000..7629faa131 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_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 "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIPerformInteractionResponse::UIPerformInteractionResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIPerformInteractionResponse::~UIPerformInteractionResponse() {} + +void UIPerformInteractionResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event(hmi_apis::FunctionID::UI_PerformInteraction); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_request.cc new file mode 100644 index 0000000000..dbe0ceb529 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/ui_scrollable_message_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIScrollableMessageRequest::UIScrollableMessageRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIScrollableMessageRequest::~UIScrollableMessageRequest() {} + +void UIScrollableMessageRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_response.cc new file mode 100644 index 0000000000..a96b9fa3ee --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_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 "sdl_rpc_plugin/commands/hmi/ui_scrollable_message_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIScrollableMessageResponse::UIScrollableMessageResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIScrollableMessageResponse::~UIScrollableMessageResponse() {} + +void UIScrollableMessageResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_ScrollableMessage); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_request.cc new file mode 100644 index 0000000000..f5f8f7bafd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_request.cc @@ -0,0 +1,61 @@ +/* + * 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/hmi/ui_send_haptic_data_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UISendHapticDataRequest::UISendHapticDataRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UISendHapticDataRequest::~UISendHapticDataRequest() {} + +void UISendHapticDataRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_response.cc new file mode 100644 index 0000000000..4555d81a0a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_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 "sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_response.h" +#include "application_manager/event_engine/event.h" + +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UISendHapticDataResponse::UISendHapticDataResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UISendHapticDataResponse::~UISendHapticDataResponse() {} + +void UISendHapticDataResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event(hmi_apis::FunctionID::UI_SendHapticData); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_request.cc new file mode 100644 index 0000000000..d25bbd1cd9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/ui_set_app_icon_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UISetAppIconRequest::UISetAppIconRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UISetAppIconRequest::~UISetAppIconRequest() {} + +void UISetAppIconRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_response.cc new file mode 100644 index 0000000000..711b5767f2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_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 "sdl_rpc_plugin/commands/hmi/ui_set_app_icon_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UISetAppIconResponse::UISetAppIconResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UISetAppIconResponse::~UISetAppIconResponse() {} + +void UISetAppIconResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_SetAppIcon); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_request.cc new file mode 100644 index 0000000000..73b813d0eb --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_request.cc @@ -0,0 +1,61 @@ +/* + * 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/hmi/ui_set_display_layout_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UiSetDisplayLayoutRequest::UiSetDisplayLayoutRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UiSetDisplayLayoutRequest::~UiSetDisplayLayoutRequest() {} + +void UiSetDisplayLayoutRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_response.cc new file mode 100644 index 0000000000..d5d2e02e33 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_response.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/ui_set_display_layout_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UiSetDisplayLayoutResponse::UiSetDisplayLayoutResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UiSetDisplayLayoutResponse::~UiSetDisplayLayoutResponse() {} + +void UiSetDisplayLayoutResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_SetDisplayLayout); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_request.cc new file mode 100644 index 0000000000..0664404361 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/ui_set_global_properties_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UISetGlobalPropertiesRequest::UISetGlobalPropertiesRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UISetGlobalPropertiesRequest::~UISetGlobalPropertiesRequest() {} + +void UISetGlobalPropertiesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_response.cc new file mode 100644 index 0000000000..2e5fecf2af --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_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 "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UISetGlobalPropertiesResponse::UISetGlobalPropertiesResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UISetGlobalPropertiesResponse::~UISetGlobalPropertiesResponse() {} + +void UISetGlobalPropertiesResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_SetGlobalProperties); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_icon_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_icon_request.cc new file mode 100644 index 0000000000..44049338a8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_icon_request.cc @@ -0,0 +1,62 @@ +/** + * 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/hmi/ui_set_icon_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UISetIconRequest::UISetIconRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UISetIconRequest::~UISetIconRequest() {} + +void UISetIconRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_request.cc new file mode 100644 index 0000000000..4e87b9ccc3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/ui_set_media_clock_timer_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UISetMediaClockTimerRequest::UISetMediaClockTimerRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UISetMediaClockTimerRequest::~UISetMediaClockTimerRequest() {} + +void UISetMediaClockTimerRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_response.cc new file mode 100644 index 0000000000..39e7e1c232 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_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 "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UISetMediaClockTimerResponse::UISetMediaClockTimerResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UISetMediaClockTimerResponse::~UISetMediaClockTimerResponse() {} + +void UISetMediaClockTimerResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_SetMediaClockTimer); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_request.cc new file mode 100644 index 0000000000..5b7568abfe --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/ui_show_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIShowRequest::UIShowRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIShowRequest::~UIShowRequest() {} + +void UIShowRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_response.cc new file mode 100644 index 0000000000..3e3c0b79d8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_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 "sdl_rpc_plugin/commands/hmi/ui_show_response.h" +#include "application_manager/event_engine/event.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIShowResponse::UIShowResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIShowResponse::~UIShowResponse() {} + +void UIShowResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_Show); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_request.cc new file mode 100644 index 0000000000..4df3adbe14 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/ui_slider_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UISliderRequest::UISliderRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UISliderRequest::~UISliderRequest() {} + +void UISliderRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_response.cc new file mode 100644 index 0000000000..2431c65ddf --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_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 "sdl_rpc_plugin/commands/hmi/ui_slider_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UISliderResponse::UISliderResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UISliderResponse::~UISliderResponse() {} + +void UISliderResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_Slider); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_request.cc new file mode 100644 index 0000000000..05b08cb723 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/update_app_list_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UpdateAppListRequest::UpdateAppListRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UpdateAppListRequest::~UpdateAppListRequest() {} + +void UpdateAppListRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_response.cc new file mode 100644 index 0000000000..3dd03993ef --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_response.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/update_app_list_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UpdateAppListResponse::UpdateAppListResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UpdateAppListResponse::~UpdateAppListResponse() {} + +void UpdateAppListResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // TODO(PV): add check +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc new file mode 100644 index 0000000000..7736f2b1e6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc @@ -0,0 +1,103 @@ +/* + * 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/hmi/update_device_list_request.h" + +#include "interfaces/HMI_API.h" + +#include <unistd.h> + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UpdateDeviceListRequest::UpdateDeviceListRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) + , EventObserver(application_manager_.event_dispatcher()) {} + +UpdateDeviceListRequest::~UpdateDeviceListRequest() {} + +void UpdateDeviceListRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(wait_hmi_lock); + // Fix problem with SDL and HMI HTML. This problem is not actual for HMI PASA. + // Flag conditional compilation for specific customer is used in order to + // exclude + // hit code to RTC + if (true == application_manager_.get_settings().launch_hmi()) { + if (!application_manager_.IsHMICooperating()) { + LOG4CXX_INFO(logger_, "Wait for HMI Cooperation"); + subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_OnReady); + termination_condition_.Wait(auto_lock); + LOG4CXX_DEBUG(logger_, "HMI Cooperation OK"); + } + } + + SendRequest(); +} + +void UpdateDeviceListRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(wait_hmi_lock); + switch (event.id()) { + case hmi_apis::FunctionID::BasicCommunication_OnReady: { + LOG4CXX_INFO(logger_, "received OnReady"); + unsubscribe_from_event(hmi_apis::FunctionID::BasicCommunication_OnReady); + termination_condition_.Broadcast(); + break; + }; + default: { + LOG4CXX_ERROR(logger_, "Unknown event "); + break; + }; + } +} + +bool UpdateDeviceListRequest::CleanUp() { + sync_primitives::AutoLock auto_lock(wait_hmi_lock); + termination_condition_.Broadcast(); + return true; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_response.cc new file mode 100644 index 0000000000..25dc9be5bd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_response.cc @@ -0,0 +1,61 @@ +/* + * 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/hmi/update_device_list_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UpdateDeviceListResponse::UpdateDeviceListResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UpdateDeviceListResponse::~UpdateDeviceListResponse() {} + +void UpdateDeviceListResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // TODO(PV): add check for correctness. +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc new file mode 100644 index 0000000000..cafacea28f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.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 "sdl_rpc_plugin/commands/hmi/update_sdl_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UpdateSDLRequest::UpdateSDLRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UpdateSDLRequest::~UpdateSDLRequest() {} + +void UpdateSDLRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + policy_handler_.PTExchangeAtUserRequest( + (*message_)[strings::params][strings::correlation_id].asInt()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_response.cc new file mode 100644 index 0000000000..a35571ec26 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_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 "sdl_rpc_plugin/commands/hmi/update_sdl_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UpdateSDLResponse::UpdateSDLResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UpdateSDLResponse::~UpdateSDLResponse() {} + +void UpdateSDLResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; + (*message_)[strings::params][strings::protocol_version] = protocol_version_; + + rpc_service_.SendMessageToHMI(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_request.cc new file mode 100644 index 0000000000..72ce387f77 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/vr_add_command_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +VRAddCommandRequest::VRAddCommandRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +VRAddCommandRequest::~VRAddCommandRequest() {} + +void VRAddCommandRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_response.cc new file mode 100644 index 0000000000..19d43616ff --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_response.cc @@ -0,0 +1,66 @@ +/* + * 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/hmi/vr_add_command_response.h" +#include "application_manager/event_engine/event.h" + +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +VRAddCommandResponse::VRAddCommandResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +VRAddCommandResponse::~VRAddCommandResponse() {} + +void VRAddCommandResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::VR_AddCommand); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_request.cc new file mode 100644 index 0000000000..9ba5fa3571 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/vr_change_registration_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +VRChangeRegistrationRequest::VRChangeRegistrationRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +VRChangeRegistrationRequest::~VRChangeRegistrationRequest() {} + +void VRChangeRegistrationRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_response.cc new file mode 100644 index 0000000000..42c5b6d65b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_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 "sdl_rpc_plugin/commands/hmi/vr_change_registration_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +VRChangeRegistrationResponse::VRChangeRegistrationResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +VRChangeRegistrationResponse::~VRChangeRegistrationResponse() {} + +void VRChangeRegistrationResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::VR_ChangeRegistration); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_request.cc new file mode 100644 index 0000000000..efc09dc157 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/vr_delete_command_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +VRDeleteCommandRequest::VRDeleteCommandRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +VRDeleteCommandRequest::~VRDeleteCommandRequest() {} + +void VRDeleteCommandRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_response.cc new file mode 100644 index 0000000000..f8f7535e68 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_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 "sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +VRDeleteCommandResponse::VRDeleteCommandResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +VRDeleteCommandResponse::~VRDeleteCommandResponse() {} + +void VRDeleteCommandResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::VR_DeleteCommand); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_request.cc new file mode 100644 index 0000000000..7e9c846857 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/vr_get_capabilities_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +VRGetCapabilitiesRequest::VRGetCapabilitiesRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +VRGetCapabilitiesRequest::~VRGetCapabilitiesRequest() {} + +void VRGetCapabilitiesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_response.cc new file mode 100644 index 0000000000..47ffb3a675 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_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 "sdl_rpc_plugin/commands/hmi/vr_get_capabilities_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +VRGetCapabilitiesResponse::VRGetCapabilitiesResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +VRGetCapabilitiesResponse::~VRGetCapabilitiesResponse() {} + +void VRGetCapabilitiesResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + HMICapabilities& hmi_capabilities = hmi_capabilities_; + + hmi_capabilities.set_vr_capabilities( + (*message_)[strings::msg_params][strings::vr_capabilities]); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_request.cc new file mode 100644 index 0000000000..d57faa08fd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/vr_get_language_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +VRGetLanguageRequest::VRGetLanguageRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +VRGetLanguageRequest::~VRGetLanguageRequest() {} + +void VRGetLanguageRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_response.cc new file mode 100644 index 0000000000..469452d108 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_response.cc @@ -0,0 +1,81 @@ +/* + * 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/hmi/vr_get_language_response.h" + +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +VRGetLanguageResponse::VRGetLanguageResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +VRGetLanguageResponse::~VRGetLanguageResponse() {} + +void VRGetLanguageResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + using namespace hmi_apis; + + Common_Language::eType language = Common_Language::INVALID_ENUM; + + if ((*message_).keyExists(strings::msg_params) && + (*message_)[strings::msg_params].keyExists(hmi_response::language)) { + language = static_cast<Common_Language::eType>( + (*message_)[strings::msg_params][hmi_response::language].asInt()); + } + + hmi_capabilities_.set_active_vr_language(language); + + LOG4CXX_DEBUG(logger_, + "Raising event for function_id " << function_id() + << " and correlation_id " + << correlation_id()); + event_engine::Event event(FunctionID::VR_GetLanguage); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_request.cc new file mode 100644 index 0000000000..bb27168a77 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/vr_get_supported_languages_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +VRGetSupportedLanguagesRequest::VRGetSupportedLanguagesRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +VRGetSupportedLanguagesRequest::~VRGetSupportedLanguagesRequest() {} + +void VRGetSupportedLanguagesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_response.cc new file mode 100644 index 0000000000..722040388d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_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 "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h" + +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +VRGetSupportedLanguagesResponse::VRGetSupportedLanguagesResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +VRGetSupportedLanguagesResponse::~VRGetSupportedLanguagesResponse() {} + +void VRGetSupportedLanguagesResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + const hmi_apis::Common_Result::eType code = + static_cast<hmi_apis::Common_Result::eType>( + (*message_)[strings::params][hmi_response::code].asInt()); + + if (hmi_apis::Common_Result::SUCCESS == code) { + HMICapabilities& hmi_capabilities = hmi_capabilities_; + hmi_capabilities.set_vr_supported_languages( + (*message_)[strings::msg_params][hmi_response::languages]); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_request.cc new file mode 100644 index 0000000000..dcf7f35e90 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_request.cc @@ -0,0 +1,115 @@ +/* + * 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/hmi/vr_is_ready_request.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +VRIsReadyRequest::VRIsReadyRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) + , EventObserver(application_manager.event_dispatcher()) {} + +VRIsReadyRequest::~VRIsReadyRequest() {} + +void VRIsReadyRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + subscribe_on_event(hmi_apis::FunctionID::VR_IsReady, correlation_id()); + SendRequest(); +} + +void VRIsReadyRequest::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::VR_IsReady: { + LOG4CXX_DEBUG(logger_, "Received VR_IsReady event"); + unsubscribe_from_event(hmi_apis::FunctionID::VR_IsReady); + const bool is_available = app_mngr::commands::ChangeInterfaceState( + application_manager_, message, HmiInterfaces::HMI_INTERFACE_VR); + + HMICapabilities& hmi_capabilities = hmi_capabilities_; + hmi_capabilities.set_is_vr_cooperating(is_available); + if (!app_mngr::commands::CheckAvailabilityHMIInterfaces( + application_manager_, HmiInterfaces::HMI_INTERFACE_VR)) { + LOG4CXX_INFO(logger_, + "HmiInterfaces::HMI_INTERFACE_VR isn't available"); + return; + } + SendMessageToHMI(); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +void VRIsReadyRequest::onTimeOut() { + // Note(dtrunov): According to new requirment APPLINK-27956 + SendMessageToHMI(); +} + +void VRIsReadyRequest::SendMessageToHMI() { + utils::SharedPtr<smart_objects::SmartObject> get_language( + MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetLanguage, + application_manager_)); + HMICapabilities& hmi_capabilities = hmi_capabilities_; + hmi_capabilities.set_handle_response_for(*get_language); + rpc_service_.ManageHMICommand(get_language); + utils::SharedPtr<smart_objects::SmartObject> get_all_languages( + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::VR_GetSupportedLanguages, + application_manager_)); + rpc_service_.ManageHMICommand(get_all_languages); + utils::SharedPtr<smart_objects::SmartObject> get_capabilities( + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::VR_GetCapabilities, application_manager_)); + rpc_service_.ManageHMICommand(get_capabilities); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_response.cc new file mode 100644 index 0000000000..48d9c3e075 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_response.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/vr_is_ready_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +VRIsReadyResponse::VRIsReadyResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +VRIsReadyResponse::~VRIsReadyResponse() {} + +void VRIsReadyResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event(hmi_apis::FunctionID::VR_IsReady); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_request.cc new file mode 100644 index 0000000000..26e308a0bc --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_request.cc @@ -0,0 +1,62 @@ +/* + * 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/hmi/vr_perform_interaction_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +VRPerformInteractionRequest::VRPerformInteractionRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +VRPerformInteractionRequest::~VRPerformInteractionRequest() {} + +void VRPerformInteractionRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_response.cc new file mode 100644 index 0000000000..dec371e889 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_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 "sdl_rpc_plugin/commands/hmi/vr_perform_interaction_response.h" +#include "application_manager/event_engine/event.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +VRPerformInteractionResponse::VRPerformInteractionResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +VRPerformInteractionResponse::~VRPerformInteractionResponse() {} + +void VRPerformInteractionResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event(hmi_apis::FunctionID::VR_PerformInteraction); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc new file mode 100644 index 0000000000..d1cb9763d9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc @@ -0,0 +1,625 @@ +/* + + 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 <string> +#include "sdl_rpc_plugin/commands/mobile/add_command_request.h" + +#include "application_manager/application.h" +#include "application_manager/message_helper.h" +#include "utils/file_system.h" +#include "utils/helpers.h" +#include "utils/custom_string.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace custom_str = utils::custom_string; + +AddCommandRequest::AddCommandRequest( + 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) + , send_ui_(false) + , send_vr_(false) + , is_ui_received_(false) + , is_vr_received_(false) + , ui_result_(hmi_apis::Common_Result::INVALID_ENUM) + , vr_result_(hmi_apis::Common_Result::INVALID_ENUM) {} + +AddCommandRequest::~AddCommandRequest() {} + +void AddCommandRequest::onTimeOut() { + LOG4CXX_AUTO_TRACE(logger_); + RemoveCommand(); + CommandRequestImpl::onTimeOut(); +} + +bool AddCommandRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +void AddCommandRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application( + (*message_)[strings::params][strings::connection_key].asUInt()); + + if (!app) { + LOG4CXX_ERROR(logger_, "No application associated with session key"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if ((*message_)[strings::msg_params].keyExists(strings::cmd_icon)) { + mobile_apis::Result::eType verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::cmd_icon], + app, + application_manager_); + + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR( + logger_, "MessageHelper::VerifyImage return " << verification_result); + SendResponse(false, verification_result); + return; + } + } + + if (!((*message_)[strings::msg_params].keyExists(strings::cmd_id))) { + LOG4CXX_ERROR(logger_, "INVALID_DATA"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if (app->FindCommand( + (*message_)[strings::msg_params][strings::cmd_id].asUInt())) { + LOG4CXX_ERROR(logger_, "INVALID_ID"); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + + bool data_exist = false; + + if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) { + if (!CheckCommandName(app)) { + SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); + return; + } + if (((*message_)[strings::msg_params][strings::menu_params].keyExists( + hmi_request::parent_id)) && + (0 != + (*message_)[strings::msg_params][strings::menu_params] + [hmi_request::parent_id].asUInt())) { + if (!CheckCommandParentId(app)) { + SendResponse( + false, mobile_apis::Result::INVALID_ID, "Parent ID doesn't exist"); + return; + } + } + data_exist = true; + } + + if (((*message_)[strings::msg_params].keyExists(strings::vr_commands)) && + ((*message_)[strings::msg_params][strings::vr_commands].length() > 0)) { + if (!CheckCommandVRSynonym(app)) { + SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); + return; + } + + data_exist = true; + } + + if (!data_exist) { + LOG4CXX_ERROR(logger_, "INVALID_DATA"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, "Incoming add command has contains \t\n \\t \\n"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + app->AddCommand((*message_)[strings::msg_params][strings::cmd_id].asUInt(), + (*message_)[strings::msg_params]); + + smart_objects::SmartObject ui_msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) { + ui_msg_params[strings::cmd_id] = + (*message_)[strings::msg_params][strings::cmd_id]; + ui_msg_params[strings::menu_params] = + (*message_)[strings::msg_params][strings::menu_params]; + + ui_msg_params[strings::app_id] = app->app_id(); + + if (((*message_)[strings::msg_params].keyExists(strings::cmd_icon)) && + ((*message_)[strings::msg_params][strings::cmd_icon].keyExists( + strings::value)) && + (0 < (*message_)[strings::msg_params][strings::cmd_icon][strings::value] + .length())) { + ui_msg_params[strings::cmd_icon] = + (*message_)[strings::msg_params][strings::cmd_icon]; + } + + send_ui_ = true; + } + + smart_objects::SmartObject vr_msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + if ((*message_)[strings::msg_params].keyExists(strings::vr_commands)) { + vr_msg_params[strings::cmd_id] = + (*message_)[strings::msg_params][strings::cmd_id]; + vr_msg_params[strings::vr_commands] = + (*message_)[strings::msg_params][strings::vr_commands]; + vr_msg_params[strings::app_id] = app->app_id(); + + vr_msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; + vr_msg_params[strings::grammar_id] = app->get_grammar_id(); + + send_vr_ = true; + } + + if (send_ui_) { + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_AddCommand, &ui_msg_params, true); + } + + if (send_vr_) { + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); + SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &vr_msg_params, true); + } +} + +bool AddCommandRequest::CheckCommandName(ApplicationConstSharedPtr app) { + if (!app) { + return false; + } + + const DataAccessor<CommandsMap> accessor = app->commands_map(); + const CommandsMap& commands = accessor.GetData(); + CommandsMap::const_iterator i = commands.begin(); + uint32_t saved_parent_id = 0; + uint32_t parent_id = 0; + if ((*message_)[strings::msg_params][strings::menu_params].keyExists( + hmi_request::parent_id)) { + parent_id = (*message_)[strings::msg_params][strings::menu_params] + [hmi_request::parent_id].asUInt(); + } + + for (; commands.end() != i; ++i) { + if (!(*i->second).keyExists(strings::menu_params)) { + continue; + } + + saved_parent_id = 0; + if ((*i->second)[strings::menu_params].keyExists(hmi_request::parent_id)) { + saved_parent_id = + (*i->second)[strings::menu_params][hmi_request::parent_id].asUInt(); + } + if (((*i->second)[strings::menu_params][strings::menu_name].asString() == + (*message_)[strings::msg_params][strings::menu_params] + [strings::menu_name].asString()) && + (saved_parent_id == parent_id)) { + LOG4CXX_INFO(logger_, + "AddCommandRequest::CheckCommandName received" + " command name already exist in same level menu"); + return false; + } + } + return true; +} + +bool AddCommandRequest::CheckCommandVRSynonym(ApplicationConstSharedPtr app) { + if (!app) { + return false; + } + + const DataAccessor<CommandsMap> accessor = app->commands_map(); + const CommandsMap& commands = accessor.GetData(); + CommandsMap::const_iterator it = commands.begin(); + + for (; commands.end() != it; ++it) { + if (!(*it->second).keyExists(strings::vr_commands)) { + continue; + } + + for (size_t i = 0; i < (*it->second)[strings::vr_commands].length(); ++i) { + for (size_t j = 0; + j < (*message_)[strings::msg_params][strings::vr_commands].length(); + ++j) { + const custom_str::CustomString& vr_cmd_i = + (*it->second)[strings::vr_commands][i].asCustomString(); + const custom_str::CustomString& vr_cmd_j = + (*message_)[strings::msg_params][strings::vr_commands][j] + .asCustomString(); + + if (vr_cmd_i.CompareIgnoreCase(vr_cmd_j)) { + LOG4CXX_INFO(logger_, + "AddCommandRequest::CheckCommandVRSynonym" + " received command vr synonym already exist"); + return false; + } + } + } + } + return true; +} + +bool AddCommandRequest::CheckCommandParentId(ApplicationConstSharedPtr app) { + if (!app) { + return false; + } + + const int32_t parent_id = + (*message_)[strings::msg_params][strings::menu_params] + [hmi_request::parent_id].asInt(); + smart_objects::SmartObject* parent = app->FindSubMenu(parent_id); + + if (!parent) { + LOG4CXX_INFO(logger_, + "AddCommandRequest::CheckCommandParentId received" + " submenu doesn't exist"); + return false; + } + return true; +} + +// TODO(AKUTSAN) APPLINK-26973: Refactor AddCommandRequest +void AddCommandRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + + const smart_objects::SmartObject& message = event.smart_object(); + + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + smart_objects::SmartObject msg_param(smart_objects::SmartType_Map); + msg_param[strings::cmd_id] = + (*message_)[strings::msg_params][strings::cmd_id]; + msg_param[strings::app_id] = application->app_id(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_AddCommand: { + LOG4CXX_INFO(logger_, "Received UI_AddCommand event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + is_ui_received_ = true; + ui_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + GetInfo(message, ui_info_); + if (hmi_apis::Common_Result::SUCCESS != ui_result_) { + (*message_)[strings::msg_params].erase(strings::menu_params); + } + break; + } + case hmi_apis::FunctionID::VR_AddCommand: { + LOG4CXX_INFO(logger_, "Received VR_AddCommand event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); + is_vr_received_ = true; + vr_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + GetInfo(message, vr_info_); + if (hmi_apis::Common_Result::SUCCESS != vr_result_) { + (*message_)[strings::msg_params].erase(strings::vr_commands); + } + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } + + if (IsPendingResponseExist()) { + return; + } + + smart_objects::SmartObject msg_params(smart_objects::SmartType_Map); + msg_params[strings::cmd_id] = + (*message_)[strings::msg_params][strings::cmd_id]; + msg_params[strings::app_id] = application->app_id(); + + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; + + const bool is_vr_invalid_unsupported = + Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + vr_result_, + hmi_apis::Common_Result::INVALID_ENUM, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); + + const bool is_ui_invalid_unsupported = + Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + ui_result_, + hmi_apis::Common_Result::INVALID_ENUM, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); + const bool is_vr_unsupported = + vr_result_ == hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + const bool is_ui_unsupported = + ui_result_ == hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + + const bool is_no_ui_error = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + ui_result_, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS, + hmi_apis::Common_Result::WRONG_LANGUAGE, + hmi_apis::Common_Result::RETRY, + hmi_apis::Common_Result::SAVED, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); + + const bool is_no_vr_error = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + vr_result_, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS, + hmi_apis::Common_Result::WRONG_LANGUAGE, + hmi_apis::Common_Result::RETRY, + hmi_apis::Common_Result::SAVED, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); + + bool result = (is_no_ui_error && is_no_vr_error) || + (is_no_ui_error && is_vr_invalid_unsupported) || + (is_no_vr_error && is_ui_invalid_unsupported); + + LOG4CXX_DEBUG(logger_, + "calculated result " << ui_result_ << " " << is_no_ui_error + << " " << is_no_vr_error); + const bool is_vr_or_ui_warning = + Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + hmi_apis::Common_Result::WARNINGS, ui_result_, vr_result_); + + const bool is_vr_or_ui_unsupported = + Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + ui_result_, + vr_result_); + + const bool is_vr_and_ui_unsupported = + Compare<hmi_apis::Common_Result::eType, EQ, ALL>( + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + ui_result_, + vr_result_); + + if (!result && hmi_apis::Common_Result::REJECTED == ui_result_) { + result_code = MessageHelper::HMIToMobileResult(ui_result_); + } else if (result && is_vr_or_ui_unsupported) { + result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE; + } else if (is_vr_or_ui_warning) { + result_code = mobile_apis::Result::WARNINGS; + } else { + result_code = + MessageHelper::HMIToMobileResult(std::max(ui_result_, vr_result_)); + if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_) { + result_code = MessageHelper::HMIToMobileResult(vr_result_); + } + if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == vr_result_) { + result_code = MessageHelper::HMIToMobileResult(ui_result_); + } + LOG4CXX_DEBUG(logger_, "HMIToMobileResult " << result_code); + } + + if (BothSend() && hmi_apis::Common_Result::SUCCESS == vr_result_) { + const bool is_ui_not_ok = Compare<hmi_apis::Common_Result::eType, NEQ, ALL>( + ui_result_, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); + + if (is_ui_not_ok) { + result_code = ui_result_ == hmi_apis::Common_Result::REJECTED + ? mobile_apis::Result::REJECTED + : mobile_apis::Result::GENERIC_ERROR; + + msg_params[strings::grammar_id] = application->get_grammar_id(); + msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; + + SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params); + application->RemoveCommand( + (*message_)[strings::msg_params][strings::cmd_id].asUInt()); + result = false; + LOG4CXX_DEBUG(logger_, "Result " << result); + } + } + + if (BothSend() && hmi_apis::Common_Result::SUCCESS == ui_result_ && + !is_no_vr_error && + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE != vr_result_) { + result_code = vr_result_ == hmi_apis::Common_Result::REJECTED + ? mobile_apis::Result::REJECTED + : mobile_apis::Result::GENERIC_ERROR; + + SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params); + + application->RemoveCommand( + (*message_)[strings::msg_params][strings::cmd_id].asUInt()); + result = false; + LOG4CXX_DEBUG(logger_, "Result " << result); + } + + HmiInterfaces::InterfaceState ui_interface_state = + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_UI); + HmiInterfaces::InterfaceState vr_interface_state = + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_VR); + + if (!BothSend() && + ((is_vr_unsupported && + HmiInterfaces::STATE_NOT_AVAILABLE == vr_interface_state) || + (is_ui_unsupported && + HmiInterfaces::STATE_NOT_AVAILABLE == ui_interface_state))) { + LOG4CXX_DEBUG(logger_, "!BothSend() && is_vr_or_ui_unsupported"); + result = false; + } + + if (is_vr_and_ui_unsupported) { + LOG4CXX_DEBUG(logger_, "UI and VR interface both unsupported"); + result = false; + } + + if (!result) { + RemoveCommand(); + } + + const std::string info = GenerateMobileResponseInfo(); + SendResponse(result, + result_code, + info.empty() ? NULL : info.c_str(), + &(message[strings::msg_params])); +} + +bool AddCommandRequest::IsPendingResponseExist() { + return send_ui_ != is_ui_received_ || send_vr_ != is_vr_received_; +} + +bool AddCommandRequest::IsWhiteSpaceExist() { + LOG4CXX_AUTO_TRACE(logger_); + const char* str = NULL; + + if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) { + str = (*message_)[strings::msg_params][strings::menu_params] + [strings::menu_name].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid menu name syntax check failed."); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::vr_commands)) { + const size_t len = + (*message_)[strings::msg_params][strings::vr_commands].length(); + + for (size_t i = 0; i < len; ++i) { + str = (*message_)[strings::msg_params][strings::vr_commands][i] + .asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid vr_commands syntax check failed"); + return true; + } + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::cmd_icon)) { + str = (*message_)[strings::msg_params][strings::cmd_icon][strings::value] + .asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid cmd_icon value syntax check failed"); + return true; + } + } + return false; +} + +bool AddCommandRequest::BothSend() const { + return send_vr_ && send_ui_; +} + +const std::string AddCommandRequest::GenerateMobileResponseInfo() { + // In case if vr_result_ is UNSUPPORTED_RESOURCE vr_info should be on the + // first place + // In case if ui_result_ is UNSUPPORTED_RESOURCE ui_info should be on the + // first place + // Other way order is doesn't matter + + HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces(); + HmiInterfaces::InterfaceState ui_interface_state = + hmi_interfaces.GetInterfaceState(HmiInterfaces::HMI_INTERFACE_UI); + + HmiInterfaces::InterfaceState vr_interface_state = + hmi_interfaces.GetInterfaceState(HmiInterfaces::HMI_INTERFACE_VR); + + if ((ui_interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) && + (vr_interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) && + !vr_info_.empty()) { + return vr_info_; + } + + if ((vr_interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) && + (ui_interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) && + !ui_info_.empty()) { + return ui_info_; + } + + return app_mngr::commands::MergeInfos(ui_info_, vr_info_); +} + +void AddCommandRequest::RemoveCommand() { + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = application_manager_.application(connection_key()); + if (!app.valid()) { + LOG4CXX_ERROR(logger_, "No application associated with session key"); + return; + } + + smart_objects::SmartObject msg_params(smart_objects::SmartType_Map); + msg_params[strings::cmd_id] = + (*message_)[strings::msg_params][strings::cmd_id]; + msg_params[strings::app_id] = app->app_id(); + + app->RemoveCommand( + (*message_)[strings::msg_params][strings::cmd_id].asUInt()); + + if (BothSend() && !(is_vr_received_ || is_ui_received_)) { + // in case we have send bth UI and VR and no one respond + // we have nothing to remove from HMI so no DeleteCommand expected + return; + } + + if (BothSend() && !is_vr_received_) { + SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params); + } + + if (BothSend() && !is_ui_received_) { + msg_params[strings::grammar_id] = app->get_grammar_id(); + msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; + SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_response.cc new file mode 100644 index 0000000000..ccb84cecbb --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_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 "sdl_rpc_plugin/commands/mobile/add_command_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +AddCommandResponse::AddCommandResponse( + 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) {} + +AddCommandResponse::~AddCommandResponse() {} + +void AddCommandResponse::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/add_sub_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc new file mode 100644 index 0000000000..3dcc414f9e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc @@ -0,0 +1,189 @@ +/* + + 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/add_sub_menu_request.h" + +#include "application_manager/message_helper.h" +#include "application_manager/application.h" +#include "utils/helpers.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +AddSubMenuRequest::AddSubMenuRequest( + 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) {} + +AddSubMenuRequest::~AddSubMenuRequest() {} + +void AddSubMenuRequest::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; + } + + smart_objects::SmartObject received_msg_params = + (*message_)[strings::msg_params]; + mobile_apis::Result::eType verification_result = + mobile_apis::Result::INVALID_ENUM; + + if (received_msg_params.keyExists(strings::menu_icon)) { + verification_result = MessageHelper::VerifyImage( + received_msg_params[strings::menu_icon], app, application_manager_); + + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR( + logger_, "MessageHelper::VerifyImage return " << verification_result); + SendResponse(false, verification_result); + return; + } + } + + const int32_t menu_id = received_msg_params[strings::menu_id].asInt(); + if (app->FindSubMenu(menu_id)) { + LOG4CXX_ERROR(logger_, "Menu with id " << menu_id << " is not found."); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + + const std::string& menu_name = + received_msg_params[strings::menu_name].asString(); + + if (app->IsSubMenuNameAlreadyExist(menu_name)) { + LOG4CXX_ERROR(logger_, "Menu name " << menu_name << " is duplicated."); + SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); + return; + } + + if (!CheckSubMenuName()) { + LOG4CXX_ERROR(logger_, "Sub-menu name is not valid."); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + msg_params[strings::menu_id] = received_msg_params[strings::menu_id]; + if (received_msg_params.keyExists(strings::position)) { + msg_params[strings::menu_params][strings::position] = + received_msg_params[strings::position]; + } + msg_params[strings::menu_params][strings::menu_name] = + received_msg_params[strings::menu_name]; + msg_params[strings::app_id] = app->app_id(); + + if (mobile_apis::Result::SUCCESS == verification_result) { + msg_params[strings::menu_icon] = received_msg_params[strings::menu_icon]; + } + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_AddSubMenu, &msg_params, true); +} + +void AddSubMenuRequest::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::UI_AddSubMenu: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(message, response_info); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_UI); + + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + if (result) { + application->AddSubMenu( + (*message_)[strings::msg_params][strings::menu_id].asInt(), + (*message_)[strings::msg_params]); + } + SendResponse(result, + 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; + } + } +} + +bool AddSubMenuRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +bool AddSubMenuRequest::CheckSubMenuName() { + LOG4CXX_AUTO_TRACE(logger_); + const char* str = NULL; + + str = (*message_)[strings::msg_params][strings::menu_name].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_INFO(logger_, "Invalid subMenu name."); + return false; + } + return true; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_response.cc new file mode 100644 index 0000000000..d0ec635dd0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_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 "sdl_rpc_plugin/commands/mobile/add_sub_menu_response.h" +#include "application_manager/rpc_service.h" +#include "application_manager/application_impl.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +AddSubMenuResponse::AddSubMenuResponse( + 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) {} + +AddSubMenuResponse::~AddSubMenuResponse() {} + +void AddSubMenuResponse::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/alert_maneuver_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_request.cc new file mode 100644 index 0000000000..5dda34b743 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_request.cc @@ -0,0 +1,291 @@ +/* + 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 <cstring> +#include <string> +#include "sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h" +#include "application_manager/application_impl.h" +#include "application_manager/policies/policy_handler.h" +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +AlertManeuverRequest::AlertManeuverRequest( + 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) + , tts_speak_result_code_(hmi_apis::Common_Result::INVALID_ENUM) + , navi_alert_maneuver_result_code_(hmi_apis::Common_Result::INVALID_ENUM) { + subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout); +} + +AlertManeuverRequest::~AlertManeuverRequest() {} + +void AlertManeuverRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + if ((!(*message_)[strings::msg_params].keyExists(strings::soft_buttons)) && + (!(*message_)[strings::msg_params].keyExists(strings::tts_chunks))) { + LOG4CXX_ERROR(logger_, "AlertManeuverRequest::Request without parameters!"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + ApplicationSharedPtr app = application_manager_.application( + (*message_)[strings::params][strings::connection_key].asUInt()); + + if (NULL == app.get()) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, + "Incoming alert maneuver has contains \\t\\n \\\\t \\\\n" + "text contains only whitespace in ttsChunks"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + // ProcessSoftButtons checks strings on the contents incorrect character + + mobile_apis::Result::eType processing_result = + MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], + app, + policy_handler_, + application_manager_); + + if (mobile_apis::Result::SUCCESS != processing_result) { + LOG4CXX_ERROR(logger_, "Wrong soft buttons parameters!"); + SendResponse(false, processing_result); + return; + } + + // Checking parameters and how many HMI requests should be sent + bool tts_is_ok = false; + + // check TTSChunk parameter + if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) { + smart_objects::SmartObject& tts_chunks = + (*message_)[strings::msg_params][strings::tts_chunks]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles(tts_chunks, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + SendResponse(false, + mobile_apis::Result::FILE_NOT_FOUND, + "One or more files needed for tts_chunks are not present"); + return; + } + + if (0 < (*message_)[strings::msg_params][strings::tts_chunks].length()) { + pending_requests_.Add(hmi_apis::FunctionID::TTS_Speak); + tts_is_ok = true; + } + } + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + msg_params[strings::app_id] = app->app_id(); + + if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + msg_params[hmi_request::soft_buttons] = + (*message_)[strings::msg_params][strings::soft_buttons]; + MessageHelper::SubscribeApplicationToSoftButton( + (*message_)[strings::msg_params], app, function_id()); + } + + pending_requests_.Add(hmi_apis::FunctionID::Navigation_AlertManeuver); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); + SendHMIRequest( + hmi_apis::FunctionID::Navigation_AlertManeuver, &msg_params, true); + + if (tts_is_ok) { + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + msg_params[hmi_request::tts_chunks] = + (*message_)[strings::msg_params][strings::tts_chunks]; + msg_params[hmi_request::speak_type] = + hmi_apis::Common_MethodName::ALERT_MANEUVER; + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); + SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, &msg_params, true); + } +} + +void AlertManeuverRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& message = event.smart_object(); + hmi_apis::FunctionID::eType event_id = event.id(); + switch (event_id) { + case hmi_apis::FunctionID::Navigation_AlertManeuver: { + LOG4CXX_INFO(logger_, "Received Navigation_AlertManeuver event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); + pending_requests_.Remove(event_id); + navi_alert_maneuver_result_code_ = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + GetInfo(message, info_navi_); + break; + } + case hmi_apis::FunctionID::TTS_Speak: { + LOG4CXX_INFO(logger_, "Received TTS_Speak event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); + pending_requests_.Remove(event_id); + tts_speak_result_code_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + GetInfo(message, info_tts_); + break; + } + case hmi_apis::FunctionID::TTS_OnResetTimeout: { + LOG4CXX_INFO(logger_, "Received TTS_OnResetTimeout event"); + + application_manager_.updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + SendResponse( + false, mobile_apis::Result::INVALID_ENUM, "Received unknown event"); + return; + } + } + + if (!pending_requests_.IsFinal(event_id)) { + LOG4CXX_DEBUG(logger_, + "There are some pending responses from HMI." + "AlertManeuverRequest still waiting."); + return; + } + std::string return_info; + mobile_apis::Result::eType result_code; + const bool result = PrepareResponseParameters(result_code, return_info); + bool must_be_empty_info = false; + if (return_info.find("\n") != std::string::npos || + return_info.find("\t") != std::string::npos) { + must_be_empty_info = true; + } + SendResponse(result, + result_code, + (must_be_empty_info) ? NULL : return_info.c_str(), + &(message[strings::msg_params])); +} + +bool AlertManeuverRequest::PrepareResponseParameters( + mobile_apis::Result::eType& result_code, std::string& return_info) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + + app_mngr::commands::ResponseInfo navigation_alert_info( + navi_alert_maneuver_result_code_, + HmiInterfaces::HMI_INTERFACE_Navigation, + application_manager_); + + app_mngr::commands::ResponseInfo tts_alert_info( + tts_speak_result_code_, + HmiInterfaces::HMI_INTERFACE_TTS, + application_manager_); + const bool result = + PrepareResultForMobileResponse(navigation_alert_info, tts_alert_info); + + if (result && (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == + tts_speak_result_code_ && + (HmiInterfaces::STATE_AVAILABLE == + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_TTS)))) { + result_code = mobile_apis::Result::WARNINGS; + return_info = std::string("Unsupported phoneme type sent in a prompt"); + return result; + } + result_code = + PrepareResultCodeForResponse(navigation_alert_info, tts_alert_info); + return_info = app_mngr::commands::MergeInfos( + navigation_alert_info, info_navi_, tts_alert_info, info_tts_); + return result; +} + +bool AlertManeuverRequest::IsWhiteSpaceExist() { + LOG4CXX_AUTO_TRACE(logger_); + using smart_objects::SmartArray; + + if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) { + const SmartArray* tts_chunks_arr = + (*message_)[strings::msg_params][strings::tts_chunks].asArray(); + + SmartArray::const_iterator it_tts_chunk = tts_chunks_arr->begin(); + + for (; it_tts_chunk != tts_chunks_arr->end(); ++it_tts_chunk) { + const char* tts_chunk_text = (*it_tts_chunk)[strings::text].asCharArray(); + if (strlen(tts_chunk_text) && !CheckSyntax(tts_chunk_text)) { + LOG4CXX_ERROR(logger_, "Invalid tts_chunks syntax check failed"); + return true; + } + } + } + if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + DCHECK_OR_RETURN( + (*message_)[strings::msg_params][strings::soft_buttons].getType() == + smart_objects::SmartType_Array, + true); + const smart_objects::SmartArray* soft_button_array = + (*message_)[strings::msg_params][strings::soft_buttons].asArray(); + + SmartArray::const_iterator it_soft_button = soft_button_array->begin(); + + for (; it_soft_button != soft_button_array->end(); ++it_soft_button) { + const char* soft_button_text = + (*it_soft_button)[strings::text].asCharArray(); + if (!CheckSyntax(soft_button_text)) { + LOG4CXX_ERROR(logger_, "Invalid soft_buttons syntax check failed"); + return true; + } + } + } + + return false; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_response.cc new file mode 100644 index 0000000000..d3e527f6ae --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_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 "sdl_rpc_plugin/commands/mobile/alert_maneuver_response.h" +#include "application_manager/rpc_service.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +AlertManeuverResponse::AlertManeuverResponse( + 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) {} + +AlertManeuverResponse::~AlertManeuverResponse() {} + +void AlertManeuverResponse::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/alert_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc new file mode 100644 index 0000000000..2806ac1d93 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc @@ -0,0 +1,453 @@ +/* + + 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/alert_request.h" + +#include <string.h> + +#include "application_manager/message_helper.h" +#include "application_manager/application_impl.h" + +#include "application_manager/policies/policy_handler.h" +#include "utils/helpers.h" +#include "smart_objects/smart_object.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +AlertRequest::AlertRequest( + 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) + , awaiting_ui_alert_response_(false) + , awaiting_tts_speak_response_(false) + , awaiting_tts_stop_speaking_response_(false) + , is_alert_succeeded_(false) + , is_ui_alert_sent_(false) + , alert_result_(hmi_apis::Common_Result::INVALID_ENUM) + , tts_speak_result_(hmi_apis::Common_Result::INVALID_ENUM) { + subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); + subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout); +} + +AlertRequest::~AlertRequest() {} + +bool AlertRequest::Init() { + /* Timeout in milliseconds. + If omitted a standard value of 10000 milliseconds is used.*/ + if ((*message_)[strings::msg_params].keyExists(strings::duration)) { + default_timeout_ = + (*message_)[strings::msg_params][strings::duration].asUInt(); + } else { + const int32_t def_value = 5000; + default_timeout_ = def_value; + } + + // If soft buttons are present, SDL will not use initiate timeout tracking for + // response. + if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + LOG4CXX_INFO(logger_, + "Request contains soft buttons - request timeout " + "will be set to 0."); + default_timeout_ = 0; + } + + return true; +} + +void AlertRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + uint32_t app_id = + (*message_)[strings::params][strings::connection_key].asInt(); + + if (!Validate(app_id)) { + // Invalid command, abort execution + return; + } + bool tts_chunks_exists = + (*message_)[strings::msg_params].keyExists(strings::tts_chunks); + size_t length_tts_chunks = 0; + + if (tts_chunks_exists) { + length_tts_chunks = + (*message_)[strings::msg_params][strings::tts_chunks].length(); + } + + if ((tts_chunks_exists && length_tts_chunks) || + ((*message_)[strings::msg_params].keyExists(strings::play_tone) && + (*message_)[strings::msg_params][strings::play_tone].asBool())) { + awaiting_tts_speak_response_ = true; + } + + SendAlertRequest(app_id); + if (awaiting_tts_speak_response_) { + SendSpeakRequest(app_id, tts_chunks_exists, length_tts_chunks); + } +} + +void AlertRequest::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::TTS_OnResetTimeout: + case hmi_apis::FunctionID::UI_OnResetTimeout: { + LOG4CXX_INFO(logger_, + "Received UI_OnResetTimeout event " + " or TTS_OnResetTimeout event" + << awaiting_tts_speak_response_ << " " + << awaiting_tts_stop_speaking_response_ << " " + << awaiting_ui_alert_response_); + application_manager_.updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + break; + } + case hmi_apis::FunctionID::UI_Alert: { + LOG4CXX_INFO(logger_, "Received UI_Alert event"); + // Unsubscribe from event to avoid unwanted messages + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + unsubscribe_from_event(hmi_apis::FunctionID::UI_Alert); + awaiting_ui_alert_response_ = false; + HmiInterfaces::InterfaceState ui_interface_state = + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_UI); + + if (awaiting_tts_speak_response_ && + HmiInterfaces::STATE_NOT_AVAILABLE != ui_interface_state) { + awaiting_tts_stop_speaking_response_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); + SendHMIRequest(hmi_apis::FunctionID::TTS_StopSpeaking, NULL, true); + } + alert_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + // Mobile Alert request is successful when UI_Alert is successful + alert_response_params_ = message[strings::msg_params]; + GetInfo(message, ui_response_info_); + break; + } + case hmi_apis::FunctionID::TTS_Speak: { + LOG4CXX_INFO(logger_, "Received TTS_Speak event"); + // Unsubscribe from event to avoid unwanted messages + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); + unsubscribe_from_event(hmi_apis::FunctionID::TTS_Speak); + awaiting_tts_speak_response_ = false; + tts_speak_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + GetInfo(message, tts_response_info_); + break; + } + case hmi_apis::FunctionID::TTS_StopSpeaking: { + LOG4CXX_INFO(logger_, "Received TTS_StopSpeaking event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); + // Unsubscribe from event to avoid unwanted messages + unsubscribe_from_event(hmi_apis::FunctionID::TTS_StopSpeaking); + awaiting_tts_stop_speaking_response_ = false; + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } + + if (HasHmiResponsesToWait()) { + return; + } + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; + std::string info; + const bool result = PrepareResponseParameters(result_code, info); + SendResponse(result, + result_code, + info.empty() ? NULL : info.c_str(), + &alert_response_params_); +} + +bool AlertRequest::PrepareResponseParameters( + mobile_apis::Result::eType& result_code, std::string& info) { + app_mngr::commands::ResponseInfo ui_alert_info( + alert_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); + app_mngr::commands::ResponseInfo tts_alert_info( + tts_speak_result_, + HmiInterfaces::HMI_INTERFACE_TTS, + application_manager_); + + bool result = PrepareResultForMobileResponse(ui_alert_info, tts_alert_info); + + /* result=false if UI interface is ok and TTS interface = UNSUPPORTED_RESOURCE + * and sdl receive TTS.IsReady=true or SDL doesn't receive responce for + * TTS.IsReady. + */ + if (result && ui_alert_info.is_ok && tts_alert_info.is_unsupported_resource && + HmiInterfaces::STATE_NOT_AVAILABLE != tts_alert_info.interface_state) { + result = false; + } + result_code = mobile_apis::Result::WARNINGS; + if ((ui_alert_info.is_ok || ui_alert_info.is_not_used) && + tts_alert_info.is_unsupported_resource && + HmiInterfaces::STATE_AVAILABLE == tts_alert_info.interface_state) { + tts_response_info_ = "Unsupported phoneme type sent in a prompt"; + info = app_mngr::commands::MergeInfos( + ui_alert_info, ui_response_info_, tts_alert_info, tts_response_info_); + return result; + } + result_code = PrepareResultCodeForResponse(ui_alert_info, tts_alert_info); + info = app_mngr::commands::MergeInfos( + ui_alert_info, ui_response_info_, tts_alert_info, tts_response_info_); + // Mobile Alert request is successful when UI_Alert is successful + if (is_ui_alert_sent_ && !ui_alert_info.is_ok) { + return false; + } + return result; +} + +bool AlertRequest::Validate(uint32_t app_id) { + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = application_manager_.application(app_id); + + if (!app) { + LOG4CXX_ERROR(logger_, "No application associated with session key"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return false; + } + + if (mobile_apis::HMILevel::HMI_BACKGROUND == app->hmi_level() && + app->AreCommandLimitsExceeded( + static_cast<mobile_apis::FunctionID::eType>(function_id()), + application_manager::TLimitSource::POLICY_TABLE)) { + LOG4CXX_ERROR(logger_, "Alert frequency is too high."); + SendResponse(false, mobile_apis::Result::REJECTED); + return false; + } + + if (!CheckStringsOfAlertRequest()) { + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return false; + } + + // ProcessSoftButtons checks strings on the contents incorrect character + + mobile_apis::Result::eType processing_result = + MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], + app, + policy_handler_, + application_manager_); + + if (mobile_apis::Result::SUCCESS != processing_result) { + LOG4CXX_ERROR(logger_, "INVALID_DATA!"); + SendResponse(false, processing_result); + return false; + } + + // check if mandatory params(alertText1 and TTSChunk) specified + if ((!(*message_)[strings::msg_params].keyExists(strings::alert_text1)) && + (!(*message_)[strings::msg_params].keyExists(strings::alert_text2)) && + (!(*message_)[strings::msg_params].keyExists(strings::tts_chunks) && + (1 > (*message_)[strings::msg_params][strings::tts_chunks].length()))) { + LOG4CXX_ERROR(logger_, "Mandatory parameters are missing"); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "Mandatory parameters are missing"); + return false; + } + + if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) { + smart_objects::SmartObject& tts_chunks = + (*message_)[strings::msg_params][strings::tts_chunks]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles(tts_chunks, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + SendResponse(false, + mobile_apis::Result::FILE_NOT_FOUND, + "One or more files needed for tts_chunks are not present"); + return false; + } + } + + return true; +} + +void AlertRequest::SendAlertRequest(int32_t app_id) { + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = application_manager_.application(app_id); + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + msg_params[hmi_request::alert_strings] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + int32_t index = 0; + if ((*message_)[strings::msg_params].keyExists(strings::alert_text1)) { + msg_params[hmi_request::alert_strings][index][hmi_request::field_name] = + hmi_apis::Common_TextFieldName::alertText1; + msg_params[hmi_request::alert_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::alert_text1]; + index++; + } + if ((*message_)[strings::msg_params].keyExists(strings::alert_text2)) { + msg_params[hmi_request::alert_strings][index][hmi_request::field_name] = + hmi_apis::Common_TextFieldName::alertText2; + msg_params[hmi_request::alert_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::alert_text2]; + index++; + } + if ((*message_)[strings::msg_params].keyExists(strings::alert_text3)) { + msg_params[hmi_request::alert_strings][index][hmi_request::field_name] = + hmi_apis::Common_TextFieldName::alertText3; + msg_params[hmi_request::alert_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::alert_text3]; + } + + // softButtons + if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + msg_params[hmi_request::soft_buttons] = + (*message_)[strings::msg_params][strings::soft_buttons]; + MessageHelper::SubscribeApplicationToSoftButton( + (*message_)[strings::msg_params], app, function_id()); + } + // app_id + msg_params[strings::app_id] = app_id; + msg_params[strings::duration] = default_timeout_; + + // NAVI platform progressIndicator + if ((*message_)[strings::msg_params].keyExists(strings::progress_indicator)) { + msg_params[strings::progress_indicator] = + (*message_)[strings::msg_params][strings::progress_indicator]; + } + + // PASA Alert type + msg_params[strings::alert_type] = hmi_apis::Common_AlertType::UI; + if (awaiting_tts_speak_response_) { + msg_params[strings::alert_type] = hmi_apis::Common_AlertType::BOTH; + } + + // check out if there are alert strings or soft buttons + if (msg_params[hmi_request::alert_strings].length() > 0 || + msg_params.keyExists(hmi_request::soft_buttons)) { + awaiting_ui_alert_response_ = true; + is_ui_alert_sent_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_Alert, &msg_params, true); + } +} + +void AlertRequest::SendSpeakRequest(int32_t app_id, + bool tts_chunks_exists, + size_t length_tts_chunks) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace hmi_apis; + using namespace smart_objects; + // crate HMI speak request + SmartObject msg_params = smart_objects::SmartObject(SmartType_Map); + if (tts_chunks_exists && length_tts_chunks) { + msg_params[hmi_request::tts_chunks] = + smart_objects::SmartObject(SmartType_Array); + msg_params[hmi_request::tts_chunks] = + (*message_)[strings::msg_params][strings::tts_chunks]; + } + if ((*message_)[strings::msg_params].keyExists(strings::play_tone) && + (*message_)[strings::msg_params][strings::play_tone].asBool()) { + msg_params[strings::play_tone] = true; + } + msg_params[strings::app_id] = app_id; + msg_params[hmi_request::speak_type] = Common_MethodName::ALERT; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); + SendHMIRequest(FunctionID::TTS_Speak, &msg_params, true); +} + +bool AlertRequest::CheckStringsOfAlertRequest() { + LOG4CXX_AUTO_TRACE(logger_); + const char* str = NULL; + + if ((*message_)[strings::msg_params].keyExists(strings::alert_text1)) { + str = (*message_)[strings::msg_params][strings::alert_text1].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid alert_text_1 syntax check failed"); + return false; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::alert_text2)) { + str = (*message_)[strings::msg_params][strings::alert_text2].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid alert_text_2 syntax check failed"); + return false; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::alert_text3)) { + str = (*message_)[strings::msg_params][strings::alert_text3].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid alert_text_3 syntax check failed"); + return false; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) { + smart_objects::SmartObject& tts_chunks_array = + (*message_)[strings::msg_params][strings::tts_chunks]; + for (size_t i = 0; i < tts_chunks_array.length(); ++i) { + str = tts_chunks_array[i][strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid tts_chunks text syntax check failed"); + return false; + } + } + } + return true; +} + +bool AlertRequest::HasHmiResponsesToWait() { + LOG4CXX_AUTO_TRACE(logger_); + return awaiting_ui_alert_response_ || awaiting_tts_speak_response_ || + awaiting_tts_stop_speaking_response_; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_response.cc new file mode 100644 index 0000000000..bab5e5a5d8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_response.cc @@ -0,0 +1,67 @@ +/* + + 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/alert_response.h" +#include "application_manager/rpc_service.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +AlertResponse::AlertResponse( + 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) {} + +AlertResponse::~AlertResponse() {} + +void AlertResponse::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/change_registration_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc new file mode 100644 index 0000000000..6af930ea53 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc @@ -0,0 +1,684 @@ +/* + + 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 <string.h> +#include <algorithm> +#include "sdl_rpc_plugin/commands/mobile/change_registration_request.h" +#include "application_manager/application_manager.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" +#include "application_manager/message_helper.h" + +namespace { +namespace custom_str = utils::custom_string; +struct IsSameNickname { + IsSameNickname(const custom_str::CustomString& app_id) : app_id_(app_id) {} + bool operator()(const policy::StringArray::value_type& nickname) const { + return app_id_.CompareIgnoreCase(nickname.c_str()); + } + + private: + const custom_str::CustomString& app_id_; +}; +} + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +ChangeRegistrationRequest::ChangeRegistrationRequest( + 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) + , ui_result_(hmi_apis::Common_Result::INVALID_ENUM) + , vr_result_(hmi_apis::Common_Result::INVALID_ENUM) + , tts_result_(hmi_apis::Common_Result::INVALID_ENUM) {} + +ChangeRegistrationRequest::~ChangeRegistrationRequest() {} + +void ChangeRegistrationRequest::SendVRRequest( + ApplicationSharedPtr app, smart_objects::SmartObject& msg_params) { + const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces(); + auto function = hmi_apis::FunctionID::VR_ChangeRegistration; + pending_requests_.Add(function); + smart_objects::SmartObject vr_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + vr_params[strings::language] = msg_params[strings::language]; + + vr_params[strings::app_id] = app->app_id(); + if (msg_params.keyExists(strings::vr_synonyms)) { + vr_params[strings::vr_synonyms] = msg_params[strings::vr_synonyms]; + app->set_vr_synonyms(msg_params[strings::vr_synonyms]); + } + StartAwaitForInterface(hmi_interfaces.GetInterfaceFromFunction(function)); + SendHMIRequest(function, &vr_params, true); +} + +void ChangeRegistrationRequest::SendTTSRequest( + ApplicationSharedPtr app, smart_objects::SmartObject& msg_params) { + const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces(); + auto function = hmi_apis::FunctionID::TTS_ChangeRegistration; + pending_requests_.Add(function); + + smart_objects::SmartObject tts_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + tts_params[strings::language] = msg_params[strings::language]; + + tts_params[strings::app_id] = app->app_id(); + if (msg_params.keyExists(strings::tts_name)) { + tts_params[strings::tts_name] = msg_params[strings::tts_name]; + app->set_tts_name(msg_params[strings::tts_name]); + } + StartAwaitForInterface(hmi_interfaces.GetInterfaceFromFunction(function)); + SendHMIRequest(function, &tts_params, true); +} + +void ChangeRegistrationRequest::SendUIRequest( + ApplicationSharedPtr app, + smart_objects::SmartObject& msg_params, + const int32_t hmi_language) { + const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces(); + auto function = hmi_apis::FunctionID::UI_ChangeRegistration; + pending_requests_.Add(function); + // UI processing + smart_objects::SmartObject ui_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + ui_params[strings::language] = hmi_language; + ui_params[strings::app_id] = app->app_id(); + if (msg_params.keyExists(strings::app_name)) { + ui_params[strings::app_name] = msg_params[strings::app_name]; + app->set_name(msg_params[strings::app_name].asCustomString()); + } + if (msg_params.keyExists(strings::ngn_media_screen_app_name)) { + ui_params[strings::ngn_media_screen_app_name] = + msg_params[strings::ngn_media_screen_app_name]; + app->set_ngn_media_screen_name( + msg_params[strings::ngn_media_screen_app_name]); + } + + StartAwaitForInterface(hmi_interfaces.GetInterfaceFromFunction(function)); + SendHMIRequest(function, &ui_params, true); +} + +void ChangeRegistrationRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + using namespace smart_objects; + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_INFO(logger_, + "Incoming request contains \t\n \\t \\n or whitespace"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if (mobile_apis::Result::SUCCESS != CheckCoincidence()) { + SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); + return; + } + + SmartObject& msg_params = (*message_)[strings::msg_params]; + + const int32_t hmi_language = + msg_params[strings::hmi_display_language].asInt(); + + const int32_t language = msg_params[strings::language].asInt(); + + if (false == (IsLanguageSupportedByUI(hmi_language) && + IsLanguageSupportedByVR(language) && + IsLanguageSupportedByTTS(language))) { + LOG4CXX_ERROR(logger_, "Language is not supported"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + if (msg_params.keyExists(strings::app_name) && + !IsNicknameAllowed(msg_params[strings::app_name].asCustomString())) { + LOG4CXX_ERROR(logger_, "Nickname is not allowed."); + SendResponse(false, mobile_apis::Result::DISALLOWED); + return; + } + + if ((*message_)[strings::msg_params].keyExists(strings::tts_name)) { + smart_objects::SmartObject& tts_name = + (*message_)[strings::msg_params][strings::tts_name]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles(tts_name, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + SendResponse(false, + mobile_apis::Result::FILE_NOT_FOUND, + "One or more files needed for tts_name are not present"); + return; + } + } + + const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces(); + + const HmiInterfaces::InterfaceState vr_state = + hmi_interfaces.GetInterfaceState( + HmiInterfaces::InterfaceID::HMI_INTERFACE_VR); + const HmiInterfaces::InterfaceState ui_state = + hmi_interfaces.GetInterfaceState( + HmiInterfaces::InterfaceID::HMI_INTERFACE_UI); + const HmiInterfaces::InterfaceState tts_state = + hmi_interfaces.GetInterfaceState( + HmiInterfaces::InterfaceID::HMI_INTERFACE_TTS); + + using helpers::Compare; + using helpers::EQ; + using helpers::ALL; + + if (Compare<HmiInterfaces::InterfaceState, EQ, ALL>( + HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE, + vr_state, + tts_state, + ui_state)) { + SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE); + return; + } + if (HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE != vr_state) { + // VR processing + SendVRRequest(app, msg_params); + } + if (HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE != tts_state) { + // TTS processing + SendTTSRequest(app, msg_params); + } + + if (HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE != ui_state) { + SendUIRequest(app, msg_params, hmi_language); + } +} + +void ChangeRegistrationRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& message = event.smart_object(); + + hmi_apis::FunctionID::eType event_id = event.id(); + + switch (event_id) { + case hmi_apis::FunctionID::UI_ChangeRegistration: { + LOG4CXX_INFO(logger_, "Received UI_ChangeRegistration event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + pending_requests_.Remove(event_id); + ui_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + GetInfo(message, ui_response_info_); + break; + } + case hmi_apis::FunctionID::VR_ChangeRegistration: { + LOG4CXX_INFO(logger_, "Received VR_ChangeRegistration event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); + pending_requests_.Remove(event_id); + vr_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + GetInfo(message, vr_response_info_); + break; + } + case hmi_apis::FunctionID::TTS_ChangeRegistration: { + LOG4CXX_INFO(logger_, "Received TTS_ChangeRegistration event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); + pending_requests_.Remove(event_id); + tts_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + GetInfo(message, tts_response_info_); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event_id); + return; + } + } + + if (pending_requests_.IsFinal(event_id)) { + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + if (hmi_apis::Common_Result::SUCCESS == ui_result_) { + application->set_ui_language(static_cast<mobile_api::Language::eType>( + (*message_)[strings::msg_params][strings::hmi_display_language] + .asInt())); + } + + if (hmi_apis::Common_Result::SUCCESS == vr_result_ || + hmi_apis::Common_Result::SUCCESS == tts_result_) { + application->set_language(static_cast<mobile_api::Language::eType>( + (*message_)[strings::msg_params][strings::language].asInt())); + } + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; + std::string response_info; + const bool result = PrepareResponseParameters(result_code, response_info); + + (*message_)[strings::params][strings::function_id] = + mobile_apis::FunctionID::eType::ChangeRegistrationID; + + SendResponse(result, + result_code, + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); + } else { + LOG4CXX_INFO(logger_, + "There are some pending responses from HMI." + "ChangeRegistrationRequest still waiting."); + } +} + +namespace { +void CheckInfo(std::string& str) { + if (std::string::npos != str.find("is not supported by system")) { + str.clear(); + } +} +} // namespace + +bool ChangeRegistrationRequest::PrepareResponseParameters( + mobile_apis::Result::eType& result_code, std::string& response_info) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + const bool is_tts_succeeded_unsupported = + Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + tts_result_, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS, + hmi_apis::Common_Result::WRONG_LANGUAGE, + hmi_apis::Common_Result::RETRY, + hmi_apis::Common_Result::SAVED, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); + + const bool is_ui_succeeded_unsupported = + Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + ui_result_, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS, + hmi_apis::Common_Result::WRONG_LANGUAGE, + hmi_apis::Common_Result::RETRY, + hmi_apis::Common_Result::SAVED, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); + + const bool is_vr_succeeded_unsupported = + Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + vr_result_, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS, + hmi_apis::Common_Result::WRONG_LANGUAGE, + hmi_apis::Common_Result::RETRY, + hmi_apis::Common_Result::SAVED, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); + + const bool is_tts_ui_vr_unsupported = + Compare<hmi_apis::Common_Result::eType, EQ, ALL>( + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + tts_result_, + ui_result_, + vr_result_); + + const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces(); + const HmiInterfaces::InterfaceState tts_state = + hmi_interfaces.GetInterfaceState( + HmiInterfaces::InterfaceID::HMI_INTERFACE_TTS); + const HmiInterfaces::InterfaceState vr_state = + hmi_interfaces.GetInterfaceState( + HmiInterfaces::InterfaceID::HMI_INTERFACE_VR); + const HmiInterfaces::InterfaceState ui_state = + hmi_interfaces.GetInterfaceState( + HmiInterfaces::InterfaceID::HMI_INTERFACE_UI); + + app_mngr::commands::ResponseInfo ui_properties_info( + ui_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); + + app_mngr::commands::ResponseInfo tts_properties_info( + tts_result_, HmiInterfaces::HMI_INTERFACE_TTS, application_manager_); + + app_mngr::commands::ResponseInfo vr_properties_info( + ui_result_, HmiInterfaces::HMI_INTERFACE_VR, application_manager_); + + bool result = ((!is_tts_ui_vr_unsupported) && is_tts_succeeded_unsupported && + is_ui_succeeded_unsupported && is_vr_succeeded_unsupported); + + const bool is_tts_or_ui_or_vr_unsupported = + Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + tts_result_, + ui_result_, + vr_result_); + + if ((result && is_tts_or_ui_or_vr_unsupported)) { + result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE; + result = + PrepareResultForMobileResponse(ui_properties_info, + tts_properties_info) && + PrepareResultForMobileResponse(tts_properties_info, vr_properties_info); + } else { + // If response contains erroneous result code SDL need return erroneus + // result code. + hmi_apis::Common_Result::eType ui_result = + hmi_apis::Common_Result::INVALID_ENUM; + hmi_apis::Common_Result::eType vr_result = + hmi_apis::Common_Result::INVALID_ENUM; + hmi_apis::Common_Result::eType tts_result = + hmi_apis::Common_Result::INVALID_ENUM; + if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE != ui_result_) { + ui_result = ui_result_; + } + if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE != vr_result_) { + vr_result = vr_result_; + } + if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE != tts_result_) { + tts_result = tts_result_; + } + result_code = MessageHelper::HMIToMobileResult( + std::max(std::max(ui_result, vr_result), tts_result)); + if (mobile_api::Result::INVALID_ENUM == result_code) { + result_code = mobile_api::Result::UNSUPPORTED_RESOURCE; + } + } + + const bool is_tts_state_available = + tts_state == HmiInterfaces::STATE_AVAILABLE; + const bool is_vr_state_available = vr_state == HmiInterfaces::STATE_AVAILABLE; + const bool is_ui_state_available = ui_state == HmiInterfaces::STATE_AVAILABLE; + + const bool is_tts_hmi_info = + is_tts_state_available && !tts_response_info_.empty(); + const bool is_vr_hmi_info = + is_vr_state_available && !vr_response_info_.empty(); + const bool is_ui_hmi_info = + is_ui_state_available && !ui_response_info_.empty(); + + if (is_tts_hmi_info || is_vr_hmi_info || is_ui_hmi_info) { + if (!is_tts_hmi_info) + CheckInfo(tts_response_info_); + if (!is_vr_hmi_info) + CheckInfo(ui_response_info_); + if (!is_ui_hmi_info) + CheckInfo(vr_response_info_); + } + + response_info = app_mngr::commands::MergeInfos( + ui_response_info_, vr_response_info_, tts_response_info_); + return result; +} + +bool ChangeRegistrationRequest::IsLanguageSupportedByUI( + const int32_t& hmi_display_lang) { + const HMICapabilities& hmi_capabilities = hmi_capabilities_; + const smart_objects::SmartObject* ui_languages = + hmi_capabilities.ui_supported_languages(); + + if (!ui_languages) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return false; + } + + for (size_t i = 0; i < ui_languages->length(); ++i) { + if (hmi_display_lang == ui_languages->getElement(i).asInt()) { + return true; + } + } + + LOG4CXX_ERROR(logger_, "Language isn't supported by UI"); + + return false; +} + +bool ChangeRegistrationRequest::IsLanguageSupportedByVR( + const int32_t& hmi_display_lang) { + const HMICapabilities& hmi_capabilities = hmi_capabilities_; + const smart_objects::SmartObject* vr_languages = + hmi_capabilities.vr_supported_languages(); + + if (!vr_languages) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return false; + } + + for (size_t i = 0; i < vr_languages->length(); ++i) { + if (hmi_display_lang == vr_languages->getElement(i).asInt()) { + return true; + } + } + + LOG4CXX_ERROR(logger_, "Language isn't supported by VR"); + + return false; +} + +bool ChangeRegistrationRequest::IsLanguageSupportedByTTS( + const int32_t& hmi_display_lang) { + const HMICapabilities& hmi_capabilities = hmi_capabilities_; + const smart_objects::SmartObject* tts_languages = + hmi_capabilities.tts_supported_languages(); + + if (!tts_languages) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return false; + } + + for (size_t i = 0; i < tts_languages->length(); ++i) { + if (hmi_display_lang == tts_languages->getElement(i).asInt()) { + return true; + break; + } + } + + LOG4CXX_ERROR(logger_, "Language isn't supported by TTS"); + return false; +} + +bool ChangeRegistrationRequest::IsWhiteSpaceExist() { + const char* str = NULL; + + if ((*message_)[strings::msg_params].keyExists(strings::app_name)) { + str = (*message_)[strings::msg_params][strings::app_name].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid app_name syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::tts_name)) { + const smart_objects::SmartArray* tn_array = + (*message_)[strings::msg_params][strings::tts_name].asArray(); + + smart_objects::SmartArray::const_iterator it_tn = tn_array->begin(); + smart_objects::SmartArray::const_iterator it_tn_end = tn_array->end(); + + for (; it_tn != it_tn_end; ++it_tn) { + str = (*it_tn)[strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid tts_name syntax check failed"); + return true; + } + } + } + + if ((*message_)[strings::msg_params].keyExists( + strings::ngn_media_screen_app_name)) { + str = (*message_)[strings::msg_params][strings::ngn_media_screen_app_name] + .asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid ngn_media_screen_app_name syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::vr_synonyms)) { + const smart_objects::SmartArray* vs_array = + (*message_)[strings::msg_params][strings::vr_synonyms].asArray(); + + smart_objects::SmartArray::const_iterator it_vs = vs_array->begin(); + smart_objects::SmartArray::const_iterator it_vs_end = vs_array->end(); + + for (; it_vs != it_vs_end; ++it_vs) { + str = (*it_vs).asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid vr_synonyms syntax check failed"); + return true; + } + } + } + return false; +} + +mobile_apis::Result::eType ChangeRegistrationRequest::CheckCoincidence() { + LOG4CXX_AUTO_TRACE(logger_); + + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + ApplicationSet accessor = application_manager_.applications().GetData(); + custom_str::CustomString app_name; + uint32_t app_id = connection_key(); + if (msg_params.keyExists(strings::app_name)) { + app_name = msg_params[strings::app_name].asCustomString(); + } + + ApplicationSetConstIt it = accessor.begin(); + for (; accessor.end() != it; ++it) { + if (app_id == (*it)->app_id()) { + continue; + } + + const custom_str::CustomString& cur_name = (*it)->name(); + if (msg_params.keyExists(strings::app_name)) { + if (app_name.CompareIgnoreCase(cur_name)) { + LOG4CXX_ERROR(logger_, "Application name is known already."); + return mobile_apis::Result::DUPLICATE_NAME; + } + + const smart_objects::SmartObject* vr = (*it)->vr_synonyms(); + const std::vector<smart_objects::SmartObject>* curr_vr = NULL; + if (NULL != vr) { + curr_vr = vr->asArray(); + CoincidencePredicateVR v(app_name); + + if (0 != std::count_if(curr_vr->begin(), curr_vr->end(), v)) { + LOG4CXX_ERROR(logger_, "Application name is known already."); + return mobile_apis::Result::DUPLICATE_NAME; + } + } + } + + // vr check + if (msg_params.keyExists(strings::vr_synonyms)) { + const std::vector<smart_objects::SmartObject>* new_vr = + msg_params[strings::vr_synonyms].asArray(); + + CoincidencePredicateVR v(cur_name); + if (0 != std::count_if(new_vr->begin(), new_vr->end(), v)) { + LOG4CXX_ERROR(logger_, "vr_synonyms duplicated with app_name ."); + return mobile_apis::Result::DUPLICATE_NAME; + } + } // end vr check + } // application for end + return mobile_apis::Result::SUCCESS; +} + +bool ChangeRegistrationRequest::IsNicknameAllowed( + const custom_str::CustomString& app_name) const { + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, + "Can't find appication with connection key " + << connection_key()); + return false; + } + + const std::string policy_app_id = app->policy_app_id(); + + policy::StringArray app_nicknames; + policy::StringArray app_hmi_types; + + bool init_result = policy_handler_.GetInitialAppData( + policy_app_id, &app_nicknames, &app_hmi_types); + + if (!init_result) { + LOG4CXX_ERROR(logger_, + "Error during getting of nickname list for application " + << policy_app_id); + return false; + } + + if (!app_nicknames.empty()) { + IsSameNickname compare(app_name); + policy::StringArray::const_iterator it = + std::find_if(app_nicknames.begin(), app_nicknames.end(), compare); + if (app_nicknames.end() == it) { + LOG4CXX_WARN(logger_, + "Application name was not found in nicknames list."); + + usage_statistics::AppCounter count_of_rejections_nickname_mismatch( + policy_handler_.GetStatisticManager(), + policy_app_id, + usage_statistics::REJECTIONS_NICKNAME_MISMATCH); + ++count_of_rejections_nickname_mismatch; + + return false; + } + } + return true; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_response.cc new file mode 100644 index 0000000000..2dae92cd9b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_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 "sdl_rpc_plugin/commands/mobile/change_registration_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +ChangeRegistrationResponse::ChangeRegistrationResponse( + 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) {} + +ChangeRegistrationResponse::~ChangeRegistrationResponse() {} + +void ChangeRegistrationResponse::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/create_interaction_choice_set_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc new file mode 100644 index 0000000000..7451ea7905 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc @@ -0,0 +1,451 @@ +/* + + 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 <string> +#include <cstring> +#include <algorithm> +#include <vector> +#include "sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h" + +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "utils/gen_hash.h" +#include "utils/helpers.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +CreateInteractionChoiceSetRequest::CreateInteractionChoiceSetRequest( + 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) + , choice_set_id_(0) + , expected_chs_count_(0) + , received_chs_count_(0) + , error_from_hmi_(false) + , is_timed_out_(false) + , vr_commands_lock_(true) {} + +CreateInteractionChoiceSetRequest::~CreateInteractionChoiceSetRequest() { + LOG4CXX_AUTO_TRACE(logger_); +} + +void CreateInteractionChoiceSetRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + using namespace mobile_apis; + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + for (uint32_t i = 0; + i < (*message_)[strings::msg_params][strings::choice_set].length(); + ++i) { + Result::eType verification_result_image = Result::SUCCESS; + Result::eType verification_result_secondary_image = Result::SUCCESS; + if ((*message_)[strings::msg_params][strings::choice_set][i].keyExists( + strings::image)) { + verification_result_image = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::choice_set][i] + [strings::image], + app, + application_manager_); + } + if ((*message_)[strings::msg_params][strings::choice_set][i].keyExists( + strings::secondary_image)) { + verification_result_secondary_image = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::choice_set][i] + [strings::secondary_image], + app, + application_manager_); + } + if (verification_result_image == Result::INVALID_DATA || + verification_result_secondary_image == Result::INVALID_DATA) { + LOG4CXX_ERROR(logger_, "Image verification failed."); + SendResponse(false, Result::INVALID_DATA); + return; + } + } + + choice_set_id_ = + (*message_)[strings::msg_params][strings::interaction_choice_set_id] + .asInt(); + + if (app->FindChoiceSet(choice_set_id_)) { + LOG4CXX_ERROR(logger_, + "Choice set with id " << choice_set_id_ << " is not found."); + SendResponse(false, Result::INVALID_ID); + return; + } + + Result::eType result = CheckChoiceSet(app); + if (Result::SUCCESS != result) { + SendResponse(false, result); + return; + } + uint32_t grammar_id = application_manager_.GenerateGrammarID(); + (*message_)[strings::msg_params][strings::grammar_id] = grammar_id; + app->AddChoiceSet(choice_set_id_, (*message_)[strings::msg_params]); + SendVRAddCommandRequests(app); +} + +mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( + ApplicationConstSharedPtr app) { + using namespace smart_objects; + LOG4CXX_AUTO_TRACE(logger_); + + std::set<uint32_t> choice_id_set; + + const SmartArray* choice_set = + (*message_)[strings::msg_params][strings::choice_set].asArray(); + + SmartArray::const_iterator current_choice_set_it = choice_set->begin(); + SmartArray::const_iterator next_choice_set_it; + + for (; choice_set->end() != current_choice_set_it; ++current_choice_set_it) { + std::pair<std::set<uint32_t>::iterator, bool> ins_res = + choice_id_set.insert( + (*current_choice_set_it)[strings::choice_id].asInt()); + if (!ins_res.second) { + LOG4CXX_ERROR(logger_, + "Choise with ID " + << (*current_choice_set_it)[strings::choice_id].asInt() + << " already exists"); + return mobile_apis::Result::INVALID_ID; + } + + if (IsWhiteSpaceExist(*current_choice_set_it)) { + LOG4CXX_ERROR(logger_, "Incoming choice set has contains \t\n \\t \\n"); + return mobile_apis::Result::INVALID_DATA; + } + for (next_choice_set_it = current_choice_set_it + 1; + choice_set->end() != next_choice_set_it; + ++next_choice_set_it) { + if (compareSynonyms(*current_choice_set_it, *next_choice_set_it)) { + return mobile_apis::Result::DUPLICATE_NAME; + } + } + } + return mobile_apis::Result::SUCCESS; +} + +bool CreateInteractionChoiceSetRequest::compareSynonyms( + const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice1, + const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice2) { + smart_objects::SmartArray* vr_cmds_1 = + choice1[strings::vr_commands].asArray(); + DCHECK(vr_cmds_1 != NULL); + smart_objects::SmartArray* vr_cmds_2 = + choice2[strings::vr_commands].asArray(); + DCHECK(vr_cmds_2 != NULL); + + smart_objects::SmartArray::iterator it; + it = std::find_first_of(vr_cmds_1->begin(), + vr_cmds_1->end(), + vr_cmds_2->begin(), + vr_cmds_2->end(), + CreateInteractionChoiceSetRequest::compareStr); + + if (it != vr_cmds_1->end()) { + LOG4CXX_INFO(logger_, + "Incoming choice set has duplicated VR synonyms " + << it->asString()); + return true; + } + + return false; +} + +bool CreateInteractionChoiceSetRequest::compareStr( + const NsSmartDeviceLink::NsSmartObjects::SmartObject& str1, + const NsSmartDeviceLink::NsSmartObjects::SmartObject& str2) { + return 0 == strcasecmp(str1.asCharArray(), str2.asCharArray()); +} + +bool CreateInteractionChoiceSetRequest::IsWhiteSpaceExist( + const smart_objects::SmartObject& choice_set) { + LOG4CXX_AUTO_TRACE(logger_); + const char* str = NULL; + + str = choice_set[strings::menu_name].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid menu_name syntax check failed"); + return true; + } + + if (choice_set.keyExists(strings::secondary_text)) { + str = choice_set[strings::secondary_text].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid secondary_text syntax check failed"); + return true; + } + } + + if (choice_set.keyExists(strings::tertiary_text)) { + str = choice_set[strings::tertiary_text].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid tertiary_text syntax check failed"); + return true; + } + } + + if (choice_set.keyExists(strings::vr_commands)) { + const size_t len = choice_set[strings::vr_commands].length(); + + for (size_t i = 0; i < len; ++i) { + str = choice_set[strings::vr_commands][i].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid vr_commands syntax check failed"); + return true; + } + } + } + + if (choice_set.keyExists(strings::image)) { + str = choice_set[strings::image][strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid image value syntax check failed"); + return true; + } + } + + if (choice_set.keyExists(strings::secondary_image)) { + str = choice_set[strings::secondary_image][strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid secondary_image value. " + "Syntax check failed"); + return true; + } + } + return false; +} + +void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests( + application_manager::ApplicationSharedPtr const app) { + LOG4CXX_AUTO_TRACE(logger_); + + smart_objects::SmartObject& choice_set = (*message_)[strings::msg_params]; + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[strings::type] = hmi_apis::Common_VRCommandType::Choice; + msg_params[strings::app_id] = app->app_id(); + msg_params[strings::grammar_id] = choice_set[strings::grammar_id]; + const uint32_t choice_count = choice_set[strings::choice_set].length(); + SetAllowedToTerminate(false); + + expected_chs_count_ = choice_count; + size_t chs_num = 0; + for (; chs_num < choice_count; ++chs_num) { + { + sync_primitives::AutoLock error_lock(error_from_hmi_lock_); + if (error_from_hmi_) { + LOG4CXX_WARN(logger_, + "Error from HMI received. Stop sending VRCommands"); + break; + } + } + + msg_params[strings::cmd_id] = + choice_set[strings::choice_set][chs_num][strings::choice_id]; + msg_params[strings::vr_commands] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + msg_params[strings::vr_commands] = + choice_set[strings::choice_set][chs_num][strings::vr_commands]; + + sync_primitives::AutoLock commands_lock(vr_commands_lock_); + const uint32_t vr_cmd_id = msg_params[strings::cmd_id].asUInt(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); + const uint32_t vr_corr_id = + SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &msg_params, true); + + VRCommandInfo vr_command(vr_cmd_id); + sent_commands_map_[vr_corr_id] = vr_command; + LOG4CXX_DEBUG(logger_, + "VR_command sent corr_id " << vr_corr_id << " cmd_id " + << vr_corr_id); + } + expected_chs_count_ = chs_num; + LOG4CXX_DEBUG(logger_, "expected_chs_count_ = " << expected_chs_count_); +} + +void CreateInteractionChoiceSetRequest::ProcessHmiError( + const hmi_apis::Common_Result::eType vr_result) { + LOG4CXX_DEBUG(logger_, + "Hmi response is not Success: " + << vr_result << ". Stop sending VRAddCommand requests"); + if (!error_from_hmi_) { + error_from_hmi_ = true; + std::string info = + vr_result == hmi_apis::Common_Result::UNSUPPORTED_RESOURCE + ? "VR is not supported by system" + : ""; + SendResponse(false, GetMobileResultCode(vr_result), info.c_str()); + } +} + +bool CreateInteractionChoiceSetRequest::ProcessSuccesfulHMIResponse( + const uint32_t corr_id) { + SentCommandsMap::iterator it = sent_commands_map_.find(corr_id); + if (sent_commands_map_.end() == it) { + LOG4CXX_WARN(logger_, "HMI response for unknown VR command received"); + return false; + } + VRCommandInfo& vr_command = it->second; + vr_command.succesful_response_received_ = true; + return true; +} + +void CreateInteractionChoiceSetRequest::CountReceivedVRResponses() { + received_chs_count_++; + LOG4CXX_DEBUG(logger_, + "Got VR.AddCommand response, there are " + << expected_chs_count_ - received_chs_count_ + << " more to wait."); + if (received_chs_count_ < expected_chs_count_) { + application_manager_.updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + LOG4CXX_DEBUG(logger_, "Timeout for request was updated"); + } else { + OnAllHMIResponsesReceived(); + } +} + +void CreateInteractionChoiceSetRequest::on_event( + const event_engine::Event& event) { + using namespace hmi_apis; + using namespace helpers; + LOG4CXX_AUTO_TRACE(logger_); + + const smart_objects::SmartObject& message = event.smart_object(); + const Common_Result::eType result = static_cast<Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + const bool is_no_error = Compare<Common_Result::eType, EQ, ONE>( + result, Common_Result::SUCCESS, Common_Result::WARNINGS); + uint32_t corr_id = static_cast<uint32_t>( + message[strings::params][strings::correlation_id].asUInt()); + if (event.id() == hmi_apis::FunctionID::VR_AddCommand) { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); + { + sync_primitives::AutoLock commands_lock(vr_commands_lock_); + if (is_no_error) { + if (!ProcessSuccesfulHMIResponse(corr_id)) { + return; + } + } else { + ProcessHmiError(result); + } + } + CountReceivedVRResponses(); + } +} + +void CreateInteractionChoiceSetRequest::onTimeOut() { + LOG4CXX_AUTO_TRACE(logger_); + + if (!error_from_hmi_) { + SendResponse(false, mobile_apis::Result::GENERIC_ERROR); + } + CommandRequestImpl::onTimeOut(); + DeleteChoices(); + + // We have to keep request alive until receive all responses from HMI + // according to SDLAQ-CRS-2976 + sync_primitives::AutoLock timeout_lock_(is_timed_out_lock_); + is_timed_out_ = true; + application_manager_.TerminateRequest( + connection_key(), correlation_id(), function_id()); +} + +bool CreateInteractionChoiceSetRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +void CreateInteractionChoiceSetRequest::DeleteChoices() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + application->RemoveChoiceSet(choice_set_id_); + + smart_objects::SmartObject msg_param(smart_objects::SmartType_Map); + msg_param[strings::app_id] = application->app_id(); + + sync_primitives::AutoLock commands_lock(vr_commands_lock_); + SentCommandsMap::const_iterator it = sent_commands_map_.begin(); + for (; it != sent_commands_map_.end(); ++it) { + const VRCommandInfo& vr_command_info = it->second; + if (vr_command_info.succesful_response_received_) { + msg_param[strings::cmd_id] = vr_command_info.cmd_id_; + SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_param); + } else { + LOG4CXX_WARN(logger_, + "succesful response has not been received for cmd_id = " + << vr_command_info.cmd_id_); + } + } + sent_commands_map_.clear(); +} + +void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() { + LOG4CXX_AUTO_TRACE(logger_); + + if (!error_from_hmi_) { + SendResponse(true, mobile_apis::Result::SUCCESS); + } else { + DeleteChoices(); + } + + application_manager_.TerminateRequest( + connection_key(), correlation_id(), function_id()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_response.cc new file mode 100644 index 0000000000..807770ed12 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_response.cc @@ -0,0 +1,75 @@ +/* + + 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/create_interaction_choice_set_response.h" + +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +CreateInteractionChoiceSetResponse::CreateInteractionChoiceSetResponse( + 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) {} + +CreateInteractionChoiceSetResponse::~CreateInteractionChoiceSetResponse() {} + +void CreateInteractionChoiceSetResponse::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; + } + } + + SendResponse(true); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc new file mode 100644 index 0000000000..bbe787a123 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc @@ -0,0 +1,234 @@ +/* + + 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/delete_command_request.h" + +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" +#include "utils/helpers.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +DeleteCommandRequest::DeleteCommandRequest( + 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) + , is_ui_send_(false) + , is_vr_send_(false) + , is_ui_received_(false) + , is_vr_received_(false) + , ui_result_(hmi_apis::Common_Result::INVALID_ENUM) + , vr_result_(hmi_apis::Common_Result::INVALID_ENUM) {} + +DeleteCommandRequest::~DeleteCommandRequest() {} + +void DeleteCommandRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + const int32_t cmd_id = + (*message_)[strings::msg_params][strings::cmd_id].asInt(); + + smart_objects::SmartObject* command = application->FindCommand(cmd_id); + + if (!command) { + LOG4CXX_ERROR(logger_, "Command with id " << cmd_id << " is not found."); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + msg_params[strings::cmd_id] = + (*message_)[strings::msg_params][strings::cmd_id]; + msg_params[strings::app_id] = application->app_id(); + + // we should specify amount of required responses in the 1st request + uint32_t chaining_counter = 0; + if ((*command).keyExists(strings::menu_params)) { + ++chaining_counter; + } + + if ((*command).keyExists(strings::vr_commands)) { + ++chaining_counter; + } + /* Need to set all flags before sending request to HMI + * for correct processing this flags in method on_event */ + if ((*command).keyExists(strings::menu_params)) { + is_ui_send_ = true; + } + // check vr params + if ((*command).keyExists(strings::vr_commands)) { + is_vr_send_ = true; + } + if (is_ui_send_) { + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params, true); + } + if (is_vr_send_) { + // VR params + msg_params[strings::grammar_id] = application->get_grammar_id(); + msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); + SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params, true); + } +} + +bool DeleteCommandRequest::PrepareResponseParameters( + mobile_apis::Result::eType& result_code, std::string& info) { + using namespace helpers; + app_mngr::commands::ResponseInfo ui_delete_info( + ui_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); + app_mngr::commands::ResponseInfo vr_delete_info( + vr_result_, HmiInterfaces::HMI_INTERFACE_VR, application_manager_); + const bool result = + PrepareResultForMobileResponse(ui_delete_info, vr_delete_info); + + const bool is_vr_or_ui_warning = + Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + hmi_apis::Common_Result::WARNINGS, ui_result_, vr_result_); + info = app_mngr::commands::MergeInfos( + ui_delete_info, ui_info_, vr_delete_info, vr_info_); + if (is_vr_or_ui_warning && !ui_delete_info.is_unsupported_resource && + !vr_delete_info.is_unsupported_resource) { + LOG4CXX_DEBUG(logger_, "VR or UI result is warning"); + result_code = mobile_apis::Result::WARNINGS; + return result; + } + result_code = PrepareResultCodeForResponse(ui_delete_info, vr_delete_info); + LOG4CXX_DEBUG(logger_, "Result is " << (result ? "true" : "false")); + return result; +} + +void DeleteCommandRequest::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::UI_DeleteCommand: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + is_ui_received_ = true; + ui_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + LOG4CXX_DEBUG(logger_, + "Received UI_DeleteCommand event with result " + << MessageHelper::HMIResultToString(ui_result_)); + GetInfo(message, ui_info_); + break; + } + case hmi_apis::FunctionID::VR_DeleteCommand: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); + is_vr_received_ = true; + vr_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + LOG4CXX_DEBUG(logger_, + "Received VR_DeleteCommand event with result " + << MessageHelper::HMIResultToString(vr_result_)); + GetInfo(message, vr_info_); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } + + if (IsPendingResponseExist()) { + LOG4CXX_DEBUG(logger_, "Still awaiting for other responses."); + return; + } + + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + return; + } + smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; + + const int32_t cmd_id = msg_params[strings::cmd_id].asInt(); + + smart_objects::SmartObject* command = application->FindCommand(cmd_id); + + if (!command) { + LOG4CXX_ERROR(logger_, + "Command id " << cmd_id << " not found for " + "application with connection key " + << connection_key()); + return; + } + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; + std::string info; + const bool result = PrepareResponseParameters(result_code, info); + if (result) { + application->RemoveCommand(msg_params[strings::cmd_id].asInt()); + } + SendResponse( + result, result_code, info.empty() ? NULL : info.c_str(), &msg_params); +} + +bool DeleteCommandRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +bool DeleteCommandRequest::IsPendingResponseExist() { + LOG4CXX_AUTO_TRACE(logger_); + return is_ui_send_ != is_ui_received_ || is_vr_send_ != is_vr_received_; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_response.cc new file mode 100644 index 0000000000..8f85d50e28 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_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 "sdl_rpc_plugin/commands/mobile/delete_command_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +DeleteCommandResponse::DeleteCommandResponse( + 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) {} + +DeleteCommandResponse::~DeleteCommandResponse() {} + +void DeleteCommandResponse::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/delete_file_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_request.cc new file mode 100644 index 0000000000..cf8a6d259f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_request.cc @@ -0,0 +1,132 @@ +/* + + 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/delete_file_request.h" + +#include "application_manager/application_impl.h" + +#include "utils/file_system.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +DeleteFileRequest::DeleteFileRequest( + 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) {} + +DeleteFileRequest::~DeleteFileRequest() {} + +void DeleteFileRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + if (!application) { + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + LOG4CXX_ERROR(logger_, "Application is not registered"); + return; + } + + if ((mobile_api::HMILevel::HMI_NONE == application->hmi_level()) && + (application_manager_.get_settings().delete_file_in_none() <= + application->delete_file_in_none_count())) { + // If application is in the HMI_NONE level the quantity of allowed + // DeleteFile request is limited by the configuration profile + LOG4CXX_ERROR(logger_, + "Too many requests from the app with HMILevel HMI_NONE "); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + const std::string& sync_file_name = + (*message_)[strings::msg_params][strings::sync_file_name].asString(); + + if (!file_system::IsFileNameValid(sync_file_name)) { + const std::string err_msg = "Sync file name contains forbidden symbols."; + LOG4CXX_ERROR(logger_, err_msg); + SendResponse(false, mobile_apis::Result::INVALID_DATA, err_msg.c_str()); + return; + } + + std::string full_file_path = + application_manager_.get_settings().app_storage_folder() + "/"; + full_file_path += application->folder_name(); + full_file_path += "/"; + full_file_path += sync_file_name; + + if (file_system::FileExists(full_file_path)) { + if (file_system::DeleteFile(full_file_path)) { + const application_manager::AppFile* file = + application->GetFile(full_file_path); + if (file) { + SendFileRemovedNotification(file); + } + + application->DeleteFile(full_file_path); + application->increment_delete_file_in_none_count(); + SendResponse(true, mobile_apis::Result::SUCCESS); + } else { + SendResponse(false, mobile_apis::Result::GENERIC_ERROR); + } + } else { + SendResponse(false, mobile_apis::Result::REJECTED); + } +} + +void DeleteFileRequest::SendFileRemovedNotification( + const application_manager::AppFile* file) const { + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + msg_params[strings::app_id] = connection_key(); + msg_params[strings::file_name] = file->file_name; + msg_params[strings::file_type] = file->file_type; + + CreateHMINotification(hmi_apis::FunctionID::BasicCommunication_OnFileRemoved, + msg_params); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_response.cc new file mode 100644 index 0000000000..66c61c9e4a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_response.cc @@ -0,0 +1,75 @@ +/* + + 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/delete_file_response.h" + +#include "application_manager/application_impl.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +DeleteFileResponse::DeleteFileResponse( + 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) {} + +DeleteFileResponse::~DeleteFileResponse() {} + +void DeleteFileResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + uint32_t app_id = + (*message_)[strings::params][strings::connection_key].asUInt(); + ApplicationSharedPtr app = application_manager_.application(app_id); + if (!app) { + LOG4CXX_ERROR(logger_, "Application not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + (*message_)[strings::msg_params][strings::space_available] = + static_cast<uint32_t>(app->GetAvailableDiskSpace()); + SendResponse((*message_)[strings::msg_params][strings::success].asBool()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc new file mode 100644 index 0000000000..a9db3975db --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc @@ -0,0 +1,168 @@ +/* + + 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/delete_interaction_choice_set_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 { + +DeleteInteractionChoiceSetRequest::DeleteInteractionChoiceSetRequest( + 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) {} + +DeleteInteractionChoiceSetRequest::~DeleteInteractionChoiceSetRequest() {} + +void DeleteInteractionChoiceSetRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, + "No application associated with connection key " + << connection_key()); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + const int32_t choice_set_id = + (*message_)[strings::msg_params][strings::interaction_choice_set_id] + .asInt(); + + if (!app->FindChoiceSet(choice_set_id)) { + LOG4CXX_ERROR(logger_, + "Choice set with id " << choice_set_id << " is not found."); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + + if (ChoiceSetInUse(app)) { + LOG4CXX_ERROR(logger_, "Choice set currently in use."); + SendResponse(false, mobile_apis::Result::IN_USE); + return; + } + SendVrDeleteCommand(app); + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + msg_params[strings::interaction_choice_set_id] = choice_set_id; + msg_params[strings::app_id] = app->app_id(); + + app->RemoveChoiceSet(choice_set_id); + + // Checking of HMI responses will be implemented with APPLINK-14600 + const bool result = true; + SendResponse(result, mobile_apis::Result::SUCCESS); +} + +bool DeleteInteractionChoiceSetRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +bool DeleteInteractionChoiceSetRequest::ChoiceSetInUse( + ApplicationConstSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + if (!app->is_perform_interaction_active()) { + return false; + } + const DataAccessor<PerformChoiceSetMap> accessor = + app->performinteraction_choice_set_map(); + const PerformChoiceSetMap& choice_set_map = accessor.GetData(); + + const uint32_t choice_set_id = + (*message_)[strings::msg_params][strings::interaction_choice_set_id] + .asUInt(); + + PerformChoiceSetMap::const_iterator it = choice_set_map.begin(); + for (; choice_set_map.end() != it; ++it) { + const PerformChoice& choice = it->second; + PerformChoice::const_iterator choice_it = choice.begin(); + for (; choice.end() != choice_it; ++choice_it) { + if (choice_it->first == choice_set_id) { + LOG4CXX_ERROR(logger_, + "Choice set with id " << choice_set_id << " is in use."); + return true; + } + } + } + return true; +} + +void DeleteInteractionChoiceSetRequest::SendVrDeleteCommand( + application_manager::ApplicationSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + + const uint32_t choice_set_id = + (*message_)[strings::msg_params][strings::interaction_choice_set_id] + .asUInt(); + + smart_objects::SmartObject* choice_set = app->FindChoiceSet(choice_set_id); + + if (!choice_set) { + LOG4CXX_ERROR(logger_, + "Choice set with id " << choice_set_id << " is not found."); + return; + } + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[strings::app_id] = app->app_id(); + msg_params[strings::type] = hmi_apis::Common_VRCommandType::Choice; + msg_params[strings::grammar_id] = (*choice_set)[strings::grammar_id]; + choice_set = &((*choice_set)[strings::choice_set]); + for (uint32_t i = 0; i < (*choice_set).length(); ++i) { + msg_params[strings::cmd_id] = (*choice_set)[i][strings::choice_id]; + SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_response.cc new file mode 100644 index 0000000000..18ca60f255 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_response.cc @@ -0,0 +1,84 @@ +/* + + 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/delete_interaction_choice_set_response.h" + +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +DeleteInteractionChoiceSetResponse::DeleteInteractionChoiceSetResponse( + 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) {} + +DeleteInteractionChoiceSetResponse::~DeleteInteractionChoiceSetResponse() {} + +void DeleteInteractionChoiceSetResponse::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; + } + } + + const int32_t code = + (*message_)[strings::msg_params][strings::result_code].asInt(); + + if (hmi_apis::Common_Result::SUCCESS == code) { + SendResponse(true); + } else { + // TODO(DK): Some logic + SendResponse(false); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc new file mode 100644 index 0000000000..38113afcc2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc @@ -0,0 +1,201 @@ +/* + + 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/delete_sub_menu_request.h" + +#include "application_manager/message_helper.h" +#include "application_manager/application_impl.h" +#include "interfaces/HMI_API.h" +#include "utils/helpers.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +DeleteSubMenuRequest::DeleteSubMenuRequest( + 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) {} + +DeleteSubMenuRequest::~DeleteSubMenuRequest() {} + +void DeleteSubMenuRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + LOG4CXX_ERROR(logger_, "Application is not registered"); + return; + } + + const int32_t menu_id = + (*message_)[strings::msg_params][strings::menu_id].asInt(); + + if (!app->FindSubMenu(menu_id)) { + LOG4CXX_ERROR(logger_, "Menu with id " << menu_id << " is not found."); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + msg_params[strings::menu_id] = + (*message_)[strings::msg_params][strings::menu_id]; + msg_params[strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + + SendHMIRequest(hmi_apis::FunctionID::UI_DeleteSubMenu, &msg_params, true); +} + +void DeleteSubMenuRequest::DeleteSubMenuVRCommands( + ApplicationConstSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + + const DataAccessor<CommandsMap> accessor = app->commands_map(); + const CommandsMap& commands = accessor.GetData(); + CommandsMap::const_iterator it = commands.begin(); + + for (; commands.end() != it; ++it) { + if (!(*it->second).keyExists(strings::vr_commands)) { + continue; + } + + if ((*message_)[strings::msg_params][strings::menu_id].asInt() == + (*it->second)[strings::menu_params][hmi_request::parent_id].asInt()) { + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[strings::cmd_id] = (*it->second)[strings::cmd_id].asInt(); + msg_params[strings::app_id] = app->app_id(); + msg_params[strings::grammar_id] = app->get_grammar_id(); + msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; + + SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params); + } + } +} + +void DeleteSubMenuRequest::DeleteSubMenuUICommands( + ApplicationSharedPtr const app) { + LOG4CXX_AUTO_TRACE(logger_); + + const DataAccessor<CommandsMap> accessor(app->commands_map()); + const CommandsMap& commands = accessor.GetData(); + CommandsMap::const_iterator it = commands.begin(); + + while (commands.end() != it) { + if (!(*it->second).keyExists(strings::menu_params)) { + LOG4CXX_ERROR(logger_, "menu_params not exist"); + ++it; + continue; + } + + if ((*message_)[strings::msg_params][strings::menu_id].asInt() == + (*it->second)[strings::menu_params][hmi_request::parent_id].asInt()) { + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[strings::app_id] = app->app_id(); + msg_params[strings::cmd_id] = (*it->second)[strings::cmd_id].asInt(); + app->RemoveCommand((*it->second)[strings::cmd_id].asInt()); + it = commands.begin(); // Can not relay on + // iterators after erase was called + + SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params); + } else { + ++it; + } + } +} + +void DeleteSubMenuRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_DeleteSubMenu: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(message, response_info); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_UI); + + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + if (result) { + // delete sub menu items from SDL and HMI + DeleteSubMenuVRCommands(application); + DeleteSubMenuUICommands(application); + application->RemoveSubMenu( + (*message_)[strings::msg_params][strings::menu_id].asInt()); + } + + SendResponse(result, + 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; + } + } +} + +bool DeleteSubMenuRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_response.cc new file mode 100644 index 0000000000..6831a66e1e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_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 "sdl_rpc_plugin/commands/mobile/delete_sub_menu_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +DeleteSubMenuResponse::DeleteSubMenuResponse( + 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) {} + +DeleteSubMenuResponse::~DeleteSubMenuResponse() {} + +void DeleteSubMenuResponse::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/dial_number_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_request.cc new file mode 100644 index 0000000000..ee0297ded6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_request.cc @@ -0,0 +1,156 @@ +/* + 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 <algorithm> +#include <string> +#include "sdl_rpc_plugin/commands/mobile/dial_number_request.h" + +#include "application_manager/application_impl.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +DialNumberRequest::DialNumberRequest( + 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) {} + +DialNumberRequest::~DialNumberRequest() {} + +bool DialNumberRequest::Init() { + LOG4CXX_AUTO_TRACE(logger_); + + default_timeout_ = 0; + + return true; +} + +void DialNumberRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + std::string number = + (*message_)[strings::msg_params][strings::number].asString(); + if (!CheckSyntax(number)) { + LOG4CXX_ERROR(logger_, "Invalid incoming data"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + StripNumberParam(number); + if (number.empty()) { + LOG4CXX_ERROR(logger_, + "After strip number param is empty. Invalid incoming data"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[strings::number] = + (*message_)[strings::msg_params][strings::number].asString(); + msg_params[strings::app_id] = application->hmi_app_id(); + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_BasicCommunication); + SendHMIRequest( + hmi_apis::FunctionID::BasicCommunication_DialNumber, &msg_params, true); +} + +void DialNumberRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + const smart_objects::SmartObject& message = event.smart_object(); + mobile_apis::Result::eType result_code = mobile_apis::Result::SUCCESS; + switch (event.id()) { + case hmi_apis::FunctionID::BasicCommunication_DialNumber: { + LOG4CXX_INFO(logger_, "Received DialNumber event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_BasicCommunication); + result_code = CommandRequestImpl::GetMobileResultCode( + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt())); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } + + const bool is_success = mobile_apis::Result::SUCCESS == result_code; + const bool is_info_valid = + message[strings::msg_params].keyExists(strings::info); + + if (is_info_valid) { + const char* info_char_array = + message[strings::msg_params][strings::info].asCharArray(); + SendResponse(is_success, result_code, info_char_array); + return; + } + + SendResponse(is_success, result_code); +} + +void DialNumberRequest::StripNumberParam(std::string& number) { + std::size_t found = 0; + while (std::string::npos != + (found = number.find_first_not_of("0123456789*#,;+"))) { + number.erase(number.begin() + found); + } + (*message_)[strings::msg_params][strings::number] = number; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_response.cc new file mode 100644 index 0000000000..a264f96e0d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_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 "sdl_rpc_plugin/commands/mobile/dial_number_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +DialNumberResponse::DialNumberResponse( + 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) {} + +DialNumberResponse::~DialNumberResponse() {} + +void DialNumberResponse::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/end_audio_pass_thru_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_request.cc new file mode 100644 index 0000000000..3650a8226c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_request.cc @@ -0,0 +1,100 @@ +/* + + 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/end_audio_pass_thru_request.h" +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +EndAudioPassThruRequest::EndAudioPassThruRequest( + 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) {} + +EndAudioPassThruRequest::~EndAudioPassThruRequest() {} + +void EndAudioPassThruRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_EndAudioPassThru, NULL, true); +} + +void EndAudioPassThruRequest::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::UI_EndAudioPassThru: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asUInt()); + std::string response_info; + GetInfo(message, response_info); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_UI); + if (result) { + uint32_t app_id = connection_key(); + bool ended_successfully = application_manager_.EndAudioPassThru(app_id); + if (ended_successfully) { + application_manager_.StopAudioPassThru(app_id); + } + } + + 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/end_audio_pass_thru_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_response.cc new file mode 100644 index 0000000000..f9f9f89d11 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_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 "sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +EndAudioPassThruResponse::EndAudioPassThruResponse( + 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) {} + +EndAudioPassThruResponse::~EndAudioPassThruResponse() {} + +void EndAudioPassThruResponse::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/generic_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/generic_response.cc new file mode 100644 index 0000000000..eef2750376 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/generic_response.cc @@ -0,0 +1,66 @@ +/* + + 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/generic_response.h" + +#include "application_manager/application_impl.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +void GenericResponse::Run() { + /*NsSmartDeviceLink::NsSmartObjects::SmartObject response; + + response[strings::params][strings::correlation_id] = + (*message_)[strings::params][strings::correlation_id]; + response[strings::params][strings::protocol_version] = + (*message_)[strings::params][strings::protocol_version]; + response[strings::params][strings::connection_key] = + (*message_)[strings::params][strings::connection_key]; + + response[strings::msg_params][strings::success] = false; + */ + + (*message_)[strings::params][strings::message_type] = MessageType::kResponse; + (*message_)[strings::msg_params][strings::success] = false; + (*message_)[strings::msg_params][strings::result_code] = + mobile_apis::Result::INVALID_DATA; + + SendResponse(false); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc new file mode 100644 index 0000000000..a6c627aad2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc @@ -0,0 +1,143 @@ +/* + 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_system_capability_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +GetSystemCapabilityRequest::GetSystemCapabilityRequest( + 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) {} + +GetSystemCapabilityRequest::~GetSystemCapabilityRequest() {} + +void GetSystemCapabilityRequest::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; + } + + if ((*message_)[strings::msg_params].empty()) { + LOG4CXX_ERROR(logger_, strings::msg_params << " is empty."); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + smart_objects::SmartObject response_params(smart_objects::SmartType_Map); + mobile_apis::SystemCapabilityType::eType response_type = + static_cast<mobile_apis::SystemCapabilityType::eType>( + (*message_)[strings::msg_params][strings::system_capability_type] + .asInt()); + response_params[strings::system_capability][strings::system_capability_type] = + response_type; + + const HMICapabilities& hmi_capabilities = hmi_capabilities_; + + switch (response_type) { + case mobile_apis::SystemCapabilityType::NAVIGATION: { + if (hmi_capabilities.navigation_capability()) { + response_params[strings::system_capability] + [strings::navigation_capability] = + *hmi_capabilities.navigation_capability(); + } else { + SendResponse(false, mobile_apis::Result::DATA_NOT_AVAILABLE); + return; + } + break; + } + case mobile_apis::SystemCapabilityType::PHONE_CALL: { + if (hmi_capabilities.phone_capability()) { + response_params[strings::system_capability][strings::phone_capability] = + *hmi_capabilities.phone_capability(); + } else { + SendResponse(false, mobile_apis::Result::DATA_NOT_AVAILABLE); + return; + } + break; + } + case mobile_apis::SystemCapabilityType::REMOTE_CONTROL: { + if (!app->is_remote_control_supported()) { + SendResponse(false, mobile_apis::Result::DISALLOWED); + return; + } + if (!hmi_capabilities.is_rc_cooperating()) { + SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE); + return; + } + if (hmi_capabilities.rc_capability()) { + response_params[strings::system_capability][strings::rc_capability] = + *hmi_capabilities.rc_capability(); + } else { + SendResponse(false, mobile_apis::Result::DATA_NOT_AVAILABLE); + return; + } + break; + } + case mobile_apis::SystemCapabilityType::VIDEO_STREAMING: + if (hmi_capabilities.video_streaming_capability()) { + response_params[strings::system_capability] + [strings::video_streaming_capability] = + *hmi_capabilities.video_streaming_capability(); + } else { + SendResponse(false, mobile_apis::Result::DATA_NOT_AVAILABLE); + return; + } + break; + default: // Return unsupported resource + SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE); + return; + } + SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params); +} + +void GetSystemCapabilityRequest::on_event(const event_engine::Event& event) { + LOG4CXX_INFO(logger_, "GetSystemCapabilityRequest on_event"); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_response.cc new file mode 100644 index 0000000000..dd5461081c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_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 "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" +#include "sdl_rpc_plugin/commands/mobile/get_system_capability_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +GetSystemCapabilityResponse::GetSystemCapabilityResponse( + 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) {} + +GetSystemCapabilityResponse::~GetSystemCapabilityResponse() {} + +void GetSystemCapabilityResponse::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_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc new file mode 100644 index 0000000000..7dc9eb9ad9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc @@ -0,0 +1,116 @@ +/* + 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 "application_manager/application_manager.h" +#include "sdl_rpc_plugin/commands/mobile/get_way_points_request.h" +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +GetWayPointsRequest::GetWayPointsRequest( + 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) { + subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); +} + +GetWayPointsRequest::~GetWayPointsRequest() {} + +void GetWayPointsRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, + "An application with connection key " + << connection_key() << " is not registered."); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + msg_params = (*message_)[strings::msg_params]; + msg_params[strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); + SendHMIRequest(hmi_apis::FunctionID::Navigation_GetWayPoints, + msg_params.empty() ? NULL : &msg_params, + true); +} + +void GetWayPointsRequest::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::UI_OnResetTimeout: { + LOG4CXX_INFO(logger_, "Received UI_OnResetTimeout event"); + application_manager_.updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + break; + } + case hmi_apis::FunctionID::Navigation_GetWayPoints: { + LOG4CXX_INFO(logger_, "Received Navigation_GetWayPoints event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); + const hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(message, response_info); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_Navigation); + 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()); + break; + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_response.cc new file mode 100644 index 0000000000..7581990273 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_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 "application_manager/application_manager.h" +#include "sdl_rpc_plugin/commands/mobile/get_way_points_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +GetWayPointsResponse::GetWayPointsResponse( + 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) {} + +GetWayPointsResponse::~GetWayPointsResponse() {} + +void GetWayPointsResponse::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/list_files_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_request.cc new file mode 100644 index 0000000000..e671dab463 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_request.cc @@ -0,0 +1,115 @@ +/* + + 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 <string> +#include "sdl_rpc_plugin/commands/mobile/list_files_request.h" + +#include "application_manager/application_impl.h" + +#include "sdl_rpc_plugin/mobile_command_factory.h" +#include "utils/file_system.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +ListFilesRequest::ListFilesRequest( + 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) {} + +ListFilesRequest::~ListFilesRequest() {} + +void ListFilesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + if (!application) { + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + LOG4CXX_ERROR(logger_, "Application is not registered"); + return; + } + + if ((mobile_api::HMILevel::HMI_NONE == application->hmi_level()) && + (application_manager_.get_settings().list_files_in_none() <= + application->list_files_in_none_count())) { + // If application is in the HMI_NONE level the quantity of allowed + // DeleteFile request is limited by the configuration profile + LOG4CXX_ERROR(logger_, + "Too many requests from the app with HMILevel HMI_NONE "); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + application->increment_list_files_in_none_count(); + + (*message_)[strings::msg_params][strings::space_available] = + static_cast<int32_t>(application->GetAvailableDiskSpace()); + // Enumarating through File system + uint32_t i = 0; + std::string directory_name = + application_manager_.get_settings().app_storage_folder(); + directory_name += "/" + application->folder_name(); + std::vector<std::string> persistent_files = + file_system::ListFiles(directory_name); + std::vector<std::string>::const_iterator it = persistent_files.begin(); + for (; it != persistent_files.end(); ++it) { + if (i < application_manager_.get_settings().list_files_response_size()) { + LOG4CXX_DEBUG(logger_, "File " + *it + " added to ListFiles response"); + (*message_)[strings::msg_params][strings::filenames][i++] = *it; + } else { + LOG4CXX_DEBUG(logger_, + "File " + *it + " not added to ListFiles response"); + } + } + (*message_)[strings::params][strings::message_type] = + application_manager::MessageType::kResponse; + SendResponse(true, + mobile_apis::Result::SUCCESS, + NULL, + &(*message_)[strings::msg_params]); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_response.cc new file mode 100644 index 0000000000..d025f05358 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_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 "sdl_rpc_plugin/commands/mobile/list_files_response.h" +#include "application_manager/rpc_service.h" +#include "application_manager/application_impl.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +ListFilesResponse::ListFilesResponse( + 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) {} + +ListFilesResponse::~ListFilesResponse() {} + +void ListFilesResponse::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_app_interface_unregistered_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_app_interface_unregistered_notification.cc new file mode 100644 index 0000000000..128ce1e3bf --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_app_interface_unregistered_notification.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 "sdl_rpc_plugin/commands/mobile/on_app_interface_unregistered_notification.h" +#include "application_manager/message.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +OnAppInterfaceUnregisteredNotification::OnAppInterfaceUnregisteredNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandNotificationImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnAppInterfaceUnregisteredNotification:: + ~OnAppInterfaceUnregisteredNotification() {} + +void OnAppInterfaceUnregisteredNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendNotification(); +} +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_audio_pass_thru_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_audio_pass_thru_notification.cc new file mode 100644 index 0000000000..ff88ae96bd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_audio_pass_thru_notification.cc @@ -0,0 +1,60 @@ +/* + + 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_audio_pass_thru_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +OnAudioPassThruNotification::OnAudioPassThruNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandNotificationImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnAudioPassThruNotification::~OnAudioPassThruNotification() {} + +void OnAudioPassThruNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendNotification(); +} +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc new file mode 100644 index 0000000000..0dda8b3277 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc @@ -0,0 +1,183 @@ +/* + + 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_button_event_notification.h" + +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace mobile { + +OnButtonEventNotification::OnButtonEventNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandNotificationImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnButtonEventNotification::~OnButtonEventNotification() {} + +void OnButtonEventNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + const uint32_t btn_id = static_cast<uint32_t>( + (*message_)[strings::msg_params][hmi_response::button_name].asInt()); + + const bool is_app_id_exists = + (*message_)[strings::msg_params].keyExists(strings::app_id); + ApplicationSharedPtr app; + + // CUSTOM_BUTTON notification + if (static_cast<uint32_t>(mobile_apis::ButtonName::CUSTOM_BUTTON) == btn_id) { + // app_id is mandatory for CUSTOM_BUTTON notification + if (!is_app_id_exists) { + LOG4CXX_ERROR(logger_, "CUSTOM_BUTTON OnButtonEvent without app_id."); + return; + } + + app = application_manager_.application( + (*message_)[strings::msg_params][strings::app_id].asUInt()); + + // custom_button_id is mandatory for CUSTOM_BUTTON notification + if (false == + (*message_)[strings::msg_params].keyExists( + hmi_response::custom_button_id)) { + LOG4CXX_ERROR(logger_, + "CUSTOM_BUTTON OnButtonEvent without custom_button_id."); + return; + } + + if (!app) { + LOG4CXX_ERROR(logger_, "Application doesn't exist."); + return; + } + + uint32_t custom_btn_id = 0; + custom_btn_id = + (*message_)[strings::msg_params][hmi_response::custom_button_id] + .asUInt(); + + if (false == app->IsSubscribedToSoftButton(custom_btn_id)) { + LOG4CXX_ERROR(logger_, + "Application doesn't subscribed to this custom_button_id."); + return; + } + + if ((mobile_api::HMILevel::HMI_FULL != app->hmi_level()) && + (mobile_api::HMILevel::HMI_LIMITED != app->hmi_level())) { + LOG4CXX_WARN(logger_, + "CUSTOM_BUTTON OnButtonEvent notification is allowed only " + << "in FULL or LIMITED hmi level"); + return; + } + + SendButtonEvent(app); + return; + } + + const std::vector<ApplicationSharedPtr>& subscribed_apps = + application_manager_.applications_by_button(btn_id); + + std::vector<ApplicationSharedPtr>::const_iterator it = + subscribed_apps.begin(); + for (; subscribed_apps.end() != it; ++it) { + ApplicationSharedPtr subscribed_app = *it; + if (!subscribed_app) { + LOG4CXX_WARN(logger_, "Null pointer to subscribed app."); + continue; + } + + // Send ButtonEvent notification only in HMI_FULL or HMI_LIMITED mode + if ((mobile_api::HMILevel::HMI_FULL != subscribed_app->hmi_level()) && + (mobile_api::HMILevel::HMI_LIMITED != subscribed_app->hmi_level())) { + LOG4CXX_WARN(logger_, + "OnButtonEvent notification is allowed only" + << "in FULL or LIMITED hmi level"); + continue; + } + // if "app_id" absent send notification only in HMI_FULL mode + if (is_app_id_exists || subscribed_app->IsFullscreen()) { + SendButtonEvent(subscribed_app); + } + } +} + +void OnButtonEventNotification::SendButtonEvent(ApplicationConstSharedPtr app) { + if (!app) { + LOG4CXX_ERROR(logger_, "OnButtonEvent NULL pointer"); + return; + } + + smart_objects::SmartObjectSPtr on_btn_event = + new smart_objects::SmartObject(); + + if (!on_btn_event) { + LOG4CXX_ERROR(logger_, "OnButtonEvent NULL pointer"); + return; + } + + (*on_btn_event)[strings::params][strings::connection_key] = app->app_id(); + + (*on_btn_event)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnButtonEventID); + + (*on_btn_event)[strings::msg_params][strings::button_name] = + (*message_)[strings::msg_params][hmi_response::button_name]; + (*on_btn_event)[strings::msg_params][strings::button_event_mode] = + (*message_)[strings::msg_params][hmi_response::button_mode]; + + if ((*message_)[strings::msg_params].keyExists( + hmi_response::custom_button_id)) { + (*on_btn_event)[strings::msg_params][strings::custom_button_id] = + (*message_)[strings::msg_params][strings::custom_button_id]; + } + + message_ = on_btn_event; + SendNotification(); +} + +} // namespace mobile + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc new file mode 100644 index 0000000000..06ff29134c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc @@ -0,0 +1,190 @@ +/* + + 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_button_press_notification.h" + +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace mobile { + +OnButtonPressNotification::OnButtonPressNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandNotificationImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnButtonPressNotification::~OnButtonPressNotification() {} + +void OnButtonPressNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + const uint32_t btn_id = static_cast<uint32_t>( + (*message_)[strings::msg_params][hmi_response::button_name].asInt()); + + const bool is_app_id_exists = + (*message_)[strings::msg_params].keyExists(strings::app_id); + ApplicationSharedPtr app; + + // CUSTOM_BUTTON notification + if (static_cast<uint32_t>(mobile_apis::ButtonName::CUSTOM_BUTTON) == btn_id) { + // app_id is mandatory for CUSTOM_BUTTON notification + if (!is_app_id_exists) { + LOG4CXX_ERROR(logger_, "CUSTOM_BUTTON OnButtonPress without app_id."); + return; + } + + app = application_manager_.application( + (*message_)[strings::msg_params][strings::app_id].asUInt()); + + // custom_button_id is mandatory for CUSTOM_BUTTON notification + if (false == + (*message_)[strings::msg_params].keyExists( + hmi_response::custom_button_id)) { + LOG4CXX_ERROR(logger_, + "CUSTOM_BUTTON OnButtonPress without custom_button_id."); + return; + } + + if (!app) { + LOG4CXX_ERROR(logger_, "Application doesn't exist."); + return; + } + + uint32_t custom_btn_id = 0; + custom_btn_id = + (*message_)[strings::msg_params][hmi_response::custom_button_id] + .asUInt(); + + if (false == app->IsSubscribedToSoftButton(custom_btn_id)) { + LOG4CXX_ERROR(logger_, + "Application doesn't subscribed to this custom_button_id."); + return; + } + + // Send ButtonPress notification only in HMI_FULL or HMI_LIMITED mode + if ((mobile_api::HMILevel::HMI_FULL != app->hmi_level()) && + (mobile_api::HMILevel::HMI_LIMITED != app->hmi_level())) { + LOG4CXX_WARN(logger_, + "CUSTOM_BUTTON OnButtonPress notification is allowed only " + << "in FULL or LIMITED hmi level"); + return; + } + + SendButtonPress(app); + return; + } + + const std::vector<ApplicationSharedPtr>& subscribed_apps = + application_manager_.applications_by_button(btn_id); + + std::vector<ApplicationSharedPtr>::const_iterator it = + subscribed_apps.begin(); + for (; subscribed_apps.end() != it; ++it) { + ApplicationSharedPtr subscribed_app = *it; + if (!subscribed_app) { + LOG4CXX_WARN(logger_, "Null pointer to subscribed app."); + continue; + } + + // Send ButtonPress notification only in HMI_FULL or HMI_LIMITED mode + if ((mobile_api::HMILevel::HMI_FULL != subscribed_app->hmi_level()) && + (mobile_api::HMILevel::HMI_LIMITED != subscribed_app->hmi_level())) { + LOG4CXX_WARN(logger_, + "OnButtonPress notification is allowed only" + << "in FULL or LIMITED hmi level"); + continue; + } + // if "appID" is present, send it to named app only if its FULL or + // LIMITED + if (app.valid()) { + if (app->app_id() == subscribed_app->app_id()) { + SendButtonPress(subscribed_app); + } + } else if (subscribed_app->IsFullscreen()) { + // if No "appID" - send it FULL apps only. + SendButtonPress(subscribed_app); + } + } +} + +void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) { + if (!app) { + LOG4CXX_ERROR(logger_, "OnButtonPress NULL pointer"); + return; + } + + smart_objects::SmartObjectSPtr on_btn_press = + new smart_objects::SmartObject(); + + if (!on_btn_press) { + LOG4CXX_ERROR(logger_, "OnButtonPress NULL pointer"); + return; + } + + (*on_btn_press)[strings::params][strings::connection_key] = app->app_id(); + + (*on_btn_press)[strings::params][strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnButtonPressID); + + (*on_btn_press)[strings::msg_params][strings::button_name] = + (*message_)[strings::msg_params][hmi_response::button_name]; + (*on_btn_press)[strings::msg_params][strings::button_press_mode] = + (*message_)[strings::msg_params][hmi_response::button_mode]; + + if ((*message_)[strings::msg_params].keyExists( + hmi_response::custom_button_id)) { + (*on_btn_press)[strings::msg_params][strings::custom_button_id] = + (*message_)[strings::msg_params][strings::custom_button_id]; + } + + message_ = on_btn_press; + SendNotification(); +} + +} // namespace mobile + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_command_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_command_notification.cc new file mode 100644 index 0000000000..dff3aa6808 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_command_notification.cc @@ -0,0 +1,87 @@ +/* + + 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_command_notification.h" + +#include "application_manager/application_impl.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnCommandNotification::OnCommandNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandNotificationImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnCommandNotification::~OnCommandNotification() {} + +void OnCommandNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application( + (*message_)[strings::msg_params][strings::app_id].asInt()); + + if (!app) { + LOG4CXX_ERROR(logger_, "No application associated with session key"); + return; + } + + const uint32_t cmd_id = + (*message_)[strings::msg_params][strings::cmd_id].asUInt(); + + if (!app->FindCommand(cmd_id)) { + LOG4CXX_ERROR(logger_, " No applications found for the command " << cmd_id); + return; + } + + (*message_)[strings::params][strings::connection_key] = app->app_id(); + // remove app_id from notification + if ((*message_)[strings::msg_params].keyExists(strings::app_id)) { + (*message_)[strings::msg_params].erase(strings::app_id); + } + + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_driver_distraction_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_driver_distraction_notification.cc new file mode 100644 index 0000000000..ca5d4bfed4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_driver_distraction_notification.cc @@ -0,0 +1,70 @@ +/* + + 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_driver_distraction_notification.h" + +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace mobile { + +OnDriverDistractionNotification::OnDriverDistractionNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandNotificationImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnDriverDistractionNotification::~OnDriverDistractionNotification() {} + +void OnDriverDistractionNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendNotification(); +} + +} // namespace mobile + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hash_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hash_change_notification.cc new file mode 100644 index 0000000000..e252b031e6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hash_change_notification.cc @@ -0,0 +1,84 @@ + +/* + + 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_hash_change_notification.h" + +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" +#include <string> + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace mobile { + +OnHashChangeNotification::OnHashChangeNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandNotificationImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnHashChangeNotification::~OnHashChangeNotification() {} + +void OnHashChangeNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + (*message_)[strings::params][strings::message_type] = + static_cast<int32_t>(application_manager::MessageType::kNotification); + + int32_t app_id; + app_id = (*message_)[strings::params][strings::connection_key].asInt(); + ApplicationSharedPtr app = application_manager_.application(app_id); + if (app) { + (*message_)[strings::msg_params][strings::hash_id] = app->curHash(); + SendNotification(); + } else { + LOG4CXX_WARN(logger_, + "Application with app_id " << app_id << " does not exist"); + } +} + +} // namespace mobile + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc new file mode 100644 index 0000000000..a495423bce --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc @@ -0,0 +1,104 @@ +/* + + 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_hmi_status_notification.h" + +#include "application_manager/message_helper.h" +#include "application_manager/message.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +OnHMIStatusNotification::OnHMIStatusNotification( + 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) {} + +OnHMIStatusNotification::~OnHMIStatusNotification() {} + +void OnHMIStatusNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + (*message_)[strings::params][strings::message_type] = + static_cast<int32_t>(application_manager::MessageType::kNotification); + ApplicationSharedPtr app = application_manager_.application(connection_key()); + if (!app.valid()) { + LOG4CXX_ERROR(logger_, "OnHMIStatusNotification application doesn't exist"); + return; + } + + // If the response has no hmi level, return and don't send the notification + if (!(*message_)[strings::msg_params].keyExists(strings::hmi_level)) { + // our notification clearly isn't well-formed + LOG4CXX_ERROR(logger_, "OnHMIStatusNotification has no hmiLevel field"); + return; + } + + // NOTE c++ maps default-construct on the [] operator, so if there is no + // hmiLevel field this will create one that is invalid + mobile_apis::HMILevel::eType hmi_level = + static_cast<mobile_apis::HMILevel::eType>( + (*message_)[strings::msg_params][strings::hmi_level].asInt()); + if ((mobile_apis::HMILevel::HMI_BACKGROUND == hmi_level) || + (mobile_apis::HMILevel::HMI_NONE == hmi_level)) { + if (!(app->tts_properties_in_none())) { + app->set_tts_properties_in_none(true); + LOG4CXX_INFO(logger_, + "OnHMIStatusNotification::Send TTS GlobalProperties" + " with empty array to HMI"); + MessageHelper::SendTTSGlobalProperties(app, false, application_manager_); + } + } else if ((mobile_apis::HMILevel::HMI_FULL == hmi_level) || + (mobile_apis::HMILevel::HMI_LIMITED == hmi_level)) { + if (!(app->tts_properties_in_full())) { + app->set_tts_properties_in_full(true); + LOG4CXX_INFO(logger_, + "OnHMIStatusNotification AddAppToTTSGlobalPropertiesList"); + application_manager_.AddAppToTTSGlobalPropertiesList(app->app_id()); + } + } + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification_from_mobile.cc new file mode 100644 index 0000000000..45caedfc2e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification_from_mobile.cc @@ -0,0 +1,135 @@ +/* + + 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_hmi_status_notification_from_mobile.h" +#include "application_manager/message_helper.h" +#include "application_manager/message.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +OnHMIStatusNotificationFromMobile::OnHMIStatusNotificationFromMobile( + 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) + : CommandNotificationFromMobileImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnHMIStatusNotificationFromMobile::~OnHMIStatusNotificationFromMobile() {} + +void OnHMIStatusNotificationFromMobile::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + (*message_)[strings::params][strings::message_type] = + static_cast<int32_t>(application_manager::MessageType::kNotification); + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app.valid()) { + LOG4CXX_ERROR( + logger_, "OnHMIStatusNotificationFromMobile application doesn't exist"); + return; + } + + mobile_apis::HMILevel::eType current_hmi_state = + static_cast<mobile_apis::HMILevel::eType>( + (*message_)[strings::msg_params][strings::hmi_level].asUInt()); + + bool is_current_state_foreground = + mobile_apis::HMILevel::HMI_FULL == current_hmi_state; + + app->set_foreground(is_current_state_foreground); + + connection_handler::DeviceHandle handle = app->device(); + bool is_apps_requested_before = + application_manager_.IsAppsQueriedFrom(handle); + + LOG4CXX_DEBUG(logger_, + "Mobile HMI state notication came for connection key:" + << connection_key() << " and handle: " << handle); + + if (!is_apps_requested_before && + Message::is_sufficient_version( + protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4, + app->protocol_version()) && + app->is_foreground()) { + // In case this notification will be received from mobile side with + // foreground level for app on mobile, this should trigger remote + // apps list query for SDL 4.0+ app + MessageHelper::SendQueryApps(connection_key(), application_manager_); + return; + } + + if (is_apps_requested_before) { + LOG4CXX_DEBUG(logger_, + "Remote apps list had been requested already " + " for handle: " + << handle); + + if (Message::is_sufficient_version( + protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4, + app->protocol_version())) { + const ApplicationSet& accessor = + application_manager_.applications().GetData(); + + bool is_another_foreground_sdl4_app = false; + ApplicationSetConstIt it = accessor.begin(); + for (; accessor.end() != it; ++it) { + if (connection_key() != (*it)->app_id() && + Message::is_sufficient_version( + protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4, + (*it)->protocol_version()) && + (*it)->is_foreground()) { + is_another_foreground_sdl4_app = true; + break; + } + } + + if (!is_another_foreground_sdl4_app) { + application_manager_.MarkAppsGreyOut(handle, + !is_current_state_foreground); + application_manager_.SendUpdateAppList(); + } + } + return; + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_keyboard_input_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_keyboard_input_notification.cc new file mode 100644 index 0000000000..2065c0b52d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_keyboard_input_notification.cc @@ -0,0 +1,96 @@ +/* + + 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_keyboard_input_notification.h" + +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace mobile { + +OnKeyBoardInputNotification::OnKeyBoardInputNotification( + 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) {} + +OnKeyBoardInputNotification::~OnKeyBoardInputNotification() {} + +void OnKeyBoardInputNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app_to_notify; + + DataAccessor<ApplicationSet> accessor = application_manager_.applications(); + ApplicationSetIt it = accessor.GetData().begin(); + for (; accessor.GetData().end() != it; ++it) { + // if there is app with active perform interaction use it for notification + ApplicationSharedPtr app = *it; + if (app->is_perform_interaction_active() && + (*it)->perform_interaction_layout() == + mobile_apis::LayoutMode::KEYBOARD) { + LOG4CXX_INFO(logger_, + "There is application with active PerformInteraction"); + app_to_notify = app; + break; + } + + if (mobile_apis::HMILevel::eType::HMI_FULL == app->hmi_level()) { + LOG4CXX_INFO(logger_, "There is application in HMI_FULL level"); + app_to_notify = app; + } + } + + if (app_to_notify.valid()) { + (*message_)[strings::params][strings::connection_key] = + app_to_notify->app_id(); + SendNotification(); + } +} + +} // namespace mobile + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_language_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_language_change_notification.cc new file mode 100644 index 0000000000..fdbdd910a0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_language_change_notification.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 "sdl_rpc_plugin/commands/mobile/on_language_change_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnLanguageChangeNotification::OnLanguageChangeNotification( + 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) {} + +OnLanguageChangeNotification::~OnLanguageChangeNotification() {} + +void OnLanguageChangeNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_permissions_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_permissions_change_notification.cc new file mode 100644 index 0000000000..32d940aca2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_permissions_change_notification.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 "sdl_rpc_plugin/commands/mobile/on_permissions_change_notification.h" +#include "application_manager/message.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnPermissionsChangeNotification::OnPermissionsChangeNotification( + 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) {} + +OnPermissionsChangeNotification::~OnPermissionsChangeNotification() {} + +void OnPermissionsChangeNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc new file mode 100644 index 0000000000..419024f9b0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc @@ -0,0 +1,229 @@ +/* + 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 <cstring> +#include <cstdio> +#include <string> +#include "sdl_rpc_plugin/commands/mobile/on_system_request_notification.h" +#include "interfaces/MOBILE_API.h" +#include "utils/file_system.h" +#include "policy/policy_table/enums.h" +#include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace mobile { + +OnSystemRequestNotification::OnSystemRequestNotification( + 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) {} + +OnSystemRequestNotification::~OnSystemRequestNotification() {} + +void OnSystemRequestNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + using namespace application_manager; + using namespace mobile_apis; + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app.valid()) { + LOG4CXX_ERROR(logger_, + "Application with connection key " << connection_key() + << " is not registered."); + return; + } + + const mobile_apis::RequestType::eType request_type = + static_cast<mobile_apis::RequestType::eType>( + (*message_)[strings::msg_params][strings::request_type].asInt()); + const policy::PolicyHandlerInterface& policy_handler = policy_handler_; + const std::string stringified_request_type = + rpc::policy_table_interface_base::EnumToJsonString( + static_cast<rpc::policy_table_interface_base::RequestType>( + request_type)); + + if (!policy_handler.IsRequestTypeAllowed(app->policy_app_id(), + request_type)) { + LOG4CXX_WARN(logger_, + "Request type " << stringified_request_type + << " is not allowed by policies"); + return; + } + + const bool request_subtype_present = + (*message_)[strings::msg_params].keyExists(strings::request_subtype); + if (request_subtype_present) { + const std::string request_subtype = + (*message_)[strings::msg_params][strings::request_subtype].asString(); + if (!policy_handler.IsRequestSubTypeAllowed(app->policy_app_id(), + request_subtype)) { + LOG4CXX_ERROR(logger_, + "Request subtype: " << request_subtype + << " is DISALLOWED by policies"); + return; + } + } + + if (mobile_apis::RequestType::PROPRIETARY == request_type) { + /* According to requirements: + "If the requestType = PROPRIETARY, add to mobile API fileType = JSON + If the requestType = HTTP, add to mobile API fileType = BINARY" + Also in Genivi SDL we don't save the PT to file - we put it directly in + binary_data */ + + const std::string filename = + (*message_)[strings::msg_params][strings::file_name].asString(); + BinaryMessage binary_data; + file_system::ReadBinaryFile(filename, binary_data); +#if defined(PROPRIETARY_MODE) + AddHeader(binary_data); +#endif // PROPRIETARY_MODE + +#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) + (*message_)[strings::params][strings::binary_data] = binary_data; +#endif // PROPRIETARY_MODE + + (*message_)[strings::msg_params][strings::file_type] = FileType::JSON; + } else if (mobile_apis::RequestType::HTTP == request_type) { + (*message_)[strings::msg_params][strings::file_type] = FileType::BINARY; + if ((*message_)[strings::msg_params].keyExists(strings::url)) { + (*message_)[strings::msg_params][strings::timeout] = + policy_handler.TimeoutExchangeSec(); + } + } + + SendNotification(); +} + +#ifdef PROPRIETARY_MODE +void OnSystemRequestNotification::AddHeader(BinaryMessage& message) const { + LOG4CXX_AUTO_TRACE(logger_); + const uint32_t timeout = policy_handler_.TimeoutExchangeSec(); + + size_t content_length; + char size_str[24]; + + if (0 > sprintf(size_str, "%zu", static_cast<size_t>(message.size()))) { + memset(size_str, 0, sizeof(size_str)); + } + + char timeout_str[24]; + if (0 > sprintf(timeout_str, "%d", timeout)) { + memset(timeout_str, 0, sizeof(timeout_str)); + } + + std::string policy_table_string = std::string(message.begin(), message.end()); + + /* The Content-Length to be sent in the HTTP Request header should be + calculated before additional escape characters are added to the + policy table string. The mobile proxy will remove the escape + characters after receiving this request. */ + + content_length = ParsePTString(policy_table_string); + + if (0 > sprintf(size_str, "%zu", content_length)) { + memset(size_str, 0, sizeof(size_str)); + } + + const std::string header = + + "{" + " \"HTTPRequest\": {" + "\"headers\": {" + "\"ContentType\": \"application/json\"," + "\"ConnectTimeout\": " + + std::string(timeout_str) + + "," + "\"DoOutput\": true," + "\"DoInput\": true," + "\"UseCaches\": false," + "\"RequestMethod\": \"POST\"," + "\"ReadTimeout\":" + + std::string(timeout_str) + + "," + "\"InstanceFollowRedirects\": false," + "\"charset\": \"utf-8\"," + "\"Content-Length\": " + + std::string(size_str) + + "}," + "\"body\": \"" + + policy_table_string + + "\"" + "}" + "}"; + + message.clear(); + message.assign(header.begin(), header.end()); + + LOG4CXX_DEBUG( + logger_, "Header added: " << std::string(message.begin(), message.end())); +} + +size_t OnSystemRequestNotification::ParsePTString( + std::string& pt_string) const { + std::string result; + size_t length = pt_string.length(); + size_t result_length = length; + result.reserve(length * 2); + for (size_t i = 0; i < length; ++i) { + if (pt_string[i] == '\"' || pt_string[i] == '\\') { + result += '\\'; + } else if (pt_string[i] == '\n') { + result_length--; // contentLength is adjusted when this character is + // not copied to result. + continue; + } + result += pt_string[i]; + } + pt_string = result; + return result_length; +} +#endif // PROPRIETARY_MODE + +} // namespace mobile + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_tbt_client_state_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_tbt_client_state_notification.cc new file mode 100644 index 0000000000..503f1b04d5 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_tbt_client_state_notification.cc @@ -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. + */ + +#include "sdl_rpc_plugin/commands/mobile/on_tbt_client_state_notification.h" + +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnTBTClientStateNotification::OnTBTClientStateNotification( + 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) {} + +OnTBTClientStateNotification::~OnTBTClientStateNotification() {} + +void OnTBTClientStateNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + (*message_)[strings::params][strings::message_type] = + static_cast<int32_t>(application_manager::MessageType::kNotification); + + const std::vector<ApplicationSharedPtr>& applications = + application_manager_.applications_with_navi(); + + std::vector<ApplicationSharedPtr>::const_iterator it = applications.begin(); + for (; applications.end() != it; ++it) { + ApplicationSharedPtr app = *it; + if (mobile_apis::HMILevel::eType::HMI_NONE != app->hmi_level()) { + (*message_)[strings::params][strings::connection_key] = app->app_id(); + SendNotification(); + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_touch_event_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_touch_event_notification.cc new file mode 100644 index 0000000000..502f0ae57d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_touch_event_notification.cc @@ -0,0 +1,96 @@ +/* + + 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_touch_event_notification.h" + +#include "application_manager/application_impl.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace mobile { + +OnTouchEventNotification::OnTouchEventNotification( + 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) {} + +OnTouchEventNotification::~OnTouchEventNotification() {} + +void OnTouchEventNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + const std::vector<ApplicationSharedPtr>& applications_with_navi = + application_manager_.applications_with_navi(); + + const std::vector<ApplicationSharedPtr>& projection_applications = + application_manager_.applications_with_mobile_projection(); + + std::vector<ApplicationSharedPtr>::const_iterator nav_it = + applications_with_navi.begin(); + + for (; applications_with_navi.end() != nav_it; ++nav_it) { + ApplicationSharedPtr app = *nav_it; + if (app->IsFullscreen()) { + (*message_)[strings::params][strings::connection_key] = app->app_id(); + SendNotification(); + } + } + + std::vector<ApplicationSharedPtr>::const_iterator projection_it = + projection_applications.begin(); + + for (; projection_applications.end() != projection_it; ++projection_it) { + ApplicationSharedPtr projection_app = *projection_it; + if (projection_app->IsFullscreen()) { + (*message_)[strings::params][strings::connection_key] = + projection_app->app_id(); + SendNotification(); + } + } +} + +} // namespace mobile + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc new file mode 100644 index 0000000000..e25e4c622b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc @@ -0,0 +1,70 @@ +/* + + 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_way_point_change_notification.h" +#include "application_manager/application_manager.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +OnWayPointChangeNotification::OnWayPointChangeNotification( + 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) {} + +OnWayPointChangeNotification::~OnWayPointChangeNotification() {} + +void OnWayPointChangeNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + std::set<int32_t> subscribed_for_way_points = + application_manager_.GetAppsSubscribedForWayPoints(); + + for (std::set<int32_t>::const_iterator app_id = + subscribed_for_way_points.begin(); + app_id != subscribed_for_way_points.end(); + ++app_id) { + (*message_)[strings::params][strings::connection_key] = *app_id; + SendNotification(); + } +} +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc new file mode 100644 index 0000000000..86a644a778 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc @@ -0,0 +1,460 @@ +/* + + 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 <cstring> +#include "sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_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 { + +namespace str = strings; + +PerformAudioPassThruRequest::PerformAudioPassThruRequest( + 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) + , result_tts_speak_(hmi_apis::Common_Result::INVALID_ENUM) + , result_ui_(hmi_apis::Common_Result::INVALID_ENUM) { + subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout); +} + +PerformAudioPassThruRequest::~PerformAudioPassThruRequest() {} + +void PerformAudioPassThruRequest::onTimeOut() { + LOG4CXX_AUTO_TRACE(logger_); + + FinishTTSSpeak(); + CommandRequestImpl::onTimeOut(); +} + +bool PerformAudioPassThruRequest::Init() { + default_timeout_ += + (((*message_)[str::msg_params][str::max_duration].asUInt())); + return true; +} + +void PerformAudioPassThruRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "APPLICATION_NOT_REGISTERED"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (mobile_api::HMILevel::HMI_NONE == app->hmi_level()) { + LOG4CXX_ERROR(logger_, "application isn't activated"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, + "Incoming perform audio pass thru has contains " + "\\t\\n \\\\t \\\\n" + " text contains only whitespace in initialPrompt"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + // According with new implementation processing of UNSUPPORTE_RESOURCE + // need set flag before sending to hmi + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + if ((*message_)[str::msg_params].keyExists(str::initial_prompt)) { + smart_objects::SmartObject& initial_prompt = + (*message_)[strings::msg_params][strings::initial_prompt]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles( + initial_prompt, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + SendResponse( + false, + mobile_apis::Result::FILE_NOT_FOUND, + "One or more files needed for initial_prompt are not present"); + return; + } + + // In case TTS Speak, subscribe on notification + SendSpeakRequest(); + SendPerformAudioPassThruRequest(); + } else { + SendPerformAudioPassThruRequest(); + SendRecordStartNotification(); + StartMicrophoneRecording(); + } +} + +void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_PerformAudioPassThru: { + LOG4CXX_TRACE(logger_, "Received UI_PerformAudioPassThru"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + + result_ui_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asUInt()); + GetInfo(message, ui_info_); + + // in case perform audio is started by other request skip stopping + if (hmi_apis::Common_Result::REJECTED == result_ui_) { + LOG4CXX_ERROR(logger_, "Request was rejected"); + SendResponse(false, + MessageHelper::HMIToMobileResult(result_ui_), + NULL, + &(message[strings::msg_params])); + return; + } + FinishTTSSpeak(); + break; + } + case hmi_apis::FunctionID::TTS_Speak: { + LOG4CXX_INFO(logger_, "Received TTS_Speak event"); + result_tts_speak_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asUInt()); + GetInfo(message, tts_info_); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); + const bool is_tts_speak_success_unsuported = + Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + result_tts_speak_, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS, + hmi_apis::Common_Result::WRONG_LANGUAGE, + hmi_apis::Common_Result::RETRY, + hmi_apis::Common_Result::SAVED, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); + + if (is_tts_speak_success_unsuported) { + SendRecordStartNotification(); + StartMicrophoneRecording(); + + // update request timeout to get time for perform audio recording + application_manager_.updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + } + break; + } + case hmi_apis::FunctionID::TTS_OnResetTimeout: { + LOG4CXX_INFO(logger_, "Received TTS_OnResetTimeout event"); + + application_manager_.updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } + if (IsWaitingHMIResponse()) { + return; + } + + const ResponseParams response_params = PrepareResponseParameters(); + + SendResponse( + response_params.success, + response_params.result_code, + response_params.info.empty() ? NULL : response_params.info.c_str(), + &(message[strings::msg_params])); +} + +const PerformAudioPassThruRequest::ResponseParams& +PerformAudioPassThruRequest::PrepareResponseParameters() { + LOG4CXX_AUTO_TRACE(logger_); + + app_mngr::commands::ResponseInfo ui_perform_info( + result_ui_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); + app_mngr::commands::ResponseInfo tts_perform_info( + result_tts_speak_, + HmiInterfaces::HMI_INTERFACE_TTS, + application_manager_); + + // Note(dtrunov): According to requirment "WARNINGS, success:true on getting + // UNSUPPORTED_RESOURCE for "ttsChunks" + if (ui_perform_info.is_ok && tts_perform_info.is_unsupported_resource && + HmiInterfaces::STATE_AVAILABLE == tts_perform_info.interface_state) { + response_params_.result_code = mobile_apis::Result::WARNINGS; + tts_info_ = "Unsupported phoneme type sent in a prompt"; + response_params_.info = app_mngr::commands::MergeInfos( + ui_perform_info, ui_info_, tts_perform_info, tts_info_); + response_params_.success = true; + return response_params_; + } + + response_params_.success = + PrepareResultForMobileResponse(ui_perform_info, tts_perform_info); + if (IsResultCodeUnsupported(ui_perform_info, tts_perform_info)) { + response_params_.result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE; + } else { + AudioPassThruResults results = PrepareAudioPassThruResultCodeForResponse( + ui_perform_info, tts_perform_info); + response_params_.success = results.second; + response_params_.result_code = results.first; + } + response_params_.info = app_mngr::commands::MergeInfos( + ui_perform_info, ui_info_, tts_perform_info, tts_info_); + + return response_params_; +} + +bool PerformAudioPassThruRequest::PrepareResponseParameters( + mobile_apis::Result::eType& result_code, std::string& info) { + LOG4CXX_AUTO_TRACE(logger_); + NOTREACHED(); + return false; +} + +void PerformAudioPassThruRequest::SendSpeakRequest() { + LOG4CXX_AUTO_TRACE(logger_); + + using namespace hmi_apis; + using namespace smart_objects; + + SmartObject msg_params = smart_objects::SmartObject(SmartType_Map); + for (uint32_t i = 0; + i < (*message_)[str::msg_params][str::initial_prompt].length(); + ++i) { + msg_params[hmi_request::tts_chunks][i][str::text] = + (*message_)[str::msg_params][str::initial_prompt][i][str::text]; + msg_params[hmi_request::tts_chunks][i][str::type] = + (*message_)[str::msg_params][str::initial_prompt][i][str::type]; + } + // app_id + msg_params[strings::app_id] = connection_key(); + msg_params[hmi_request::speak_type] = Common_MethodName::AUDIO_PASS_THRU; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); + SendHMIRequest(FunctionID::TTS_Speak, &msg_params, true); +} + +void PerformAudioPassThruRequest::SendPerformAudioPassThruRequest() { + LOG4CXX_AUTO_TRACE(logger_); + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + msg_params[str::app_id] = connection_key(); + + msg_params[hmi_request::max_duration] = + (*message_)[str::msg_params][str::max_duration]; + + msg_params[hmi_request::audio_pass_display_texts] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + if ((*message_)[str::msg_params].keyExists(str::audio_pass_display_text1)) { + msg_params[hmi_request::audio_pass_display_texts][0] + [hmi_request::field_name] = static_cast<int32_t>( + hmi_apis::Common_TextFieldName::audioPassThruDisplayText1); + msg_params[hmi_request::audio_pass_display_texts][0] + [hmi_request::field_text] = + (*message_)[str::msg_params][str::audio_pass_display_text1]; + } + + if ((*message_)[str::msg_params].keyExists(str::audio_pass_display_text2)) { + msg_params[hmi_request::audio_pass_display_texts][1] + [hmi_request::field_name] = static_cast<int32_t>( + hmi_apis::Common_TextFieldName::audioPassThruDisplayText2); + msg_params[hmi_request::audio_pass_display_texts][1] + [hmi_request::field_text] = + (*message_)[str::msg_params][str::audio_pass_display_text2]; + } + + if ((*message_)[str::msg_params].keyExists(str::mute_audio)) { + msg_params[str::mute_audio] = + (*message_)[str::msg_params][str::mute_audio].asBool(); + } else { + // If omitted, the value is set to true + msg_params[str::mute_audio] = true; + } + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest( + hmi_apis::FunctionID::UI_PerformAudioPassThru, &msg_params, true); +} + +void PerformAudioPassThruRequest::SendRecordStartNotification() { + LOG4CXX_AUTO_TRACE(logger_); + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[strings::app_id] = connection_key(); + + CreateHMINotification(hmi_apis::FunctionID::UI_OnRecordStart, msg_params); +} + +void PerformAudioPassThruRequest::StartMicrophoneRecording() { + LOG4CXX_AUTO_TRACE(logger_); + + uint32_t app_id = connection_key(); + application_manager_.BeginAudioPassThru(app_id); + + application_manager_.StartAudioPassThruThread( + connection_key(), + correlation_id(), + (*message_)[str::msg_params][str::max_duration].asInt(), + (*message_)[str::msg_params][str::sampling_rate].asInt(), + (*message_)[str::msg_params][str::bits_per_sample].asInt(), + (*message_)[str::msg_params][str::audio_type].asInt()); +} + +bool PerformAudioPassThruRequest::IsWhiteSpaceExist() { + LOG4CXX_AUTO_TRACE(logger_); + const char* str = NULL; + + if ((*message_)[strings::msg_params].keyExists(strings::initial_prompt)) { + const smart_objects::SmartArray* ip_array = + (*message_)[strings::msg_params][strings::initial_prompt].asArray(); + + smart_objects::SmartArray::const_iterator it_ip = ip_array->begin(); + smart_objects::SmartArray::const_iterator it_ip_end = ip_array->end(); + + for (; it_ip != it_ip_end; ++it_ip) { + str = (*it_ip)[strings::text].asCharArray(); + if (std::strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid initial_prompt syntax check failed"); + return true; + } + } + } + + if ((*message_)[strings::msg_params].keyExists( + strings::audio_pass_display_text1)) { + str = (*message_)[strings::msg_params][strings::audio_pass_display_text1] + .asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR( + logger_, + "Invalid audio_pass_display_text1 value syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists( + strings::audio_pass_display_text2)) { + str = (*message_)[strings::msg_params][strings::audio_pass_display_text2] + .asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR( + logger_, + "Invalid audio_pass_display_text2 value syntax check failed"); + return true; + } + } + return false; +} + +void PerformAudioPassThruRequest::FinishTTSSpeak() { + LOG4CXX_AUTO_TRACE(logger_); + uint32_t app_id = connection_key(); + if (application_manager_.EndAudioPassThru(app_id)) { + LOG4CXX_DEBUG(logger_, "Stop AudioPassThru."); + application_manager_.StopAudioPassThru(app_id); + } + if (!IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_TTS)) { + LOG4CXX_WARN(logger_, "TTS Speak is inactive."); + return; + } + SendHMIRequest(hmi_apis::FunctionID::TTS_StopSpeaking, NULL); +} + +PerformAudioPassThruRequest::AudioPassThruResults +PerformAudioPassThruRequest::PrepareAudioPassThruResultCodeForResponse( + const app_mngr::commands::ResponseInfo& ui_response, + const app_mngr::commands::ResponseInfo& tts_response) { + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; + + hmi_apis::Common_Result::eType common_result = + hmi_apis::Common_Result::INVALID_ENUM; + const hmi_apis::Common_Result::eType ui_result = ui_response.result_code; + const hmi_apis::Common_Result::eType tts_result = tts_response.result_code; + bool result = false; + + if ((ui_result == hmi_apis::Common_Result::SUCCESS) && + (tts_result == hmi_apis::Common_Result::SUCCESS)) { + result = true; + } + + if ((ui_result == hmi_apis::Common_Result::SUCCESS) && + (tts_result == hmi_apis::Common_Result::INVALID_ENUM)) { + result = true; + } + + if ((ui_result == hmi_apis::Common_Result::SUCCESS) && + (tts_result != hmi_apis::Common_Result::SUCCESS) && + (tts_result != hmi_apis::Common_Result::INVALID_ENUM)) { + common_result = hmi_apis::Common_Result::WARNINGS; + result = true; + } else if (ui_response.is_ok && + tts_result == hmi_apis::Common_Result::WARNINGS) { + common_result = hmi_apis::Common_Result::WARNINGS; + result = true; + } else if (ui_result == hmi_apis::Common_Result::INVALID_ENUM) { + common_result = tts_result; + } else { + common_result = ui_result; + } + result_code = MessageHelper::HMIToMobileResult(common_result); + return std::make_pair(result_code, result); +} + +bool PerformAudioPassThruRequest::IsWaitingHMIResponse() { + LOG4CXX_AUTO_TRACE(logger_); + return IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_TTS) || + IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_response.cc new file mode 100644 index 0000000000..a5eb98f2ba --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_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 "sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +PerformAudioPassThruResponse::PerformAudioPassThruResponse( + 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) {} + +PerformAudioPassThruResponse::~PerformAudioPassThruResponse() {} + +void PerformAudioPassThruResponse::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/perform_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc new file mode 100644 index 0000000000..8710f3c3d6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc @@ -0,0 +1,1013 @@ +/* + + 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 <numeric> +#include <string.h> +#include <string> +#include "sdl_rpc_plugin/commands/mobile/perform_interaction_request.h" + +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" + +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" +#include "utils/file_system.h" +#include "utils/helpers.h" +#include "utils/custom_string.h" +#include "utils/gen_hash.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace custom_str = utils::custom_string; + +uint32_t PerformInteractionRequest::pi_requests_count_ = 0; + +PerformInteractionRequest::PerformInteractionRequest( + 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) + , interaction_mode_(mobile_apis::InteractionMode::INVALID_ENUM) + , ui_response_received_(false) + , vr_response_received_(false) + , app_pi_was_active_before_(false) + , vr_result_code_(hmi_apis::Common_Result::INVALID_ENUM) + , ui_result_code_(hmi_apis::Common_Result::INVALID_ENUM) { + subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); + subscribe_on_event(hmi_apis::FunctionID::VR_OnCommand); + subscribe_on_event(hmi_apis::FunctionID::Buttons_OnButtonPress); +} + +PerformInteractionRequest::~PerformInteractionRequest() {} + +bool PerformInteractionRequest::Init() { + /* Timeout in milliseconds. + If omitted a standard value of 10000 milliseconds is used.*/ + if ((*message_)[strings::msg_params].keyExists(strings::timeout)) { + default_timeout_ = + (*message_)[strings::msg_params][strings::timeout].asUInt(); + } + + interaction_mode_ = static_cast<mobile_apis::InteractionMode::eType>( + (*message_)[strings::msg_params][strings::interaction_mode].asInt()); + + if (mobile_apis::InteractionMode::BOTH == interaction_mode_ || + mobile_apis::InteractionMode::MANUAL_ONLY == interaction_mode_) { + default_timeout_ *= 2; + } + return true; +} + +void PerformInteractionRequest::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; + } + + if (app->is_perform_interaction_active()) { + LOG4CXX_DEBUG(logger_, "Application has active PerformInteraction"); + app_pi_was_active_before_ = true; + } + + smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; + mobile_apis::LayoutMode::eType interaction_layout = + mobile_apis::LayoutMode::INVALID_ENUM; + + if (msg_params.keyExists(hmi_request::interaction_layout)) { + interaction_layout = static_cast<mobile_apis::LayoutMode::eType>( + msg_params[hmi_request::interaction_layout].asInt()); + } + + if ((mobile_apis::InteractionMode::VR_ONLY == interaction_mode_) && + (mobile_apis::LayoutMode::KEYBOARD == interaction_layout)) { + LOG4CXX_ERROR(logger_, + "PerformInteraction contains InteractionMode" + "=VR_ONLY and interactionLayout=KEYBOARD"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + const size_t choice_set_id_list_length = + msg_params[strings::interaction_choice_set_id_list].length(); + + if (0 == choice_set_id_list_length) { + if (mobile_apis::LayoutMode::KEYBOARD == interaction_layout) { + if (mobile_apis::InteractionMode::BOTH == interaction_mode_) { + LOG4CXX_ERROR(logger_, + "interactionChoiceSetIDList is empty," + " InteractionMode=BOTH and" + " interactionLayout=KEYBOARD"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } else { + LOG4CXX_ERROR(logger_, + "interactionChoiceSetIDList is empty" + " and interactionLayout!=KEYBOARD"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } + + if (!CheckChoiceIDFromRequest( + app, + choice_set_id_list_length, + msg_params[strings::interaction_choice_set_id_list])) { + LOG4CXX_ERROR(logger_, + "PerformInteraction has choice sets with " + "duplicated IDs or application does not have choice sets"); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + + if (msg_params.keyExists(strings::vr_help)) { + if (mobile_apis::Result::SUCCESS != + MessageHelper::VerifyImageVrHelpItems( + msg_params[strings::vr_help], app, application_manager_)) { + LOG4CXX_ERROR(logger_, + "Verification of " << strings::vr_help << " failed."); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, + "Incoming perform interaction has contains \t\n \\t \\n"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + switch (interaction_mode_) { + case mobile_apis::InteractionMode::BOTH: { + LOG4CXX_DEBUG(logger_, "Interaction Mode: BOTH"); + if (!CheckChoiceSetVRSynonyms(app) || !CheckChoiceSetMenuNames(app) || + !CheckVrHelpItemPositions(app)) { + return; + } + break; + } + case mobile_apis::InteractionMode::MANUAL_ONLY: { + LOG4CXX_DEBUG(logger_, "Interaction Mode: MANUAL_ONLY"); + if (!CheckChoiceSetVRSynonyms(app) || !CheckChoiceSetMenuNames(app) || + !CheckVrHelpItemPositions(app)) { + return; + } + break; + } + case mobile_apis::InteractionMode::VR_ONLY: { + LOG4CXX_DEBUG(logger_, "Interaction Mode: VR_ONLY"); + if (!CheckChoiceSetVRSynonyms(app) || !CheckVrHelpItemPositions(app)) { + return; + } + break; + } + default: { + LOG4CXX_ERROR(logger_, "Unknown interaction mode"); + return; + } + } + + app->set_perform_interaction_mode(static_cast<int32_t>(interaction_mode_)); + app->set_perform_interaction_active(true); + app->set_perform_interaction_layout(interaction_layout); + // increment amount of active requests + ++pi_requests_count_; + SendVRPerformInteractionRequest(app); + SendUIPerformInteractionRequest(app); +} + +void PerformInteractionRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& message = event.smart_object(); + smart_objects::SmartObject msg_param = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_OnResetTimeout: { + LOG4CXX_DEBUG(logger_, "Received UI_OnResetTimeout event"); + application_manager_.updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + break; + } + case hmi_apis::FunctionID::UI_PerformInteraction: { + LOG4CXX_DEBUG(logger_, "Received UI_PerformInteraction event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + ui_response_received_ = true; + unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction); + ui_result_code_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asUInt()); + GetInfo(message, ui_info_); + ProcessUIResponse(event.smart_object(), msg_param); + break; + } + case hmi_apis::FunctionID::VR_PerformInteraction: { + LOG4CXX_DEBUG(logger_, "Received VR_PerformInteraction"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); + vr_response_received_ = true; + unsubscribe_from_event(hmi_apis::FunctionID::VR_PerformInteraction); + vr_result_code_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asUInt()); + GetInfo(message, vr_info_); + if (ProcessVRResponse(event.smart_object(), msg_param)) { + return; + } + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + break; + } + } + + if (!HasHMIResponsesToWait()) { + LOG4CXX_DEBUG(logger_, "Send response in BOTH iteraction mode"); + SendBothModeResponse(msg_param); + } +} + +void PerformInteractionRequest::onTimeOut() { + LOG4CXX_AUTO_TRACE(logger_); + + switch (interaction_mode_) { + case mobile_apis::InteractionMode::BOTH: { + LOG4CXX_DEBUG(logger_, "Interaction Mode: BOTH"); + if (true == vr_response_received_) { + unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction); + DisablePerformInteraction(); + CommandRequestImpl::onTimeOut(); + } else { + application_manager_.updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + } + break; + } + case mobile_apis::InteractionMode::VR_ONLY: { + LOG4CXX_DEBUG(logger_, "Interaction Mode: VR_ONLY"); + unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction); + DisablePerformInteraction(); + CommandRequestImpl::onTimeOut(); + break; + } + case mobile_apis::InteractionMode::MANUAL_ONLY: { + LOG4CXX_DEBUG(logger_, "InteractionMode: MANUAL_ONLY"); + unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction); + DisablePerformInteraction(); + CommandRequestImpl::onTimeOut(); + break; + } + default: { + LOG4CXX_ERROR(logger_, "INVALID ENUM"); + return; + } + }; +} + +bool PerformInteractionRequest::ProcessVRResponse( + const smart_objects::SmartObject& message, + smart_objects::SmartObject& msg_params) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace hmi_apis; + using namespace mobile_apis; + using namespace smart_objects; + using namespace helpers; + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return false; + } + + msg_params[strings::trigger_source] = + static_cast<int32_t>(TriggerSource::TS_VR); + + const bool is_vr_aborted_timeout = Compare<Common_Result::eType, EQ, ONE>( + vr_result_code_, Common_Result::ABORTED, Common_Result::TIMED_OUT); + + if (is_vr_aborted_timeout) { + LOG4CXX_DEBUG(logger_, "VR response aborted"); + if (InteractionMode::VR_ONLY == interaction_mode_) { + LOG4CXX_DEBUG(logger_, "Aborted or Timeout Send Close Popup"); + TerminatePerformInteraction(); + SendResponse(false, MessageHelper::HMIToMobileResult(vr_result_code_)); + return true; + } + LOG4CXX_DEBUG(logger_, "Update timeout for UI"); + application_manager_.updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + return false; + } + + if (Common_Result::SUCCESS == vr_result_code_ && + InteractionMode::MANUAL_ONLY == interaction_mode_) { + LOG4CXX_DEBUG(logger_, + "VR response SUCCESS in MANUAL_ONLY mode " + << "Wait for UI response"); + // in case MANUAL_ONLY mode VR.PI SUCCESS just return + return false; + } + + const SmartObject& hmi_msg_params = message[strings::msg_params]; + if (hmi_msg_params.keyExists(strings::choice_id)) { + const int choise_id = hmi_msg_params[strings::choice_id].asInt(); + if (!CheckChoiceIDFromResponse(app, choise_id)) { + LOG4CXX_ERROR(logger_, "Wrong choiceID was received from HMI"); + TerminatePerformInteraction(); + SendResponse( + false, Result::GENERIC_ERROR, "Wrong choiceID was received from HMI"); + return true; + } + msg_params[strings::choice_id] = choise_id; + } + return false; +} + +void PerformInteractionRequest::ProcessUIResponse( + const smart_objects::SmartObject& message, + smart_objects::SmartObject& msg_params) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + using namespace smart_objects; + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + HmiInterfaces::InterfaceState ui_interface_state = + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_UI); + bool result = false; + result = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + ui_result_code_, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS); + + result = result || + (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_code_ && + HmiInterfaces::STATE_NOT_AVAILABLE != ui_interface_state); + + const bool is_pi_warning = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + ui_result_code_, hmi_apis::Common_Result::WARNINGS); + + const bool is_pi_unsupported = + Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + ui_result_code_, hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); + + if (result) { + if (is_pi_warning) { + ui_result_code_ = hmi_apis::Common_Result::WARNINGS; + ui_info_ = message[strings::msg_params][strings::info].asString(); + if (message.keyExists(strings::params) && + message[strings::params].keyExists(strings::data)) { + msg_params = message[strings::params][strings::data]; + } + } else if (is_pi_unsupported) { + ui_result_code_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + ui_info_ = message[strings::msg_params][strings::info].asString(); + } else if (message.keyExists(strings::msg_params)) { + msg_params = message[strings::msg_params]; + } + // result code must be GENERIC_ERROR in case wrong choice_id + if (msg_params.keyExists(strings::choice_id)) { + if (!CheckChoiceIDFromResponse(app, + msg_params[strings::choice_id].asInt())) { + ui_result_code_ = hmi_apis::Common_Result::GENERIC_ERROR; + ui_info_ = "Wrong choiceID was received from HMI"; + } else { + msg_params[strings::trigger_source] = + mobile_apis::TriggerSource::TS_MENU; + } + } else if (msg_params.keyExists(strings::manual_text_entry)) { + msg_params[strings::trigger_source] = + mobile_apis::TriggerSource::TS_KEYBOARD; + if (msg_params[strings::manual_text_entry].empty()) { + msg_params.erase(strings::manual_text_entry); + } + } + } +} + +void PerformInteractionRequest::SendUIPerformInteractionRequest( + application_manager::ApplicationSharedPtr const app) { + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject& choice_set_id_list = + (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + mobile_apis::InteractionMode::eType mode = + static_cast<mobile_apis::InteractionMode::eType>( + (*message_)[strings::msg_params][strings::interaction_mode].asInt()); + + if (mobile_apis::InteractionMode::VR_ONLY != mode) { + msg_params[hmi_request::initial_text][hmi_request::field_name] = + static_cast<int32_t>( + hmi_apis::Common_TextFieldName::initialInteractionText); + msg_params[hmi_request::initial_text][hmi_request::field_text] = + (*message_)[strings::msg_params][hmi_request::initial_text]; + } + bool is_vr_help_item = false; + if (mobile_apis::InteractionMode::MANUAL_ONLY != mode) { + msg_params[strings::vr_help_title] = + (*message_)[strings::msg_params][strings::initial_text].asString(); + if ((*message_)[strings::msg_params].keyExists(strings::vr_help)) { + is_vr_help_item = true; + msg_params[strings::vr_help] = + (*message_)[strings::msg_params][strings::vr_help]; + } + } + + if (mobile_apis::InteractionMode::BOTH == mode || + mobile_apis::InteractionMode::MANUAL_ONLY == mode) { + msg_params[strings::timeout] = default_timeout_ / 2; + } else { + msg_params[strings::timeout] = default_timeout_; + } + msg_params[strings::app_id] = app->app_id(); + if (mobile_apis::InteractionMode::VR_ONLY != mode) { + msg_params[strings::choice_set] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + } + int32_t index_array_of_vr_help = 0; + for (size_t i = 0; i < choice_set_id_list.length(); ++i) { + smart_objects::SmartObject* choice_set = + app->FindChoiceSet(choice_set_id_list[i].asInt()); + if (choice_set) { + // save perform interaction choice set + app->AddPerformInteractionChoiceSet( + correlation_id(), choice_set_id_list[i].asInt(), *choice_set); + for (size_t j = 0; j < (*choice_set)[strings::choice_set].length(); ++j) { + if (mobile_apis::InteractionMode::VR_ONLY != mode) { + size_t index = msg_params[strings::choice_set].length(); + msg_params[strings::choice_set][index] = + (*choice_set)[strings::choice_set][j]; + // vrCommands should be added via VR.AddCommand only + msg_params[strings::choice_set][index].erase(strings::vr_commands); + } + if (mobile_apis::InteractionMode::MANUAL_ONLY != mode && + !is_vr_help_item) { + smart_objects::SmartObject& vr_commands = + (*choice_set)[strings::choice_set][j][strings::vr_commands]; + if (0 < vr_commands.length()) { + // copy only first synonym + smart_objects::SmartObject item(smart_objects::SmartType_Map); + item[strings::text] = vr_commands[0].asString(); + item[strings::position] = index_array_of_vr_help + 1; + msg_params[strings::vr_help][index_array_of_vr_help++] = item; + } + } + } + } + } + if ((*message_)[strings::msg_params].keyExists( + hmi_request::interaction_layout) && + mobile_apis::InteractionMode::VR_ONLY != mode) { + msg_params[hmi_request::interaction_layout] = + (*message_)[strings::msg_params][hmi_request::interaction_layout] + .asInt(); + } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest( + hmi_apis::FunctionID::UI_PerformInteraction, &msg_params, true); +} + +void PerformInteractionRequest::SendVRPerformInteractionRequest( + application_manager::ApplicationSharedPtr const app) { + LOG4CXX_AUTO_TRACE(logger_); + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + smart_objects::SmartObject& choice_list = + (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; + + if (mobile_apis::InteractionMode::MANUAL_ONLY != interaction_mode_) { + msg_params[strings::grammar_id] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + int32_t grammar_id_index = 0; + for (uint32_t i = 0; i < choice_list.length(); ++i) { + smart_objects::SmartObject* choice_set = + app->FindChoiceSet(choice_list[i].asInt()); + if (!choice_set) { + LOG4CXX_WARN(logger_, "Couldn't found choiset"); + continue; + } + msg_params[strings::grammar_id][grammar_id_index++] = + (*choice_set)[strings::grammar_id].asUInt(); + } + } + + std::vector<std::string> invalid_params; + if ((*message_)[strings::msg_params].keyExists(strings::help_prompt)) { + smart_objects::SmartObject& help_prompt = + (*message_)[strings::msg_params][strings::help_prompt]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles(help_prompt, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_WARN(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + invalid_params.push_back("help_prompt"); + } else { + msg_params[strings::help_prompt] = help_prompt; + } + } else { + if (choice_list.length() != 0) { + msg_params[strings::help_prompt] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + } + int32_t index = 0; + for (uint32_t i = 0; i < choice_list.length(); ++i) { + smart_objects::SmartObject* choice_set = + app->FindChoiceSet(choice_list[i].asInt()); + + if (choice_set) { + for (uint32_t j = 0; j < (*choice_set)[strings::choice_set].length(); + ++j) { + smart_objects::SmartObject& vr_commands = + (*choice_set)[strings::choice_set][j][strings::vr_commands]; + if (0 < vr_commands.length()) { + // copy only first synonym + smart_objects::SmartObject item(smart_objects::SmartType_Map); + // Since there is no custom data from application side, SDL should + // construct prompt and append delimiter to each item + item[strings::type] = hmi_apis::Common_SpeechCapabilities::SC_TEXT; + item[strings::text] = + vr_commands[0].asString() + + application_manager_.get_settings().tts_delimiter(); + msg_params[strings::help_prompt][index++] = item; + } + } + } else { + LOG4CXX_ERROR(logger_, "Can't found choiceSet!"); + } + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::timeout_prompt)) { + smart_objects::SmartObject& timeout_prompt = + (*message_)[strings::msg_params][strings::timeout_prompt]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles( + timeout_prompt, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_WARN(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + invalid_params.push_back("timeout_prompt"); + } else { + msg_params[strings::timeout_prompt] = timeout_prompt; + } + } else { + if (msg_params.keyExists(strings::help_prompt)) { + msg_params[strings::timeout_prompt] = msg_params[strings::help_prompt]; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::initial_prompt)) { + smart_objects::SmartObject& initial_prompt = + (*message_)[strings::msg_params][strings::initial_prompt]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles( + initial_prompt, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_WARN(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + invalid_params.push_back("initial_prompt"); + } else { + msg_params[strings::initial_prompt] = initial_prompt; + } + } + + if (!invalid_params.empty()) { + const std::string params_list = + std::accumulate(std::begin(invalid_params), + std::end(invalid_params), + std::string(""), + [](std::string& first, std::string& second) { + return first.empty() ? second : first + ", " + second; + }); + const std::string info = + "One or more files needed for " + params_list + " are not present"; + SendResponse(false, mobile_apis::Result::FILE_NOT_FOUND, info.c_str()); + return; + } + + mobile_apis::InteractionMode::eType mode = + static_cast<mobile_apis::InteractionMode::eType>( + (*message_)[strings::msg_params][strings::interaction_mode].asInt()); + + if (mobile_apis::InteractionMode::BOTH == mode || + mobile_apis::InteractionMode::MANUAL_ONLY == mode) { + msg_params[strings::timeout] = default_timeout_ / 2; + } else { + msg_params[strings::timeout] = default_timeout_; + } + msg_params[strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); + SendHMIRequest( + hmi_apis::FunctionID::VR_PerformInteraction, &msg_params, true); +} + +bool PerformInteractionRequest::CheckChoiceSetMenuNames( + application_manager::ApplicationSharedPtr const app) { + LOG4CXX_AUTO_TRACE(logger_); + + smart_objects::SmartObject& choice_list = + (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; + + for (size_t i = 0; i < choice_list.length(); ++i) { + // choice_set contains SmartObject msg_params + smart_objects::SmartObject* i_choice_set = + app->FindChoiceSet(choice_list[i].asInt()); + + for (size_t j = 0; j < choice_list.length(); ++j) { + smart_objects::SmartObject* j_choice_set = + app->FindChoiceSet(choice_list[j].asInt()); + + if (i == j) { + // skip check the same element + continue; + } + + if (!i_choice_set || !j_choice_set) { + LOG4CXX_ERROR(logger_, "Invalid ID"); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return false; + } + + size_t ii = 0; + size_t jj = 0; + for (; ii < (*i_choice_set)[strings::choice_set].length(); ++ii) { + for (; jj < (*j_choice_set)[strings::choice_set].length(); ++jj) { + const std::string& ii_menu_name = + (*i_choice_set)[strings::choice_set][ii][strings::menu_name] + .asString(); + const std::string& jj_menu_name = + (*j_choice_set)[strings::choice_set][jj][strings::menu_name] + .asString(); + + if (ii_menu_name == jj_menu_name) { + LOG4CXX_ERROR(logger_, "Choice set has duplicated menu name"); + SendResponse(false, + mobile_apis::Result::DUPLICATE_NAME, + "Choice set has duplicated menu name"); + return false; + } + } + } + } + } + + return true; +} + +bool PerformInteractionRequest::CheckChoiceSetVRSynonyms( + application_manager::ApplicationSharedPtr const app) { + LOG4CXX_AUTO_TRACE(logger_); + + smart_objects::SmartObject& choice_list = + (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; + + for (size_t i = 0; i < choice_list.length(); ++i) { + // choice_set contains SmartObject msg_params + smart_objects::SmartObject* i_choice_set = + app->FindChoiceSet(choice_list[i].asInt()); + + for (size_t j = 0; j < choice_list.length(); ++j) { + smart_objects::SmartObject* j_choice_set = + app->FindChoiceSet(choice_list[j].asInt()); + + if (i == j) { + // skip check the same element + continue; + } + + if ((!i_choice_set) || (!j_choice_set)) { + LOG4CXX_ERROR(logger_, "Invalid ID"); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return false; + } + + size_t ii = 0; + size_t jj = 0; + for (; ii < (*i_choice_set)[strings::choice_set].length(); ++ii) { + for (; jj < (*j_choice_set)[strings::choice_set].length(); ++jj) { + // choice_set pointer contains SmartObject msg_params + smart_objects::SmartObject& ii_vr_commands = + (*i_choice_set)[strings::choice_set][ii][strings::vr_commands]; + + smart_objects::SmartObject& jj_vr_commands = + (*j_choice_set)[strings::choice_set][jj][strings::vr_commands]; + + for (size_t iii = 0; iii < ii_vr_commands.length(); ++iii) { + for (size_t jjj = 0; jjj < jj_vr_commands.length(); ++jjj) { + const custom_str::CustomString& vr_cmd_i = + ii_vr_commands[iii].asCustomString(); + const custom_str::CustomString& vr_cmd_j = + jj_vr_commands[jjj].asCustomString(); + if (vr_cmd_i.CompareIgnoreCase(vr_cmd_j)) { + LOG4CXX_ERROR(logger_, "Choice set has duplicated VR synonym"); + SendResponse(false, + mobile_apis::Result::DUPLICATE_NAME, + "Choice set has duplicated VR synonym"); + return false; + } + } + } + } + } + } + } + return true; +} + +bool PerformInteractionRequest::CheckVrHelpItemPositions( + application_manager::ApplicationSharedPtr const app) { + LOG4CXX_AUTO_TRACE(logger_); + + if (!(*message_)[strings::msg_params].keyExists(strings::vr_help)) { + LOG4CXX_DEBUG(logger_, strings::vr_help << " is omitted."); + return true; + } + + smart_objects::SmartObject& vr_help = + (*message_)[strings::msg_params][strings::vr_help]; + + int32_t position = 1; + for (size_t i = 0; i < vr_help.length(); ++i) { + if (position != vr_help[i][strings::position].asInt()) { + LOG4CXX_ERROR(logger_, "Non-sequential vrHelp item position"); + SendResponse(false, + mobile_apis::Result::REJECTED, + "Non-sequential vrHelp item position"); + return false; + } + ++position; + } + return true; +} + +void PerformInteractionRequest::DisablePerformInteraction() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + if (app->is_perform_interaction_active()) { + // decrease amount of active requests + --pi_requests_count_; + if (!pi_requests_count_) { + app->set_perform_interaction_active(false); + app->set_perform_interaction_mode(-1); + } + } + app->DeletePerformInteractionChoiceSet(correlation_id()); +} + +bool PerformInteractionRequest::IsWhiteSpaceExist() { + LOG4CXX_AUTO_TRACE(logger_); + const char* str = NULL; + + str = (*message_)[strings::msg_params][strings::initial_text].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid initial_text syntax check failed"); + return true; + } + + if ((*message_)[strings::msg_params].keyExists(strings::initial_prompt)) { + const smart_objects::SmartArray* ip_array = + (*message_)[strings::msg_params][strings::initial_prompt].asArray(); + + smart_objects::SmartArray::const_iterator it_ip = ip_array->begin(); + smart_objects::SmartArray::const_iterator it_ip_end = ip_array->end(); + + for (; it_ip != it_ip_end; ++it_ip) { + str = (*it_ip)[strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid initial_prompt syntax check failed"); + return true; + } + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::help_prompt)) { + const smart_objects::SmartArray* hp_array = + (*message_)[strings::msg_params][strings::help_prompt].asArray(); + + smart_objects::SmartArray::const_iterator it_hp = hp_array->begin(); + smart_objects::SmartArray::const_iterator it_hp_end = hp_array->end(); + + for (; it_hp != it_hp_end; ++it_hp) { + str = (*it_hp)[strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid help_prompt syntax check failed"); + return true; + } + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::timeout_prompt)) { + const smart_objects::SmartArray* tp_array = + (*message_)[strings::msg_params][strings::timeout_prompt].asArray(); + + smart_objects::SmartArray::const_iterator it_tp = tp_array->begin(); + smart_objects::SmartArray::const_iterator it_tp_end = tp_array->end(); + + for (; it_tp != it_tp_end; ++it_tp) { + str = (*it_tp)[strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid timeout_prompt syntax check failed"); + return true; + } + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::vr_help)) { + const smart_objects::SmartArray* vh_array = + (*message_)[strings::msg_params][strings::vr_help].asArray(); + + smart_objects::SmartArray::const_iterator it_vh = vh_array->begin(); + smart_objects::SmartArray::const_iterator it_vh_end = vh_array->end(); + + for (; it_vh != it_vh_end; ++it_vh) { + str = (*it_vh)[strings::text].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid vr_help syntax check failed"); + return true; + } + + if ((*it_vh).keyExists(strings::image)) { + str = (*it_vh)[strings::image][strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid vr_help image value syntax check failed"); + return true; + } + } + } + } + return false; +} + +void PerformInteractionRequest::TerminatePerformInteraction() { + LOG4CXX_AUTO_TRACE(logger_); + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[hmi_request::method_name] = "UI.PerformInteraction"; + SendHMIRequest(hmi_apis::FunctionID::UI_ClosePopUp, &msg_params); + DisablePerformInteraction(); +} + +bool PerformInteractionRequest::CheckChoiceIDFromResponse( + ApplicationSharedPtr app, int32_t choice_id) { + LOG4CXX_AUTO_TRACE(logger_); + const DataAccessor<PerformChoiceSetMap> accessor = + app->performinteraction_choice_set_map(); + const PerformChoiceSetMap& choice_set_map = accessor.GetData(); + + PerformChoiceSetMap::const_iterator choice_set_map_it = + choice_set_map.find(correlation_id()); + if (choice_set_map.end() != choice_set_map_it) { + const PerformChoice& choice = choice_set_map_it->second; + PerformChoice::const_iterator it = choice.begin(); + for (; choice.end() != it; ++it) { + const smart_objects::SmartObject& choice_set = + (*it->second).getElement(strings::choice_set); + for (size_t j = 0; j < choice_set.length(); ++j) { + if (choice_id == + choice_set.getElement(j).getElement(strings::choice_id).asInt()) { + return true; + } + } + } + } + return false; +} + +bool PerformInteractionRequest::CheckChoiceIDFromRequest( + ApplicationSharedPtr app, + const size_t choice_set_id_list_length, + const smart_objects::SmartObject& choice_set_id_list) const { + LOG4CXX_AUTO_TRACE(logger_); + + size_t choice_list_length = 0; + std::set<uint32_t> choice_id_set; + smart_objects::SmartObject* choice_set = 0; + std::pair<std::set<uint32_t>::iterator, bool> ins_res; + + for (size_t i = 0; i < choice_set_id_list_length; ++i) { + choice_set = app->FindChoiceSet(choice_set_id_list[i].asInt()); + if (!choice_set) { + LOG4CXX_ERROR( + logger_, + "Couldn't find choiset_id = " << choice_set_id_list[i].asInt()); + return false; + } + choice_list_length = (*choice_set)[strings::choice_set].length(); + const smart_objects::SmartObject& choices_list = + (*choice_set)[strings::choice_set]; + for (size_t k = 0; k < choice_list_length; ++k) { + ins_res = + choice_id_set.insert(choices_list[k][strings::choice_id].asInt()); + if (!ins_res.second) { + LOG4CXX_ERROR(logger_, + "Choise with ID " + << choices_list[k][strings::choice_id].asInt() + << " already exists"); + return false; + } + } + } + return true; +} + +const bool PerformInteractionRequest::HasHMIResponsesToWait() const { + LOG4CXX_AUTO_TRACE(logger_); + return !ui_response_received_ || !vr_response_received_; +} + +void PerformInteractionRequest::SendBothModeResponse( + const smart_objects::SmartObject& msg_param) { + LOG4CXX_AUTO_TRACE(logger_); + mobile_apis::Result::eType perform_interaction_result_code = + mobile_apis::Result::INVALID_ENUM; + app_mngr::commands::ResponseInfo ui_perform_info( + ui_result_code_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); + app_mngr::commands::ResponseInfo vr_perform_info( + vr_result_code_, HmiInterfaces::HMI_INTERFACE_VR, application_manager_); + const bool result = + PrepareResultForMobileResponse(ui_perform_info, vr_perform_info); + perform_interaction_result_code = + PrepareResultCodeForResponse(ui_perform_info, vr_perform_info); + const smart_objects::SmartObject* response_params = + msg_param.empty() ? NULL : &msg_param; + std::string info = app_mngr::commands::MergeInfos( + ui_perform_info, ui_info_, vr_perform_info, vr_info_); + DisablePerformInteraction(); + SendResponse(result, + perform_interaction_result_code, + info.empty() ? NULL : info.c_str(), + response_params); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_response.cc new file mode 100644 index 0000000000..85bef9b2ad --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_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 "sdl_rpc_plugin/commands/mobile/perform_interaction_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +PerformInteractionResponse::PerformInteractionResponse( + 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) {} + +PerformInteractionResponse::~PerformInteractionResponse() {} + +void PerformInteractionResponse::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/put_file_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_request.cc new file mode 100644 index 0000000000..18fe00b54a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_request.cc @@ -0,0 +1,326 @@ +/* + + 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 <algorithm> +#include "sdl_rpc_plugin/commands/mobile/put_file_request.h" + +#include "application_manager/policies/policy_handler.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" + +#include "utils/file_system.h" +#include <boost/crc.hpp> + +namespace { +/** +* Calculates CRC32 checksum +* @param binary_data - input data for which CRC32 should be calculated +* @return calculated CRC32 checksum +*/ +uint32_t GetCrc32CheckSum(const std::vector<uint8_t>& binary_data) { + const std::size_t file_size = binary_data.size(); + boost::crc_32_type result; + result.process_bytes(&binary_data[0], file_size); + return result.checksum(); +} + +} // namespace + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +PutFileRequest::PutFileRequest( + 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) + , offset_(0) + , sync_file_name_() + , length_(0) + , file_type_(mobile_apis::FileType::INVALID_ENUM) + , is_persistent_file_(false) {} + +PutFileRequest::~PutFileRequest() {} + +void PutFileRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + smart_objects::SmartObject response_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + if (!application) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (mobile_api::HMILevel::HMI_NONE == application->hmi_level() && + application_manager_.get_settings().put_file_in_none() <= + application->put_file_in_none_count()) { + // If application is in the HMI_NONE level the quantity of allowed + // PutFile request is limited by the configuration profile + LOG4CXX_ERROR(logger_, + "Too many requests from the app with HMILevel HMI_NONE "); + SendResponse(false, + mobile_apis::Result::REJECTED, + "Too many requests from the app with HMILevel HMI_NONE", + &response_params); + return; + } + + if (!(*message_)[strings::params].keyExists(strings::binary_data)) { + LOG4CXX_ERROR(logger_, "Binary data empty"); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "Binary data empty", + &response_params); + return; + } + + if (!(*message_)[strings::msg_params].keyExists(strings::sync_file_name)) { + LOG4CXX_ERROR(logger_, "No file name"); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "No file name", + &response_params); + return; + } + + if (!(*message_)[strings::msg_params].keyExists(strings::file_type)) { + LOG4CXX_ERROR(logger_, "No file type"); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "No file type", + &response_params); + return; + } + sync_file_name_ = + (*message_)[strings::msg_params][strings::sync_file_name].asString(); + + if (!file_system::IsFileNameValid(sync_file_name_)) { + const std::string err_msg = "Sync file name contains forbidden symbols."; + LOG4CXX_ERROR(logger_, err_msg); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + err_msg.c_str(), + &response_params); + return; + } + + file_type_ = static_cast<mobile_apis::FileType::eType>( + (*message_)[strings::msg_params][strings::file_type].asInt()); + const std::vector<uint8_t> binary_data = + (*message_)[strings::params][strings::binary_data].asBinary(); + + // Policy table update in json format is currently to be received via PutFile + // TODO(PV): after latest discussion has to be changed + if (mobile_apis::FileType::JSON == file_type_) { + policy_handler_.ReceiveMessageFromSDK(sync_file_name_, binary_data); + } + + offset_ = 0; + is_persistent_file_ = false; + bool is_system_file = false; + length_ = binary_data.size(); + bool is_download_complete = true; + bool offset_exist = + (*message_)[strings::msg_params].keyExists(strings::offset); + + if (offset_exist) { + offset_ = (*message_)[strings::msg_params][strings::offset].asInt(); + } + + if ((*message_)[strings::msg_params].keyExists(strings::persistent_file)) { + is_persistent_file_ = + (*message_)[strings::msg_params][strings::persistent_file].asBool(); + } + if ((*message_)[strings::msg_params].keyExists(strings::system_file)) { + is_system_file = + (*message_)[strings::msg_params][strings::system_file].asBool(); + } + + std::string file_path; + + if (is_system_file) { + response_params[strings::space_available] = 0; + file_path = application_manager_.get_settings().system_files_path(); + } else { + file_path = application_manager_.get_settings().app_storage_folder(); + file_path += "/" + application->folder_name(); + + uint32_t space_available = application->GetAvailableDiskSpace(); + + if (binary_data.size() > space_available) { + response_params[strings::space_available] = + static_cast<uint32_t>(space_available); + + LOG4CXX_ERROR(logger_, "Out of memory"); + SendResponse(false, + mobile_apis::Result::OUT_OF_MEMORY, + "Out of memory", + &response_params); + return; + } + } + + if (!file_system::CreateDirectoryRecursively(file_path)) { + LOG4CXX_ERROR(logger_, "Can't create folder"); + SendResponse(false, + mobile_apis::Result::GENERIC_ERROR, + "Can't create folder.", + &response_params); + return; + } + const std::string full_path = file_path + "/" + sync_file_name_; + const size_t bin_data_size = binary_data.size(); + + if ((*message_)[strings::msg_params].keyExists(strings::crc32_check_sum)) { + LOG4CXX_TRACE(logger_, "Binary Data Size: " << bin_data_size); + const uint32_t crc_received = + (*message_)[strings::msg_params][strings::crc32_check_sum].asUInt(); + LOG4CXX_TRACE(logger_, "CRC32 SUM Received: " << crc_received); + const uint32_t crc_calculated = GetCrc32CheckSum(binary_data); + LOG4CXX_TRACE(logger_, "CRC32 SUM Calculated: " << crc_calculated); + if (crc_calculated != crc_received) { + SendResponse(false, + mobile_apis::Result::CORRUPTED_DATA, + "CRC Check on file failed. File upload has been cancelled, " + "please retry.", + &response_params); + return; + } + } + + LOG4CXX_DEBUG(logger_, + "Writing " << bin_data_size << " bytes to " << full_path + << " (current size is" + << file_system::FileSize(full_path) << ")"); + + mobile_apis::Result::eType save_result = application_manager_.SaveBinary( + binary_data, file_path, sync_file_name_, offset_); + + LOG4CXX_DEBUG(logger_, + "New size of " << full_path << " is " + << file_system::FileSize(full_path) << " bytes"); + if (!is_system_file) { + response_params[strings::space_available] = + static_cast<uint32_t>(application->GetAvailableDiskSpace()); + } + + sync_file_name_ = file_path + "/" + sync_file_name_; + switch (save_result) { + case mobile_apis::Result::SUCCESS: { + LOG4CXX_INFO(logger_, "PutFile is successful"); + if (!is_system_file) { + AppFile file(sync_file_name_, + is_persistent_file_, + is_download_complete, + file_type_); + + if (0 == offset_) { + LOG4CXX_INFO(logger_, "New file downloading"); + if (!application->AddFile(file)) { + LOG4CXX_INFO(logger_, + "Couldn't add file to application (File already Exist" + << " in application and was rewritten on FS)"); + /* It can be first part of new big file, so we need to update + information about it's downloading status and persistence */ + if (!application->UpdateFile(file)) { + LOG4CXX_ERROR(logger_, "Couldn't update file"); + /* If it is impossible to update file, application doesn't + know about existing this file */ + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "Couldn't update file", + &response_params); + return; + } + } else { + /* if file added - increment it's count + ( may be application->AddFile have to incapsulate it? ) + Any way now this method evals not only in "none"*/ + application->increment_put_file_in_none_count(); + } + } + } + + SendResponse(true, save_result, "File was downloaded", &response_params); + if (is_system_file) { + SendOnPutFileNotification(); + } + break; + } + default: + LOG4CXX_WARN(logger_, + "PutFile is unsuccessful. Result = " << save_result); + SendResponse(false, save_result, "Can't save file", &response_params); + break; + } +} + +void PutFileRequest::SendOnPutFileNotification() { + LOG4CXX_INFO(logger_, "SendOnPutFileNotification"); + smart_objects::SmartObjectSPtr notification = + new smart_objects::SmartObject(smart_objects::SmartType_Map); + + smart_objects::SmartObject& message = *notification; + message[strings::params][strings::function_id] = + hmi_apis::FunctionID::BasicCommunication_OnPutFile; + + message[strings::params][strings::message_type] = MessageType::kNotification; + message[strings::msg_params][strings::app_id] = connection_key(); + message[strings::msg_params][strings::sync_file_name] = sync_file_name_; + message[strings::msg_params][strings::offset] = offset_; + if (0 == offset_) { + message[strings::msg_params][strings::file_size] = + (*message_)[strings::msg_params][strings::length]; + } + message[strings::msg_params][strings::length] = length_; + message[strings::msg_params][strings::persistent_file] = is_persistent_file_; + message[strings::msg_params][strings::file_type] = file_type_; + rpc_service_.ManageHMICommand(notification); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_response.cc new file mode 100644 index 0000000000..8c54970a5c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_response.cc @@ -0,0 +1,73 @@ +/* + + 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/put_file_response.h" +#include "utils/file_system.h" +#include "application_manager/application_impl.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +PutFileResponse::PutFileResponse( + 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) {} + +PutFileResponse::~PutFileResponse() {} + +void PutFileResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + uint32_t app_id = + (*message_)[strings::params][strings::connection_key].asUInt(); + ApplicationSharedPtr app = application_manager_.application(app_id); + if (!app) { + LOG4CXX_ERROR(logger_, "Application not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + SendResponse((*message_)[strings::msg_params][strings::success].asBool()); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc new file mode 100644 index 0000000000..20302be585 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -0,0 +1,1375 @@ +/* + + 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/register_app_interface_request.h" + +#include <unistd.h> +#include <algorithm> +#include <map> +#include <string.h> + +#include <utils/make_shared.h> +#include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/application_impl.h" +#include "application_manager/app_launch/app_launch_ctrl.h" +#include "application_manager/message_helper.h" +#include "application_manager/resumption/resume_ctrl.h" +#include "application_manager/policies/policy_handler.h" +#include "application_manager/helpers/application_helper.h" +#include "application_manager/rpc_service.h" +#include "config_profile/profile.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/generated_msg_version.h" +#include "utils/file_system.h" + +namespace { +namespace custom_str = utils::custom_string; + +mobile_apis::AppHMIType::eType StringToAppHMIType(const std::string& str) { + if ("DEFAULT" == str) { + return mobile_apis::AppHMIType::DEFAULT; + } else if ("COMMUNICATION" == str) { + return mobile_apis::AppHMIType::COMMUNICATION; + } else if ("MEDIA" == str) { + return mobile_apis::AppHMIType::MEDIA; + } else if ("MESSAGING" == str) { + return mobile_apis::AppHMIType::MESSAGING; + } else if ("NAVIGATION" == str) { + return mobile_apis::AppHMIType::NAVIGATION; + } else if ("INFORMATION" == str) { + return mobile_apis::AppHMIType::INFORMATION; + } else if ("SOCIAL" == str) { + return mobile_apis::AppHMIType::SOCIAL; + } else if ("BACKGROUND_PROCESS" == str) { + return mobile_apis::AppHMIType::BACKGROUND_PROCESS; + } else if ("TESTING" == str) { + return mobile_apis::AppHMIType::TESTING; + } else if ("SYSTEM" == str) { + return mobile_apis::AppHMIType::SYSTEM; + } else if ("PROJECTION" == str) { + return mobile_apis::AppHMIType::PROJECTION; + } else if ("REMOTE_CONTROL" == str) { + return mobile_apis::AppHMIType::REMOTE_CONTROL; + } else { + return mobile_apis::AppHMIType::INVALID_ENUM; + } +} + +std::string AppHMITypeToString(mobile_apis::AppHMIType::eType type) { + const std::map<mobile_apis::AppHMIType::eType, std::string> app_hmi_type_map = + {{mobile_apis::AppHMIType::DEFAULT, "DEFAULT"}, + {mobile_apis::AppHMIType::REMOTE_CONTROL, "REMOTE_CONTROL"}, + {mobile_apis::AppHMIType::COMMUNICATION, "COMMUNICATION"}, + {mobile_apis::AppHMIType::MEDIA, "MEDIA"}, + {mobile_apis::AppHMIType::MESSAGING, "MESSAGING"}, + {mobile_apis::AppHMIType::NAVIGATION, "NAVIGATION"}, + {mobile_apis::AppHMIType::INFORMATION, "INFORMATION"}, + {mobile_apis::AppHMIType::SOCIAL, "SOCIAL"}, + {mobile_apis::AppHMIType::BACKGROUND_PROCESS, "BACKGROUND_PROCESS"}, + {mobile_apis::AppHMIType::TESTING, "TESTING"}, + {mobile_apis::AppHMIType::SYSTEM, "SYSTEM"}, + {mobile_apis::AppHMIType::PROJECTION, "PROJECTION"}}; + + std::map<mobile_apis::AppHMIType::eType, std::string>::const_iterator iter = + app_hmi_type_map.find(type); + + return app_hmi_type_map.end() != iter ? iter->second : std::string(""); +} + +struct AppHMITypeInserter { + AppHMITypeInserter(smart_objects::SmartObject& so_array) + : index_(0), so_array_(so_array) {} + + bool operator()(const std::string& app_hmi_type) { + so_array_[index_] = StringToAppHMIType(app_hmi_type); + ++index_; + return true; + } + + private: + uint32_t index_; + smart_objects::SmartObject& so_array_; +}; + +struct CheckMissedTypes { + CheckMissedTypes(const policy::StringArray& policy_app_types, + std::string& log) + : policy_app_types_(policy_app_types), log_(log) {} + + bool operator()(const smart_objects::SmartArray::value_type& value) { + std::string app_type_str = AppHMITypeToString( + static_cast<mobile_apis::AppHMIType::eType>(value.asInt())); + if (!app_type_str.empty()) { + policy::StringArray::const_iterator it = policy_app_types_.begin(); + policy::StringArray::const_iterator it_end = policy_app_types_.end(); + for (; it != it_end; ++it) { + if (app_type_str == *it) { + return true; + } + } + } + + log_ += app_type_str; + log_ += ","; + + return true; + } + + private: + const policy::StringArray& policy_app_types_; + std::string& log_; +}; + +class SmartArrayValueExtractor { + public: + AppHmiType operator()(const smart_objects::SmartObject& so) const { + return static_cast<AppHmiType>(so.asInt()); + } +}; + +struct IsSameNickname { + IsSameNickname(const custom_str::CustomString& app_id) : app_id_(app_id) {} + bool operator()(const policy::StringArray::value_type& nickname) const { + return app_id_.CompareIgnoreCase(nickname.c_str()); + } + + private: + const custom_str::CustomString& app_id_; +}; +} + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +RegisterAppInterfaceRequest::RegisterAppInterfaceRequest( + 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) + , result_code_(mobile_apis::Result::INVALID_ENUM) {} + +RegisterAppInterfaceRequest::~RegisterAppInterfaceRequest() {} + +bool RegisterAppInterfaceRequest::Init() { + LOG4CXX_AUTO_TRACE(logger_); + return true; +} + +void RegisterAppInterfaceRequest::Run() { + using namespace helpers; + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, "Connection key is " << connection_key()); + + // Fix problem with SDL and HMI HTML. This problem is not actual for HMI PASA. + // Flag conditional compilation specific to customer is used in order to + // exclude hit code + // to RTC + // FIXME(EZamakhov): on shutdown - get freez + + // wait till HMI started + while (!application_manager_.IsStopping() && + !application_manager_.IsHMICooperating()) { + LOG4CXX_DEBUG(logger_, + "Waiting for the HMI... conn_key=" + << connection_key() + << ", correlation_id=" << correlation_id() + << ", default_timeout=" << default_timeout() + << ", thread=" << pthread_self()); + application_manager_.updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + sleep(1); + // TODO(DK): timer_->StartWait(1); + } + + if (application_manager_.IsStopping()) { + LOG4CXX_WARN(logger_, "The ApplicationManager is stopping!"); + return; + } + + if (IsApplicationSwitched()) { + return; + } + + const std::string mobile_app_id = + (*message_)[strings::msg_params][strings::app_id].asString(); + + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + if (application) { + SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY); + return; + } + + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + const std::string policy_app_id = msg_params[strings::app_id].asString(); + std::string new_policy_app_id = policy_app_id; + std::transform(policy_app_id.begin(), + policy_app_id.end(), + new_policy_app_id.begin(), + ::tolower); + (*message_)[strings::msg_params][strings::app_id] = new_policy_app_id; + + if (application_manager_.IsApplicationForbidden(connection_key(), + policy_app_id)) { + SendResponse(false, mobile_apis::Result::TOO_MANY_PENDING_REQUESTS); + return; + } + + if (IsApplicationWithSameAppIdRegistered()) { + SendResponse(false, mobile_apis::Result::DISALLOWED); + return; + } + + mobile_apis::Result::eType policy_result = CheckWithPolicyData(); + + if (Compare<mobile_apis::Result::eType, NEQ, ALL>( + policy_result, + mobile_apis::Result::SUCCESS, + mobile_apis::Result::WARNINGS)) { + SendResponse(false, policy_result); + return; + } + + mobile_apis::Result::eType coincidence_result = CheckCoincidence(); + + if (mobile_apis::Result::SUCCESS != coincidence_result) { + LOG4CXX_ERROR(logger_, "Coincidence check failed."); + if (mobile_apis::Result::DUPLICATE_NAME == coincidence_result) { + usage_statistics::AppCounter count_of_rejections_duplicate_name( + GetPolicyHandler().GetStatisticManager(), + policy_app_id, + usage_statistics::REJECTIONS_DUPLICATE_NAME); + ++count_of_rejections_duplicate_name; + } + SendResponse(false, coincidence_result); + return; + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_INFO(logger_, + "Incoming register app interface has contains \t\n \\t \\n"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + application = application_manager_.RegisterApplication(message_); + + if (!application) { + LOG4CXX_ERROR(logger_, "Application hasn't been registered!"); + return; + } + // For resuming application need to restore hmi_app_id from resumeCtrl + resumption::ResumeCtrl& resumer = application_manager_.resume_controller(); + const std::string& device_mac = application->mac_address(); + + // there is side affect with 2 mobile app with the same mobile app_id + if (resumer.IsApplicationSaved(policy_app_id, device_mac)) { + application->set_hmi_application_id( + resumer.GetHMIApplicationID(policy_app_id, device_mac)); + } else { + application->set_hmi_application_id( + application_manager_.GenerateNewHMIAppID()); + } + + application->set_is_media_application( + msg_params[strings::is_media_application].asBool()); + + if (msg_params.keyExists(strings::vr_synonyms)) { + application->set_vr_synonyms(msg_params[strings::vr_synonyms]); + } + + if (msg_params.keyExists(strings::ngn_media_screen_app_name)) { + application->set_ngn_media_screen_name( + msg_params[strings::ngn_media_screen_app_name]); + } + + if (msg_params.keyExists(strings::tts_name)) { + smart_objects::SmartObject& tts_name = + (*message_)[strings::msg_params][strings::tts_name]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles( + tts_name, application, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_WARN(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + response_info_ = "One or more files needed for tts_name are not present"; + result_code_ = mobile_apis::Result::WARNINGS; + } + application->set_tts_name(tts_name); + } + + if (msg_params.keyExists(strings::app_hmi_type)) { + application->set_app_types(msg_params[strings::app_hmi_type]); + + // check app type + const smart_objects::SmartObject& app_type = + msg_params.getElement(strings::app_hmi_type); + + for (size_t i = 0; i < app_type.length(); ++i) { + mobile_apis::AppHMIType::eType current_app_type = + static_cast<mobile_apis::AppHMIType::eType>( + app_type.getElement(i).asUInt()); + + switch (current_app_type) { + case mobile_apis::AppHMIType::NAVIGATION: { + application->set_is_navi(true); + break; + } + case mobile_apis::AppHMIType::COMMUNICATION: { + application->set_voice_communication_supported(true); + break; + } + case mobile_apis::AppHMIType::PROJECTION: { + application->set_mobile_projection_enabled(true); + break; + } + case mobile_apis::AppHMIType::REMOTE_CONTROL: { + application->set_remote_control_supported(true); + break; + } + default: {} + } + } + } + + if (msg_params.keyExists(strings::day_color_scheme)) { + application->set_day_color_scheme(msg_params[strings::day_color_scheme]); + } + + if (msg_params.keyExists(strings::night_color_scheme)) { + application->set_night_color_scheme( + msg_params[strings::night_color_scheme]); + } + + // Add device to policy table and set device info, if any + policy::DeviceParams dev_params; + if (-1 == + application_manager_.connection_handler() + .get_session_observer() + .GetDataOnDeviceID(application->device(), + &dev_params.device_name, + NULL, + &dev_params.device_mac_address, + &dev_params.device_connection_type)) { + LOG4CXX_ERROR(logger_, + "Failed to extract information for device " + << application->device()); + } + policy::DeviceInfo device_info; + device_info.AdoptDeviceType(dev_params.device_connection_type); + if (msg_params.keyExists(strings::device_info)) { + FillDeviceInfo(&device_info); + } + + GetPolicyHandler().SetDeviceInfo(device_mac, device_info); + + SendRegisterAppInterfaceResponseToMobile(ApplicationType::kNewApplication); + smart_objects::SmartObjectSPtr so = + GetLockScreenIconUrlNotification(connection_key(), application); + rpc_service_.ManageMobileCommand(so, SOURCE_SDL); +} + +smart_objects::SmartObjectSPtr +RegisterAppInterfaceRequest::GetLockScreenIconUrlNotification( + const uint32_t connection_key, ApplicationSharedPtr app) { + DCHECK_OR_RETURN(app.get(), smart_objects::SmartObjectSPtr()); + smart_objects::SmartObjectSPtr message = + utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); + (*message)[strings::params][strings::function_id] = + mobile_apis::FunctionID::OnSystemRequestID; + (*message)[strings::params][strings::connection_key] = connection_key; + (*message)[strings::params][strings::message_type] = + mobile_apis::messageType::notification; + (*message)[strings::params][strings::protocol_type] = mobile_protocol_type_; + (*message)[strings::params][strings::protocol_version] = protocol_version_; + (*message)[strings::msg_params][strings::request_type] = + mobile_apis::RequestType::LOCK_SCREEN_ICON_URL; + (*message)[strings::msg_params][strings::url] = + GetPolicyHandler().GetLockScreenIconUrl(); + return message; +} + +void FillVRRelatedFields(smart_objects::SmartObject& response_params, + const HMICapabilities& hmi_capabilities) { + response_params[strings::language] = hmi_capabilities.active_vr_language(); + if (hmi_capabilities.vr_capabilities()) { + response_params[strings::vr_capabilities] = + *hmi_capabilities.vr_capabilities(); + } +} + +void FillVIRelatedFields(smart_objects::SmartObject& response_params, + const HMICapabilities& hmi_capabilities) { + if (hmi_capabilities.vehicle_type()) { + response_params[hmi_response::vehicle_type] = + *hmi_capabilities.vehicle_type(); + } +} + +void FillTTSRelatedFields(smart_objects::SmartObject& response_params, + const HMICapabilities& hmi_capabilities) { + response_params[strings::language] = hmi_capabilities.active_tts_language(); + if (hmi_capabilities.speech_capabilities()) { + response_params[strings::speech_capabilities] = + *hmi_capabilities.speech_capabilities(); + } + if (hmi_capabilities.prerecorded_speech()) { + response_params[strings::prerecorded_speech] = + *(hmi_capabilities.prerecorded_speech()); + } +} + +void FillUIRelatedFields(smart_objects::SmartObject& response_params, + const HMICapabilities& hmi_capabilities) { + response_params[strings::hmi_display_language] = + hmi_capabilities.active_ui_language(); + if (hmi_capabilities.display_capabilities()) { + response_params[hmi_response::display_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + smart_objects::SmartObject& display_caps = + response_params[hmi_response::display_capabilities]; + + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::display_type)) { + display_caps[hmi_response::display_type] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::display_type); + } + + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::display_name)) { + display_caps[hmi_response::display_name] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::display_name); + } + + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::text_fields)) { + display_caps[hmi_response::text_fields] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::text_fields); + } + + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::image_fields)) { + display_caps[hmi_response::image_fields] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::image_fields); + } + + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::media_clock_formats)) { + display_caps[hmi_response::media_clock_formats] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::media_clock_formats); + } + + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::templates_available)) { + display_caps[hmi_response::templates_available] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::templates_available); + } + + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::screen_params)) { + display_caps[hmi_response::screen_params] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::screen_params); + } + + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::num_custom_presets_available)) { + display_caps[hmi_response::num_custom_presets_available] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::num_custom_presets_available); + } + + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::image_capabilities)) { + display_caps[hmi_response::graphic_supported] = + (hmi_capabilities.display_capabilities() + ->getElement(hmi_response::image_capabilities) + .length() > 0); + } + } + + if (hmi_capabilities.audio_pass_thru_capabilities()) { + if (smart_objects::SmartType_Array == + hmi_capabilities.audio_pass_thru_capabilities()->getType()) { + // hmi_capabilities json contains array and HMI response object + response_params[strings::audio_pass_thru_capabilities] = + *hmi_capabilities.audio_pass_thru_capabilities(); + } else { + response_params[strings::audio_pass_thru_capabilities][0] = + *hmi_capabilities.audio_pass_thru_capabilities(); + } + } + response_params[strings::hmi_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + response_params[strings::hmi_capabilities][strings::navigation] = + hmi_capabilities.navigation_supported(); + response_params[strings::hmi_capabilities][strings::phone_call] = + hmi_capabilities.phone_call_supported(); + response_params[strings::hmi_capabilities][strings::video_streaming] = + hmi_capabilities.video_streaming_supported(); + response_params[strings::hmi_capabilities][strings::remote_control] = + hmi_capabilities.rc_supported(); +} + +void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( + ApplicationType app_type) { + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject response_params(smart_objects::SmartType_Map); + + mobile_apis::Result::eType result_code = mobile_apis::Result::SUCCESS; + + const HMICapabilities& hmi_capabilities = hmi_capabilities_; + + const uint32_t key = connection_key(); + ApplicationSharedPtr application = application_manager_.application(key); + + resumption::ResumeCtrl& resumer = application_manager_.resume_controller(); + + if (!application) { + LOG4CXX_ERROR(logger_, + "There is no application for such connection key" << key); + LOG4CXX_DEBUG(logger_, "Need to start resume data persistent timer"); + resumer.OnAppRegistrationEnd(); + return; + } + + response_params[strings::sync_msg_version][strings::major_version] = + major_version; // From generated file interfaces/generated_msg_version.h + response_params[strings::sync_msg_version][strings::minor_version] = + minor_version; // From generated file interfaces/generated_msg_version.h + response_params[strings::sync_msg_version][strings::patch_version] = + patch_version; // From generated file interfaces/generated_msg_version.h + + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + if (msg_params[strings::language_desired].asInt() != + hmi_capabilities.active_vr_language() || + msg_params[strings::hmi_display_language_desired].asInt() != + hmi_capabilities.active_ui_language()) { + LOG4CXX_WARN(logger_, + "Wrong language on registering application " + << application->name().c_str()); + + LOG4CXX_ERROR( + logger_, + "VR language desired code is " + << msg_params[strings::language_desired].asInt() + << " , active VR language code is " + << hmi_capabilities.active_vr_language() << ", UI language code is " + << msg_params[strings::hmi_display_language_desired].asInt() + << " , active UI language code is " + << hmi_capabilities.active_ui_language()); + + result_code = mobile_apis::Result::WRONG_LANGUAGE; + } + + if (HmiInterfaces::STATE_NOT_AVAILABLE != + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_TTS)) { + FillTTSRelatedFields(response_params, hmi_capabilities); + } + + if (HmiInterfaces::STATE_NOT_AVAILABLE != + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_VR)) { + FillVRRelatedFields(response_params, hmi_capabilities); + } + + if (HmiInterfaces::STATE_NOT_AVAILABLE != + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_UI)) { + FillUIRelatedFields(response_params, hmi_capabilities); + } + + if (HmiInterfaces::STATE_NOT_AVAILABLE != + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_VehicleInfo)) { + FillVIRelatedFields(response_params, hmi_capabilities); + } + + if (hmi_capabilities.button_capabilities()) { + response_params[hmi_response::button_capabilities] = + *hmi_capabilities.button_capabilities(); + } + + if (hmi_capabilities.soft_button_capabilities()) { + response_params[hmi_response::soft_button_capabilities] = + *hmi_capabilities.soft_button_capabilities(); + } + + if (hmi_capabilities.preset_bank_capabilities()) { + response_params[hmi_response::preset_bank_capabilities] = + *hmi_capabilities.preset_bank_capabilities(); + } + + if (hmi_capabilities.hmi_zone_capabilities()) { + if (smart_objects::SmartType_Array == + hmi_capabilities.hmi_zone_capabilities()->getType()) { + // hmi_capabilities json contains array and HMI response object + response_params[hmi_response::hmi_zone_capabilities] = + *hmi_capabilities.hmi_zone_capabilities(); + } else { + response_params[hmi_response::hmi_zone_capabilities][0] = + *hmi_capabilities.hmi_zone_capabilities(); + } + } + + if (hmi_capabilities.pcm_stream_capabilities()) { + response_params[strings::pcm_stream_capabilities] = + *hmi_capabilities.pcm_stream_capabilities(); + } + + const std::vector<uint32_t>& diag_modes = + application_manager_.get_settings().supported_diag_modes(); + if (!diag_modes.empty()) { + std::vector<uint32_t>::const_iterator it = diag_modes.begin(); + uint32_t index = 0; + for (; it != diag_modes.end(); ++it) { + response_params[strings::supported_diag_modes][index] = *it; + ++index; + } + } + + response_params[strings::sdl_version] = + application_manager_.get_settings().sdl_version(); + const std::string ccpu_version = hmi_capabilities_.ccpu_version(); + if (!ccpu_version.empty()) { + response_params[strings::system_software_version] = ccpu_version; + } + + if (ApplicationType::kSwitchedApplicationWrongHashId == app_type) { + LOG4CXX_DEBUG(logger_, + "Application has been switched from another transport, " + "but doesn't have correct hashID."); + + application_manager::DeleteApplicationData(application, + application_manager_); + + SendResponse( + true, mobile_apis::Result::RESUME_FAILED, NULL, &response_params); + return; + } + + if (ApplicationType::kSwitchedApplicationHashOk == app_type) { + LOG4CXX_DEBUG(logger_, + "Application has been switched from another transport " + "and has correct hashID."); + SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params); + return; + } + + bool resumption = + (*message_)[strings::msg_params].keyExists(strings::hash_id); + + bool need_restore_vr = resumption; + + std::string hash_id; + std::string add_info; + if (resumption) { + hash_id = (*message_)[strings::msg_params][strings::hash_id].asString(); + if (!resumer.CheckApplicationHash(application, hash_id)) { + LOG4CXX_WARN(logger_, + "Hash from RAI does not match to saved resume data."); + result_code = mobile_apis::Result::RESUME_FAILED; + add_info = "Hash from RAI does not match to saved resume data."; + need_restore_vr = false; + } else if (!resumer.CheckPersistenceFilesForResumption(application)) { + LOG4CXX_WARN(logger_, "Persistent data is missing."); + result_code = mobile_apis::Result::RESUME_FAILED; + add_info = "Persistent data is missing."; + need_restore_vr = false; + } else { + add_info = "Resume succeeded."; + } + } + if ((mobile_apis::Result::SUCCESS == result_code) && + (mobile_apis::Result::INVALID_ENUM != result_code_)) { + add_info += response_info_; + result_code = result_code_; + } + + // in case application exist in resumption we need to send resumeVrgrammars + if (false == resumption) { + resumption = resumer.IsApplicationSaved(application->policy_app_id(), + application->mac_address()); + } + + AppHmiTypes hmi_types; + if ((*message_)[strings::msg_params].keyExists(strings::app_hmi_type)) { + smart_objects::SmartArray* hmi_types_ptr = + (*message_)[strings::msg_params][strings::app_hmi_type].asArray(); + DCHECK_OR_RETURN_VOID(hmi_types_ptr); + SmartArrayValueExtractor extractor; + if (hmi_types_ptr && 0 < hmi_types_ptr->size()) { + std::transform(hmi_types_ptr->begin(), + hmi_types_ptr->end(), + std::back_inserter(hmi_types), + extractor); + } + } + policy::StatusNotifier notify_upd_manager = GetPolicyHandler().AddApplication( + application->policy_app_id(), hmi_types); + + response_params[strings::icon_resumed] = + file_system::FileExists(application->app_icon_path()); + + SendResponse(true, result_code, add_info.c_str(), &response_params); + SendOnAppRegisteredNotificationToHMI( + *(application.get()), resumption, need_restore_vr); + if (msg_params.keyExists(strings::app_hmi_type)) { + GetPolicyHandler().SetDefaultHmiTypes(application->policy_app_id(), + &(msg_params[strings::app_hmi_type])); + } + + // Default HMI level should be set before any permissions validation, since it + // relies on HMI level. + application_manager_.OnApplicationRegistered(application); + (*notify_upd_manager)(); + + // Start PTU after successfull registration + // Sends OnPermissionChange notification to mobile right after RAI response + // and HMI level set-up + GetPolicyHandler().OnAppRegisteredOnMobile(application->policy_app_id()); + + if (result_code != mobile_apis::Result::RESUME_FAILED) { + resumer.StartResumption(application, hash_id); + } else { + resumer.StartResumptionOnlyHMILevel(application); + } + + // By default app subscribed to CUSTOM_BUTTON + SendSubscribeCustomButtonNotification(); + SendChangeRegistrationOnHMI(application); +} + +DEPRECATED void +RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() { + SendRegisterAppInterfaceResponseToMobile(ApplicationType::kNewApplication); +} + +void RegisterAppInterfaceRequest::SendChangeRegistration( + const hmi_apis::FunctionID::eType function_id, + const int32_t language, + const uint32_t app_id) { + using helpers::Compare; + using helpers::EQ; + using helpers::ONE; + const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces(); + const HmiInterfaces::InterfaceID interface = + hmi_interfaces.GetInterfaceFromFunction(function_id); + if (hmi_interfaces.GetInterfaceState(interface) != + HmiInterfaces::STATE_NOT_AVAILABLE) { + smart_objects::SmartObject msg_params(smart_objects::SmartType_Map); + msg_params[strings::language] = language; + msg_params[strings::app_id] = app_id; + SendHMIRequest(function_id, &msg_params); + } else { + LOG4CXX_DEBUG(logger_, "Interface " << interface << "is not avaliable"); + } +} + +void RegisterAppInterfaceRequest::SendChangeRegistrationOnHMI( + ApplicationConstSharedPtr app) { + using namespace hmi_apis::FunctionID; + DCHECK_OR_RETURN_VOID(app); + DCHECK_OR_RETURN_VOID(mobile_apis::Language::INVALID_ENUM != app->language()); + SendChangeRegistration(VR_ChangeRegistration, app->language(), app->app_id()); + SendChangeRegistration( + TTS_ChangeRegistration, app->language(), app->app_id()); + SendChangeRegistration(UI_ChangeRegistration, app->language(), app->app_id()); +} + +void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI( + const app_mngr::Application& application_impl, + bool resumption, + bool need_restore_vr) { + using namespace smart_objects; + SmartObjectSPtr notification = utils::MakeShared<SmartObject>(SmartType_Map); + if (!notification) { + LOG4CXX_ERROR(logger_, "Failed to create smart object"); + return; + } + + (*notification)[strings::params] = SmartObject(SmartType_Map); + smart_objects::SmartObject& params = (*notification)[strings::params]; + params[strings::function_id] = static_cast<int32_t>( + hmi_apis::FunctionID::BasicCommunication_OnAppRegistered); + params[strings::message_type] = static_cast<int32_t>(kNotification); + params[strings::protocol_version] = protocol_version_; + params[strings::protocol_type] = hmi_protocol_type_; + + (*notification)[strings::msg_params] = SmartObject(SmartType_Map); + smart_objects::SmartObject& msg_params = (*notification)[strings::msg_params]; + // Due to current requirements in case when we're in resumption mode + // we have to always send resumeVRGrammar field. + if (resumption) { + msg_params[strings::resume_vr_grammars] = need_restore_vr; + } + + if (application_impl.vr_synonyms()) { + msg_params[strings::vr_synonyms] = *(application_impl.vr_synonyms()); + } + + if (application_impl.tts_name()) { + msg_params[strings::tts_name] = *(application_impl.tts_name()); + } + + const std::string policy_app_id = application_impl.policy_app_id(); + std::string priority; + GetPolicyHandler().GetPriority(policy_app_id, &priority); + + if (!priority.empty()) { + msg_params[strings::priority] = MessageHelper::GetPriorityCode(priority); + } + + msg_params[strings::msg_params] = SmartObject(SmartType_Map); + smart_objects::SmartObject& application = msg_params[strings::application]; + application[strings::app_name] = application_impl.name(); + application[strings::app_id] = application_impl.app_id(); + application[hmi_response::policy_app_id] = policy_app_id; + if (file_system::FileExists(application_impl.app_icon_path())) { + application[strings::icon] = application_impl.app_icon_path(); + } + + const smart_objects::SmartObject* ngn_media_screen_name = + application_impl.ngn_media_screen_name(); + if (ngn_media_screen_name) { + application[strings::ngn_media_screen_app_name] = *ngn_media_screen_name; + } + + application[strings::hmi_display_language_desired] = + static_cast<int32_t>(application_impl.ui_language()); + + application[strings::is_media_application] = + application_impl.is_media_application(); + + const smart_objects::SmartObject* app_type = application_impl.app_types(); + if (app_type) { + application[strings::app_type] = *app_type; + } + + const policy::RequestType::State app_request_types_state = + GetPolicyHandler().GetAppRequestTypeState(policy_app_id); + if (policy::RequestType::State::AVAILABLE == app_request_types_state) { + const auto request_types = + GetPolicyHandler().GetAppRequestTypes(policy_app_id); + application[strings::request_type] = SmartObject(SmartType_Array); + smart_objects::SmartObject& request_types_array = + application[strings::request_type]; + + size_t index = 0; + for (auto it : request_types) { + request_types_array[index] = it; + ++index; + } + } else if (policy::RequestType::State::EMPTY == app_request_types_state) { + application[strings::request_type] = SmartObject(SmartType_Array); + } + + const policy::RequestSubType::State app_request_subtypes_state = + GetPolicyHandler().GetAppRequestSubTypeState(policy_app_id); + if (policy::RequestSubType::State::AVAILABLE == app_request_subtypes_state) { + const auto request_subtypes = + GetPolicyHandler().GetAppRequestSubTypes(policy_app_id); + application[strings::request_subtype] = SmartObject(SmartType_Array); + smart_objects::SmartObject& request_subtypes_array = + application[strings::request_subtype]; + + size_t index = 0; + for (auto it : request_subtypes) { + request_subtypes_array[index] = it; + ++index; + } + } else if (policy::RequestSubType::State::EMPTY == + app_request_subtypes_state) { + application[strings::request_subtype] = SmartObject(SmartType_Array); + } + + const protocol_handler::SessionObserver& session_observer = + application_manager_.connection_handler().get_session_observer(); + + application[strings::device_info] = SmartObject(SmartType_Map); + smart_objects::SmartObject& device_info = application[strings::device_info]; + MessageHelper::CreateDeviceInfo(application_impl.device(), + session_observer, + GetPolicyHandler(), + application_manager_, + &device_info); + + if (application_impl.secondary_device() != 0) { + application[strings::secondary_device_info] = SmartObject(SmartType_Map); + smart_objects::SmartObject& secondary_device_info = + application[strings::secondary_device_info]; + MessageHelper::CreateDeviceInfo(application_impl.secondary_device(), + session_observer, + GetPolicyHandler(), + application_manager_, + &secondary_device_info); + } + + const smart_objects::SmartObject* day_color_scheme = + application_impl.day_color_scheme(); + if (day_color_scheme) { + application[strings::day_color_scheme] = *day_color_scheme; + } + + const smart_objects::SmartObject* night_color_scheme = + application_impl.night_color_scheme(); + if (night_color_scheme) { + application[strings::night_color_scheme] = *night_color_scheme; + } + + DCHECK(rpc_service_.ManageHMICommand(notification)); +} + +mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence() { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + ApplicationSet accessor = application_manager_.applications().GetData(); + + ApplicationSetConstIt it = accessor.begin(); + const custom_str::CustomString& app_name = + msg_params[strings::app_name].asCustomString(); + + for (; accessor.end() != it; ++it) { + // name check + const custom_str::CustomString& cur_name = (*it)->name(); + if (app_name.CompareIgnoreCase(cur_name)) { + LOG4CXX_ERROR(logger_, "Application name is known already."); + return mobile_apis::Result::DUPLICATE_NAME; + } + + const smart_objects::SmartObject* vr = (*it)->vr_synonyms(); + const std::vector<smart_objects::SmartObject>* curr_vr = NULL; + if (NULL != vr) { + curr_vr = vr->asArray(); + CoincidencePredicateVR v(app_name); + + if (0 != std::count_if(curr_vr->begin(), curr_vr->end(), v)) { + LOG4CXX_ERROR(logger_, "Application name is known already."); + return mobile_apis::Result::DUPLICATE_NAME; + } + } + + // vr check + if (msg_params.keyExists(strings::vr_synonyms)) { + const std::vector<smart_objects::SmartObject>* new_vr = + msg_params[strings::vr_synonyms].asArray(); + + CoincidencePredicateVR v(cur_name); + if (0 != std::count_if(new_vr->begin(), new_vr->end(), v)) { + LOG4CXX_ERROR(logger_, "vr_synonyms duplicated with app_name ."); + return mobile_apis::Result::DUPLICATE_NAME; + } + } // end vr check + + } // application for end + + return mobile_apis::Result::SUCCESS; +} // method end + +mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() { + LOG4CXX_AUTO_TRACE(logger_); + // TODO(AOleynik): Check is necessary to allow register application in case + // of disabled policy + // Remove this check, when HMI will support policy + if (!GetPolicyHandler().PolicyEnabled()) { + return mobile_apis::Result::WARNINGS; + } + + smart_objects::SmartObject& message = *message_; + policy::StringArray app_nicknames; + policy::StringArray app_hmi_types; + + const std::string mobile_app_id = + message[strings::msg_params][strings::app_id].asString(); + const bool init_result = GetPolicyHandler().GetInitialAppData( + mobile_app_id, &app_nicknames, &app_hmi_types); + + if (!init_result) { + LOG4CXX_ERROR(logger_, "Error during initial application data check."); + return mobile_apis::Result::INVALID_DATA; + } + + if (!app_nicknames.empty()) { + IsSameNickname compare( + message[strings::msg_params][strings::app_name].asCustomString()); + policy::StringArray::const_iterator it = + std::find_if(app_nicknames.begin(), app_nicknames.end(), compare); + if (app_nicknames.end() == it) { + LOG4CXX_WARN(logger_, + "Application name was not found in nicknames list."); + // App should be unregistered, if its name is not present in nicknames + // list + usage_statistics::AppCounter count_of_rejections_nickname_mismatch( + GetPolicyHandler().GetStatisticManager(), + mobile_app_id, + usage_statistics::REJECTIONS_NICKNAME_MISMATCH); + ++count_of_rejections_nickname_mismatch; + return mobile_apis::Result::DISALLOWED; + } + } + + mobile_apis::Result::eType result = mobile_apis::Result::SUCCESS; + + // If AppHMIType is not included in policy - allow any type + if (!app_hmi_types.empty()) { + if (message[strings::msg_params].keyExists(strings::app_hmi_type)) { + // If AppHmiTypes are partially same, the system should allow those listed + // in the policy table and send warning info on missed values + smart_objects::SmartArray app_types = + *(message[strings::msg_params][strings::app_hmi_type].asArray()); + + std::string log; + CheckMissedTypes checker(app_hmi_types, log); + std::for_each(app_types.begin(), app_types.end(), checker); + if (!log.empty()) { + response_info_ = + "Following AppHmiTypes are not present in policy " + "table:" + + log; + result_code_ = mobile_apis::Result::WARNINGS; + } + } + // Replace AppHmiTypes in request with values allowed by policy table + message[strings::msg_params][strings::app_hmi_type] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + smart_objects::SmartObject& app_hmi_type = + message[strings::msg_params][strings::app_hmi_type]; + + AppHMITypeInserter inserter(app_hmi_type); + std::for_each(app_hmi_types.begin(), app_hmi_types.end(), inserter); + } + + return result; +} + +void RegisterAppInterfaceRequest::FillDeviceInfo( + policy::DeviceInfo* device_info) { + const std::string hardware = "hardware"; + const std::string firmware_rev = "firmwareRev"; + const std::string os = "os"; + const std::string os_ver = "osVersion"; + const std::string carrier = "carrier"; + const std::string max_number_rfcom_ports = "maxNumberRFCOMMPorts"; + + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + const smart_objects::SmartObject& device_info_so = + msg_params[strings::device_info]; + + if (device_info_so.keyExists(hardware)) { + device_info->hardware = + msg_params[strings::device_info][hardware].asString(); + } + if (device_info_so.keyExists(firmware_rev)) { + device_info->firmware_rev = + msg_params[strings::device_info][firmware_rev].asString(); + } + if (device_info_so.keyExists(os)) { + device_info->os = device_info_so[os].asString(); + } + if (device_info_so.keyExists(os_ver)) { + device_info->os_ver = device_info_so[os_ver].asString(); + } + if (device_info_so.keyExists(carrier)) { + device_info->carrier = device_info_so[carrier].asString(); + } + if (device_info_so.keyExists(max_number_rfcom_ports)) { + device_info->max_number_rfcom_ports = + device_info_so[max_number_rfcom_ports].asInt(); + } +} + +bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() { + LOG4CXX_AUTO_TRACE(logger_); + + const custom_string::CustomString mobile_app_id = + (*message_)[strings::msg_params][strings::app_id].asCustomString(); + + const ApplicationSet& applications = + application_manager_.applications().GetData(); + + ApplicationSetConstIt it = applications.begin(); + ApplicationSetConstIt it_end = applications.end(); + + for (; it != it_end; ++it) { + if (mobile_app_id.CompareIgnoreCase((*it)->policy_app_id().c_str())) { + return true; + } + } + + return false; +} + +bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() { + LOG4CXX_AUTO_TRACE(logger_); + const char* str = NULL; + + str = (*message_)[strings::msg_params][strings::app_name].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid app_name syntax check failed"); + return true; + } + + if ((*message_)[strings::msg_params].keyExists(strings::tts_name)) { + const smart_objects::SmartArray* tn_array = + (*message_)[strings::msg_params][strings::tts_name].asArray(); + + smart_objects::SmartArray::const_iterator it_tn = tn_array->begin(); + smart_objects::SmartArray::const_iterator it_tn_end = tn_array->end(); + + for (; it_tn != it_tn_end; ++it_tn) { + str = (*it_tn)[strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid tts_name syntax check failed"); + return true; + } + } + } + + if ((*message_)[strings::msg_params].keyExists( + strings::ngn_media_screen_app_name)) { + str = (*message_)[strings::msg_params][strings::ngn_media_screen_app_name] + .asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid ngn_media_screen_app_name syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::vr_synonyms)) { + const smart_objects::SmartArray* vs_array = + (*message_)[strings::msg_params][strings::vr_synonyms].asArray(); + + smart_objects::SmartArray::const_iterator it_vs = vs_array->begin(); + smart_objects::SmartArray::const_iterator it_vs_end = vs_array->end(); + + for (; it_vs != it_vs_end; ++it_vs) { + str = (*it_vs).asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid vr_synonyms syntax check failed"); + return true; + } + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::hash_id)) { + str = (*message_)[strings::msg_params][strings::hash_id].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid hash_id syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::device_info)) { + if ((*message_)[strings::msg_params][strings::device_info].keyExists( + strings::hardware)) { + str = (*message_)[strings::msg_params][strings::device_info] + [strings::hardware].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid device_info hardware syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params][strings::device_info].keyExists( + strings::firmware_rev)) { + str = (*message_)[strings::msg_params][strings::device_info] + [strings::firmware_rev].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid device_info firmware_rev syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params][strings::device_info].keyExists( + strings::os)) { + str = (*message_)[strings::msg_params][strings::device_info][strings::os] + .asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid device_info os syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params][strings::device_info].keyExists( + strings::os_version)) { + str = (*message_)[strings::msg_params][strings::device_info] + [strings::os_version].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid device_info os_version syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params][strings::device_info].keyExists( + strings::carrier)) { + str = (*message_)[strings::msg_params][strings::device_info] + [strings::carrier].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid device_info carrier syntax check failed"); + return true; + } + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::app_id)) { + str = (*message_)[strings::msg_params][strings::app_id].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid app_id syntax check failed"); + return true; + } + } + + return false; +} + +void RegisterAppInterfaceRequest::CheckResponseVehicleTypeParam( + smart_objects::SmartObject& vehicle_type, + const std::string& param, + const std::string& backup_value) { + using namespace hmi_response; + if (!vehicle_type.keyExists(param) || vehicle_type[param].empty()) { + if (!backup_value.empty()) { + LOG4CXX_DEBUG(logger_, + param << " is missing." + "Will be replaced with policy table value."); + vehicle_type[param] = backup_value; + } else { + vehicle_type.erase(param); + } + } +} + +void RegisterAppInterfaceRequest::SendSubscribeCustomButtonNotification() { + using namespace smart_objects; + using namespace hmi_apis; + + SmartObject msg_params = SmartObject(SmartType_Map); + msg_params[strings::app_id] = connection_key(); + msg_params[strings::name] = Common_ButtonName::CUSTOM_BUTTON; + msg_params[strings::is_suscribed] = true; + CreateHMINotification(FunctionID::Buttons_OnButtonSubscription, msg_params); +} + +bool RegisterAppInterfaceRequest::IsApplicationSwitched() { + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + const std::string& policy_app_id = msg_params[strings::app_id].asString(); + + LOG4CXX_DEBUG(logger_, "Looking for application id " << policy_app_id); + + auto app = application_manager_.application_by_policy_id(policy_app_id); + + if (!app) { + LOG4CXX_DEBUG(logger_, + "Application with policy id " << policy_app_id + << " is not found."); + return false; + } + + LOG4CXX_DEBUG(logger_, + "Application with policy id " << policy_app_id << " is found."); + if (!application_manager_.IsAppInReconnectMode(policy_app_id)) { + LOG4CXX_DEBUG(logger_, + "Policy id " << policy_app_id + << " is not found in reconnection list."); + SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY); + return false; + } + + LOG4CXX_DEBUG(logger_, "Application is found in reconnection list."); + + auto app_type = ApplicationType::kSwitchedApplicationWrongHashId; + if ((*message_)[strings::msg_params].keyExists(strings::hash_id)) { + const auto hash_id = + (*message_)[strings::msg_params][strings::hash_id].asString(); + + auto& resume_ctrl = application_manager_.resume_controller(); + if (resume_ctrl.CheckApplicationHash(app, hash_id)) { + app_type = ApplicationType::kSwitchedApplicationHashOk; + } + } + + application_manager_.ProcessReconnection(app, connection_key()); + SendRegisterAppInterfaceResponseToMobile(app_type); + + application_manager_.SendHMIStatusNotification(app); + + application_manager_.OnApplicationSwitched(app); + + return true; +} + +policy::PolicyHandlerInterface& +RegisterAppInterfaceRequest::GetPolicyHandler() { + return policy_handler_; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc new file mode 100644 index 0000000000..73b38823d8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc @@ -0,0 +1,99 @@ +/* + + 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/register_app_interface_response.h" +#include "interfaces/MOBILE_API.h" +#include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "connection_handler/connection_handler.h" +#include "application_manager/policies/policy_handler_interface.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +void RegisterAppInterfaceResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + mobile_apis::Result::eType result_code = mobile_apis::Result::SUCCESS; + bool success = (*message_)[strings::msg_params][strings::success].asBool(); + bool last_message = !success; + // Do not close connection in case of APPLICATION_NOT_REGISTERED despite it is + // an error + if (!success && + (*message_)[strings::msg_params].keyExists(strings::result_code)) { + result_code = static_cast<mobile_apis::Result::eType>( + (*message_)[strings::msg_params][strings::result_code].asInt()); + if (result_code == mobile_apis::Result::APPLICATION_REGISTERED_ALREADY) { + last_message = false; + } + } + + SendResponse(success, result_code, last_message); + + if (mobile_apis::Result::SUCCESS != result_code) { + return; + } + + // Add registered application to the policy db right after response sent to + // mobile to be able to check all other API according to app permissions + application_manager::ApplicationSharedPtr application = + application_manager_.application(connection_key()); + if (!application) { + LOG4CXX_ERROR(logger_, + "Application with connection key " << connection_key() + << " is not registered."); + return; + } + + SetHeartBeatTimeout(connection_key(), application->policy_app_id()); +} + +void RegisterAppInterfaceResponse::SetHeartBeatTimeout( + uint32_t connection_key, const std::string& mobile_app_id) { + LOG4CXX_AUTO_TRACE(logger_); + policy::PolicyHandlerInterface& policy_handler = policy_handler_; + if (policy_handler.PolicyEnabled()) { + const uint32_t timeout = policy_handler.HeartBeatTimeout(mobile_app_id); + if (timeout > 0) { + application_manager_.connection_handler().SetHeartBeatTimeout( + connection_key, timeout); + } + } else { + LOG4CXX_INFO(logger_, "Policy is turn off"); + } +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc new file mode 100644 index 0000000000..ab6e1cc143 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc @@ -0,0 +1,336 @@ +/* + + 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/reset_global_properties_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 { + +ResetGlobalPropertiesRequest::ResetGlobalPropertiesRequest( + 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) + , ui_result_(hmi_apis::Common_Result::INVALID_ENUM) + , tts_result_(hmi_apis::Common_Result::INVALID_ENUM) {} + +ResetGlobalPropertiesRequest::~ResetGlobalPropertiesRequest() {} + +void ResetGlobalPropertiesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + uint32_t app_id = + (*message_)[strings::params][strings::connection_key].asUInt(); + ApplicationSharedPtr app = application_manager_.application(app_id); + + if (!app) { + LOG4CXX_ERROR(logger_, "No application associated with session key"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + size_t obj_length = + (*message_)[strings::msg_params][strings::properties].length(); + // if application waits for sending ttsGlobalProperties need to remove this + // application from tts_global_properties_app_list_ + LOG4CXX_INFO(logger_, "RemoveAppFromTTSGlobalPropertiesList"); + application_manager_.RemoveAppFromTTSGlobalPropertiesList(app_id); + + bool helpt_promt = false; + bool timeout_prompt = false; + bool vr_help_title_items = false; + bool menu_name = false; + bool menu_icon = false; + bool is_key_board_properties = false; + int number_of_reset_vr = 0; + mobile_apis::GlobalProperty::eType global_property = + mobile_apis::GlobalProperty::INVALID_ENUM; + + for (size_t i = 0; i < obj_length; ++i) { + global_property = static_cast<mobile_apis::GlobalProperty::eType>( + (*message_)[strings::msg_params][strings::properties][i].asInt()); + + if (mobile_apis::GlobalProperty::HELPPROMPT == global_property) { + helpt_promt = ResetHelpPromt(app); + } else if (mobile_apis::GlobalProperty::TIMEOUTPROMPT == global_property) { + timeout_prompt = ResetTimeoutPromt(app); + } else if (((mobile_apis::GlobalProperty::VRHELPTITLE == global_property) || + (mobile_apis::GlobalProperty::VRHELPITEMS == + global_property)) && + (0 == number_of_reset_vr)) { + ++number_of_reset_vr; + vr_help_title_items = ResetVrHelpTitleItems(app); + } else if (mobile_apis::GlobalProperty::MENUNAME == global_property) { + menu_name = true; + } else if (mobile_apis::GlobalProperty::MENUICON == global_property) { + menu_icon = true; + } else if (mobile_apis::GlobalProperty::KEYBOARDPROPERTIES == + global_property) { + is_key_board_properties = true; + } + } + + if (vr_help_title_items || menu_name || menu_icon || + is_key_board_properties) { + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + } + + if (timeout_prompt || helpt_promt) { + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); + } + + app->set_reset_global_properties_active(true); + + if (vr_help_title_items || menu_name || menu_icon || + is_key_board_properties) { + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + if (vr_help_title_items) { + smart_objects::SmartObjectSPtr vr_help = + MessageHelper::CreateAppVrHelp(app); + if (!vr_help) { + return; + } + msg_params = *vr_help; + } + if (menu_name) { + msg_params[hmi_request::menu_title] = ""; + app->set_menu_title(msg_params[hmi_request::menu_title]); + } + // TODO(DT): clarify the sending parameter menuIcon + // if (menu_icon) { + //} + if (is_key_board_properties) { + smart_objects::SmartObject key_board_properties = + smart_objects::SmartObject(smart_objects::SmartType_Map); + key_board_properties[strings::language] = + static_cast<int32_t>(hmi_apis::Common_Language::EN_US); + key_board_properties[hmi_request::keyboard_layout] = + static_cast<int32_t>(hmi_apis::Common_KeyboardLayout::QWERTY); + + // Look for APPLINK-4432 for details. + /*smart_objects::SmartObject limited_character_list = + smart_objects::SmartObject( + smart_objects::SmartType_Array); + limited_character_list[0] = ""; + key_board_properties[hmi_request::limited_character_list] = + limited_character_list;*/ + + key_board_properties[hmi_request::auto_complete_text] = ""; + msg_params[hmi_request::keyboard_properties] = key_board_properties; + } + + msg_params[strings::app_id] = app->app_id(); + SendHMIRequest( + hmi_apis::FunctionID::UI_SetGlobalProperties, &msg_params, true); + } + + if (timeout_prompt || helpt_promt) { + // create ui request + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + if (helpt_promt) { + msg_params[strings::help_prompt] = (*app->help_prompt()); + } + + if (timeout_prompt) { + msg_params[strings::timeout_prompt] = (*app->timeout_prompt()); + } + + msg_params[strings::app_id] = app->app_id(); + + SendHMIRequest( + hmi_apis::FunctionID::TTS_SetGlobalProperties, &msg_params, true); + } +} + +bool ResetGlobalPropertiesRequest::ResetHelpPromt( + application_manager::ApplicationSharedPtr app) { + if (!app) { + LOG4CXX_ERROR(logger_, "Null pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return false; + } + smart_objects::SmartObject so_help_prompt = + smart_objects::SmartObject(smart_objects::SmartType_Array); + app->set_help_prompt(so_help_prompt); + return true; +} + +bool ResetGlobalPropertiesRequest::ResetTimeoutPromt( + application_manager::ApplicationSharedPtr const app) { + if (!app) { + LOG4CXX_ERROR(logger_, "Null pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return false; + } + + const std::vector<std::string>& time_out_promt = + application_manager_.get_settings().time_out_promt(); + + smart_objects::SmartObject so_time_out_promt = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + for (uint32_t i = 0; i < time_out_promt.size(); ++i) { + smart_objects::SmartObject timeoutPrompt = + smart_objects::SmartObject(smart_objects::SmartType_Map); + timeoutPrompt[strings::text] = time_out_promt[i]; + timeoutPrompt[strings::type] = hmi_apis::Common_SpeechCapabilities::SC_TEXT; + so_time_out_promt[i] = timeoutPrompt; + } + + app->set_timeout_prompt(so_time_out_promt); + + return true; +} + +bool ResetGlobalPropertiesRequest::ResetVrHelpTitleItems( + application_manager::ApplicationSharedPtr const app) { + if (!app) { + LOG4CXX_ERROR(logger_, "Null pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return false; + } + app->reset_vr_help_title(); + app->reset_vr_help(); + + return true; +} + +void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_SetGlobalProperties: { + LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + ui_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + GetInfo(message, ui_response_info_); + break; + } + case hmi_apis::FunctionID::TTS_SetGlobalProperties: { + LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); + tts_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + GetInfo(message, tts_response_info_); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } + + if (IsPendingResponseExist()) { + LOG4CXX_DEBUG(logger_, "Waiting for remaining responses"); + return; + } + + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; + std::string response_info; + const bool result = PrepareResponseParameters(result_code, response_info); + + SendResponse(result, + static_cast<mobile_apis::Result::eType>(result_code), + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); +} + +bool ResetGlobalPropertiesRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +bool ResetGlobalPropertiesRequest::PrepareResponseParameters( + mobile_apis::Result::eType& out_result_code, + std::string& out_response_info) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + + bool result = false; + app_mngr::commands::ResponseInfo ui_properties_info( + ui_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); + app_mngr::commands::ResponseInfo tts_properties_info( + tts_result_, HmiInterfaces::HMI_INTERFACE_TTS, application_manager_); + + HmiInterfaces::InterfaceState tts_interface_state = + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_TTS); + + if (hmi_apis::Common_Result::SUCCESS == ui_result_ && + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_ && + HmiInterfaces::STATE_AVAILABLE == tts_interface_state) { + result = true; + out_result_code = mobile_apis::Result::WARNINGS; + out_response_info = "Unsupported phoneme type sent in a prompt"; + } else { + result = + PrepareResultForMobileResponse(ui_properties_info, tts_properties_info); + out_result_code = + PrepareResultCodeForResponse(ui_properties_info, tts_properties_info); + out_response_info = app_mngr::commands::MergeInfos(tts_properties_info, + tts_response_info_, + ui_properties_info, + ui_response_info_); + } + + return result; +} + +bool ResetGlobalPropertiesRequest::IsPendingResponseExist() { + return IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_TTS) || + IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_response.cc new file mode 100644 index 0000000000..f5542ab26b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_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 "sdl_rpc_plugin/commands/mobile/reset_global_properties_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +ResetGlobalPropertiesResponse::ResetGlobalPropertiesResponse( + 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) {} + +ResetGlobalPropertiesResponse::~ResetGlobalPropertiesResponse() {} + +void ResetGlobalPropertiesResponse::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/scrollable_message_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc new file mode 100644 index 0000000000..0b28e09210 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc @@ -0,0 +1,163 @@ +/* + + 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 <string.h> +#include "sdl_rpc_plugin/commands/mobile/scrollable_message_request.h" + +#include "application_manager/application_impl.h" +#include "application_manager/policies/policy_handler.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" +#include "utils/helpers.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +ScrollableMessageRequest::ScrollableMessageRequest( + 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) { + subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); +} + +ScrollableMessageRequest::~ScrollableMessageRequest() {} + +bool ScrollableMessageRequest::Init() { + /* Timeout in milliseconds. + If omitted a standard value of 10000 milliseconds is used.*/ + if ((*message_)[strings::msg_params].keyExists(strings::timeout)) { + default_timeout_ = + (*message_)[strings::msg_params][strings::timeout].asUInt(); + } else { + const int32_t def_value = 30000; + default_timeout_ = def_value; + } + + return true; +} + +void ScrollableMessageRequest::Run() { + LOG4CXX_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; + } + + // ProcessSoftButtons checks strings on the contents incorrect character + + mobile_apis::Result::eType processing_result = + MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], + app, + policy_handler_, + application_manager_); + + if (mobile_apis::Result::SUCCESS != processing_result) { + LOG4CXX_ERROR(logger_, "Wrong soft buttons parameters!"); + SendResponse(false, processing_result); + return; + } + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + msg_params[hmi_request::message_text][hmi_request::field_name] = + static_cast<int32_t>( + hmi_apis::Common_TextFieldName::scrollableMessageBody); + msg_params[hmi_request::message_text][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::scroll_message_body]; + msg_params[strings::app_id] = app->app_id(); + msg_params[strings::timeout] = default_timeout_; + + if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + msg_params[strings::soft_buttons] = + (*message_)[strings::msg_params][strings::soft_buttons]; + MessageHelper::SubscribeApplicationToSoftButton( + (*message_)[strings::msg_params], app, function_id()); + } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_ScrollableMessage, &msg_params, true); +} + +void ScrollableMessageRequest::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::UI_OnResetTimeout: { + LOG4CXX_INFO(logger_, "Received UI_OnResetTimeout event"); + application_manager_.updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + break; + } + case hmi_apis::FunctionID::UI_ScrollableMessage: { + LOG4CXX_INFO(logger_, "Received UI_ScrollableMessage event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + + hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(message, response_info); + + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_UI); + + 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()); + break; + } + } +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_response.cc new file mode 100644 index 0000000000..4eee819497 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_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 "sdl_rpc_plugin/commands/mobile/scrollable_message_response.h" +#include "application_manager/rpc_service.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +ScrollableMessageResponse::ScrollableMessageResponse( + 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) {} + +void ScrollableMessageResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + mobile_apis::Result::eType result_code = + static_cast<mobile_apis::Result::eType>( + (*message_)[strings::msg_params][strings::result_code].asInt()); + ApplicationSharedPtr application = application_manager_.application( + (*message_)[strings::params][strings::connection_key].asInt()); + if ((mobile_apis::Result::REJECTED != result_code) && application) { + application->UnsubscribeFromSoftButtons( + (*message_)[strings::params][strings::function_id].asInt()); + } + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_request.cc new file mode 100644 index 0000000000..a09434ebb6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_request.cc @@ -0,0 +1,108 @@ +/* + * 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/send_haptic_data_request.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace custom_str = utils::custom_string; + +SendHapticDataRequest::SendHapticDataRequest( + 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) {} + +SendHapticDataRequest::~SendHapticDataRequest() {} + +void SendHapticDataRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; + + 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; + } + + if (app->is_navi() || app->mobile_projection_enabled()) { + SendHMIRequest(hmi_apis::FunctionID::UI_SendHapticData, &msg_params, true); + } else { + SendResponse(false, + mobile_apis::Result::DISALLOWED, + "Application is not of type Navigation or Mobile Projection"); + } +} + +void SendHapticDataRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_SendHapticData: { + mobile_apis::Result::eType result_code = + GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asUInt())); + + const bool result = Compare<mobile_api::Result::eType, EQ, ONE>( + result_code, + mobile_api::Result::SUCCESS, + mobile_api::Result::WARNINGS); + + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_response.cc new file mode 100644 index 0000000000..f4515472a4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_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 "sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SendHapticDataResponse::SendHapticDataResponse( + 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) {} + +SendHapticDataResponse::~SendHapticDataResponse() {} + +void SendHapticDataResponse::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/send_location_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc new file mode 100644 index 0000000000..ab8de5923a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc @@ -0,0 +1,284 @@ +/* + + 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 <algorithm> +#include "sdl_rpc_plugin/commands/mobile/send_location_request.h" +#include "application_manager/message_helper.h" +#include "utils/custom_string.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SendLocationRequest::SendLocationRequest( + 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) {} + +SendLocationRequest::~SendLocationRequest() {} + +void SendLocationRequest::Run() { + using namespace hmi_apis; + using smart_objects::SmartObject; + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, + "An application with connection key " + << connection_key() << " is not registered."); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; + if (msg_params.keyExists(strings::delivery_mode)) { + const RPCParams& allowed_params = parameters_permissions().allowed_params; + + if (helpers::in_range(allowed_params, strings::delivery_mode)) { + msg_params.erase(strings::delivery_mode); + } + } + + std::vector<Common_TextFieldName::eType> fields_to_check; + if (msg_params.keyExists(strings::location_name)) { + fields_to_check.push_back(Common_TextFieldName::locationName); + } + if (msg_params.keyExists(strings::location_description)) { + fields_to_check.push_back(Common_TextFieldName::locationDescription); + } + if (msg_params.keyExists(strings::address_lines)) { + fields_to_check.push_back(Common_TextFieldName::addressLines); + } + if (msg_params.keyExists(strings::phone_number)) { + fields_to_check.push_back(Common_TextFieldName::phoneNumber); + } + + if (!CheckHMICapabilities(fields_to_check)) { + SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE); + return; + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, "Strings contain invalid characters"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if (msg_params.keyExists(strings::address)) { + const utils::custom_string::CustomString& address = + msg_params[strings::address].asCustomString(); + if (address.empty()) { + msg_params.erase(strings::address); + } + } + + if (!CheckFieldsCompatibility()) { + LOG4CXX_ERROR(logger_, "CheckFieldsCompatibility failed"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if (msg_params.keyExists(strings::location_image)) { + mobile_apis::Result::eType verification_result = + mobile_apis::Result::SUCCESS; + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::location_image], + app, + application_manager_); + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + SendResponse(false, verification_result); + return; + } + } + + SmartObject request_msg_params = SmartObject(smart_objects::SmartType_Map); + request_msg_params = msg_params; + request_msg_params[strings::app_id] = app->hmi_app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); + SendHMIRequest( + hmi_apis::FunctionID::Navigation_SendLocation, &request_msg_params, true); +} + +void SendLocationRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace hmi_apis; + const smart_objects::SmartObject& message = event.smart_object(); + if (hmi_apis::FunctionID::Navigation_SendLocation == event.id()) { + LOG4CXX_INFO(logger_, "Received Navigation_SendLocation event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); + const Common_Result::eType result_code = static_cast<Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(message, response_info); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_Navigation); + SendResponse(result, + MessageHelper::HMIToMobileResult(result_code), + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::params])); + return; + } + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); +} + +bool SendLocationRequest::CheckFieldsCompatibility() { + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + MessageHelper::PrintSmartObject(msg_params); + const bool longitude_degrees_exist = + msg_params.keyExists(strings::longitude_degrees); + const bool latitude_degrees_exist = + msg_params.keyExists(strings::latitude_degrees); + const bool address_exist = msg_params.keyExists(strings::address); + + if (latitude_degrees_exist ^ longitude_degrees_exist) { + LOG4CXX_DEBUG(logger_, + "latitude and longitude should be provided only in pair"); + return false; + } + + if (!address_exist && !longitude_degrees_exist && !latitude_degrees_exist) { + LOG4CXX_DEBUG(logger_, + "address or latitude/longtitude should should be provided"); + return false; + } + return true; +} +void insert_if_contains( + const smart_objects::SmartObject& msg_params, + const std::string& param_key, + std::vector<utils::custom_string::CustomString>& output_vector) { + if (msg_params.keyExists(param_key)) { + output_vector.push_back(msg_params[param_key].asCustomString()); + } +} + +bool SendLocationRequest::IsWhiteSpaceExist() { + LOG4CXX_AUTO_TRACE(logger_); + std::vector<utils::custom_string::CustomString> fields_to_check; + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + insert_if_contains(msg_params, strings::location_name, fields_to_check); + insert_if_contains( + msg_params, strings::location_description, fields_to_check); + insert_if_contains(msg_params, strings::phone_number, fields_to_check); + + if (msg_params.keyExists(strings::address_lines)) { + const smart_objects::SmartArray* al_array = + msg_params[strings::address_lines].asArray(); + smart_objects::SmartArray::const_iterator it_al = al_array->begin(); + smart_objects::SmartArray::const_iterator it_al_end = al_array->end(); + for (; it_al != it_al_end; ++it_al) { + const utils::custom_string::CustomString& val = (*it_al).asCustomString(); + fields_to_check.push_back(val); + } + } + + if (msg_params.keyExists(strings::address)) { + const smart_objects::SmartObject& address_so = msg_params[strings::address]; + insert_if_contains(address_so, strings::country_name, fields_to_check); + insert_if_contains(address_so, strings::country_code, fields_to_check); + insert_if_contains(address_so, strings::postal_code, fields_to_check); + insert_if_contains( + address_so, strings::administrative_area, fields_to_check); + insert_if_contains(address_so, strings::locality, fields_to_check); + insert_if_contains(address_so, strings::sub_locality, fields_to_check); + insert_if_contains(address_so, strings::thoroughfare, fields_to_check); + insert_if_contains(address_so, strings::sub_thoroughfare, fields_to_check); + } + + std::vector<utils::custom_string::CustomString>::iterator it = + fields_to_check.begin(); + for (; it != fields_to_check.end(); ++it) { + const std::string& str = it->AsMBString(); + if (!CheckSyntax(str, false)) { + LOG4CXX_ERROR(logger_, + "string '" << str << "'' contains invalid characters"); + return true; + } + } + return false; +} + +bool SendLocationRequest::CheckHMICapabilities( + std::vector<hmi_apis::Common_TextFieldName::eType>& fields_names) { + using namespace smart_objects; + using namespace hmi_apis; + if (fields_names.empty()) { + return true; + } + + const HMICapabilities& hmi_capabilities = hmi_capabilities_; + if (!hmi_capabilities.is_ui_cooperating()) { + LOG4CXX_ERROR(logger_, "UI is not supported."); + return false; + } + + if (hmi_capabilities.display_capabilities()) { + const SmartObject disp_cap = (*hmi_capabilities.display_capabilities()); + const SmartObject& text_fields = + disp_cap.getElement(hmi_response::text_fields); + const size_t len = text_fields.length(); + for (size_t i = 0; i < len; ++i) { + const SmartObject& text_field = text_fields[i]; + const Common_TextFieldName::eType filed_name = + static_cast<Common_TextFieldName::eType>( + text_field.getElement(strings::name).asInt()); + const std::vector<Common_TextFieldName::eType>::iterator it = + std::find(fields_names.begin(), fields_names.end(), filed_name); + if (it != fields_names.end()) { + fields_names.erase(it); + } + } + } + + if (!fields_names.empty()) { + LOG4CXX_ERROR(logger_, "Some fields are not supported by capabilities"); + return false; + } + return true; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_response.cc new file mode 100644 index 0000000000..59dab4a9a7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_response.cc @@ -0,0 +1,66 @@ +/* + + 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/send_location_response.h" +#include "application_manager/rpc_service.h" +#include "application_manager/application_impl.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SendLocationResponse::SendLocationResponse( + 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) {} + +SendLocationResponse::~SendLocationResponse() {} + +void SendLocationResponse::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/set_app_icon_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_request.cc new file mode 100644 index 0000000000..3cb57c90e8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_request.cc @@ -0,0 +1,296 @@ +/* + + 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/set_app_icon_request.h" +#include <algorithm> + +#include "application_manager/message_helper.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" +#include "utils/file_system.h" +#include "utils/helpers.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SetAppIconRequest::SetAppIconRequest( + 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) + , is_icons_saving_enabled_(false) { + const std::string path = + application_manager_.get_settings().app_icons_folder(); + is_icons_saving_enabled_ = file_system::IsWritingAllowed(path) && + file_system::IsReadingAllowed(path); +} + +SetAppIconRequest::~SetAppIconRequest() {} + +void SetAppIconRequest::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::string& sync_file_name = + (*message_)[strings::msg_params][strings::sync_file_name].asString(); + + if (!file_system::IsFileNameValid(sync_file_name)) { + const std::string err_msg = "Sync file name contains forbidden symbols."; + LOG4CXX_ERROR(logger_, err_msg); + SendResponse(false, mobile_apis::Result::INVALID_DATA, err_msg.c_str()); + return; + } + + std::string full_file_path = + application_manager_.get_settings().app_storage_folder() + "/"; + full_file_path += app->folder_name(); + full_file_path += "/"; + full_file_path += sync_file_name; + + if (!file_system::FileExists(full_file_path)) { + LOG4CXX_ERROR(logger_, "No such file " << full_file_path); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + msg_params[strings::app_id] = app->app_id(); + msg_params[strings::sync_file_name] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + // Panasonic requres unchanged path value without encoded special characters + const std::string full_file_path_for_hmi = + file_system::ConvertPathForURL(full_file_path); + + msg_params[strings::sync_file_name][strings::value] = full_file_path_for_hmi; + + // TODO(VS): research why is image_type hardcoded + msg_params[strings::sync_file_name][strings::image_type] = + static_cast<int32_t>(SetAppIconRequest::ImageType::DYNAMIC); + + // for further use in on_event function + (*message_)[strings::msg_params][strings::sync_file_name] = + msg_params[strings::sync_file_name]; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_SetAppIcon, &msg_params, true); +} + +void SetAppIconRequest::CopyToIconStorage( + const std::string& path_to_file) const { + if (!(application_manager_.protocol_handler() + .get_settings() + .max_supported_protocol_version() >= + protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4)) { + LOG4CXX_WARN(logger_, + "Icon copying skipped, since protocol ver. 4 is not enabled."); + return; + } + + std::vector<uint8_t> file_content; + if (!file_system::ReadBinaryFile(path_to_file, file_content)) { + LOG4CXX_ERROR(logger_, "Can't read icon file: " << path_to_file); + return; + } + + const std::string icon_storage = + application_manager_.get_settings().app_icons_folder(); + const uint64_t storage_max_size = static_cast<uint64_t>( + application_manager_.get_settings().app_icons_folder_max_size()); + const uint64_t file_size = file_system::FileSize(path_to_file); + + if (storage_max_size < file_size) { + LOG4CXX_ERROR(logger_, + "Icon size (" << file_size << ") is bigger, than " + " icons storage maximum size (" + << storage_max_size << ")." + "Copying skipped."); + return; + } + + const uint64_t storage_size = + static_cast<uint64_t>(file_system::DirectorySize(icon_storage)); + if (storage_max_size < (file_size + storage_size)) { + const uint32_t icons_amount = + application_manager_.get_settings().app_icons_amount_to_remove(); + + if (!icons_amount) { + LOG4CXX_DEBUG(logger_, + "No icons will be deleted, since amount icons to remove " + "is zero. Icon saving skipped."); + return; + } + + while (!IsEnoughSpaceForIcon(file_size)) { + RemoveOldestIcons(icon_storage, icons_amount); + } + } + ApplicationConstSharedPtr app = + application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR( + logger_, + "Can't get application for connection key: " << connection_key()); + return; + } + + const std::string icon_path = icon_storage + "/" + app->policy_app_id(); + if (!file_system::CreateFile(icon_path)) { + LOG4CXX_ERROR(logger_, "Can't create icon: " << icon_path); + return; + } + + if (!file_system::Write(icon_path, file_content)) { + LOG4CXX_ERROR(logger_, "Can't write icon: " << icon_path); + return; + } + + LOG4CXX_DEBUG(logger_, + "Icon was successfully copied from :" << path_to_file << " to " + << icon_path); + + return; +} + +void SetAppIconRequest::RemoveOldestIcons(const std::string& storage, + const uint32_t icons_amount) const { + const std::vector<std::string> icons_list = file_system::ListFiles(storage); + std::map<uint64_t, std::string> icon_modification_time; + std::vector<std::string>::const_iterator it = icons_list.begin(); + for (; it != icons_list.end(); ++it) { + const std::string file_name = *it; + const std::string file_path = storage + "/" + file_name; + if (!file_system::FileExists(file_path)) { + continue; + } + const uint64_t time = file_system::GetFileModificationTime(file_path); + icon_modification_time[time] = file_name; + } + + for (size_t counter = 0; counter < icons_amount; ++counter) { + if (!icon_modification_time.size()) { + LOG4CXX_ERROR(logger_, "No more icons left for deletion."); + return; + } + const std::string file_name = icon_modification_time.begin()->second; + const std::string file_path = storage + "/" + file_name; + if (!file_system::DeleteFile(file_path)) { + LOG4CXX_DEBUG(logger_, "Error while deleting icon " << file_path); + } + icon_modification_time.erase(icon_modification_time.begin()); + LOG4CXX_DEBUG(logger_, + "Old icon " << file_path << " was deleted successfully."); + } +} + +bool SetAppIconRequest::IsEnoughSpaceForIcon(const uint64_t icon_size) const { + const std::string icon_storage = + application_manager_.get_settings().app_icons_folder(); + const uint64_t storage_max_size = static_cast<uint64_t>( + application_manager_.get_settings().app_icons_folder_max_size()); + const uint64_t storage_size = + static_cast<uint64_t>(file_system::DirectorySize(icon_storage)); + return storage_max_size >= (icon_size + storage_size); +} + +void SetAppIconRequest::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::UI_SetAppIcon: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_UI); + std::string response_info; + GetInfo(message, response_info); + if (result) { + ApplicationSharedPtr app = + application_manager_.application(connection_key()); + + if (!message_.valid() || !app.valid()) { + LOG4CXX_ERROR(logger_, "NULL pointer."); + return; + } + + const std::string& path = + (*message_)[strings::msg_params][strings::sync_file_name] + [strings::value].asString(); + + if (is_icons_saving_enabled_) { + CopyToIconStorage(path); + } + + app->set_app_icon_path(path); + + LOG4CXX_INFO(logger_, + "Icon path was set to '" << app->app_icon_path() << "'"); + } + + 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/set_app_icon_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_response.cc new file mode 100644 index 0000000000..aa8731f062 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_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 "sdl_rpc_plugin/commands/mobile/set_app_icon_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SetAppIconResponse::SetAppIconResponse( + 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) {} + +SetAppIconResponse::~SetAppIconResponse() {} + +void SetAppIconResponse::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/set_display_layout_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_request.cc new file mode 100644 index 0000000000..32164b8f0e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_request.cc @@ -0,0 +1,173 @@ +/* + + 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/set_display_layout_request.h" + +#include "application_manager/message_helper.h" +#include "application_manager/application_impl.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SetDisplayLayoutRequest::SetDisplayLayoutRequest( + 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) {} + +SetDisplayLayoutRequest::~SetDisplayLayoutRequest() {} + +void SetDisplayLayoutRequest::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 smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + std::string old_layout = app->display_layout(); + std::string new_layout = ""; + + if (msg_params.keyExists(strings::display_layout)) { + new_layout = msg_params[strings::display_layout].asString(); + } + + if (new_layout != old_layout && + !new_layout.empty()) { // Template switched, allow any color change + LOG4CXX_DEBUG(logger_, + "SetDisplayLayoutRequest New Layout: " << new_layout); + app->set_display_layout(new_layout); + } else { + LOG4CXX_DEBUG(logger_, "SetDisplayLayoutRequest No Layout Change"); + // Template layout is the same as previous layout + // Reject message if colors are set + if (msg_params.keyExists(strings::day_color_scheme) && + app->day_color_scheme() != NULL && + !(msg_params[strings::day_color_scheme] == + *(app->day_color_scheme()))) { + // Color scheme param exists and has been previously set, do not allow + // color change + LOG4CXX_DEBUG(logger_, "Reject Day Color Scheme Change"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + if (msg_params.keyExists(strings::night_color_scheme) && + app->night_color_scheme() != NULL && + !(msg_params[strings::night_color_scheme] == + *(app->night_color_scheme()))) { + // Color scheme param exists and has been previously set, do not allow + // color change + LOG4CXX_DEBUG(logger_, "Reject Night Color Scheme Change"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + } + + if (msg_params.keyExists(strings::day_color_scheme)) { + LOG4CXX_DEBUG(logger_, "Allow Day Color Scheme Change"); + app->set_day_color_scheme(msg_params[strings::day_color_scheme]); + } + + if (msg_params.keyExists(strings::night_color_scheme)) { + LOG4CXX_DEBUG(logger_, "Allow Night Color Scheme Change"); + app->set_night_color_scheme(msg_params[strings::night_color_scheme]); + } + + (*message_)[strings::msg_params][strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_SetDisplayLayout, + &((*message_)[strings::msg_params]), + true); +} + +void SetDisplayLayoutRequest::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::UI_SetDisplayLayout: { + LOG4CXX_INFO(logger_, "Received UI_SetDisplayLayout event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + const bool response_success = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_UI); + std::string info; + GetInfo(message, info); + smart_objects::SmartObject msg_params = message[strings::msg_params]; + if (response_success) { + HMICapabilities& hmi_capabilities = hmi_capabilities_; + + // in case templates_available is empty copy from hmi capabilities + if (msg_params.keyExists(hmi_response::display_capabilities)) { + if (0 == + msg_params[hmi_response::display_capabilities] + [hmi_response::templates_available].length()) { + msg_params[hmi_response::display_capabilities] + [hmi_response::templates_available] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::templates_available); + } + } + } + SendResponse(response_success, + MessageHelper::HMIToMobileResult(result_code), + info.empty() ? NULL : info.c_str(), + &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/set_display_layout_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_response.cc new file mode 100644 index 0000000000..4bab4a3e5b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_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 "sdl_rpc_plugin/commands/mobile/set_display_layout_response.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SetDisplayLayoutResponse::SetDisplayLayoutResponse( + 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) {} + +SetDisplayLayoutResponse::~SetDisplayLayoutResponse() {} + +void SetDisplayLayoutResponse::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/set_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc new file mode 100644 index 0000000000..90ec06025e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc @@ -0,0 +1,610 @@ +/* + 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 <string.h> +#include <numeric> +#include <algorithm> +#include "sdl_rpc_plugin/commands/mobile/set_global_properties_request.h" + +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" +#include "utils/helpers.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SetGlobalPropertiesRequest::SetGlobalPropertiesRequest( + 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) + , is_ui_send_(false) + , is_tts_send_(false) + , is_ui_received_(false) + , is_tts_received_(false) + , ui_result_(hmi_apis::Common_Result::INVALID_ENUM) + , tts_result_(hmi_apis::Common_Result::INVALID_ENUM) {} + +SetGlobalPropertiesRequest::~SetGlobalPropertiesRequest() {} + +void SetGlobalPropertiesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, + "No application associated with connection key " + << connection_key()); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (!ValidateConditionalMandatoryParameters(msg_params)) { + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "There are no parameters present in request."); + return; + } + + mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS; + + if ((*message_)[strings::msg_params].keyExists(strings::menu_icon)) { + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::menu_icon], + app, + application_manager_); + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR( + logger_, "MessageHelper::VerifyImage return " << verification_result); + SendResponse(false, verification_result); + return; + } + } + // Check for image file(s) in vrHelpItem + if ((*message_)[strings::msg_params].keyExists(strings::vr_help)) { + if (mobile_apis::Result::SUCCESS != + MessageHelper::VerifyImageVrHelpItems( + (*message_)[strings::msg_params][strings::vr_help], + app, + application_manager_)) { + LOG4CXX_ERROR(logger_, "MessageHelper::VerifyImage return INVALID_DATA!"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, "White spaces found"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + // if application waits for sending ttsGlobalProperties need to remove this + // application from tts_global_properties_app_list_ + application_manager_.RemoveAppFromTTSGlobalPropertiesList(connection_key()); + bool is_help_prompt_present = msg_params.keyExists(strings::help_prompt); + bool is_timeout_prompt_present = + msg_params.keyExists(strings::timeout_prompt); + bool is_vr_help_title_present = msg_params.keyExists(strings::vr_help_title); + bool is_vr_help_present = msg_params.keyExists(strings::vr_help); + + // check VR params + if (is_vr_help_title_present ^ is_vr_help_present) { + LOG4CXX_ERROR(logger_, + "Reject because of vr_help or vr_help_title only provided"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + /* Need to set flags before sending request to HMI + * for correct processing this flags in method on_event */ + if (is_help_prompt_present || is_timeout_prompt_present) { + is_tts_send_ = true; + } + if (is_vr_help_title_present && is_vr_help_present) { + LOG4CXX_DEBUG(logger_, "VRHelp params presents"); + + if (!CheckVrHelpItemsOrder(msg_params[strings::vr_help])) { + LOG4CXX_ERROR(logger_, + "VR Help Items contains nonsequential positions" + << " (e.g. [1,2,4]) or not started from 1"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + smart_objects::SmartObject params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + PrepareUIRequestVRHelpData(app, msg_params, params); + PrepareUIRequestMenuAndKeyboardData(app, msg_params, params); + + params[strings::app_id] = app->app_id(); + SendUIRequest(params, true); + } else { + LOG4CXX_DEBUG(logger_, "VRHelp params does not present"); + DCHECK_OR_RETURN_VOID(!is_vr_help_title_present && !is_vr_help_present); + + smart_objects::SmartObject params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + if (ValidateVRHelpTitle(app->vr_help_title())) { + LOG4CXX_DEBUG(logger_, "App already contains VRHelp data"); + } else { + if (!PrepareUIRequestDefaultVRHelpData(app, params)) { + LOG4CXX_ERROR(logger_, "default VRHElp data could not be generated"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } + PrepareUIRequestMenuAndKeyboardData(app, msg_params, params); + + // Preparing data + if (params.empty()) { + LOG4CXX_DEBUG(logger_, "No UI info provided"); + } else { + params[strings::app_id] = app->app_id(); + SendUIRequest(params, true); + } + } + + // check TTS params + if (is_help_prompt_present || is_timeout_prompt_present) { + LOG4CXX_DEBUG(logger_, "TTS params presents"); + smart_objects::SmartObject params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + std::vector<std::string> invalid_params; + if (is_help_prompt_present) { + smart_objects::SmartObject& help_prompt = + (*message_)[strings::msg_params][strings::help_prompt]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles(help_prompt, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + invalid_params.push_back("help_prompt"); + } else { + app->set_help_prompt(help_prompt); + params[strings::help_prompt] = (*app->help_prompt()); + } + } + + if (is_timeout_prompt_present) { + smart_objects::SmartObject& timeout_prompt = + (*message_)[strings::msg_params][strings::timeout_prompt]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles( + timeout_prompt, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + invalid_params.push_back("timeout_prompt"); + } else { + app->set_timeout_prompt(timeout_prompt); + params[strings::timeout_prompt] = (*app->timeout_prompt()); + } + } + + if (!invalid_params.empty()) { + std::string params_list = std::accumulate( + std::begin(invalid_params), + std::end(invalid_params), + std::string(""), + [](std::string& first, std::string& second) { + return first.empty() ? second : first + ", " + second; + }); + const std::string info = + "One or more files needed for " + params_list + " are not present"; + SendResponse(false, mobile_apis::Result::FILE_NOT_FOUND, info.c_str()); + return; + } + + params[strings::app_id] = app->app_id(); + SendTTSRequest(params, true); + } +} + +bool SetGlobalPropertiesRequest::CheckVrHelpItemsOrder( + const smart_objects::SmartObject& vr_help) { + LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN(vr_help.getType() == smart_objects::SmartType_Array, false); + const size_t vr_help_length = vr_help.length(); + DCHECK_OR_RETURN(vr_help_length > 0, false); + + for (size_t j = 0; j < vr_help_length; ++j) { + const size_t position = + vr_help.getElement(j).getElement(strings::position).asUInt(); + // Elements shall start from 1 and increment one by one + if (position != (j + 1)) { + LOG4CXX_ERROR(logger_, + "VR help items order is wrong" + << " at " << j << ", position value:" << position); + return false; + } + } + return true; +} + +void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_SetGlobalProperties: { + LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + is_ui_received_ = true; + ui_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + GetInfo(message, ui_response_info_); + break; + } + case hmi_apis::FunctionID::TTS_SetGlobalProperties: { + LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); + is_tts_received_ = true; + tts_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + GetInfo(message, tts_response_info_); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } + + if (IsPendingResponseExist()) { + LOG4CXX_DEBUG(logger_, "Continue waiting for response"); + return; + } + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; + std::string response_info; + const bool result = PrepareResponseParameters(result_code, response_info); + + // TODO{ALeshin} APPLINK-15858. connection_key removed during SendResponse + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + SendResponse(result, + result_code, + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); +} + +bool SetGlobalPropertiesRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +bool SetGlobalPropertiesRequest::PrepareResponseParameters( + mobile_apis::Result::eType& result_code, std::string& info) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + + app_mngr::commands::ResponseInfo ui_properties_info( + ui_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); + + app_mngr::commands::ResponseInfo tts_properties_info( + tts_result_, HmiInterfaces::HMI_INTERFACE_TTS, application_manager_); + const bool result = + PrepareResultForMobileResponse(ui_properties_info, tts_properties_info); + if (result && + (HmiInterfaces::STATE_AVAILABLE == tts_properties_info.interface_state) && + (tts_properties_info.is_unsupported_resource)) { + result_code = mobile_apis::Result::WARNINGS; + tts_response_info_ = "Unsupported phoneme type sent in a prompt"; + info = app_mngr::commands::MergeInfos(tts_properties_info, + tts_response_info_, + ui_properties_info, + ui_response_info_); + return result; + } + result_code = + PrepareResultCodeForResponse(ui_properties_info, tts_properties_info); + info = app_mngr::commands::MergeInfos(tts_properties_info, + tts_response_info_, + ui_properties_info, + ui_response_info_); + return result; +} + +bool SetGlobalPropertiesRequest::ValidateVRHelpTitle( + const smart_objects::SmartObject* const vr_help_so_ptr) { + LOG4CXX_AUTO_TRACE(logger_); + if (vr_help_so_ptr) { + const std::string& vr_help = vr_help_so_ptr->asString(); + LOG4CXX_TRACE(logger_, "App contains vr_help_title: \"" << vr_help << '"'); + return !vr_help.empty(); + } + return false; +} + +void SetGlobalPropertiesRequest::PrepareUIRequestVRHelpData( + const ApplicationSharedPtr app, + const smart_objects::SmartObject& msg_params, + smart_objects::SmartObject& out_params) { + LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN_VOID(app); + + app->set_vr_help_title(msg_params.getElement(strings::vr_help_title)); + app->set_vr_help(msg_params.getElement(strings::vr_help)); + + out_params[strings::vr_help_title] = (*app->vr_help_title()); + out_params[strings::vr_help] = (*app->vr_help()); +} + +bool SetGlobalPropertiesRequest::PrepareUIRequestDefaultVRHelpData( + const ApplicationSharedPtr app, smart_objects::SmartObject& out_params) { + LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN(app, false); + + LOG4CXX_DEBUG(logger_, "Generate default VRHelp data"); + const DataAccessor<CommandsMap> accessor = app->commands_map(); + const CommandsMap& cmdMap = accessor.GetData(); + + int32_t index = 0; + smart_objects::SmartObject vr_help_items; + for (CommandsMap::const_iterator command_it = cmdMap.begin(); + cmdMap.end() != command_it; + ++command_it) { + const smart_objects::SmartObject& command = *command_it->second; + if (!command.keyExists(strings::vr_commands)) { + LOG4CXX_ERROR(logger_, "VR synonyms are empty"); + return false; + } + // use only first + vr_help_items[index][strings::position] = (index + 1); + vr_help_items[index++][strings::text] = + (*command_it->second)[strings::vr_commands][0]; + } + + app->set_vr_help_title(smart_objects::SmartObject(app->name())); + + out_params[strings::vr_help_title] = (*app->vr_help_title()); + if (vr_help_items.length() > 0) { + app->set_vr_help(vr_help_items); + out_params[strings::vr_help] = (*app->vr_help()); + } + return true; +} + +void SetGlobalPropertiesRequest::PrepareUIRequestMenuAndKeyboardData( + const ApplicationSharedPtr app, + const smart_objects::SmartObject& msg_params, + smart_objects::SmartObject& out_params) { + LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN_VOID(app); + + const bool is_menu_title_present = + msg_params.keyExists(hmi_request::menu_title); + const bool is_menu_icon_present = + msg_params.keyExists(hmi_request::menu_icon); + const bool is_keyboard_props_present = + msg_params.keyExists(hmi_request::keyboard_properties); + + if (is_menu_title_present) { + out_params[hmi_request::menu_title] = + msg_params[hmi_request::menu_title].asString(); + app->set_menu_title(msg_params[hmi_request::menu_title]); + } + if (is_menu_icon_present) { + out_params[hmi_request::menu_icon] = msg_params[hmi_request::menu_icon]; + app->set_menu_icon(msg_params[hmi_request::menu_icon]); + } + if (is_keyboard_props_present) { + out_params[hmi_request::keyboard_properties] = + msg_params[hmi_request::keyboard_properties]; + app->set_keyboard_props(msg_params[hmi_request::keyboard_properties]); + } +} + +void SetGlobalPropertiesRequest::SendTTSRequest( + const smart_objects::SmartObject& params, bool use_events) { + LOG4CXX_AUTO_TRACE(logger_); + is_tts_send_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); + SendHMIRequest( + hmi_apis::FunctionID::TTS_SetGlobalProperties, ¶ms, use_events); +} + +void SetGlobalPropertiesRequest::SendUIRequest( + const smart_objects::SmartObject& params, bool use_events) { + LOG4CXX_AUTO_TRACE(logger_); + is_ui_send_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest( + hmi_apis::FunctionID::UI_SetGlobalProperties, ¶ms, use_events); +} + +bool SetGlobalPropertiesRequest::IsPendingResponseExist() { + return is_ui_send_ != is_ui_received_ || is_tts_send_ != is_tts_received_; +} + +bool SetGlobalPropertiesRequest::ValidateConditionalMandatoryParameters( + const smart_objects::SmartObject& params) { + LOG4CXX_AUTO_TRACE(logger_); + return params.keyExists(strings::help_prompt) || + params.keyExists(strings::timeout_prompt) || + params.keyExists(strings::vr_help_title) || + params.keyExists(strings::vr_help) || + params.keyExists(strings::menu_title) || + params.keyExists(strings::menu_icon) || + params.keyExists(strings::keyboard_properties); +} + +bool SetGlobalPropertiesRequest::IsWhiteSpaceExist() { + LOG4CXX_AUTO_TRACE(logger_); + const char* str; + + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + if (msg_params.keyExists(strings::help_prompt)) { + const smart_objects::SmartArray* hp_array = + msg_params[strings::help_prompt].asArray(); + + smart_objects::SmartArray::const_iterator it_hp = hp_array->begin(); + smart_objects::SmartArray::const_iterator it_hp_end = hp_array->end(); + + for (; it_hp != it_hp_end; ++it_hp) { + str = (*it_hp)[strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid help_prompt syntax check failed"); + return true; + } + } + } + + if (msg_params.keyExists(strings::timeout_prompt)) { + const smart_objects::SmartArray* tp_array = + msg_params[strings::timeout_prompt].asArray(); + + smart_objects::SmartArray::const_iterator it_tp = tp_array->begin(); + smart_objects::SmartArray::const_iterator it_tp_end = tp_array->end(); + + for (; it_tp != it_tp_end; ++it_tp) { + str = (*it_tp)[strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid timeout_prompt syntax check failed"); + return true; + } + } + } + + if (msg_params.keyExists(strings::vr_help)) { + const smart_objects::SmartArray* vh_array = + msg_params[strings::vr_help].asArray(); + + smart_objects::SmartArray::const_iterator it_vh = vh_array->begin(); + smart_objects::SmartArray::const_iterator it_vh_end = vh_array->end(); + + for (; it_vh != it_vh_end; ++it_vh) { + str = (*it_vh)[strings::text].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid vr_help text syntax check failed"); + return true; + } + + if ((*it_vh).keyExists(strings::image)) { + str = (*it_vh)[strings::image][strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid vr_help image value syntax check failed"); + return true; + } + } // if image exists + } // for - vh_array iteration + } + + if (msg_params.keyExists(strings::menu_icon)) { + str = msg_params[strings::menu_icon][strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid menu_icon value syntax check failed"); + return true; + } + } + + if (msg_params.keyExists(strings::vr_help_title)) { + str = msg_params[strings::vr_help_title].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid vr_help_title value syntax check failed"); + return true; + } + } + + if (msg_params.keyExists(strings::menu_title)) { + str = msg_params[strings::menu_title].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid menu_title value syntax check failed"); + return true; + } + } + + if (msg_params.keyExists(strings::keyboard_properties)) { + if (msg_params[strings::keyboard_properties].keyExists( + strings::limited_character_list)) { + const smart_objects::SmartArray* lcl_array = + msg_params[strings::keyboard_properties] + [strings::limited_character_list].asArray(); + + smart_objects::SmartArray::const_iterator it_lcl = lcl_array->begin(); + smart_objects::SmartArray::const_iterator it_lcl_end = lcl_array->end(); + + for (; it_lcl != it_lcl_end; ++it_lcl) { + str = (*it_lcl).asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid keyboard_properties " + "limited_character_list syntax check failed"); + return true; + } + } + } + + if (msg_params[strings::keyboard_properties].keyExists( + strings::auto_complete_text)) { + str = + msg_params[strings::keyboard_properties][strings::auto_complete_text] + .asCharArray(); + + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid keyboard_properties " + "auto_complete_text syntax check failed"); + return true; + } + } + } + return false; +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_response.cc new file mode 100644 index 0000000000..567a1a088b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_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 "sdl_rpc_plugin/commands/mobile/set_global_properties_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SetGlobalPropertiesResponse::SetGlobalPropertiesResponse( + 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) {} + +SetGlobalPropertiesResponse::~SetGlobalPropertiesResponse() {} + +void SetGlobalPropertiesResponse::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/set_icon_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_icon_request.cc new file mode 100644 index 0000000000..54c202f7b0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_icon_request.cc @@ -0,0 +1,149 @@ +/* + + 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/set_icon_request.h" +#include "application_manager/application_manager.h" +#include "application_manager/application_impl.h" +#include "config_profile/profile.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" +#include "utils/file_system.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SetIconRequest::SetIconRequest( + 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) {} + +SetIconRequest::~SetIconRequest() {} + +void SetIconRequest::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::string& sync_file_name = + (*message_)[strings::msg_params][strings::sync_file_name].asString(); + + std::string full_file_path = + application_manager_.get_settings().app_storage_folder() + "/"; + full_file_path += app->folder_name(); + full_file_path += "/"; + full_file_path += sync_file_name; + + if (!file_system::FileExists(full_file_path)) { + LOG4CXX_ERROR(logger_, "No such file " << full_file_path); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + msg_params[strings::app_id] = app->app_id(); + msg_params[strings::sync_file_name] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + // Panasonic requres unchanged path value without encoded special characters + const std::string full_file_path_for_hmi = + file_system::ConvertPathForURL(full_file_path); + + msg_params[strings::sync_file_name][strings::value] = full_file_path_for_hmi; + + // TODO(VS): research why is image_type hardcoded + msg_params[strings::sync_file_name][strings::image_type] = + static_cast<int32_t>(SetIconRequest::ImageType::DYNAMIC); + + // for further use in on_event function + (*message_)[strings::msg_params][strings::sync_file_name] = + msg_params[strings::sync_file_name]; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_SetAppIcon, &msg_params, true); +} + +void SetIconRequest::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::UI_SetAppIcon: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + mobile_apis::Result::eType result_code = + static_cast<mobile_apis::Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + bool result = mobile_apis::Result::SUCCESS == result_code; + + if (result) { + ApplicationSharedPtr app = + application_manager_.application(connection_key()); + + const std::string path = + (*message_)[strings::msg_params][strings::sync_file_name] + [strings::value].asString(); + app->set_app_icon_path(path); + + LOG4CXX_INFO(logger_, + "Icon path was set to '" << app->app_icon_path() << "'"); + } + + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_icon_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_icon_response.cc new file mode 100644 index 0000000000..514c6ad6d4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_icon_response.cc @@ -0,0 +1,62 @@ +/* + + 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/set_icon_response.h" +#include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SetIconResponse::SetIconResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& app_man, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl( + message, app_man, rpc_service, hmi_capabilities, policy_handler) {} + +SetIconResponse::~SetIconResponse() {} + +void SetIconResponse::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/set_media_clock_timer_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_request.cc new file mode 100644 index 0000000000..55bd164368 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_request.cc @@ -0,0 +1,166 @@ +/* + + 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/set_media_clock_timer_request.h" + +#include "application_manager/message_helper.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SetMediaClockRequest::SetMediaClockRequest( + 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) {} + +SetMediaClockRequest::~SetMediaClockRequest() {} + +void SetMediaClockRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + LOG4CXX_ERROR(logger_, "Application is not registered"); + return; + } + + if (!app->is_media_application()) { + LOG4CXX_ERROR(logger_, "Application is not media application"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + if (isDataValid()) { + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + // copy entirely msg + msg_params = (*message_)[strings::msg_params]; + msg_params[strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + + SendHMIRequest( + hmi_apis::FunctionID::UI_SetMediaClockTimer, &msg_params, true); + } else { + SendResponse(false, mobile_apis::Result::INVALID_DATA); + } +} + +void SetMediaClockRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_SetMediaClockTimer: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_UI); + 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; + } + } +} + +bool SetMediaClockRequest::isDataValid() { + smart_objects::SmartObject msg_params = (*message_)[strings::msg_params]; + mobile_apis::UpdateMode::eType update_mode = + static_cast<mobile_apis::UpdateMode::eType>( + msg_params[strings::update_mode].asUInt()); + + if (update_mode == mobile_apis::UpdateMode::COUNTUP || + update_mode == mobile_apis::UpdateMode::COUNTDOWN) { + if (!msg_params.keyExists(strings::start_time)) { + LOG4CXX_INFO(logger_, "Invalid data"); + return false; + } + + if (msg_params.keyExists(strings::end_time)) { + unsigned int start_time_in_seconds = 0; + start_time_in_seconds = + (msg_params[strings::start_time][strings::hours].asUInt()) * 3600; + start_time_in_seconds += + (msg_params[strings::start_time][strings::minutes].asUInt()) * 60; + start_time_in_seconds += + (msg_params[strings::start_time][strings::seconds].asUInt()); + + unsigned int end_time_in_seconds = 0; + end_time_in_seconds = + (msg_params[strings::end_time][strings::hours].asUInt()) * 3600; + end_time_in_seconds += + (msg_params[strings::end_time][strings::minutes].asUInt()) * 60; + end_time_in_seconds += + (msg_params[strings::end_time][strings::seconds].asUInt()); + + if (((end_time_in_seconds > start_time_in_seconds) && + (update_mode == mobile_apis::UpdateMode::COUNTDOWN)) || + ((end_time_in_seconds < start_time_in_seconds) && + (update_mode == mobile_apis::UpdateMode::COUNTUP))) { + LOG4CXX_INFO(logger_, "Invalid data"); + return false; + } + } + } + + LOG4CXX_INFO(logger_, "Data is valid"); + return true; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_response.cc new file mode 100644 index 0000000000..e777533ce4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_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 "sdl_rpc_plugin/commands/mobile/set_media_clock_timer_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SetMediaClockTimerResponse::SetMediaClockTimerResponse( + 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) {} + +SetMediaClockTimerResponse::~SetMediaClockTimerResponse() {} + +void SetMediaClockTimerResponse::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/show_constant_tbt_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc new file mode 100644 index 0000000000..c2eb067e18 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc @@ -0,0 +1,292 @@ +/* + + 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 <cstring> +#include "sdl_rpc_plugin/commands/mobile/show_constant_tbt_request.h" + +#include "application_manager/policies/policy_handler.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +ShowConstantTBTRequest::ShowConstantTBTRequest( + 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) {} + +ShowConstantTBTRequest::~ShowConstantTBTRequest() {} + +void ShowConstantTBTRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application( + (*message_)[strings::params][strings::connection_key].asUInt()); + + if (!app) { + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + LOG4CXX_ERROR(logger_, "Application is not registered"); + return; + } + // SDLAQ-CRS-664, VC3.1 + if ((*message_)[strings::msg_params].empty()) { + LOG4CXX_ERROR(logger_, "INVALID_DATA!"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params = (*message_)[strings::msg_params]; + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, + "Incoming show constant TBT has contains \t\n \\t \\n"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + // ProcessSoftButtons checks strings on the contents incorrect character + + mobile_apis::Result::eType processing_result = + MessageHelper::ProcessSoftButtons( + msg_params, app, policy_handler_, application_manager_); + + if (mobile_apis::Result::SUCCESS != processing_result) { + LOG4CXX_ERROR(logger_, "INVALID_DATA!"); + SendResponse(false, processing_result); + return; + } + + mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS; + if (msg_params.keyExists(strings::turn_icon)) { + verification_result = MessageHelper::VerifyImage( + msg_params[strings::turn_icon], app, application_manager_); + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + SendResponse(false, verification_result); + return; + } + } + + if (msg_params.keyExists(strings::next_turn_icon)) { + verification_result = MessageHelper::VerifyImage( + msg_params[strings::next_turn_icon], app, application_manager_); + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + SendResponse(false, verification_result); + return; + } + } + + msg_params[strings::app_id] = app->app_id(); + + msg_params[hmi_request::navi_texts] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + int32_t index = 0; + if (msg_params.keyExists(strings::navigation_text_1)) { + // erase useless parametr + msg_params.erase(strings::navigation_text_1); + msg_params[hmi_request::navi_texts][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::navigationText1); + msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::navigation_text_1]; + } + + if (msg_params.keyExists(strings::navigation_text_2)) { + // erase useless param + msg_params.erase(strings::navigation_text_2); + msg_params[hmi_request::navi_texts][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::navigationText2); + msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::navigation_text_2]; + } + + if (msg_params.keyExists(strings::eta)) { + // erase useless param + msg_params.erase(strings::eta); + msg_params[hmi_request::navi_texts][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::ETA); + msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::eta]; + } + + if (msg_params.keyExists(strings::total_distance)) { + // erase useless param + msg_params.erase(strings::total_distance); + msg_params[hmi_request::navi_texts][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::totalDistance); + msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::total_distance]; + } + + if (msg_params.keyExists(strings::time_to_destination)) { + // erase useless param + msg_params.erase(strings::time_to_destination); + msg_params[hmi_request::navi_texts][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::timeToDestination); + msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::time_to_destination]; + } + + if (msg_params.keyExists(strings::soft_buttons)) { + MessageHelper::SubscribeApplicationToSoftButton( + msg_params, app, function_id()); + } + + app->set_tbt_show_command(msg_params); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); + SendHMIRequest( + hmi_apis::FunctionID::Navigation_ShowConstantTBT, &msg_params, true); +} + +void ShowConstantTBTRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace hmi_apis; + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::Navigation_ShowConstantTBT: { + LOG4CXX_INFO(logger_, "Received Navigation_ShowConstantTBT event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); + const Common_Result::eType result_code = + static_cast<Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(message, response_info); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_Navigation); + 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()); + break; + } + } +} + +bool ShowConstantTBTRequest::IsWhiteSpaceExist() { + LOG4CXX_AUTO_TRACE(logger_); + const char* str = NULL; + + if ((*message_)[strings::msg_params].keyExists(strings::turn_icon)) { + str = (*message_)[strings::msg_params][strings::turn_icon][strings::value] + .asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid turn_icon value syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::next_turn_icon)) { + str = (*message_)[strings::msg_params][strings::next_turn_icon] + [strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid next_turn_icon value syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::navigation_text_1)) { + str = (*message_)[strings::msg_params][strings::navigation_text_1] + .asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid navigation_text_1 value syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::navigation_text_2)) { + str = (*message_)[strings::msg_params][strings::navigation_text_2] + .asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid navigation_text_2 value syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::eta)) { + str = (*message_)[strings::msg_params][strings::eta].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid eta value syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::total_distance)) { + str = + (*message_)[strings::msg_params][strings::total_distance].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid total_distance value syntax check failed"); + return true; + } + } + + if ((*message_)[strings::msg_params].keyExists( + strings::time_to_destination)) { + str = (*message_)[strings::msg_params][strings::time_to_destination] + .asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid time_to_destination value syntax check failed"); + return true; + } + } + return false; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_response.cc new file mode 100644 index 0000000000..239040a3b3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_response.cc @@ -0,0 +1,66 @@ +/* + + 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/show_constant_tbt_response.h" +#include "application_manager/rpc_service.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +ShowConstantTBTResponse::ShowConstantTBTResponse( + 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) {} + +ShowConstantTBTResponse::~ShowConstantTBTResponse() {} + +void ShowConstantTBTResponse::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/show_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc new file mode 100644 index 0000000000..80a28b288c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc @@ -0,0 +1,413 @@ +/* + + 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 <string.h> +#include "sdl_rpc_plugin/commands/mobile/show_request.h" + +#include "application_manager/policies/policy_handler.h" +#include "application_manager/application.h" +#include "application_manager/message_helper.h" +#include "utils/file_system.h" +#include "utils/helpers.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +ShowRequest::ShowRequest( + 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) + , core_result_code_(mobile_apis::Result::INVALID_ENUM) {} + +ShowRequest::~ShowRequest() {} + +void ShowRequest::HandleMetadata(const char* field_id, + int32_t field_index, + smart_objects::SmartObject& msg_params) { + smart_objects::SmartObject& metadata_tags = + (*message_)[strings::msg_params][strings::metadata_tags]; + + if (metadata_tags.keyExists(field_id)) { + if (field_index != -1) { + msg_params[hmi_request::show_strings][field_index] + [hmi_request::field_types] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + const size_t num_tags = metadata_tags[field_id].length(); + for (size_t i = 0; i < num_tags; ++i) { + const int32_t current_tag = metadata_tags[field_id][i].asInt(); + msg_params[hmi_request::show_strings][field_index] + [hmi_request::field_types][i] = current_tag; + } + } else { + LOG4CXX_INFO(logger_, + "metadata tag provided with no item for " + << field_id << ", ignoring with warning"); + // tag provided with no item, ignore with warning + if (mobile_apis::Result::INVALID_ENUM == core_result_code_) { + core_result_code_ = mobile_apis::Result::WARNINGS; + core_response_info_ = + "Metadata tag was provided for a field with no data."; + } + } + } else { + LOG4CXX_INFO(logger_, + "No metadata tagging provided for field: " << field_id); + } +} + +void ShowRequest::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; + } + // SDLAQ-CRS-494, VC3.1 + if ((*message_)[strings::msg_params].empty()) { + LOG4CXX_ERROR(logger_, strings::msg_params << " is empty."); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if (!CheckStringsOfShowRequest()) { + LOG4CXX_ERROR(logger_, "Incorrect characters in string"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + // ProcessSoftButtons checks strings on the contents incorrect character + + mobile_apis::Result::eType processing_result = mobile_apis::Result::SUCCESS; + if (((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) && + ((*message_)[strings::msg_params][strings::soft_buttons].length() > 0)) { + processing_result = + MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], + app, + policy_handler_, + application_manager_); + } + + if (mobile_apis::Result::SUCCESS != processing_result) { + LOG4CXX_ERROR(logger_, "Processing of soft buttons failed."); + SendResponse(false, processing_result); + return; + } + + mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS; + if (((*message_)[strings::msg_params].keyExists(strings::graphic)) && + ((*message_)[strings::msg_params][strings::graphic][strings::value] + .asString()).length()) { + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::graphic], + app, + application_manager_); + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR(logger_, "Image verification failed."); + SendResponse(false, verification_result); + return; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::secondary_graphic)) { + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::secondary_graphic], + app, + application_manager_); + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR(logger_, "Image verification failed."); + SendResponse(false, verification_result); + return; + } + } + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[strings::app_id] = app->app_id(); + + msg_params[hmi_request::show_strings] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + int32_t index = 0; + int32_t main_field_1_index = -1; + if ((*message_)[strings::msg_params].keyExists(strings::main_field_1)) { + msg_params[hmi_request::show_strings][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::mainField1); + msg_params[hmi_request::show_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::main_field_1]; + main_field_1_index = index; + ++index; + } + + int32_t main_field_2_index = -1; + if ((*message_)[strings::msg_params].keyExists(strings::main_field_2)) { + msg_params[hmi_request::show_strings][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::mainField2); + msg_params[hmi_request::show_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::main_field_2]; + main_field_2_index = index; + ++index; + } + + int32_t main_field_3_index = -1; + if ((*message_)[strings::msg_params].keyExists(strings::main_field_3)) { + msg_params[hmi_request::show_strings][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::mainField3); + msg_params[hmi_request::show_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::main_field_3]; + main_field_3_index = index; + ++index; + } + + int32_t main_field_4_index = -1; + if ((*message_)[strings::msg_params].keyExists(strings::main_field_4)) { + msg_params[hmi_request::show_strings][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::mainField4); + msg_params[hmi_request::show_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::main_field_4]; + main_field_4_index = index; + ++index; + } + + if ((*message_)[strings::msg_params].keyExists(strings::metadata_tags)) { + HandleMetadata(strings::main_field_1, main_field_1_index, msg_params); + HandleMetadata(strings::main_field_2, main_field_2_index, msg_params); + HandleMetadata(strings::main_field_3, main_field_3_index, msg_params); + HandleMetadata(strings::main_field_4, main_field_4_index, msg_params); + } + + if ((*message_)[strings::msg_params].keyExists(strings::media_clock)) { + msg_params[hmi_request::show_strings][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::mediaClock); + msg_params[hmi_request::show_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::media_clock]; + ++index; + } + + if ((*message_)[strings::msg_params].keyExists(strings::media_track)) { + msg_params[hmi_request::show_strings][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::mediaTrack); + msg_params[hmi_request::show_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::media_track]; + ++index; + } + + if ((*message_)[strings::msg_params].keyExists(strings::status_bar)) { + msg_params[hmi_request::show_strings][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::statusBar); + msg_params[hmi_request::show_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::status_bar]; + ++index; + } + + if ((*message_)[strings::msg_params].keyExists(strings::alignment)) { + msg_params[strings::alignment] = + (*message_)[strings::msg_params][strings::alignment]; + } + + if ((*message_)[strings::msg_params].keyExists(strings::graphic)) { + msg_params[strings::graphic] = + (*message_)[strings::msg_params][strings::graphic]; + } + + if ((*message_)[strings::msg_params].keyExists(strings::secondary_graphic)) { + msg_params[strings::secondary_graphic] = + (*message_)[strings::msg_params][strings::secondary_graphic]; + } + + if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + msg_params[strings::soft_buttons] = + (*message_)[strings::msg_params][strings::soft_buttons]; + if ((*message_)[strings::msg_params][strings::soft_buttons].length() == 0) { + app->UnsubscribeFromSoftButtons(function_id()); + } else { + MessageHelper::SubscribeApplicationToSoftButton( + (*message_)[strings::msg_params], app, function_id()); + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::custom_presets)) { + msg_params[strings::custom_presets] = + (*message_)[strings::msg_params][strings::custom_presets]; + } + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_Show, &msg_params, true); + + app_mngr::commands::MessageSharedPtr persistentData = + new smart_objects::SmartObject(msg_params); + app->set_show_command(*persistentData); +} + +void ShowRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_Show: { + LOG4CXX_DEBUG(logger_, "Received UI_Show event."); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + std::string response_info; + hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_UI); + GetInfo(message, response_info); + if (hmi_apis::Common_Result::WARNINGS == result_code && + message[strings::params].keyExists(hmi_response::message)) { + response_info = + message[strings::params][hmi_response::message].asString(); + } + mobile_apis::Result::eType converted_result_code = + MessageHelper::HMIToMobileResult(result_code); + if (mobile_apis::Result::SUCCESS == converted_result_code && + mobile_apis::Result::INVALID_ENUM != core_result_code_) { + converted_result_code = core_result_code_; + response_info = core_response_info_; + } + SendResponse(result, + converted_result_code, + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event " << event.id()); + break; + } + } +} + +bool ShowRequest::CheckStringsOfShowRequest() { + LOG4CXX_AUTO_TRACE(logger_); + const char* str; + + if ((*message_)[strings::msg_params].keyExists(strings::main_field_4)) { + str = (*message_)[strings::msg_params][strings::main_field_4].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid main_field_4 syntax check failed"); + return false; + } + } + if ((*message_)[strings::msg_params].keyExists(strings::main_field_3)) { + str = (*message_)[strings::msg_params][strings::main_field_3].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid main_field_3 syntax check failed"); + return false; + } + } + if ((*message_)[strings::msg_params].keyExists(strings::main_field_2)) { + str = (*message_)[strings::msg_params][strings::main_field_2].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid main_field_2 syntax check failed"); + return false; + } + } + if ((*message_)[strings::msg_params].keyExists(strings::main_field_1)) { + str = (*message_)[strings::msg_params][strings::main_field_1].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid main_field_1 syntax check failed"); + return false; + } + } + if ((*message_)[strings::msg_params].keyExists(strings::status_bar)) { + str = (*message_)[strings::msg_params][strings::status_bar].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid status_bar syntax check failed"); + return false; + } + } + if ((*message_)[strings::msg_params].keyExists(strings::media_clock)) { + str = (*message_)[strings::msg_params][strings::media_clock].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid media_clock syntax check failed"); + return false; + } + } + if ((*message_)[strings::msg_params].keyExists(strings::media_track)) { + str = (*message_)[strings::msg_params][strings::media_track].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid media_track syntax check failed"); + return false; + } + } + if ((*message_)[strings::msg_params].keyExists(strings::custom_presets)) { + smart_objects::SmartObject& custom_presets_array = + (*message_)[strings::msg_params][strings::custom_presets]; + for (size_t i = 0; i < custom_presets_array.length(); ++i) { + str = custom_presets_array[i].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid custom_presets syntax check failed"); + return false; + } + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::graphic)) { + str = (*message_)[strings::msg_params][strings::graphic][strings::value] + .asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid graphic value syntax check failed"); + return false; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::secondary_graphic)) { + str = (*message_)[strings::msg_params][strings::secondary_graphic] + [strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid secondary_graphic value syntax check failed"); + return false; + } + } + return true; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_response.cc new file mode 100644 index 0000000000..4e167e7531 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_response.cc @@ -0,0 +1,66 @@ +/* + + 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/show_response.h" +#include "application_manager/rpc_service.h" +#include "application_manager/application_impl.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +ShowResponse::ShowResponse( + 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) {} + +ShowResponse::~ShowResponse() {} + +void ShowResponse::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/slider_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc new file mode 100644 index 0000000000..08b4775d3f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc @@ -0,0 +1,207 @@ +/* + + 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/slider_request.h" + +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "utils/helpers.h" +#include "config_profile/profile.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SliderRequest::SliderRequest( + 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) { + subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); +} + +SliderRequest::~SliderRequest() {} + +bool SliderRequest::Init() { + /* Timeout in milliseconds. + If omitted a standard value of 10000 milliseconds is used.*/ + if ((*message_)[strings::msg_params].keyExists(strings::timeout)) { + default_timeout_ = + application_manager_.get_settings().default_timeout() + + (*message_)[strings::msg_params][strings::timeout].asUInt(); + } + + return true; +} + +void SliderRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr application = application_manager_.application( + (*message_)[strings::params][strings::connection_key].asUInt()); + + if (!application) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if ((*message_)[strings::msg_params][strings::num_ticks].asInt() < + (*message_)[strings::msg_params][strings::position].asInt()) { + LOG4CXX_ERROR(logger_, "INVALID_DATA"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if ((*message_)[strings::msg_params].keyExists(strings::slider_footer)) { + if (1 < (*message_)[strings::msg_params][strings::slider_footer].length()) { + if ((*message_)[strings::msg_params][strings::num_ticks].asUInt() != + (*message_)[strings::msg_params][strings::slider_footer].length()) { + LOG4CXX_ERROR(logger_, "INVALID_DATA"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, "Incoming slider has contains \t\n \\t \\n"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params = (*message_)[strings::msg_params]; + msg_params[strings::app_id] = application->app_id(); + + if (!(*message_)[strings::msg_params].keyExists(strings::timeout)) { + msg_params[strings::timeout] = default_timeout_; + } + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_Slider, &msg_params, true); +} + +void SliderRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + using namespace smart_objects; + using namespace hmi_apis; + + const SmartObject& message = event.smart_object(); + + const event_engine::Event::EventID event_id = event.id(); + if (event_id == FunctionID::UI_OnResetTimeout) { + LOG4CXX_INFO(logger_, "Received UI_OnResetTimeout event"); + application_manager_.updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + return; + } + + if (event_id != FunctionID::UI_Slider) { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + + LOG4CXX_DEBUG(logger_, "Received UI_Slider event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + const Common_Result::eType response_code = static_cast<Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + SmartObject response_msg_params = message[strings::msg_params]; + + const bool is_timeout_aborted = Compare<Common_Result::eType, EQ, ONE>( + response_code, Common_Result::TIMED_OUT, Common_Result::ABORTED); + + if (is_timeout_aborted) { + if (message[strings::params][strings::data].keyExists( + strings::slider_position)) { + // Copy slider_position info to msg_params section + response_msg_params[strings::slider_position] = + message[strings::params][strings::data][strings::slider_position]; + } else { + LOG4CXX_ERROR(logger_, + strings::slider_position << " field is absent" + " in response."); + response_msg_params[strings::slider_position] = 0; + } + } + std::string response_info; + GetInfo(message, response_info); + const bool is_response_success = PrepareResultForMobileResponse( + response_code, HmiInterfaces::HMI_INTERFACE_UI); + + SendResponse(is_response_success, + MessageHelper::HMIToMobileResult(response_code), + response_info.empty() ? NULL : response_info.c_str(), + &response_msg_params); +} + +bool SliderRequest::IsWhiteSpaceExist() { + LOG4CXX_AUTO_TRACE(logger_); + const char* str = NULL; + + str = (*message_)[strings::msg_params][strings::slider_header].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid slider_header value syntax check failed"); + return true; + } + + if ((*message_)[strings::msg_params].keyExists(strings::slider_footer)) { + const smart_objects::SmartArray* sf_array = + (*message_)[strings::msg_params][strings::slider_footer].asArray(); + + smart_objects::SmartArray::const_iterator it_sf = sf_array->begin(); + smart_objects::SmartArray::const_iterator it_sf_end = sf_array->end(); + + for (; it_sf != it_sf_end; ++it_sf) { + str = (*it_sf).asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid slider_footer syntax check failed"); + return true; + } + } + } + return false; +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_response.cc new file mode 100644 index 0000000000..4d6e714e88 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_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 "sdl_rpc_plugin/commands/mobile/slider_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SliderResponse::SliderResponse( + 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) {} + +SliderResponse::~SliderResponse() {} + +void SliderResponse::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/speak_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc new file mode 100644 index 0000000000..e14321c488 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc @@ -0,0 +1,184 @@ +/* + + 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 <string.h> +#include "sdl_rpc_plugin/commands/mobile/speak_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 { + +SpeakRequest::SpeakRequest( + 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) { + subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout); +} + +SpeakRequest::~SpeakRequest() {} + +void SpeakRequest::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; + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, + "Incoming speak has contains \\t\\n \\\\t \\\\n " + " text contains only whitespace in ttsChunks"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + smart_objects::SmartObject& tts_chunks = + (*message_)[strings::msg_params][strings::tts_chunks]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles(tts_chunks, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + SendResponse(false, + mobile_apis::Result::FILE_NOT_FOUND, + "One or more files needed for tts_chunks are not present"); + return; + } + + (*message_)[strings::msg_params][strings::app_id] = app->app_id(); + (*message_)[strings::msg_params][hmi_request::speak_type] = + hmi_apis::Common_MethodName::SPEAK; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); + SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, + &message_->getElement(strings::msg_params), + true); +} + +void SpeakRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + switch (event.id()) { + case hmi_apis::FunctionID::TTS_Speak: { + LOG4CXX_INFO(logger_, "Received TTS_Speak event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); + ProcessTTSSpeakResponse(event.smart_object()); + break; + } + case hmi_apis::FunctionID::TTS_OnResetTimeout: { + LOG4CXX_INFO(logger_, "Received TTS_OnResetTimeout event"); + + application_manager_.updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + break; + } + } +} + +void SpeakRequest::ProcessTTSSpeakResponse( + const smart_objects::SmartObject& message) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + hmi_apis::Common_Result::eType hmi_result_code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + mobile_apis::Result::eType result_code = + MessageHelper::HMIToMobileResult(hmi_result_code); + + const bool result = PrepareResultForMobileResponse( + hmi_result_code, HmiInterfaces::HMI_INTERFACE_TTS); + + (*message_)[strings::params][strings::function_id] = + mobile_apis::FunctionID::SpeakID; + + const char* return_info = NULL; + + SendResponse( + result, result_code, return_info, &(message[strings::msg_params])); +} + +bool SpeakRequest::IsWhiteSpaceExist() { + LOG4CXX_AUTO_TRACE(logger_); + const char* str = NULL; + + if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) { + const smart_objects::SmartArray* tc_array = + (*message_)[strings::msg_params][strings::tts_chunks].asArray(); + + smart_objects::SmartArray::const_iterator it_tc = tc_array->begin(); + smart_objects::SmartArray::const_iterator it_tc_end = tc_array->end(); + + for (; it_tc != it_tc_end; ++it_tc) { + str = (*it_tc)[strings::text].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid tts_chunks syntax check failed"); + return true; + } + } + } + return false; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_response.cc new file mode 100644 index 0000000000..f57bd91cd5 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_response.cc @@ -0,0 +1,66 @@ +/* + + 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/speak_response.h" +#include "application_manager/rpc_service.h" +#include "application_manager/application_impl.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SpeakResponse::SpeakResponse( + 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) {} + +SpeakResponse::~SpeakResponse() {} + +void SpeakResponse::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_button_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc new file mode 100644 index 0000000000..908a251962 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc @@ -0,0 +1,132 @@ +/* + + 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_button_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace str = strings; + +SubscribeButtonRequest::SubscribeButtonRequest( + 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) {} + +SubscribeButtonRequest::~SubscribeButtonRequest() {} + +void SubscribeButtonRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "APPLICATION_NOT_REGISTERED"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + const mobile_apis::ButtonName::eType btn_id = + static_cast<mobile_apis::ButtonName::eType>( + (*message_)[str::msg_params][str::button_name].asInt()); + + if (!IsSubscriptionAllowed(app, btn_id)) { + LOG4CXX_ERROR(logger_, + "Subscribe on button " << btn_id << " isn't allowed"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + if (!CheckHMICapabilities(btn_id)) { + LOG4CXX_ERROR(logger_, + "Subscribe on button " + << btn_id << " isn't allowed by HMI capabilities"); + SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE); + return; + } + + if (app->IsSubscribedToButton(btn_id)) { + LOG4CXX_ERROR(logger_, "Already subscribed to button " << btn_id); + SendResponse(false, mobile_apis::Result::IGNORED); + return; + } + + app->SubscribeToButton(static_cast<mobile_apis::ButtonName::eType>(btn_id)); + SendSubscribeButtonNotification(); + + const bool is_succedeed = true; + SendResponse(is_succedeed, mobile_apis::Result::SUCCESS); +} + +bool SubscribeButtonRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +bool SubscribeButtonRequest::IsSubscriptionAllowed( + ApplicationSharedPtr app, mobile_apis::ButtonName::eType btn_id) { + if (!app->is_media_application() && + ((mobile_apis::ButtonName::SEEKLEFT == btn_id) || + (mobile_apis::ButtonName::SEEKRIGHT == btn_id) || + (mobile_apis::ButtonName::TUNEUP == btn_id) || + (mobile_apis::ButtonName::TUNEDOWN == btn_id))) { + return false; + } + return true; +} + +void SubscribeButtonRequest::SendSubscribeButtonNotification() { + using namespace smart_objects; + using namespace hmi_apis; + + // send OnButtonSubscription notification + SmartObject msg_params = SmartObject(SmartType_Map); + msg_params[strings::app_id] = connection_key(); + msg_params[strings::name] = static_cast<Common_ButtonName::eType>( + (*message_)[strings::msg_params][strings::button_name].asUInt()); + msg_params[strings::is_suscribed] = true; + CreateHMINotification(FunctionID::Buttons_OnButtonSubscription, msg_params); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_response.cc new file mode 100644 index 0000000000..1350cfb66e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_response.cc @@ -0,0 +1,73 @@ +/* + + 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_button_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SubscribeButtonResponse::SubscribeButtonResponse( + 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) {} + +SubscribeButtonResponse::~SubscribeButtonResponse() {} + +void SubscribeButtonResponse::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/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc new file mode 100644 index 0000000000..eb4ca42568 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc @@ -0,0 +1,123 @@ +/* + 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 "application_manager/application_manager.h" +#include "sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h" +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SubscribeWayPointsRequest::SubscribeWayPointsRequest( + 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) {} + +SubscribeWayPointsRequest::~SubscribeWayPointsRequest() {} + +void SubscribeWayPointsRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, + "An application with connection key " + << connection_key() << " is not registered."); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (application_manager_.IsAppSubscribedForWayPoints(app)) { + SendResponse(false, mobile_apis::Result::IGNORED); + return; + } + + if (application_manager_.IsAnyAppSubscribedForWayPoints()) { + application_manager_.SubscribeAppForWayPoints(app); + SendResponse(true, mobile_apis::Result::SUCCESS); + return; + } + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); + SendHMIRequest( + hmi_apis::FunctionID::Navigation_SubscribeWayPoints, NULL, true); +} + +void SubscribeWayPointsRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = application_manager_.application(connection_key()); + const smart_objects::SmartObject& message = event.smart_object(); + switch (event.id()) { + case hmi_apis::FunctionID::Navigation_SubscribeWayPoints: { + LOG4CXX_INFO(logger_, "Received Navigation_SubscribeWayPoints event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); + const hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(message, response_info); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_Navigation); + if (result) { + application_manager_.SubscribeAppForWayPoints(app); + } + 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()); + break; + } + } +} + +bool SubscribeWayPointsRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_response.cc new file mode 100644 index 0000000000..7d051df7e9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_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 "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" +#include "sdl_rpc_plugin/commands/mobile/subscribe_way_points_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SubscribeWayPointsResponse::SubscribeWayPointsResponse( + 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) {} + +SubscribeWayPointsResponse::~SubscribeWayPointsResponse() {} + +void SubscribeWayPointsResponse::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/system_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc new file mode 100644 index 0000000000..62eb2d59c5 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc @@ -0,0 +1,700 @@ +/* + +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/system_request.h" + +#include <vector> +#include <string> +#include <stdio.h> +#include <algorithm> +#include <sstream> +#include "application_manager/policies/policy_handler_interface.h" +#include "interfaces/MOBILE_API.h" +#include "utils/file_system.h" +#include "policy/policy_table/enums.h" +#include "formatters/CFormatterJsonBase.h" +#include "json/json.h" +#include "utils/helpers.h" +#include "utils/custom_string.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +CREATE_LOGGERPTR_LOCAL(logger_, "ApplicationManager") +namespace { + +#ifdef ENABLE_LOG +const char* kQueryAppsValidationFailedPrefix = + ":QUERY_APPS_VALIDATION_FAILED: "; +#endif + +const unsigned int kVrSynonymLengthMax = 40U; +const unsigned int kVrSynonymLengthMin = 1U; +const unsigned int kTtsNameLengthMax = 500U; +const unsigned int kVrArraySizeMax = 100U; +const unsigned int kVrArraySizeMin = 1U; +const unsigned int kUrlSchemaLengthMax = 255U; +const unsigned int kPackageNameLengthMax = 255U; +const unsigned int kAppIdLengthMax = 40U; +const unsigned int kAppNameLengthMax = 100U; +const unsigned int kLanguageArraySizeMax = 100U; + +class QueryAppsDataValidator { + public: + typedef std::set<std::string> SynonymsSet; + typedef std::map<std::string, SynonymsSet> SynonymsMap; + + QueryAppsDataValidator(smart_objects::SmartObject& object, + const ApplicationManager& manager) + : data_(object), manager_(manager) {} + + bool Validate() { + LOG4CXX_AUTO_TRACE(logger_); + if (!data_.isValid()) { + LOG4CXX_ERROR(logger_, + kQueryAppsValidationFailedPrefix + << "QueryApps response is not valid."); + return false; + } + if (!HasResponseKey()) { + return false; + } + return ValidateAppDataAndOsAndLanguagesData(); + } + + private: + bool HasResponseKey() const { + if (!data_.keyExists(json::response)) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "QueryApps response does not contain '" + << json::response << "' parameter."); + return false; + } + return true; + } + + bool ValidateAppDataAndOsAndLanguagesData() { + smart_objects::SmartArray* objects_array = data_[json::response].asArray(); + + if (!objects_array) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "QueryApps response is not array."); + return false; + } + + SynonymsMap synonyms_map; + bool has_response_valid_application = false; + + smart_objects::SmartArray::iterator applications_iterator = + objects_array->begin(); + + for (; applications_iterator != objects_array->end();) { + const smart_objects::SmartObject& app_data = *applications_iterator; + + if (!app_data.isValid()) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "Wrong application data in json file."); + return false; + } + + if (!CheckMandatoryParametersPresent(app_data)) { + LOG4CXX_WARN(logger_, + "Application hasn`t some of mandatory parameters. " + "Application will be skipped."); + + applications_iterator = objects_array->erase(applications_iterator); + continue; + } + + if (!ValidateAppIdAndAppName(app_data)) { + return false; + } + + // If we dont have any of android/ios field + // we skip this json in CheckMandatoryParametersPresent + const std::string os_type = + (app_data.keyExists(json::android)) ? json::android : json::ios; + + // Verify os and dependent languages data + if (json::ios == os_type) { + if (app_data[json::ios][json::urlScheme].asString().length() > + kUrlSchemaLengthMax) { + LOG4CXX_WARN( + logger_, + kQueryAppsValidationFailedPrefix + << "An urlscheme length exceeds maximum allowed [" + << app_data[json::ios][json::urlScheme].asString().length() + << "]>[" << kUrlSchemaLengthMax << "]"); + return false; + } + } + + if (json::android == os_type) { + if (app_data[json::android][json::packageName].asString().length() > + kPackageNameLengthMax) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "Package name length [" + << app_data[json::android][json::packageName] + .asString() + .length() << "] exceeds max length [" + << kPackageNameLengthMax << "]in json file."); + return false; + } + } + + // Languages verification + if (!app_data[os_type].keyExists(json::languages)) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "'languages' doesn't exist"); + return false; + } + if (!ValidateLanguages(app_data[os_type][json::languages], + synonyms_map)) { + return false; + } + has_response_valid_application = true; + ++applications_iterator; + } + return has_response_valid_application; + } + + bool ValidateAppIdAndAppName(const smart_objects::SmartObject& app_data) { + // Verify appid length + const std::string app_id(app_data[json::appId].asString()); + if (app_id.length() > kAppIdLengthMax) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "An Object ID length exceeds maximum allowed [" + << app_id.length() << "]>[" << kAppIdLengthMax << "]"); + return false; + } + + // Verify that appid is unique + if (applications_id_set_.find(app_id) != applications_id_set_.end()) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "An Object ID is not unigue [" << app_id << "]"); + return false; + } + applications_id_set_.insert(app_id); + + // Verify that app is not registered yet + ApplicationSharedPtr registered_app = + manager_.application_by_policy_id(app_id); + if (registered_app) { + LOG4CXX_INFO(logger_, + "Application with the id: " << app_id + << " is already registered."); + } + // And app name length + const std::string appName(app_data[json::name].asString()); + if (appName.length() > kAppNameLengthMax) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "Name of application exceeds maximum allowed [" + << appName.length() << "]>[" << kAppNameLengthMax + << "]."); + return false; + } + return true; + } + + bool ValidateLanguages(const smart_objects::SmartObject& languages, + SynonymsMap& synonyms_map) const { + bool default_language_found = false; + const size_t languages_array_size = languages.length(); + if (languages_array_size > kLanguageArraySizeMax) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "'languages' array exceeds max size [" + << languages_array_size << "]>[" << kLanguageArraySizeMax + << "]"); + return false; + } + // Every language has ttsname string and vrsynonyms array + for (size_t idx = 0; idx < languages_array_size; ++idx) { + const smart_objects::SmartObject& language = languages.getElement(idx); + if (smart_objects::SmartType_Map != language.getType()) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "language is not a map."); + return false; + } + if (language.length() != 1) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "language map size is not equal 1."); + return false; + } + const std::string language_name = (*language.map_begin()).first; + if (!language_name.length()) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "language name is empty"); + return false; + } + // Verify default language defined + if (!(language_name).compare(json::default_)) { + default_language_found = true; + } + // Add set for synonyms' duplicates validation + if (synonyms_map.find(language_name) == synonyms_map.end()) { + synonyms_map[language_name] = SynonymsSet(); + } + // ttsName verification + if (!language[language_name].keyExists(json::ttsName)) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "'languages.ttsName' doesn't exist"); + return false; + } + const smart_objects::SmartObject& ttsNameObject = + language[language_name][json::ttsName]; + // ttsName is string + if (smart_objects::SmartType_String == ttsNameObject.getType()) { + const std::string ttsName = + language[language_name][json::ttsName].asString(); + if (ttsName.length() > kTtsNameLengthMax) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "ttsName string exceeds max length [" + << ttsName.length() << "]>[" << kTtsNameLengthMax + << "]"); + return false; + } + } else { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "ttsName is not the string type."); + return false; + } + + if (!ValidateSynonymsAtLanguage(language, language_name, synonyms_map)) { + return false; + } + } + if (!default_language_found) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << " 'languages'.default' doesn't exist"); + return false; + } + return true; + } + + bool ValidateSynonymsAtLanguage(const smart_objects::SmartObject& language, + const std::string& language_name, + SynonymsMap& synonyms_map) const { + if (!language[language_name].keyExists(json::vrSynonyms)) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "'languages.vrSynonyms' doesn't exist"); + return false; + } + const smart_objects::SmartArray* synonyms_array = + language[language_name][json::vrSynonyms].asArray(); + if (!synonyms_array) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "vrSynonyms is not array."); + return false; + } + const size_t synonyms_array_size = synonyms_array->size(); + if (synonyms_array_size < kVrArraySizeMin) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "vrSynomyms array has [" << synonyms_array_size + << "] size < allowed min size [" << kVrArraySizeMin + << "]"); + return false; + } + if (synonyms_array_size > kVrArraySizeMax) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "vrSynomyms array size [" << synonyms_array_size + << "] exceeds maximum allowed size [" << kVrArraySizeMax + << "]"); + return false; + } + + for (std::size_t idx = 0; idx < synonyms_array_size; ++idx) { + const smart_objects::SmartObject& synonym = (*synonyms_array)[idx]; + const std::string vrSynonym = synonym.asString(); + if (vrSynonym.length() > kVrSynonymLengthMax) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "vrSYnomym item [" << idx + << "] exceeds max length [" << vrSynonym.length() + << "]>[" << kVrSynonymLengthMax << "]"); + return false; + } + if (vrSynonym.length() < kVrSynonymLengthMin) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "vrSYnomym item [" << idx << "] length [" + << vrSynonym.length() << "] is less then min length [" + << kVrSynonymLengthMin << "] allowed."); + return false; + } + // Verify duplicates + SynonymsMap::iterator synonyms_map_iter = + synonyms_map.find(language_name); + if (synonyms_map_iter != synonyms_map.end()) { + if (!(*synonyms_map_iter).second.insert(vrSynonym).second) { + LOG4CXX_WARN(logger_, + kQueryAppsValidationFailedPrefix + << "vrSYnomym item already defined [" + << vrSynonym.c_str() << "] for language [" + << language_name << "]"); + return false; + } + } + } + return true; + } + + bool CheckMandatoryParametersPresent( + const smart_objects::SmartObject& app_data) const { + if (!app_data.keyExists(json::android) && !app_data.keyExists(json::ios)) { + return false; + } + + if (app_data.keyExists(json::android) && + !app_data[json::android].keyExists(json::packageName)) { + return false; + } + + if (app_data.keyExists(json::ios) && + !app_data[json::ios].keyExists(json::urlScheme)) { + return false; + } + + if (!app_data.keyExists(json::appId)) { + return false; + } + + if (!app_data.keyExists(json::name)) { + return false; + } + + return true; + } + + smart_objects::SmartObject& data_; + std::set<std::string> applications_id_set_; + const ApplicationManager& manager_; + + DISALLOW_COPY_AND_ASSIGN(QueryAppsDataValidator); +}; +} + +namespace commands { + +namespace custom_str = utils::custom_string; + +uint32_t SystemRequest::index = 0; + +const std::string kSYNC = "SYNC"; +const std::string kIVSU = "IVSU"; + +SystemRequest::SystemRequest( + 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) {} + +SystemRequest::~SystemRequest() {} + +void SystemRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + if (!(application.valid())) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + const mobile_apis::RequestType::eType request_type = + static_cast<mobile_apis::RequestType::eType>( + (*message_)[strings::msg_params][strings::request_type].asInt()); + + const policy::PolicyHandlerInterface& policy_handler = policy_handler_; + + const std::string stringified_request_type = + rpc::policy_table_interface_base::EnumToJsonString( + static_cast<rpc::policy_table_interface_base::RequestType>( + request_type)); + + if (!policy_handler.IsRequestTypeAllowed(application->policy_app_id(), + request_type)) { + LOG4CXX_ERROR(logger_, + "RequestType " << stringified_request_type + << " is DISALLOWED by policies"); + SendResponse(false, mobile_apis::Result::DISALLOWED); + return; + } + LOG4CXX_TRACE(logger_, + "RequestType " << stringified_request_type << " is ALLOWED"); + + const bool request_subtype_present = + (*message_)[strings::msg_params].keyExists(strings::request_subtype); + if (request_subtype_present) { + const std::string request_subtype = + (*message_)[strings::msg_params][strings::request_subtype].asString(); + if (!policy_handler.IsRequestSubTypeAllowed(application->policy_app_id(), + request_subtype)) { + LOG4CXX_ERROR(logger_, + "Request subtype: " << request_subtype + << " is DISALLOWED by policies"); + SendResponse(false, mobile_apis::Result::DISALLOWED); + return; + } + LOG4CXX_TRACE(logger_, + "Request subtype: " << request_subtype << " is ALLOWED"); + } + + std::string file_name = kSYNC; + if ((*message_)[strings::msg_params].keyExists(strings::file_name)) { + file_name = (*message_)[strings::msg_params][strings::file_name].asString(); + } else { + file_name = kSYNC; + } + + if (!CheckSyntax(file_name)) { + LOG4CXX_ERROR(logger_, + "Incoming request contains \t\n \\t \\n or whitespace"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if (!file_system::IsFileNameValid(file_name)) { + const std::string err_msg = "Sync file name contains forbidden symbols."; + LOG4CXX_ERROR(logger_, err_msg); + SendResponse(false, mobile_apis::Result::INVALID_DATA, err_msg.c_str()); + return; + } + + const bool is_system_file = std::string::npos != file_name.find(kSYNC) || + std::string::npos != file_name.find(kIVSU); + + // to avoid override existing file + if (is_system_file) { + const uint8_t max_size = 255; + char buf[max_size] = {'\0'}; + snprintf(buf, max_size - 1, "%d%s", index++, file_name.c_str()); + file_name = buf; + } + + std::vector<uint8_t> binary_data; + std::string binary_data_folder; + if ((*message_)[strings::params].keyExists(strings::binary_data)) { + binary_data = (*message_)[strings::params][strings::binary_data].asBinary(); + binary_data_folder = + application_manager_.get_settings().system_files_path(); + } else { + binary_data_folder = + application_manager_.get_settings().app_storage_folder(); + binary_data_folder += "/"; + binary_data_folder += application->folder_name(); + binary_data_folder += "/"; + } + + std::string file_dst_path = + application_manager_.get_settings().system_files_path(); + file_dst_path += "/"; + file_dst_path += file_name; + + if ((*message_)[strings::params].keyExists(strings::binary_data)) { + LOG4CXX_DEBUG( + logger_, + "Binary data is present. Trying to save it to: " << binary_data_folder); + if (mobile_apis::Result::SUCCESS != + (application_manager_.SaveBinary( + binary_data, binary_data_folder, file_name, 0))) { + LOG4CXX_DEBUG(logger_, "Binary data can't be saved."); + SendResponse(false, mobile_apis::Result::GENERIC_ERROR); + return; + } + } else { + std::string app_full_file_path = binary_data_folder; + app_full_file_path += file_name; + + LOG4CXX_DEBUG(logger_, + "Binary data is not present. Trying to find file " + << file_name << " within previously saved app file in " + << binary_data_folder); + + const application_manager::AppFile* file = + application->GetFile(app_full_file_path); + if (!file || !file->is_download_complete || + !file_system::MoveFile(app_full_file_path, file_dst_path)) { + LOG4CXX_DEBUG(logger_, "Binary data not found."); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + processing_file_ = file_dst_path; + } + + LOG4CXX_DEBUG(logger_, "Binary data ok."); + + if (mobile_apis::RequestType::HTTP == request_type && + (*message_)[strings::msg_params].keyExists(strings::file_name)) { + const std::string& file = + (*message_)[strings::msg_params][strings::file_name].asString(); + policy_handler_.ReceiveMessageFromSDK(file, binary_data); + SendResponse(true, mobile_apis::Result::SUCCESS); + return; + } else if (mobile_apis::RequestType::QUERY_APPS == request_type) { + using namespace NsSmartDeviceLink::NsJSONHandler::Formatters; + + smart_objects::SmartObject sm_object; + Json::Reader reader; + std::string json(binary_data.begin(), binary_data.end()); + Json::Value root; + if (!reader.parse(json.c_str(), root)) { + LOG4CXX_DEBUG(logger_, "Unable to parse query_app json file."); + return; + } + + CFormatterJsonBase::jsonValueToObj(root, sm_object); + if (!ValidateQueryAppData(sm_object)) { + SendResponse(false, mobile_apis::Result::GENERIC_ERROR); + return; + } + + application_manager_.ProcessQueryApp(sm_object, connection_key()); + SendResponse(true, mobile_apis::Result::SUCCESS); + return; + } + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + if (std::string::npos != file_name.find(kIVSU)) { + msg_params[strings::file_name] = file_name; + } else { + msg_params[strings::file_name] = file_dst_path; + } + + // expected int, mandatory=true, all Policies flow (HTTP,Proprietary,External) + msg_params[strings::app_id] = application->hmi_app_id(); + + msg_params[strings::request_type] = + (*message_)[strings::msg_params][strings::request_type]; + if (request_subtype_present) { + msg_params[strings::request_subtype] = + (*message_)[strings::msg_params][strings::request_subtype]; + } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_BasicCommunication); + SendHMIRequest(hmi_apis::FunctionID::BasicCommunication_SystemRequest, + &msg_params, + true); +} + +void SystemRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::BasicCommunication_SystemRequest: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_BasicCommunication); + mobile_apis::Result::eType result_code = + GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asUInt())); + + const bool result = Compare<mobile_api::Result::eType, EQ, ONE>( + result_code, + mobile_api::Result::SUCCESS, + mobile_api::Result::WARNINGS); + + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + if (!(application.valid())) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; + } + + if (!processing_file_.empty()) { + file_system::DeleteFile(processing_file_); + processing_file_.clear(); + } + + SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + +bool SystemRequest::ValidateQueryAppData( + smart_objects::SmartObject& data) const { + if (!data.isValid()) { + LOG4CXX_ERROR(logger_, + kQueryAppsValidationFailedPrefix + << "QueryApps response is not valid."); + return false; + } + if (!data.keyExists(json::response)) { + LOG4CXX_ERROR(logger_, + kQueryAppsValidationFailedPrefix + << "QueryApps response does not contain '" + << json::response << "' parameter."); + return false; + } + + QueryAppsDataValidator validator(data, application_manager_); + return validator.Validate(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_response.cc new file mode 100644 index 0000000000..dc2e3ea3f5 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_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 "sdl_rpc_plugin/commands/mobile/system_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SystemResponse::SystemResponse( + 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) {} + +SystemResponse::~SystemResponse() {} + +void SystemResponse::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/unregister_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_request.cc new file mode 100644 index 0000000000..9119fb48da --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_request.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 "sdl_rpc_plugin/commands/mobile/unregister_app_interface_request.h" +#include "application_manager/rpc_service.h" +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +void UnregisterAppInterfaceRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + if (!application_manager_.application(connection_key())) { + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + LOG4CXX_ERROR(logger_, "Application is not registered"); + return; + } + + rpc_service_.ManageMobileCommand( + MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + connection_key(), + mobile_api::AppInterfaceUnregisteredReason::INVALID_ENUM), + SOURCE_SDL); + application_manager_.EndNaviServices(connection_key()); + application_manager_.UnregisterApplication(connection_key(), + mobile_apis::Result::SUCCESS); + SendResponse(true, mobile_apis::Result::SUCCESS); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_response.cc new file mode 100644 index 0000000000..4e7c879b58 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_response.cc @@ -0,0 +1,48 @@ +/* + + 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/unregister_app_interface_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +void UnregisterAppInterfaceResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendResponse((*message_)[strings::msg_params][strings::success].asBool()); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc new file mode 100644 index 0000000000..6537f0e7b2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc @@ -0,0 +1,112 @@ +/* + + 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_button_request.h" + +#include "application_manager/application_impl.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace str = strings; + +UnsubscribeButtonRequest::UnsubscribeButtonRequest( + 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) {} + +UnsubscribeButtonRequest::~UnsubscribeButtonRequest() {} + +void UnsubscribeButtonRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "APPLICATION_NOT_REGISTERED"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + const mobile_apis::ButtonName::eType btn_id = + static_cast<mobile_apis::ButtonName::eType>( + (*message_)[str::msg_params][str::button_name].asInt()); + + if (!CheckHMICapabilities(btn_id)) { + LOG4CXX_ERROR(logger_, + "Button " << btn_id << " isn't allowed by HMI capabilities"); + SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE); + return; + } + + if (!app->UnsubscribeFromButton( + static_cast<mobile_apis::ButtonName::eType>(btn_id))) { + LOG4CXX_ERROR(logger_, "App doesn't subscibe to button " << btn_id); + SendResponse(false, mobile_apis::Result::IGNORED); + return; + } + + SendUnsubscribeButtonNotification(); + SendResponse(true, mobile_apis::Result::SUCCESS); +} + +bool UnsubscribeButtonRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +void UnsubscribeButtonRequest::SendUnsubscribeButtonNotification() { + using namespace smart_objects; + using namespace hmi_apis; + + // send OnButtonSubscription notification + SmartObject msg_params = SmartObject(SmartType_Map); + msg_params[strings::app_id] = connection_key(); + msg_params[strings::name] = static_cast<Common_ButtonName::eType>( + (*message_)[strings::msg_params][strings::button_name].asInt()); + msg_params[strings::is_suscribed] = false; + CreateHMINotification(FunctionID::Buttons_OnButtonSubscription, msg_params); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_response.cc new file mode 100644 index 0000000000..592b91851e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_response.cc @@ -0,0 +1,74 @@ +/* + + 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_button_response.h" +#include "smart_objects/smart_object.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UnsubscribeButtonResponse::UnsubscribeButtonResponse( + 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) {} + +UnsubscribeButtonResponse::~UnsubscribeButtonResponse() {} + +void UnsubscribeButtonResponse::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/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc new file mode 100644 index 0000000000..0d0836878f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc @@ -0,0 +1,117 @@ +/* + 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 "application_manager/application_manager.h" +#include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h" +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UnSubscribeWayPointsRequest::UnSubscribeWayPointsRequest( + 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) {} + +UnSubscribeWayPointsRequest::~UnSubscribeWayPointsRequest() {} + +void UnSubscribeWayPointsRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, + "An application with connection key " + << connection_key() << " is not registered."); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (!application_manager_.IsAppSubscribedForWayPoints(app)) { + SendResponse(false, mobile_apis::Result::IGNORED); + return; + } + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); + SendHMIRequest( + hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints, NULL, true); +} + +void UnSubscribeWayPointsRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = application_manager_.application(connection_key()); + const smart_objects::SmartObject& message = event.smart_object(); + switch (event.id()) { + case hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints: { + LOG4CXX_INFO(logger_, "Received Navigation_UnSubscribeWayPoints event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); + const hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(message, response_info); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_Navigation); + if (result) { + application_manager_.UnsubscribeAppFromWayPoints(app); + } + 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()); + break; + } + } +} + +bool UnSubscribeWayPointsRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_response.cc new file mode 100644 index 0000000000..67e3466a44 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_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 "application_manager/application_manager.h" +#include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UnsubscribeWayPointsResponse::UnsubscribeWayPointsResponse( + 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) {} + +UnsubscribeWayPointsResponse::~UnsubscribeWayPointsResponse() {} + +void UnsubscribeWayPointsResponse::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/update_turn_list_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc new file mode 100644 index 0000000000..69379135b5 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc @@ -0,0 +1,243 @@ +/* + + 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 <string> +#include "sdl_rpc_plugin/commands/mobile/update_turn_list_request.h" + +#include "application_manager/policies/policy_handler.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" +#include "utils/custom_string.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace custom_str = utils::custom_string; + +UpdateTurnListRequest::UpdateTurnListRequest( + 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) {} + +UpdateTurnListRequest::~UpdateTurnListRequest() {} + +void UpdateTurnListRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application( + (*message_)[strings::params][strings::connection_key].asUInt()); + + if (!app) { + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + LOG4CXX_ERROR(logger_, "Application is not registered"); + return; + } + + if (IsWhiteSpaceExist()) { + LOG4CXX_ERROR(logger_, + "Incoming update turn list has contains \t\n \\t \\n"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + // ProcessSoftButtons checks strings on the contents incorrect character + + mobile_apis::Result::eType processing_result = + MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], + app, + policy_handler_, + application_manager_); + + if (mobile_apis::Result::SUCCESS != processing_result) { + LOG4CXX_ERROR(logger_, "INVALID_DATA!"); + SendResponse(false, processing_result); + return; + } + + if ((*message_)[strings::msg_params].keyExists(strings::turn_list)) { + smart_objects::SmartObject& turn_list_array = + ((*message_)[strings::msg_params][strings::turn_list]); + for (uint32_t i = 0; i < turn_list_array.length(); ++i) { + if ((turn_list_array[i].keyExists(strings::turn_icon)) && + (mobile_apis::Result::SUCCESS != + MessageHelper::VerifyImage(turn_list_array[i][strings::turn_icon], + app, + application_manager_))) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyImage return INVALID_DATA"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } + } + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params = (*message_)[strings::msg_params]; + + if ((*message_)[strings::msg_params].keyExists(strings::turn_list)) { + if (!CheckTurnListArray()) { + LOG4CXX_ERROR(logger_, "INVALID_DATA!"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + for (uint32_t i = 0; i < msg_params[strings::turn_list].length(); ++i) { + if (msg_params[strings::turn_list][i].keyExists(hmi_request::navi_text)) { + const custom_str::CustomString& navigation_text = + msg_params[strings::turn_list][i][hmi_request::navi_text] + .asCustomString(); + msg_params[strings::turn_list][i].erase(hmi_request::navi_text); + msg_params[strings::turn_list][i][hmi_request::navi_text] + [hmi_request::field_name] = static_cast<int>( + hmi_apis::Common_TextFieldName::turnText); + msg_params[strings::turn_list][i][hmi_request::navi_text] + [hmi_request::field_text] = navigation_text; + } + } + } + + msg_params[strings::app_id] = app->app_id(); + + if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + MessageHelper::SubscribeApplicationToSoftButton( + (*message_)[strings::msg_params], app, function_id()); + } + + if ((*message_)[strings::msg_params].keyExists(strings::turn_list) || + (*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); + SendHMIRequest( + hmi_apis::FunctionID::Navigation_UpdateTurnList, &msg_params, true); + } else { + // conditional mandatory + LOG4CXX_ERROR(logger_, "INVALID_DATA!"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + } +} + +void UpdateTurnListRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::Navigation_UpdateTurnList: { + LOG4CXX_INFO(logger_, "Received Navigation_UpdateTurnList event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); + const hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(message, response_info); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_Navigation); + 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()); + break; + } + } +} + +bool UpdateTurnListRequest::CheckTurnListArray() { + int32_t length = + (*message_)[strings::msg_params][strings::turn_list].length(); + if (0 == length) { + return false; + } + + for (int32_t i = 0; i < length; ++i) { + if (!((*message_)[strings::msg_params][strings::turn_list][i].keyExists( + hmi_request::navi_text)) && + !((*message_)[strings::msg_params][strings::turn_list][i].keyExists( + strings::turn_icon))) { + return false; + } + } + return true; +} + +bool UpdateTurnListRequest::IsWhiteSpaceExist() { + LOG4CXX_AUTO_TRACE(logger_); + const char* str = NULL; + + if ((*message_)[strings::msg_params].keyExists(strings::turn_list)) { + const smart_objects::SmartArray* tl_array = + (*message_)[strings::msg_params][strings::turn_list].asArray(); + + smart_objects::SmartArray::const_iterator it_tl = tl_array->begin(); + smart_objects::SmartArray::const_iterator it_tl_end = tl_array->end(); + + for (; it_tl != it_tl_end; ++it_tl) { + if ((*it_tl).keyExists(strings::navigation_text)) { + str = (*it_tl)[strings::navigation_text].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR( + logger_, + "Invalid turn_list navigation_text text syntax check failed"); + return true; + } + } + + if ((*it_tl).keyExists(strings::turn_icon)) { + str = (*it_tl)[strings::turn_icon][strings::value].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR( + logger_, "Invalid turn_list turn_icon value syntax check failed"); + return true; + } + } + } + } + return false; +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_response.cc new file mode 100644 index 0000000000..5ddf355f88 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_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 "sdl_rpc_plugin/commands/mobile/update_turn_list_response.h" +#include "application_manager/rpc_service.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UpdateTurnListResponse::UpdateTurnListResponse( + 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) {} + +UpdateTurnListResponse::~UpdateTurnListResponse() {} + +void UpdateTurnListResponse::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/hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc new file mode 100644 index 0000000000..bb621f814c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc @@ -0,0 +1,1703 @@ +/* + 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 copyright holders nor the names of their contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 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/hmi_command_factory.h" + +#include "application_manager/message.h" +#include "interfaces/HMI_API.h" + +#include "sdl_rpc_plugin/commands/hmi/update_device_list_request.h" +#include "sdl_rpc_plugin/commands/hmi/update_device_list_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_update_device_list.h" +#include "sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h" +#include "sdl_rpc_plugin/commands/hmi/update_app_list_request.h" +#include "sdl_rpc_plugin/commands/hmi/update_app_list_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_find_applications.h" +#include "sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h" +#include "sdl_rpc_plugin/commands/hmi/allow_all_apps_response.h" +#include "sdl_rpc_plugin/commands/hmi/allow_app_request.h" +#include "sdl_rpc_plugin/commands/hmi/allow_app_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_status_update_notification.h" +#include "sdl_rpc_plugin/commands/hmi/update_sdl_request.h" +#include "sdl_rpc_plugin/commands/hmi/update_sdl_response.h" +#include "sdl_rpc_plugin/commands/hmi/activate_app_request.h" +#include "sdl_rpc_plugin/commands/hmi/activate_app_response.h" +#include "sdl_rpc_plugin/commands/hmi/mixing_audio_supported_request.h" +#include "sdl_rpc_plugin/commands/hmi/mixing_audio_supported_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_audio_data_streaming_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_put_file_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_resume_audio_source_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/get_system_info_request.h" +#include "sdl_rpc_plugin/commands/hmi/get_system_info_response.h" +#include "sdl_rpc_plugin/commands/hmi/close_popup_request.h" +#include "sdl_rpc_plugin/commands/hmi/close_popup_response.h" +#include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_add_command_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_add_command_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_delete_command_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_add_submenu_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_add_submenu_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_delete_submenu_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_delete_submenu_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_language_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_change_registration_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_change_registration_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_show_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_show_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_alert_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_alert_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_is_ready_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_slider_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_slider_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_scrollable_message_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_app_icon_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_is_ready_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_add_command_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_add_command_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_change_registration_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_change_registration_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_language_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_is_ready_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_language_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_speak_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_speak_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_set_global_properties_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_perform_interaction_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_perform_interaction_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h" + +#ifdef EXTERNAL_PROPRIETARY_MODE +#include "sdl_rpc_plugin/commands/hmi/decrypt_certificate_request.h" +#include "sdl_rpc_plugin/commands/hmi/decrypt_certificate_response.h" +#endif // EXTERNAL_PROPRIETARY_MODE + +#ifdef HMI_DBUS_API +#include "sdl_rpc_plugin/commands/hmi/vi_get_vehicle_data_request_template.h" +#include "sdl_rpc_plugin/commands/hmi/vi_get_vehicle_data_response_template.h" +#include "sdl_rpc_plugin/commands/hmi/vi_subscribe_vehicle_data_request_template.h" +#include "sdl_rpc_plugin/commands/hmi/vi_subscribe_vehicle_data_response_template.h" +#include "sdl_rpc_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request_template.h" +#include "sdl_rpc_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response_template.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_gps_data_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_speed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_rpm_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_state_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_instant_fuel_consumption_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_external_temperature_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_vin_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_prndl_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_tire_pressure_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_odometer_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_belt_status_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_body_information_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_device_status_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_driver_braking_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_wiper_status_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_head_lamp_status_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_engine_torque_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_acc_pedal_position_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_steering_wheel_angle_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_my_key_notification.h" +#endif // #ifdef HMI_DBUS_API + +#include "sdl_rpc_plugin/commands/hmi/navi_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_is_ready_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_update_turn_list_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_get_way_points_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_ready_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_context_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_registered_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_button_event_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_button_press_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_button_subscription_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h" +#include "sdl_rpc_plugin/commands/hmi/navi_set_video_config_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_set_video_config_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_request_notification.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_record_start_notification.h" +#include "sdl_rpc_plugin/commands/hmi/add_statistics_info_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_error_notification.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_response.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_request.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_on_awake_sdl.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_policy_update.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_policy_update_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_received_policy_update.h" +#include "sdl_rpc_plugin/commands/hmi/on_policy_update.h" +#include "sdl_rpc_plugin/commands/hmi/get_urls.h" +#include "sdl_rpc_plugin/commands/hmi/get_urls_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/navi_send_location_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_send_location_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h" +#include "sdl_rpc_plugin/commands/hmi/dial_number_request.h" +#include "sdl_rpc_plugin/commands/hmi/dial_number_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_response.h" + +#include "sdl_rpc_plugin/commands/hmi/rc_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h" +#include "sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +HMICommandFactory::HMICommandFactory( + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : application_manager_(application_manager) + , rpc_service_(rpc_service) + , hmi_capabilities_(hmi_capabilities) + , policy_handler_(policy_handler) {} + +CommandSharedPtr HMICommandFactory::CreateCommand( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::commands::Command::CommandSource source) { + const hmi_apis::FunctionID::eType function_id = + static_cast<hmi_apis::FunctionID::eType>( + (*message)[strings::params][strings::function_id].asInt()); + LOG4CXX_DEBUG( + logger_, "HMICommandFactory::CreateCommand function_id: " << function_id); + + const hmi_apis::messageType::eType message_type = + static_cast<hmi_apis::messageType::eType>( + (*message)[strings::params][strings::message_type].asInt()); + + if (hmi_apis::messageType::response == message_type) { + LOG4CXX_DEBUG(logger_, "HMICommandFactory::CreateCommand response"); + } else if ((*message)[strings::params][strings::message_type] == + hmi_apis::messageType::error_response) { + LOG4CXX_DEBUG(logger_, "HMICommandFactory::CreateCommand error response"); + } else { + LOG4CXX_DEBUG(logger_, "HMICommandFactory::CreateCommand request"); + } + + return get_creator_factory(function_id, message_type, source).create(message); +} + +bool HMICommandFactory::IsAbleToProcess( + const int32_t function_id, + const application_manager::commands::Command::CommandSource message_source) + const { + using app_mngr::commands::Command; + return get_creator_factory( + static_cast<hmi_apis::FunctionID::eType>(function_id), + hmi_apis::messageType::INVALID_ENUM, + message_source).CanBeCreated(); +} + +CommandCreator& HMICommandFactory::get_creator_factory( + hmi_apis::FunctionID::eType id, + hmi_apis::messageType::eType message_type, + application_manager::commands::Command::CommandSource source) const { + CommandCreatorFactory factory( + application_manager_, rpc_service_, hmi_capabilities_, policy_handler_); + + switch (static_cast<int32_t>(id)) { + case hmi_apis::FunctionID::BasicCommunication_OnStartDeviceDiscovery: { + return factory.GetCreator<commands::OnStartDeviceDiscovery>(); + } + case hmi_apis::FunctionID::BasicCommunication_UpdateDeviceList: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UpdateDeviceListRequest>() + : factory.GetCreator<commands::UpdateDeviceListResponse>(); + } + case hmi_apis::FunctionID::BasicCommunication_ActivateApp: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::ActivateAppRequest>() + : factory.GetCreator<commands::ActivateAppResponse>(); + } +#ifdef EXTERNAL_PROPRIETARY_MODE + case hmi_apis::FunctionID::BasicCommunication_DecryptCertificate: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::DecryptCertificateRequest>() + : factory.GetCreator<commands::DecryptCertificateResponse>(); + } +#endif // EXTERNAL_PROPRIETARY_MODE + case hmi_apis::FunctionID::BasicCommunication_GetSystemInfo: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::GetSystemInfoRequest>() + : factory.GetCreator<commands::GetSystemInfoResponse>(); + } + case hmi_apis::FunctionID::SDL_ActivateApp: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::SDLActivateAppRequest>() + : factory.GetCreator<commands::SDLActivateAppResponse>(); + } + case hmi_apis::FunctionID::BasicCommunication_PolicyUpdate: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::SDLPolicyUpdate>() + : factory.GetCreator<commands::SDLPolicyUpdateResponse>(); + } + case hmi_apis::FunctionID::SDL_GetURLS: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::GetUrls>() + : factory.GetCreator<commands::GetUrlsResponse>(); + } + case hmi_apis::FunctionID::SDL_OnAppPermissionChanged: { + return factory.GetCreator<commands::OnAppPermissionChangedNotification>(); + } + case hmi_apis::FunctionID::SDL_GetListOfPermissions: { + return hmi_apis::messageType::request == message_type + ? factory + .GetCreator<commands::SDLGetListOfPermissionsRequest>() + : factory + .GetCreator<commands::SDLGetListOfPermissionsResponse>(); + } + case hmi_apis::FunctionID::SDL_GetUserFriendlyMessage: { + return hmi_apis::messageType::request == message_type + ? factory + .GetCreator<commands::SDLGetUserFriendlyMessageRequest>() + : factory.GetCreator< + commands::SDLGetUserFriendlyMessageResponse>(); + } + case hmi_apis::FunctionID::SDL_GetStatusUpdate: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::SDLGetStatusUpdateRequest>() + : factory.GetCreator<commands::SDLGetStatusUpdateResponse>(); + } + case hmi_apis::FunctionID::SDL_OnStatusUpdate: { + return factory.GetCreator<commands::OnStatusUpdateNotification>(); + } + case hmi_apis::FunctionID::SDL_OnAppPermissionConsent: { + return factory.GetCreator<commands::OnAppPermissionConsentNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_MixingAudioSupported: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::MixingAudioSupportedRequest>() + : factory.GetCreator<commands::MixingAudioSupportedResponse>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnExitAllApplications: { + return factory.GetCreator<commands::OnExitAllApplicationsNotification>(); + } + case hmi_apis::FunctionID::UI_AddCommand: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UIAddCommandRequest>() + : factory.GetCreator<commands::UIAddCommandResponse>(); + } + case hmi_apis::FunctionID::UI_DeleteCommand: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UIDeleteCommandRequest>() + : factory.GetCreator<commands::UIDeleteCommandResponse>(); + } + case hmi_apis::FunctionID::UI_AddSubMenu: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UIAddSubmenuRequest>() + : factory.GetCreator<commands::UIAddSubmenuResponse>(); + } + case hmi_apis::FunctionID::UI_DeleteSubMenu: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UIDeleteSubmenuRequest>() + : factory.GetCreator<commands::UIDeleteSubmenuResponse>(); + } + case hmi_apis::FunctionID::UI_SetMediaClockTimer: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UISetMediaClockTimerRequest>() + : factory.GetCreator<commands::UISetMediaClockTimerResponse>(); + } + case hmi_apis::FunctionID::UI_PerformInteraction: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UIPerformInteractionRequest>() + : factory.GetCreator<commands::UIPerformInteractionResponse>(); + } + case hmi_apis::FunctionID::UI_SetGlobalProperties: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UISetGlobalPropertiesRequest>() + : factory + .GetCreator<commands::UISetGlobalPropertiesResponse>(); + } + case hmi_apis::FunctionID::UI_ScrollableMessage: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UIScrollableMessageRequest>() + : factory.GetCreator<commands::UIScrollableMessageResponse>(); + } + case hmi_apis::FunctionID::UI_SetAppIcon: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UISetAppIconRequest>() + : factory.GetCreator<commands::UISetAppIconResponse>(); + } + case hmi_apis::FunctionID::UI_GetSupportedLanguages: { + return hmi_apis::messageType::request == message_type + ? factory + .GetCreator<commands::UIGetSupportedLanguagesRequest>() + : factory + .GetCreator<commands::UIGetSupportedLanguagesResponse>(); + } + case hmi_apis::FunctionID::UI_GetLanguage: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UIGetLanguageRequest>() + : factory.GetCreator<commands::UIGetLanguageResponse>(); + } + case hmi_apis::FunctionID::UI_GetCapabilities: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UIGetCapabilitiesRequest>() + : factory.GetCreator<commands::UIGetCapabilitiesResponse>(); + } + case hmi_apis::FunctionID::UI_ChangeRegistration: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UIChangeRegistrationRequest>() + : factory.GetCreator<commands::UIChangeRegistratioResponse>(); + } + case hmi_apis::FunctionID::UI_PerformAudioPassThru: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UIPerformAudioPassThruRequest>() + : factory + .GetCreator<commands::UIPerformAudioPassThruResponse>(); + } + case hmi_apis::FunctionID::UI_EndAudioPassThru: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UIEndAudioPassThruRequest>() + : factory.GetCreator<commands::UIEndAudioPassThruResponse>(); + } + case hmi_apis::FunctionID::UI_Alert: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UIAlertRequest>() + : factory.GetCreator<commands::UIAlertResponse>(); + } + case hmi_apis::FunctionID::VR_IsReady: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VRIsReadyRequest>() + : factory.GetCreator<commands::VRIsReadyResponse>(); + } + case hmi_apis::FunctionID::VR_AddCommand: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VRAddCommandRequest>() + : factory.GetCreator<commands::VRAddCommandResponse>(); + } + case hmi_apis::FunctionID::VR_DeleteCommand: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VRDeleteCommandRequest>() + : factory.GetCreator<commands::VRDeleteCommandResponse>(); + } + case hmi_apis::FunctionID::VR_ChangeRegistration: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VRChangeRegistrationRequest>() + : factory.GetCreator<commands::VRChangeRegistrationResponse>(); + } + case hmi_apis::FunctionID::VR_GetSupportedLanguages: { + return hmi_apis::messageType::request == message_type + ? factory + .GetCreator<commands::VRGetSupportedLanguagesRequest>() + : factory + .GetCreator<commands::VRGetSupportedLanguagesResponse>(); + } + case hmi_apis::FunctionID::VR_GetLanguage: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VRGetLanguageRequest>() + : factory.GetCreator<commands::VRGetLanguageResponse>(); + } + case hmi_apis::FunctionID::VR_GetCapabilities: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VRGetCapabilitiesRequest>() + : factory.GetCreator<commands::VRGetCapabilitiesResponse>(); + } + case hmi_apis::FunctionID::TTS_IsReady: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::TTSIsReadyRequest>() + : factory.GetCreator<commands::TTSIsReadyResponse>(); + } + case hmi_apis::FunctionID::TTS_ChangeRegistration: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::TTSChangeRegistrationRequest>() + : factory.GetCreator<commands::TTSChangeRegistratioResponse>(); + } + case hmi_apis::FunctionID::TTS_GetSupportedLanguages: { + return hmi_apis::messageType::request == message_type + ? factory + .GetCreator<commands::TTSGetSupportedLanguagesRequest>() + : factory.GetCreator< + commands::TTSGetSupportedLanguagesResponse>(); + } + case hmi_apis::FunctionID::TTS_StopSpeaking: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::TTSStopSpeakingRequest>() + : factory.GetCreator<commands::TTSStopSpeakingResponse>(); + } + case hmi_apis::FunctionID::TTS_GetLanguage: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::TTSGetLanguageRequest>() + : factory.GetCreator<commands::TTSGetLanguageResponse>(); + } + case hmi_apis::FunctionID::TTS_Speak: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::TTSSpeakRequest>() + : factory.GetCreator<commands::TTSSpeakResponse>(); + } + case hmi_apis::FunctionID::TTS_SetGlobalProperties: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::TTSSetGlobalPropertiesRequest>() + : factory + .GetCreator<commands::TTSSetGlobalPropertiesResponse>(); + } + case hmi_apis::FunctionID::TTS_GetCapabilities: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::TTSGetCapabilitiesRequest>() + : factory.GetCreator<commands::TTSGetCapabilitiesResponse>(); + } + case hmi_apis::FunctionID::TTS_Started: { + return factory.GetCreator<commands::OnTTSStartedNotification>(); + } + case hmi_apis::FunctionID::TTS_Stopped: { + return factory.GetCreator<commands::OnTTSStoppedNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnAppActivated: { + return factory.GetCreator<commands::OnAppActivatedNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnAwakeSDL: { + return factory.GetCreator<commands::OnAwakeSDLNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnExitApplication: { + return factory.GetCreator<commands::OnExitApplicationNotification>(); + } + case hmi_apis::FunctionID::UI_Show: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UIShowRequest>() + : factory.GetCreator<commands::UIShowResponse>(); + } + case hmi_apis::FunctionID::UI_Slider: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UISliderRequest>() + : factory.GetCreator<commands::UISliderResponse>(); + } + case hmi_apis::FunctionID::UI_ClosePopUp: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::ClosePopupRequest>() + : factory.GetCreator<commands::ClosePopupResponse>(); + } + case hmi_apis::FunctionID::UI_IsReady: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UIIsReadyRequest>() + : factory.GetCreator<commands::UIIsReadyResponse>(); + } +#ifdef HMI_DBUS_API + case hmi_apis::FunctionID::VehicleInfo_GetGpsData: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetGpsData> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID::VehicleInfo_GetGpsData> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetSpeed: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetSpeed> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID::VehicleInfo_GetSpeed> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetRpm: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehitcleInfo_GetRpm> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID::VehicleInfo_GetRpm> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetFuelLevel: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetFuelLevel> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID::VehicleInfo_GetFuelLevel> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetFuelLevelState: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetFuelLevelState> >(); + : factory.GetCreator< + commands::VIGetVehicleDataResponseTemplate<hmi_apis:: + FunctionID::VehicleInfo_GetFuelLevelState>> () + } + case hmi_apis::FunctionID::VehicleInfo_GetInstantFuelConsumption: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetInstantFuelConsumption> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetInstantFuelConsumption> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetExternalTemperature: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetExternalTemperature> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetExternalTemperature> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetPrndl: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetPrndl> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID::VehicleInfo_GetPrndl> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetVin: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetVin> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID::VehicleInfo_GetVin> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetTirePressure: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetTirePressure> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetTirePressure> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetOdometer: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetOdometer> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID::VehicleInfo_GetOdometer> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetBeltStatus: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetBeltStatus> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID::VehicleInfo_GetBeltStatus> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetBodyInformation: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetBodyInformation> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetBodyInformation> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetDeviceStatus: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetDeviceStatus> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetDeviceStatus> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetDriverBraking: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetDriverBraking> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetDriverBraking> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetWiperStatus: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetWiperStatus> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetWiperStatus> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetHeadLampStatus: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetHeadLampStatus> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetHeadLampStatus> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetEngineTorque: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetEngineTorque> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetEngineTorque> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetAccPedalPosition: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetAccPedalPosition> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetAccPedalPosition> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetSteeringWheelAngle: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetSteeringWheelAngle> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetSteeringWheelAngle> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetECallInfo: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetECallInfo> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID::VehicleInfo_GetECallInfo> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetAirbagStatus: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetAirbagStatus> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetAirbagStatus> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetEmergencyEvent: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetEmergencyEvent> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetEmergencyEvent> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetClusterModeStatus: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetClusterModeStatus> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_GetClusterModeStatus> >(); + } + case hmi_apis::FunctionID::VehicleInfo_GetMyKey: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VIGetVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_GetMyKey> >() + : factory + .GetCreator<commands::VIGetVehicleDataResponseTemplate< + hmi_apis::FunctionID::VehicleInfo_GetMyKey> >(); + } +#endif // #ifdef HMI_DBUS_API + case hmi_apis::FunctionID::Navigation_IsReady: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::NaviIsReadyRequest>() + : factory.GetCreator<commands::NaviIsReadyResponse>(); + } + case hmi_apis::FunctionID::Navigation_AlertManeuver: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::NaviAlertManeuverRequest>() + : factory.GetCreator<commands::NaviAlertManeuverResponse>(); + } + case hmi_apis::FunctionID::Navigation_GetWayPoints: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::NaviGetWayPointsRequest>() + : factory.GetCreator<commands::NaviGetWayPointsResponse>(); + } + case hmi_apis::FunctionID::Navigation_UpdateTurnList: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::NaviUpdateTurnListRequest>() + : factory.GetCreator<commands::NaviUpdateTurnListResponse>(); + } + case hmi_apis::FunctionID::Navigation_ShowConstantTBT: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::NaviShowConstantTBTRequest>() + : factory.GetCreator<commands::NaviShowConstantTBTResponse>(); + } + case hmi_apis::FunctionID::Navigation_SubscribeWayPoints: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::NaviSubscribeWayPointsRequest>() + : factory + .GetCreator<commands::NaviSubscribeWayPointsResponse>(); + } + case hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints: { + return hmi_apis::messageType::request == message_type + ? factory + .GetCreator<commands::NaviUnSubscribeWayPointsRequest>() + : factory.GetCreator< + commands::NaviUnsubscribeWayPointsResponse>(); + } + case hmi_apis::FunctionID::Buttons_GetCapabilities: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::ButtonGetCapabilitiesRequest>() + : factory + .GetCreator<commands::ButtonGetCapabilitiesResponse>(); + } + case hmi_apis::FunctionID::SDL_OnAllowSDLFunctionality: { + return factory + .GetCreator<commands::OnAllowSDLFunctionalityNotification>(); + } + case hmi_apis::FunctionID::SDL_OnSDLConsentNeeded: { + return factory.GetCreator<commands::OnSDLConsentNeededNotification>(); + } + case hmi_apis::FunctionID::SDL_UpdateSDL: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UpdateSDLRequest>() + : factory.GetCreator<commands::UpdateSDLResponse>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnIgnitionCycleOver: { + return factory.GetCreator<commands::OnIgnitionCycleOverNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnSystemInfoChanged: { + return factory.GetCreator<commands::OnSystemInfoChangedNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnReady: { + return factory.GetCreator<commands::OnReadyNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnSystemTimeReady: { + return factory.GetCreator<commands::OnSystemTimeReadyNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnDeviceChosen: { + return factory.GetCreator<commands::OnDeviceChosenNotification>(); + } + case hmi_apis::FunctionID::UI_OnSystemContext: { + return factory.GetCreator<commands::OnSystemContextNotification>(); + } + case hmi_apis::FunctionID::UI_OnDriverDistraction: { + return factory + .GetCreator<commands::hmi::OnDriverDistractionNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnUpdateDeviceList: { + return factory.GetCreator<commands::OnUpdateDeviceList>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnAppRegistered: { + return factory.GetCreator<commands::OnAppRegisteredNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnAppUnregistered: { + return factory.GetCreator<commands::OnAppUnregisteredNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnFindApplications: { + return factory.GetCreator<commands::OnFindApplications>(); + } + case hmi_apis::FunctionID::BasicCommunication_UpdateAppList: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UpdateAppListRequest>() + : factory.GetCreator<commands::UpdateAppListResponse>(); + } + case hmi_apis::FunctionID::VR_Started: { + return factory.GetCreator<commands::OnVRStartedNotification>(); + } + case hmi_apis::FunctionID::VR_Stopped: { + return factory.GetCreator<commands::OnVRStoppedNotification>(); + } + case hmi_apis::FunctionID::VR_OnCommand: { + return factory.GetCreator<commands::OnVRCommandNotification>(); + } + case hmi_apis::FunctionID::UI_OnCommand: { + return factory.GetCreator<commands::OnUICommandNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnAppDeactivated: { + return factory.GetCreator<commands::OnAppDeactivatedNotification>(); + } + case hmi_apis::FunctionID::UI_OnLanguageChange: { + return factory.GetCreator<commands::OnUILanguageChangeNotification>(); + } + case hmi_apis::FunctionID::VR_OnLanguageChange: { + return factory.GetCreator<commands::OnVRLanguageChangeNotification>(); + } + case hmi_apis::FunctionID::TTS_OnLanguageChange: { + return factory.GetCreator<commands::OnTTSLanguageChangeNotification>(); + } + case hmi_apis::FunctionID::Buttons_OnButtonEvent: { + return factory.GetCreator<commands::hmi::OnButtonEventNotification>(); + } + case hmi_apis::FunctionID::Buttons_OnButtonPress: { + return factory.GetCreator<commands::hmi::OnButtonPressNotification>(); + } + case hmi_apis::FunctionID::Buttons_OnButtonSubscription: { + return factory + .GetCreator<commands::hmi::OnButtonSubscriptionNotification>(); + } +#ifdef HMI_DBUS_API + case hmi_apis::FunctionID::VehicleInfo_SubscribeGps: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_SubscribeGps> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID::VehicleInfo_SubscribeGps> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeSpeed: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_SubscribeSpeed> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeSpeed> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeRpm: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_SubscribeRpm> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID::VehicleInfo_SubscribeRpm> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeFuelLevel: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeFuelLevel> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeFuelLevel> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeFuelLevel_State: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeFuelLevel_State> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeFuelLevel_State> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeInstantFuelConsumption: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeInstantFuelConsumption> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeInstantFuelConsumption> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeExternalTemperature: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeExternalTemperature> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeExternalTemperature> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribePrndl: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_SubscribePrndl> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribePrndl> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeVin: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_SubscribeVin> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID::VehicleInfo_SubscribeVin> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeTirePressure: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeTirePressure> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeTirePressure> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeOdometer: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeOdometer> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeOdometer> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeBeltStatus: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeBeltStatus> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeBeltStatus> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeBodyInformation: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeBodyInformation> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeBodyInformation> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeDeviceStatus: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeDeviceStatus> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeDeviceStatus> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeDriverBraking: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeDriverBraking> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeDriverBraking> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeWiperStatus: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeWiperStatus> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeWiperStatus> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeHeadLampStatus: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeHeadLampStatus> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeHeadLampStatus> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeEngineTorque: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeEngineTorque> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeEngineTorque> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeAccPedalPosition: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeAccPedalPosition> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeAccPedalPosition> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeSteeringWheelAngle: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeSteeringWheelAngle> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeSteeringWheelAngle> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeECallInfo: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeECallInfo> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeECallInfo> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeAirbagStatus: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeAirbagStatus> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeAirbagStatus> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeEmergencyEvent: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeEmergencyEvent> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeEmergencyEvent> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeClusterModeStatus: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeClusterModeStatus> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeClusterModeStatus> >(); + } + case hmi_apis::FunctionID::VehicleInfo_SubscribeMyKey: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VISubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_SubscribeMyKey> >() + : factory.GetCreator< + commands::VISubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_SubscribeMyKey> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeGps: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator < + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_UnsubscribeGps>() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeGps> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeSpeed: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeSpeed> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeSpeed> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeRpm: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_UnsubscribeRpm> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeRpm> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeFuelLevel: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeFuelLevel> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeFuelLevel> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeFuelLevel_State: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeFuelLevel_State> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeFuelLevel_State> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeInstantFuelConsumption: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeInstantFuelConsumption> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeInstantFuelConsumption> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeExternalTemperature: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeExternalTemperature> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeExternalTemperature> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribePrndl: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribePrndl> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribePrndl> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeVin: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_UnsubscribeVin> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeVin> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeTirePressure: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeTirePressure> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeTirePressure> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeOdometer: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeOdometer> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeOdometer> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeBeltStatus: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeBeltStatus> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeBeltStatus> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeBodyInformation: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeBodyInformation> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeBodyInformation> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeDeviceStatus: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeDeviceStatus> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeDeviceStatus> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeDriverBraking: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeDriverBraking> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeDriverBraking> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeWiperStatus: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeWiperStatus> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeWiperStatus> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeHeadLampStatus: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeHeadLampStatus> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeHeadLampStatus> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeEngineTorque: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeEngineTorque> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeEngineTorque> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeAccPedalPosition: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeAccPedalPosition> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeAccPedalPosition> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeSteeringWheelAngle: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeSteeringWheelAngle> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeSteeringWheelAngle> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeECallInfo: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeECallInfo> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeECallInfo> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeAirbagStatus: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeAirbagStatus> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeAirbagStatus> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeEmergencyEvent: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeEmergencyEvent> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeEmergencyEvent> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeClusterModeStatus: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeClusterModeStatus> >() + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeClusterModeStatus> >(); + } + case hmi_apis::FunctionID::VehicleInfo_UnsubscribeMyKey: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::>( + VIUnsubscribeVehicleDataRequestTemplate< + hmi_apis::FunctionID::VehicleInfo_UnsubscribeMyKey>) + : factory.GetCreator< + commands::VIUnsubscribeVehicleDataResponseTemplate< + hmi_apis::FunctionID:: + VehicleInfo_UnsubscribeMyKey> >(); + } + case hmi_apis::FunctionID::VehicleInfo_OnGpsData: { + return factory.GetCreator<commands::OnVIGpsDataNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnSpeed: { + return factory.GetCreator<commands::OnVISpeedNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnRpm: { + return factory.GetCreator<commands::OnVIRpmNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnFuelLevel: { + return factory.GetCreator<commands::OnVifuelLevelNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnFuelLevelState: { + return factory.GetCreator<commands::OnVifuelLevelStateNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnInstantFuelConsumption: { + return factory + .GetCreator<commands::OnVIInstantFuelConsumptionNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnExternalTemperature: { + return factory + .GetCreator<commands::OnVIExternalTemperatureNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnVin: { + return factory.GetCreator<commands::OnVIVinNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnPrndl: { + return factory.GetCreator<commands::OnVIPrndlNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnTirePressure: { + return factory.GetCreator<commands::OnVITirePressureNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnOdometer: { + return factory.GetCreator<commands::OnVIOdometerNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnBeltStatus: { + return factory.GetCreator<commands::OnVIBeltStatusNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnBodyInformation: { + return factory.GetCreator<commands::OnVIBodyInformationNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnDeviceStatus: { + return factory.GetCreator<commands::OnVIDeviceStatusNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnDriverBraking: { + return factory.GetCreator<commands::OnVIDriverBrakingNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnWiperStatus: { + return factory.GetCreator<commands::OnVIWiperStatusNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnHeadLampStatus: { + return factory.GetCreator<commands::OnVIHeadLampStatusNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnEngineTorque: { + return factory.GetCreator<commands::OnVIEngineTorqueNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnAccPedalPosition: { + return factory.GetCreator<commands::OnVIAccPedalPositionNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnSteeringWheelAngle: { + return factory.GetCreator<commands::OnVISteeringWheelAngleNotification>(); + } + case hmi_apis::FunctionID::VehicleInfo_OnMyKey: { + return factory.GetCreator<commands::OnVIMyKeyNotification>(); + } +#endif // #ifdef HMI_DBUS_API + case hmi_apis::FunctionID::Navigation_OnTBTClientState: { + return factory.GetCreator<commands::OnNaviTBTClientStateNotification>(); + } + case hmi_apis::FunctionID::UI_OnKeyboardInput: { + return factory.GetCreator<commands::hmi::OnUIKeyBoardInputNotification>(); + } + case hmi_apis::FunctionID::UI_OnTouchEvent: { + return factory.GetCreator<commands::hmi::OnUITouchEventNotification>(); + } + case hmi_apis::FunctionID::UI_OnResetTimeout: { + return factory.GetCreator<commands::hmi::OnUIResetTimeoutNotification>(); + } + case hmi_apis::FunctionID::Navigation_SetVideoConfig: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::NaviSetVideoConfigRequest>() + : factory.GetCreator<commands::NaviSetVideoConfigResponse>(); + } + case hmi_apis::FunctionID::Navigation_StartStream: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::NaviStartStreamRequest>() + : factory.GetCreator<commands::NaviStartStreamResponse>(); + } + case hmi_apis::FunctionID::Navigation_StopStream: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::NaviStopStreamRequest>() + : factory.GetCreator<commands::NaviStopStreamResponse>(); + } + case hmi_apis::FunctionID::Navigation_StartAudioStream: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::AudioStartStreamRequest>() + : factory.GetCreator<commands::AudioStartStreamResponse>(); + } + case hmi_apis::FunctionID::Navigation_StopAudioStream: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::AudioStopStreamRequest>() + : factory.GetCreator<commands::AudioStopStreamResponse>(); + } + case hmi_apis::FunctionID::Navigation_OnAudioDataStreaming: { + return factory.GetCreator<commands::OnAudioDataStreamingNotification>(); + } + case hmi_apis::FunctionID::Navigation_OnVideoDataStreaming: { + return factory.GetCreator<commands::OnVideoDataStreamingNotification>(); + } + case hmi_apis::FunctionID::VR_PerformInteraction: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::VRPerformInteractionRequest>() + : factory.GetCreator<commands::VRPerformInteractionResponse>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnSystemRequest: { + return factory.GetCreator<commands::OnSystemRequestNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnPutFile: { + return factory.GetCreator<commands::OnPutFileNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnResumeAudioSource: { + return factory.GetCreator<commands::OnResumeAudioSourceNotification>(); + } + case hmi_apis::FunctionID::UI_SetDisplayLayout: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UiSetDisplayLayoutRequest>() + : factory.GetCreator<commands::UiSetDisplayLayoutResponse>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnSDLClose: { + return factory.GetCreator<commands::OnSDLCloseNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnSDLPersistenceComplete: { + return factory + .GetCreator<commands::OnSDLPersistenceCompleteNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnFileRemoved: { + return factory.GetCreator<commands::OnFileRemovedNotification>(); + } + case hmi_apis::FunctionID::UI_OnRecordStart: { + return factory.GetCreator<commands::OnRecordStartdNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_SystemRequest: { + return hmi_apis::messageType::request == message_type + ? factory + .GetCreator<commands::BasicCommunicationSystemRequest>() + : factory.GetCreator< + commands::BasicCommunicationSystemResponse>(); + } + case hmi_apis::FunctionID::BasicCommunication_GetSystemTime: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::BasicCommunicationGetSystemTimeRequest>() + : factory.GetCreator< + commands::BasicCommunicationGetSystemTimeResponse>(); + } + case hmi_apis::FunctionID::Navigation_SendLocation: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::NaviSendLocationRequest>() + : factory.GetCreator<commands::NaviSendLocationResponse>(); + } + case hmi_apis::FunctionID::SDL_AddStatisticsInfo: { + return factory.GetCreator<commands::AddStatisticsInfoNotification>(); + } + case hmi_apis::FunctionID::SDL_OnSystemError: { + return factory.GetCreator<commands::OnSystemErrorNotification>(); + } + case hmi_apis::FunctionID::SDL_OnReceivedPolicyUpdate: { + return factory.GetCreator<commands::OnReceivedPolicyUpdate>(); + } + case hmi_apis::FunctionID::SDL_OnPolicyUpdate: { + return factory.GetCreator<commands::OnPolicyUpdate>(); + } + case hmi_apis::FunctionID::SDL_OnDeviceStateChanged: { + return factory.GetCreator<commands::OnDeviceStateChangedNotification>(); + } + case hmi_apis::FunctionID::TTS_OnResetTimeout: { + return factory.GetCreator<commands::hmi::OnTTSResetTimeoutNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_OnEventChanged: { + return factory.GetCreator<commands::OnEventChangedNotification>(); + } + case hmi_apis::FunctionID::BasicCommunication_DialNumber: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::hmi::DialNumberRequest>() + : factory.GetCreator<commands::hmi::DialNumberResponse>(); + } + case hmi_apis::FunctionID::Navigation_OnWayPointChange: { + return factory.GetCreator<commands::OnNaviWayPointChangeNotification>(); + } + case hmi_apis::FunctionID::RC_IsReady: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::RCIsReadyRequest>() + : factory.GetCreator<commands::RCIsReadyResponse>(); + } + case hmi_apis::FunctionID::RC_GetCapabilities: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::RCGetCapabilitiesRequest>() + : factory.GetCreator<commands::RCGetCapabilitiesResponse>(); + } + case hmi_apis::FunctionID::UI_SendHapticData: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UISendHapticDataRequest>() + : factory.GetCreator<commands::UISendHapticDataResponse>(); + } + default: { return factory.GetCreator<InvalidCommand>(); } + } +} + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc new file mode 100644 index 0000000000..d27161ff77 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc @@ -0,0 +1,443 @@ +/* + 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 copyright holders nor the names of their contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 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/mobile_command_factory.h" +#include "sdl_rpc_plugin/commands/mobile/add_command_request.h" +#include "sdl_rpc_plugin/commands/mobile/add_command_response.h" +#include "sdl_rpc_plugin/commands/mobile/delete_command_request.h" +#include "sdl_rpc_plugin/commands/mobile/delete_command_response.h" +#include "sdl_rpc_plugin/commands/mobile/add_sub_menu_request.h" +#include "sdl_rpc_plugin/commands/mobile/add_sub_menu_response.h" +#include "sdl_rpc_plugin/commands/mobile/alert_request.h" +#include "sdl_rpc_plugin/commands/mobile/alert_response.h" +#include "sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h" +#include "sdl_rpc_plugin/commands/mobile/alert_maneuver_response.h" +#include "sdl_rpc_plugin/commands/mobile/change_registration_request.h" +#include "sdl_rpc_plugin/commands/mobile/change_registration_response.h" +#include "sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h" +#include "sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_response.h" +#include "sdl_rpc_plugin/commands/mobile/delete_file_request.h" +#include "sdl_rpc_plugin/commands/mobile/delete_file_response.h" +#include "sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_request.h" +#include "sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_response.h" +#include "sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h" +#include "sdl_rpc_plugin/commands/mobile/delete_sub_menu_response.h" +#include "sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_request.h" +#include "sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_response.h" +#include "sdl_rpc_plugin/commands/mobile/generic_response.h" +#include "sdl_rpc_plugin/commands/mobile/get_system_capability_request.h" +#include "sdl_rpc_plugin/commands/mobile/get_system_capability_response.h" +#include "sdl_rpc_plugin/commands/mobile/get_way_points_request.h" +#include "sdl_rpc_plugin/commands/mobile/get_way_points_response.h" +#include "sdl_rpc_plugin/commands/mobile/list_files_request.h" +#include "sdl_rpc_plugin/commands/mobile/list_files_response.h" +#include "sdl_rpc_plugin/commands/mobile/on_app_interface_unregistered_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_audio_pass_thru_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_button_event_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_button_press_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_driver_distraction_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_hmi_status_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_hmi_status_notification_from_mobile.h" +#include "sdl_rpc_plugin/commands/mobile/on_language_change_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_command_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_permissions_change_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_tbt_client_state_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_way_point_change_notification.h" +#include "sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h" +#include "sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_response.h" +#include "sdl_rpc_plugin/commands/mobile/perform_interaction_request.h" +#include "sdl_rpc_plugin/commands/mobile/perform_interaction_response.h" +#include "sdl_rpc_plugin/commands/mobile/put_file_request.h" +#include "sdl_rpc_plugin/commands/mobile/put_file_response.h" +#include "sdl_rpc_plugin/commands/mobile/register_app_interface_request.h" +#include "sdl_rpc_plugin/commands/mobile/register_app_interface_response.h" +#include "sdl_rpc_plugin/commands/mobile/reset_global_properties_request.h" +#include "sdl_rpc_plugin/commands/mobile/reset_global_properties_response.h" +#include "sdl_rpc_plugin/commands/mobile/scrollable_message_request.h" +#include "sdl_rpc_plugin/commands/mobile/scrollable_message_response.h" +#include "sdl_rpc_plugin/commands/mobile/set_display_layout_request.h" +#include "sdl_rpc_plugin/commands/mobile/set_display_layout_response.h" +#include "sdl_rpc_plugin/commands/mobile/set_global_properties_request.h" +#include "sdl_rpc_plugin/commands/mobile/set_global_properties_response.h" +#include "sdl_rpc_plugin/commands/mobile/set_app_icon_request.h" +#include "sdl_rpc_plugin/commands/mobile/set_app_icon_response.h" +#include "sdl_rpc_plugin/commands/mobile/set_media_clock_timer_request.h" +#include "sdl_rpc_plugin/commands/mobile/set_media_clock_timer_response.h" +#include "sdl_rpc_plugin/commands/mobile/show_constant_tbt_request.h" +#include "sdl_rpc_plugin/commands/mobile/show_constant_tbt_response.h" +#include "sdl_rpc_plugin/commands/mobile/show_request.h" +#include "sdl_rpc_plugin/commands/mobile/show_response.h" +#include "sdl_rpc_plugin/commands/mobile/slider_request.h" +#include "sdl_rpc_plugin/commands/mobile/slider_response.h" +#include "sdl_rpc_plugin/commands/mobile/speak_request.h" +#include "sdl_rpc_plugin/commands/mobile/speak_response.h" +#include "sdl_rpc_plugin/commands/mobile/subscribe_button_request.h" +#include "sdl_rpc_plugin/commands/mobile/subscribe_button_response.h" +#include "sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h" +#include "sdl_rpc_plugin/commands/mobile/subscribe_way_points_response.h" +#include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h" +#include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_response.h" +#include "sdl_rpc_plugin/commands/mobile/unregister_app_interface_request.h" +#include "sdl_rpc_plugin/commands/mobile/unregister_app_interface_response.h" +#include "sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h" +#include "sdl_rpc_plugin/commands/mobile/unsubscribe_button_response.h" +#include "sdl_rpc_plugin/commands/mobile/update_turn_list_request.h" +#include "sdl_rpc_plugin/commands/mobile/update_turn_list_response.h" +#include "sdl_rpc_plugin/commands/mobile/system_request.h" +#include "sdl_rpc_plugin/commands/mobile/system_response.h" +#include "sdl_rpc_plugin/commands/mobile/on_keyboard_input_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_touch_event_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_system_request_notification.h" +#include "sdl_rpc_plugin/commands/mobile/send_location_request.h" +#include "sdl_rpc_plugin/commands/mobile/send_location_response.h" +#include "sdl_rpc_plugin/commands/mobile/dial_number_request.h" +#include "sdl_rpc_plugin/commands/mobile/dial_number_response.h" +#include "sdl_rpc_plugin/commands/mobile/send_haptic_data_request.h" +#include "sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h" +#include "interfaces/MOBILE_API.h" +#include "utils/make_shared.h" + +CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") +namespace sdl_rpc_plugin { +using namespace application_manager; + +CommandCreator& MobileCommandFactory::get_creator_factory( + mobile_apis::FunctionID::eType id, + mobile_apis::messageType::eType message_type, + app_mngr::commands::Command::CommandSource source) const { + CommandCreatorFactory factory( + application_manager_, rpc_service_, hmi_capabilities_, policy_handler_); + + switch (id) { + case mobile_apis::FunctionID::RegisterAppInterfaceID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::RegisterAppInterfaceRequest>() + : factory.GetCreator<commands::RegisterAppInterfaceResponse>(); + } + case mobile_apis::FunctionID::UnregisterAppInterfaceID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::UnregisterAppInterfaceRequest>() + : factory + .GetCreator<commands::UnregisterAppInterfaceResponse>(); + } + case mobile_apis::FunctionID::SetGlobalPropertiesID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::SetGlobalPropertiesRequest>() + : factory.GetCreator<commands::SetGlobalPropertiesResponse>(); + } + case mobile_apis::FunctionID::ResetGlobalPropertiesID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::ResetGlobalPropertiesRequest>() + : factory + .GetCreator<commands::ResetGlobalPropertiesResponse>(); + } + case mobile_apis::FunctionID::AddCommandID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::AddCommandRequest>() + : factory.GetCreator<commands::AddCommandResponse>(); + } + case mobile_apis::FunctionID::DeleteCommandID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::DeleteCommandRequest>() + : factory.GetCreator<commands::DeleteCommandResponse>(); + } + case mobile_apis::FunctionID::AddSubMenuID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::AddSubMenuRequest>() + : factory.GetCreator<commands::AddSubMenuResponse>(); + } + + case mobile_apis::FunctionID::DeleteSubMenuID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::DeleteSubMenuRequest>() + : factory.GetCreator<commands::DeleteSubMenuResponse>(); + } + case mobile_apis::FunctionID::DeleteInteractionChoiceSetID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator< + commands::DeleteInteractionChoiceSetRequest>() + : factory.GetCreator< + commands::DeleteInteractionChoiceSetResponse>(); + } + case mobile_apis::FunctionID::AlertID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::AlertRequest>() + : factory.GetCreator<commands::AlertResponse>(); + } + case mobile_apis::FunctionID::SpeakID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::SpeakRequest>() + : factory.GetCreator<commands::SpeakResponse>(); + } + case mobile_apis::FunctionID::SliderID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::SliderRequest>() + : factory.GetCreator<commands::SliderResponse>(); + } + case mobile_apis::FunctionID::PerformAudioPassThruID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::PerformAudioPassThruRequest>() + : factory.GetCreator<commands::PerformAudioPassThruResponse>(); + } + + case mobile_apis::FunctionID::CreateInteractionChoiceSetID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator< + commands::CreateInteractionChoiceSetRequest>() + : factory.GetCreator< + commands::CreateInteractionChoiceSetResponse>(); + } + case mobile_apis::FunctionID::PerformInteractionID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::PerformInteractionRequest>() + : factory.GetCreator<commands::PerformInteractionResponse>(); + } + case mobile_apis::FunctionID::EndAudioPassThruID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::EndAudioPassThruRequest>() + : factory.GetCreator<commands::EndAudioPassThruResponse>(); + } + case mobile_apis::FunctionID::PutFileID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::PutFileRequest>() + : factory.GetCreator<commands::PutFileResponse>(); + } + case mobile_apis::FunctionID::DeleteFileID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::DeleteFileRequest>() + : factory.GetCreator<commands::DeleteFileResponse>(); + } + case mobile_apis::FunctionID::ListFilesID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::ListFilesRequest>() + : factory.GetCreator<commands::ListFilesResponse>(); + } + case mobile_apis::FunctionID::SubscribeButtonID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::SubscribeButtonRequest>() + : factory.GetCreator<commands::SubscribeButtonResponse>(); + } + case mobile_apis::FunctionID::UnsubscribeButtonID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::UnsubscribeButtonRequest>() + : factory.GetCreator<commands::UnsubscribeButtonResponse>(); + } + case mobile_apis::FunctionID::ShowConstantTBTID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::ShowConstantTBTRequest>() + : factory.GetCreator<commands::ShowConstantTBTResponse>(); + } + case mobile_apis::FunctionID::ShowID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::ShowRequest>() + : factory.GetCreator<commands::ShowResponse>(); + } + case mobile_apis::FunctionID::GetWayPointsID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::ShowConstantTBTRequest>() + : factory.GetCreator<commands::GetWayPointsResponse>(); + } + case mobile_apis::FunctionID::SubscribeWayPointsID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::SubscribeWayPointsRequest>() + : factory.GetCreator<commands::SubscribeWayPointsResponse>(); + } + case mobile_apis::FunctionID::UnsubscribeWayPointsID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::ShowConstantTBTRequest>() + : factory.GetCreator<commands::ShowConstantTBTResponse>(); + } + case mobile_apis::FunctionID::GetSystemCapabilityID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::GetSystemCapabilityRequest>() + : factory.GetCreator<commands::GetSystemCapabilityResponse>(); + } + case mobile_apis::FunctionID::ScrollableMessageID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::ScrollableMessageRequest>() + : factory.GetCreator<commands::ScrollableMessageResponse>(); + } + + case mobile_apis::FunctionID::AlertManeuverID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::AlertManeuverRequest>() + : factory.GetCreator<commands::AlertManeuverResponse>(); + } + case mobile_apis::FunctionID::SetAppIconID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::SetAppIconRequest>() + : factory.GetCreator<commands::SetAppIconResponse>(); + } + case mobile_apis::FunctionID::SetDisplayLayoutID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::SetDisplayLayoutRequest>() + : factory.GetCreator<commands::SetDisplayLayoutResponse>(); + } + case mobile_apis::FunctionID::UpdateTurnListID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::UpdateTurnListRequest>() + : factory.GetCreator<commands::UpdateTurnListResponse>(); + } + case mobile_apis::FunctionID::ChangeRegistrationID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::ChangeRegistrationRequest>() + : factory.GetCreator<commands::ChangeRegistrationResponse>(); + } + case mobile_apis::FunctionID::SetMediaClockTimerID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::SetMediaClockRequest>() + : factory.GetCreator<commands::SetMediaClockTimerResponse>(); + } + case mobile_apis::FunctionID::SystemRequestID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::SystemRequest>() + : factory.GetCreator<commands::SystemResponse>(); + } + case mobile_apis::FunctionID::SendLocationID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::SendLocationRequest>() + : factory.GetCreator<commands::SendLocationResponse>(); + } + case mobile_apis::FunctionID::DialNumberID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::DialNumberRequest>() + : factory.GetCreator<commands::DialNumberResponse>(); + } + case mobile_apis::FunctionID::SendHapticDataID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::SendHapticDataRequest>() + : factory.GetCreator<commands::SendHapticDataResponse>(); + } + case mobile_apis::FunctionID::OnButtonEventID: { + return factory.GetCreator<commands::mobile::OnButtonEventNotification>(); + } + case mobile_apis::FunctionID::OnButtonPressID: { + return factory.GetCreator<commands::mobile::OnButtonPressNotification>(); + } + case mobile_apis::FunctionID::OnAudioPassThruID: { + return factory.GetCreator<commands::OnAudioPassThruNotification>(); + } + case mobile_apis::FunctionID::OnAppInterfaceUnregisteredID: { + return factory + .GetCreator<commands::OnAppInterfaceUnregisteredNotification>(); + } + case mobile_apis::FunctionID::OnCommandID: { + return factory.GetCreator<commands::OnCommandNotification>(); + } + case mobile_apis::FunctionID::OnTBTClientStateID: { + return factory.GetCreator<commands::OnTBTClientStateNotification>(); + } + case mobile_apis::FunctionID::OnDriverDistractionID: { + return factory + .GetCreator<commands::mobile::OnDriverDistractionNotification>(); + } + case mobile_apis::FunctionID::OnLanguageChangeID: { + return factory.GetCreator<commands::OnLanguageChangeNotification>(); + } + case mobile_apis::FunctionID::OnPermissionsChangeID: { + return factory.GetCreator<commands::OnPermissionsChangeNotification>(); + } + case mobile_apis::FunctionID::OnHMIStatusID: { + using app_mngr::commands::Command; + return Command::CommandSource::SOURCE_MOBILE == source + ? factory.GetCreator< + commands::OnHMIStatusNotificationFromMobile>() + : factory.GetCreator<commands::OnHMIStatusNotification>(); + } + case mobile_apis::FunctionID::OnKeyboardInputID: { + return factory + .GetCreator<commands::mobile::OnKeyBoardInputNotification>(); + } + case mobile_apis::FunctionID::OnTouchEventID: { + return factory.GetCreator<commands::mobile::OnTouchEventNotification>(); + } + case mobile_apis::FunctionID::OnSystemRequestID: { + return factory + .GetCreator<commands::mobile::OnSystemRequestNotification>(); + } + case mobile_apis::FunctionID::OnHashChangeID: { + using app_mngr::commands::Command; + return factory.GetCreator<commands::mobile::OnHashChangeNotification>(); + } + case mobile_apis::FunctionID::OnWayPointChangeID: { + using app_mngr::commands::Command; + return factory.GetCreator<commands::OnWayPointChangeNotification>(); + } + case mobile_apis::FunctionID::GenericResponseID: { + using app_mngr::commands::Command; + return factory.GetCreator<commands::GenericResponse>(); + } + default: { return factory.GetCreator<InvalidCommand>(); } + } +} + +MobileCommandFactory::MobileCommandFactory( + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : application_manager_(application_manager) + , rpc_service_(rpc_service) + , hmi_capabilities_(hmi_capabilities) + , policy_handler_(policy_handler) {} + +bool MobileCommandFactory::IsAbleToProcess( + const int32_t function_id, + const application_manager::commands::Command::CommandSource message_source) + const { + using app_mngr::commands::Command; + return get_creator_factory( + static_cast<mobile_apis::FunctionID::eType>(function_id), + mobile_apis::messageType::INVALID_ENUM, + message_source).CanBeCreated(); +} + +CommandSharedPtr MobileCommandFactory::CreateCommand( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::commands::Command::CommandSource source) { + mobile_apis::messageType::eType message_type = + static_cast<mobile_apis::messageType::eType>( + (*message)[strings::params][strings::message_type].asInt()); + + mobile_apis::FunctionID::eType function_id = + static_cast<mobile_apis::FunctionID::eType>( + (*message)[strings::params][strings::function_id].asInt()); + + LOG4CXX_DEBUG( + logger_, + "MobileCommandFactory::CreateCommand function_id: " << function_id); + + return get_creator_factory(function_id, message_type, source).create(message); +} + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_command_factory.cc new file mode 100644 index 0000000000..efdcde7526 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_command_factory.cc @@ -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 copyright holders nor the names of their contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 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/sdl_command_factory.h" +#include "sdl_rpc_plugin/hmi_command_factory.h" +#include "sdl_rpc_plugin/mobile_command_factory.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +SDLCommandFactory::SDLCommandFactory( + app_mngr::ApplicationManager& app_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : app_manager_(app_manager) + , rpc_service_(rpc_service) + , hmi_capabilities_(hmi_capabilities) + , policy_handler_(policy_handler) { + hmi_command_factory_.reset(new HMICommandFactory( + app_manager, rpc_service, hmi_capabilities, policy_handler)); + mobile_command_factory_.reset(new MobileCommandFactory( + app_manager, rpc_service, hmi_capabilities, policy_handler)); +} + +app_mngr::CommandSharedPtr SDLCommandFactory::CreateCommand( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::commands::Command::CommandSource source) { + if (app_mngr::commands::Command::SOURCE_HMI == source) { + return hmi_command_factory_->CreateCommand(message, source); + } else { + return mobile_command_factory_->CreateCommand(message, source); + } +} + +bool SDLCommandFactory::IsAbleToProcess( + const int32_t FunctionID, + const application_manager::commands::Command::CommandSource source) const { + bool is_hmi_command_factory_able_to_process = + hmi_command_factory_->IsAbleToProcess(FunctionID, source); + bool is_mobile_command_factory_able_to_process = + mobile_command_factory_->IsAbleToProcess(FunctionID, source); + + return app_mngr::commands::Command::SOURCE_HMI == source + ? is_hmi_command_factory_able_to_process + : is_mobile_command_factory_able_to_process; +} + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc new file mode 100644 index 0000000000..22b818f5e0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc @@ -0,0 +1,75 @@ +/* + 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 copyright holders nor the names of their contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 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/sdl_rpc_plugin.h" +#include "sdl_rpc_plugin/sdl_command_factory.h" + +namespace sdl_rpc_plugin { +namespace plugins = application_manager::plugin_manager; + +bool SDLRPCPlugin::Init( + application_manager::ApplicationManager& app_manager, + application_manager::rpc_service::RPCService& rpc_service, + application_manager::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) { + command_factory_.reset(new sdl_rpc_plugin::SDLCommandFactory( + app_manager, rpc_service, hmi_capabilities, policy_handler)); + return true; +} + +bool SDLRPCPlugin::IsAbleToProcess( + const int32_t function_id, + const application_manager::commands::Command::CommandSource + message_source) { + return command_factory_->IsAbleToProcess(function_id, message_source); +} + +std::string SDLRPCPlugin::PluginName() { + return "SDL RPC Plugin"; +} + +application_manager::CommandFactory& SDLRPCPlugin::GetCommandFactory() { + return *command_factory_; +} + +void SDLRPCPlugin::OnPolicyEvent( + application_manager::plugin_manager::PolicyEvent event) {} + +void SDLRPCPlugin::OnApplicationEvent( + application_manager::plugin_manager::ApplicationEvent event, + application_manager::ApplicationSharedPtr application) {} + +} // namespace sdl_rpc_plugin + +extern "C" application_manager::plugin_manager::RPCPlugin* Create() { + return new sdl_rpc_plugin::SDLRPCPlugin(); +} diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt new file mode 100644 index 0000000000..da51c3e4e4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt @@ -0,0 +1,36 @@ +include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake) + +include_directories( + ${GMOCK_INCLUDE_DIRECTORY} + ${COMPONENTS_DIR}/application_manager/rpc_plugins/sdl_rpc_plugin/include + ${COMPONENTS_DIR}/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/ + ${COMPONENTS_DIR}/application_manager/test/include/ + ${POLICY_MOCK_INCLUDE_PATH}/ +) + + +set(COMMANDS_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/commands) + +file(GLOB SOURCES + ${COMPONENTS_DIR}/application_manager/test/mock_message_helper.cc + ${COMPONENTS_DIR}/application_manager/test/mock_application_helper.cc + ${COMPONENTS_DIR}/application_manager/src/smart_object_keys.cc + ${COMMANDS_TEST_DIR}/hmi/* + ${COMMANDS_TEST_DIR}/mobile/* + ${COMPONENTS_DIR}/application_manager/src/message.cc + ${COMPONENTS_DIR}/application_manager/src/event_engine/* +) + +set(LIBRARIES + gmock + Utils + SmartObjects + HMI_API + MOBILE_API + connectionHandler + sdl_rpc_plugin + jsoncpp + Policy +) + +create_cotired_test("sdl_commands_test" "${SOURCES}" "${LIBRARIES}" ) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/activate_app_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/activate_app_request_test.cc new file mode 100644 index 0000000000..dcbd21dbe0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/activate_app_request_test.cc @@ -0,0 +1,125 @@ +/* + * 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 "gtest/gtest.h" +#include "hmi/activate_app_request.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_application.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace activate_app_request { + +using ::testing::_; +using ::utils::SharedPtr; +namespace am = ::application_manager; +namespace strings = ::application_manager::strings; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::ActivateAppRequest; +using am::commands::CommandImpl; + +using ::test::components::application_manager_test::MockApplication; + +typedef SharedPtr<MockApplication> MockAppPtr; +typedef ::utils::SharedPtr<ActivateAppRequest> ActivateAppRequestPtr; + +MATCHER_P(CheckMessage, level, "") { + return level == + static_cast<mobile_apis::HMILevel::eType>( + (*arg)[strings::msg_params][strings::activate_app_hmi_level] + .asInt()); +} + +namespace { +const uint32_t kAppId = 1u; +const uint32_t kCorrelationId = 2u; +} // namespace + +class ActivateAppRequestTest : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + MessageSharedPtr CreateMsgParams() { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[strings::app_id] = kAppId; + msg_params[strings::correlation_id] = kCorrelationId; + (*msg)[strings::msg_params] = msg_params; + (*msg)[strings::params][strings::app_id] = kAppId; + (*msg)[strings::params][strings::correlation_id] = kCorrelationId; + (*msg)[strings::app_id] = kAppId; + return msg; + } +}; + +TEST_F(ActivateAppRequestTest, Run_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + MockAppPtr app = CreateMockApp(); + + EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app)); + + ON_CALL(*app, hmi_app_id()).WillByDefault(Return(kAppId)); + +// TODO(OKozlov) Investigate and fix issue with using log +#ifdef ENABLE_LOG + (*msg)[strings::msg_params][strings::activate_app_hmi_level] = + mobile_apis::HMILevel::HMI_FULL; +#endif + ActivateAppRequestPtr command(CreateCommand<ActivateAppRequest>(msg)); + + EXPECT_CALL(app_mngr_, set_application_id(kCorrelationId, kAppId)); +#ifdef ENABLE_LOG + EXPECT_CALL(mock_rpc_service_, + SendMessageToHMI(CheckMessage(mobile_apis::HMILevel::HMI_FULL))); +#else + EXPECT_CALL(mock_rpc_service_, + SendMessageToHMI(msg))); +#endif + command->Run(); + +#ifndef ENABLE_LOG + EXPECT_EQ(CommandImpl::hmi_protocol_type_, + (*msg)[strings::params][strings::protocol_type].asInt()); + EXPECT_EQ(CommandImpl::protocol_version_, + (*msg)[strings::params][strings::protocol_version].asInt()); +#endif +} + +} // namespace activate_app_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/add_statistics_info_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/add_statistics_info_notification_test.cc new file mode 100644 index 0000000000..d43d70b5ca --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/add_statistics_info_notification_test.cc @@ -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. + */ + +#include "gtest/gtest.h" +#include "hmi/add_statistics_info_notification.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_application.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/policies/policy_handler.h" +#include "application_manager/policies/mock_policy_handler_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace add_statistics_info_notification { + +namespace am = ::application_manager; +namespace strings = ::application_manager::strings; +namespace hmi_notification = ::application_manager::hmi_notification; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::AddStatisticsInfoNotification; +using am::commands::CommandImpl; +using policy::PolicyHandler; +using policy_test::MockPolicyHandlerInterface; +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +typedef ::utils::SharedPtr<AddStatisticsInfoNotification> NotificationPtr; + +namespace { +const uint32_t kStatisticType = 1u; +} // namespace + +class AddStatisticsInfoNotificationTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(AddStatisticsInfoNotificationTest, Run_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[am::strings::msg_params][am::hmi_notification::statistic_type] = + kStatisticType; + NotificationPtr command(CreateCommand<AddStatisticsInfoNotification>(msg)); + + EXPECT_CALL(mock_policy_handler_, AddStatisticsInfo(kStatisticType)); + + command->Run(); +} + +} // namespace add_statistics_info_notification +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_all_apps_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_all_apps_response_test.cc new file mode 100644 index 0000000000..4b7fb0fc09 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_all_apps_response_test.cc @@ -0,0 +1,76 @@ +/* + * 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 "gtest/gtest.h" +#include "hmi/allow_all_apps_response.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_application.h" +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace allow_all_apps_response { + +using application_manager::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::AllowAllAppsResponse; + +namespace strings = ::application_manager::strings; +namespace hmi_response = ::application_manager::hmi_response; + +typedef ::utils::SharedPtr<AllowAllAppsResponse> ResponsePtr; + +namespace { +const bool kResponseIsAllowed = true; +} // + +class AllowAllAppsResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(AllowAllAppsResponseTest, Run_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::msg_params][hmi_response::allowed] = kResponseIsAllowed; + + ResponsePtr command(CreateCommand<AllowAllAppsResponse>(msg)); + + EXPECT_CALL(app_mngr_, SetAllAppsAllowed(kResponseIsAllowed)); + + command->Run(); +} + +} // namespace allow_all_apps_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_app_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_app_response_test.cc new file mode 100644 index 0000000000..3681bf01b6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_app_response_test.cc @@ -0,0 +1,95 @@ +/* + * 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 "gtest/gtest.h" +#include "hmi/allow_app_response.h" +#include "utils/shared_ptr.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_application.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace allow_app_response { + +using application_manager::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::AllowAppResponse; +using ::testing::_; +using ::testing::Return; + +namespace strings = ::application_manager::strings; +namespace hmi_response = ::application_manager::hmi_response; + +namespace { +const uint32_t kConnectionKey = 1u; +const bool kIsResponseAllowed = true; +} + +typedef ::utils::SharedPtr<AllowAppResponse> ResponsePtr; + +class AllowAppResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(AllowAppResponseTest, Run_AppCreated_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::connection_key] = kConnectionKey; + (*msg)[strings::msg_params][hmi_response::allowed] = kIsResponseAllowed; + + ResponsePtr command(CreateCommand<AllowAppResponse>(msg)); + + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, set_app_allowed(kIsResponseAllowed)); + + command->Run(); +} + +TEST_F(AllowAppResponseTest, Run_AppNotCreated_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::connection_key] = kConnectionKey; + (*msg)[strings::msg_params][hmi_response::allowed] = kIsResponseAllowed; + + ResponsePtr command(CreateCommand<AllowAppResponse>(msg)); + + MockAppPtr mock_app; + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(MockAppPtr())); + + command->Run(); +} + +} // namespace allow_app_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_request_test.cc new file mode 100644 index 0000000000..78fec997e9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_request_test.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 names of the copyright holders nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "hmi/basic_communication_get_system_time_request.h" + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "application_manager/commands/command_request_test.h" +#include "protocol_handler/mock_protocol_handler.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace basic_communication_get_system_time_request { + +using ::testing::ReturnRef; +namespace am = ::application_manager; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::BasicCommunicationGetSystemTimeRequest; +using namespace ::protocol_handler; + +class BasicCommunicationGetSystemTimeRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(BasicCommunicationGetSystemTimeRequestTest, OnTimeout) { + MessageSharedPtr msg = CreateMessage(); + protocol_handler_test::MockProtocolHandler mock_protocol_handler; + + auto command = CreateCommand<BasicCommunicationGetSystemTimeRequest>(msg); + + ON_CALL(app_mngr_, protocol_handler()) + .WillByDefault(ReturnRef(mock_protocol_handler)); + EXPECT_CALL(mock_protocol_handler, NotifyOnFailedHandshake()); + + command->onTimeOut(); +} + +} // namespace basic_communication_get_system_time_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_response_test.cc new file mode 100644 index 0000000000..8f56c6462c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_response_test.cc @@ -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 names of the copyright holders nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "gtest/gtest.h" +#include "application_manager/commands/commands_test.h" +#include "hmi/basic_communication_get_system_time_response.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/smart_object_keys.h" +#include "interfaces/HMI_API.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace basic_communication_get_system_time_response { + +using sdl_rpc_plugin::commands::BasicCommunicationGetSystemTimeResponse; +using test::components::event_engine_test::MockEventDispatcher; +using testing::ReturnRef; + +ACTION_P(GetEventId, event_id) { + *event_id = arg0.id(); +} + +class BasicCommunicationGetSystemTimeResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(BasicCommunicationGetSystemTimeResponseTest, Run_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + MockEventDispatcher mock_event_dispatcher; + int32_t event_id = hmi_apis::FunctionID::INVALID_ENUM; + + auto command(CreateCommand<BasicCommunicationGetSystemTimeResponse>(msg)); + + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher)); + EXPECT_CALL(mock_event_dispatcher, raise_event(_)) + .WillOnce(GetEventId(&event_id)); + + command->Run(); + + EXPECT_EQ(hmi_apis::FunctionID::BasicCommunication_GetSystemTime, event_id); +} + +} // namespace basic_communication_get_system_time_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/button_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/button_get_capabilities_response_test.cc new file mode 100644 index 0000000000..930e024b4b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/button_get_capabilities_response_test.cc @@ -0,0 +1,112 @@ +/* + * 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 "gtest/gtest.h" +#include "hmi/button_get_capabilities_response.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_hmi_capabilities.h" +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace button_get_capabilities_response { + +using application_manager::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::ButtonGetCapabilitiesResponse; +using ::testing::ReturnRef; +using ::testing::NiceMock; + +namespace strings = ::application_manager::strings; +namespace hmi_response = ::application_manager::hmi_response; + +typedef ::utils::SharedPtr<ButtonGetCapabilitiesResponse> ResponsePtr; + +typedef NiceMock< + ::test::components::application_manager_test::MockHMICapabilities> + MockHMICapabilities; + +class ButtonGetCapabilitiesResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + MessageSharedPtr CreateMsgParams() { + capabilities_[strings::name] = hmi_apis::Common_ButtonName::OK; + preset_bank_capabilities_ = true; + + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::msg_params][hmi_response::capabilities] = (capabilities_); + (*msg)[strings::msg_params][hmi_response::preset_bank_capabilities] = + (preset_bank_capabilities_); + + return msg; + } + + SmartObject capabilities_; + SmartObject preset_bank_capabilities_; +}; + +TEST_F(ButtonGetCapabilitiesResponseTest, Run_CodeSuccess_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + (*msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + + ResponsePtr command(CreateCommand<ButtonGetCapabilitiesResponse>(msg)); + + EXPECT_CALL(mock_hmi_capabilities_, set_button_capabilities(capabilities_)); + EXPECT_CALL(mock_hmi_capabilities_, + set_preset_bank_capabilities(preset_bank_capabilities_)); + + command->Run(); +} + +TEST_F(ButtonGetCapabilitiesResponseTest, Run_CodeAborted_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + (*msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::ABORTED; + + ResponsePtr command(CreateCommand<ButtonGetCapabilitiesResponse>(msg)); + + EXPECT_CALL(mock_hmi_capabilities_, set_button_capabilities(capabilities_)) + .Times(0); + EXPECT_CALL(mock_hmi_capabilities_, + set_preset_bank_capabilities(preset_bank_capabilities_)).Times(0); + + command->Run(); +} + +} // namespace button_get_capabilities_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/close_popup_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/close_popup_response_test.cc new file mode 100644 index 0000000000..1bae77bb30 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/close_popup_response_test.cc @@ -0,0 +1,74 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/command.h" +#include "application_manager/commands/response_from_hmi.h" +#include "hmi/close_popup_response.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_application.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace close_popup_response { + +using ::utils::SharedPtr; +namespace am = ::application_manager; +using application_manager::commands::ResponseFromHMI; +using sdl_rpc_plugin::commands::ClosePopupResponse; +using am::commands::CommandImpl; + +typedef SharedPtr<ResponseFromHMI> ResponseFromHMIPtr; + +class ClosePopupResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> { +}; + +TEST_F(ClosePopupResponseTest, RUN_SUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + ResponseFromHMIPtr command(CreateCommand<ClosePopupResponse>(command_msg)); + + command->Run(); +} + +} // namespace close_popup_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc new file mode 100644 index 0000000000..2374609774 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc @@ -0,0 +1,583 @@ +/* + * 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 "application_manager/commands/command_request_test.h" + +#include <stdint.h> +#include <string> +#include <vector> +#include "gtest/gtest.h" + +#include "hmi/allow_all_apps_request.h" +#include "hmi/allow_all_apps_response.h" +#include "hmi/allow_app_request.h" +#include "hmi/allow_app_response.h" +#include "hmi/navi_audio_start_stream_request.h" +#include "hmi/navi_audio_start_stream_response.h" +#include "hmi/navi_audio_stop_stream_request.h" +#include "hmi/navi_audio_stop_stream_response.h" +#include "hmi/update_device_list_request.h" +#include "hmi/update_device_list_response.h" +#include "hmi/on_update_device_list.h" +#include "hmi/on_start_device_discovery.h" +#include "hmi/update_app_list_request.h" +#include "hmi/update_app_list_response.h" +#include "hmi/on_find_applications.h" +#include "hmi/sdl_get_list_of_permissions_request.h" +#include "hmi/sdl_get_list_of_permissions_response.h" +#include "hmi/sdl_get_user_friendly_message_request.h" +#include "hmi/sdl_get_user_friendly_message_response.h" +#include "hmi/sdl_get_status_update_request.h" +#include "hmi/sdl_get_status_update_response.h" +#include "hmi/on_status_update_notification.h" +#include "hmi/update_sdl_request.h" +#include "hmi/update_sdl_response.h" +#include "hmi/activate_app_request.h" +#include "hmi/activate_app_response.h" +#include "hmi/mixing_audio_supported_request.h" +#include "hmi/mixing_audio_supported_response.h" +#include "hmi/on_allow_sdl_functionality_notification.h" +#include "hmi/on_app_permission_changed_notification.h" +#include "hmi/on_app_permission_consent_notification.h" +#include "hmi/on_app_activated_notification.h" +#include "hmi/on_audio_data_streaming_notification.h" +#include "hmi/on_video_data_streaming_notification.h" +#include "hmi/on_sdl_consent_needed_notification.h" +#include "hmi/on_exit_all_applications_notification.h" +#include "hmi/on_exit_application_notification.h" +#include "hmi/on_put_file_notification.h" +#include "hmi/on_resume_audio_source_notification.h" +#include "hmi/on_ignition_cycle_over_notification.h" +#include "hmi/on_system_info_changed_notification.h" +#include "hmi/get_system_info_request.h" +#include "hmi/get_system_info_response.h" +#include "hmi/close_popup_request.h" +#include "hmi/close_popup_response.h" +#include "hmi/button_get_capabilities_request.h" +#include "hmi/button_get_capabilities_response.h" +#include "hmi/ui_add_command_request.h" +#include "hmi/ui_add_command_response.h" +#include "hmi/ui_delete_command_request.h" +#include "hmi/ui_delete_command_response.h" +#include "hmi/ui_add_submenu_request.h" +#include "hmi/ui_add_submenu_response.h" +#include "hmi/ui_delete_submenu_request.h" +#include "hmi/ui_delete_submenu_response.h" +#include "hmi/ui_get_supported_languages_request.h" +#include "hmi/ui_get_supported_languages_response.h" +#include "hmi/ui_get_language_request.h" +#include "hmi/ui_get_language_response.h" +#include "hmi/ui_get_capabilities_request.h" +#include "hmi/ui_get_capabilities_response.h" +#include "hmi/ui_change_registration_request.h" +#include "hmi/ui_change_registration_response.h" +#include "hmi/ui_show_request.h" +#include "hmi/ui_show_response.h" +#include "hmi/ui_alert_request.h" +#include "hmi/ui_alert_response.h" +#include "hmi/ui_is_ready_request.h" +#include "hmi/ui_is_ready_response.h" +#include "hmi/ui_slider_request.h" +#include "hmi/ui_slider_response.h" +#include "hmi/ui_set_media_clock_timer_request.h" +#include "hmi/ui_set_media_clock_timer_response.h" +#include "hmi/ui_set_global_properties_request.h" +#include "hmi/ui_set_global_properties_response.h" +#include "hmi/ui_scrollable_message_request.h" +#include "hmi/ui_scrollable_message_response.h" +#include "hmi/ui_set_app_icon_request.h" +#include "hmi/ui_set_app_icon_response.h" +#include "hmi/ui_perform_audio_pass_thru_response.h" +#include "hmi/ui_perform_audio_pass_thru_request.h" +#include "hmi/ui_end_audio_pass_thru_request.h" +#include "hmi/ui_end_audio_pass_thru_response.h" +#include "hmi/ui_perform_interaction_request.h" +#include "hmi/ui_perform_interaction_response.h" +#include "hmi/vr_is_ready_request.h" +#include "hmi/vr_is_ready_response.h" +#include "hmi/vr_add_command_request.h" +#include "hmi/vr_add_command_response.h" +#include "hmi/vr_delete_command_request.h" +#include "hmi/vr_delete_command_response.h" +#include "hmi/vr_change_registration_request.h" +#include "hmi/vr_change_registration_response.h" +#include "hmi/vr_get_supported_languages_request.h" +#include "hmi/vr_get_supported_languages_response.h" +#include "hmi/vr_get_language_request.h" +#include "hmi/vr_get_language_response.h" +#include "hmi/vr_get_capabilities_request.h" +#include "hmi/vr_get_capabilities_response.h" +#include "hmi/tts_is_ready_request.h" +#include "hmi/tts_is_ready_response.h" +#include "hmi/tts_change_registration_request.h" +#include "hmi/tts_change_registration_response.h" +#include "hmi/tts_get_supported_languages_request.h" +#include "hmi/tts_get_supported_languages_response.h" +#include "hmi/tts_get_language_request.h" +#include "hmi/tts_get_language_response.h" +#include "hmi/tts_stop_speaking_request.h" +#include "hmi/tts_stop_speaking_response.h" +#include "hmi/tts_speak_request.h" +#include "hmi/tts_speak_response.h" +#include "hmi/tts_set_global_properties_request.h" +#include "hmi/tts_set_global_properties_response.h" +#include "hmi/tts_get_capabilities_request.h" +#include "hmi/tts_get_capabilities_response.h" +#include "hmi/vr_perform_interaction_request.h" +#include "hmi/vr_perform_interaction_response.h" +#include "hmi/sdl_activate_app_request.h" +#include "hmi/sdl_activate_app_response.h" +#include "hmi/on_app_permission_changed_notification.h" +#include "hmi/on_event_changed_notification.h" +#include "hmi/navi_is_ready_request.h" +#include "hmi/navi_show_constant_tbt_request.h" +#include "hmi/navi_show_constant_tbt_response.h" +#include "hmi/navi_is_ready_response.h" +#include "hmi/navi_alert_maneuver_request.h" +#include "hmi/navi_alert_maneuver_response.h" +#include "hmi/navi_update_turn_list_request.h" +#include "hmi/navi_update_turn_list_response.h" +#include "hmi/navi_subscribe_way_points_request.h" +#include "hmi/navi_subscribe_way_points_response.h" +#include "hmi/navi_unsubscribe_way_points_request.h" +#include "hmi/navi_unsubscribe_way_points_response.h" +#include "hmi/navi_get_way_points_request.h" +#include "hmi/navi_get_way_points_response.h" +#include "hmi/on_ready_notification.h" +#include "hmi/on_device_chosen_notification.h" +#include "hmi/on_file_removed_notification.h" +#include "hmi/on_system_context_notification.h" +#include "hmi/on_app_registered_notification.h" +#include "hmi/on_app_unregistered_notification.h" +#include "hmi/on_driver_distraction_notification.h" +#include "hmi/on_tts_started_notification.h" +#include "hmi/on_tts_stopped_notification.h" +#include "hmi/on_vr_started_notification.h" +#include "hmi/on_vr_stopped_notification.h" +#include "hmi/on_vr_command_notification.h" +#include "hmi/on_ui_command_notification.h" +#include "hmi/on_app_deactivated_notification.h" +#include "hmi/on_ui_language_change_notification.h" +#include "hmi/on_vr_language_change_notification.h" +#include "hmi/on_tts_language_change_notification.h" +#include "hmi/on_navi_tbt_client_state_notification.h" +#include "hmi/on_navi_way_point_change_notification.h" +#include "hmi/on_button_event_notification.h" +#include "hmi/on_button_press_notification.h" +#include "hmi/on_button_subscription_notification.h" +#include "hmi/on_ui_keyboard_input_notification.h" +#include "hmi/on_ui_touch_event_notification.h" +#include "hmi/on_ui_reset_timeout_notification.h" +#include "hmi/navi_start_stream_request.h" +#include "hmi/navi_start_stream_response.h" +#include "hmi/navi_stop_stream_request.h" +#include "hmi/navi_stop_stream_response.h" +#include "hmi/on_system_request_notification.h" +#include "hmi/ui_set_display_layout_request.h" +#include "hmi/ui_set_display_layout_response.h" +#include "hmi/on_sdl_close_notification.h" +#include "hmi/on_sdl_persistence_complete_notification.h" +#include "hmi/on_record_start_notification.h" +#include "hmi/add_statistics_info_notification.h" +#include "hmi/on_system_error_notification.h" +#include "hmi/basic_communication_system_request.h" +#include "hmi/basic_communication_system_response.h" +#include "hmi/sdl_policy_update.h" +#include "hmi/sdl_policy_update_response.h" +#include "hmi/on_received_policy_update.h" +#include "hmi/on_policy_update.h" +#include "hmi/get_urls.h" +#include "hmi/get_urls_response.h" +#include "hmi/on_device_state_changed_notification.h" +#include "hmi/navi_send_location_request.h" +#include "hmi/navi_send_location_response.h" +#include "hmi/on_tts_reset_timeout_notification.h" +#include "hmi/dial_number_request.h" +#include "hmi/dial_number_response.h" +#include "hmi/on_vi_gps_data_notification.h" +#include "hmi/on_vi_speed_notification.h" +#include "hmi/on_vi_rpm_notification.h" +#include "hmi/on_vi_fuel_level_notification.h" +#include "hmi/on_vi_fuel_level_state_notification.h" +#include "hmi/on_vi_instant_fuel_consumption_notification.h" +#include "hmi/on_vi_external_temperature_notification.h" +#include "hmi/on_vi_vin_notification.h" +#include "hmi/on_vi_prndl_notification.h" +#include "hmi/on_vi_tire_pressure_notification.h" +#include "hmi/on_vi_odometer_notification.h" +#include "hmi/on_vi_belt_status_notification.h" +#include "hmi/on_vi_body_information_notification.h" +#include "hmi/on_vi_device_status_notification.h" +#include "hmi/on_vi_driver_braking_notification.h" +#include "hmi/on_vi_wiper_status_notification.h" +#include "hmi/on_vi_head_lamp_status_notification.h" +#include "hmi/on_vi_engine_torque_notification.h" +#include "hmi/on_vi_acc_pedal_position_notification.h" +#include "hmi/on_vi_steering_wheel_angle_notification.h" +#include "hmi/on_vi_my_key_notification.h" +#include "hmi/ui_set_icon_request.h" + +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application_manager_settings.h" +#include "application_manager/mock_event_dispatcher.h" + +namespace am = application_manager; + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace dummy_hmi_commands_test { + +namespace commands = sdl_rpc_plugin::commands; + +using ::testing::_; +using ::testing::NotNull; +using ::testing::Types; +using application_manager::commands::MessageSharedPtr; +using ::test::components::event_engine_test::MockEventDispatcher; +using ::test::components::application_manager_test::MockApplicationManager; +using ::test::components::application_manager_test:: + MockApplicationManagerSettings; +using ::application_manager::ApplicationSharedPtr; +using ::test::components::application_manager_test::MockApplication; + +template <class Command> +class HMICommandsTest : public components::commands_test::CommandRequestTest< + CommandsTestMocks::kIsNice> { + public: + typedef Command CommandType; + + void InitCommand(const uint32_t& timeout) OVERRIDE { + stream_retry_.first = 0; + stream_retry_.second = 0; + EXPECT_CALL(app_mngr_settings_, default_timeout()) + .WillOnce(ReturnRef(timeout)); + ON_CALL(app_mngr_, event_dispatcher()) + .WillByDefault(ReturnRef(event_dispatcher_)); + ON_CALL(app_mngr_, get_settings()) + .WillByDefault(ReturnRef(app_mngr_settings_)); + ON_CALL(app_mngr_settings_, start_stream_retry_amount()) + .WillByDefault(ReturnRef(stream_retry_)); + } + + protected: + std::pair<uint32_t, int32_t> stream_retry_; +}; + +template <class Command> +class HMICommandsTestFirst : public HMICommandsTest<Command> { + public: + using typename HMICommandsTest<Command>::CommandType; +}; + +template <class Command> +class HMICommandsTestSecond : public HMICommandsTest<Command> { + public: + using typename HMICommandsTest<Command>::CommandType; +}; + +template <class Command> +class HMICommandsTestThird : public HMICommandsTest<Command> { + public: + using typename HMICommandsTest<Command>::CommandType; +}; + +template <class Command> +class HMICommandsTestFourth : public HMICommandsTest<Command> { + public: + using typename HMICommandsTest<Command>::CommandType; +}; + +template <class Command> +class HMICommandsTestFifth : public HMICommandsTest<Command> { + public: + using typename HMICommandsTest<Command>::CommandType; +}; + +/* macro TYPED_TEST_CASE takes max 50 args. That is why there are few + * TYPED_TEST_CASE for HMI and mobile commands + */ + +typedef Types<commands::OnStartDeviceDiscovery, + commands::UpdateDeviceListResponse, + commands::UpdateDeviceListRequest, + commands::ActivateAppResponse, + commands::ActivateAppRequest, + commands::GetSystemInfoResponse, + commands::GetSystemInfoRequest, + commands::SDLActivateAppResponse, + commands::SDLActivateAppRequest, + commands::SDLPolicyUpdateResponse, + commands::SDLPolicyUpdate, + commands::GetUrlsResponse, + commands::GetUrls, + commands::OnAppPermissionChangedNotification, + commands::SDLGetListOfPermissionsResponse, + commands::SDLGetListOfPermissionsRequest, + commands::SDLGetUserFriendlyMessageResponse, + commands::SDLGetUserFriendlyMessageRequest, + commands::SDLGetStatusUpdateResponse, + commands::SDLGetStatusUpdateRequest, + commands::OnStatusUpdateNotification, + commands::OnAppPermissionConsentNotification, + commands::MixingAudioSupportedResponse, + commands::MixingAudioSupportedRequest, + commands::OnExitAllApplicationsNotification, + commands::UIAddCommandResponse, + commands::UIAddCommandRequest, + commands::UIDeleteCommandResponse, + commands::UIDeleteCommandRequest, + commands::UIAddSubmenuResponse, + commands::UIAddSubmenuRequest, + commands::UIDeleteSubmenuResponse, + commands::UIDeleteSubmenuRequest, + commands::UISetMediaClockTimerResponse, + commands::UISetMediaClockTimerRequest, + commands::UIPerformInteractionResponse, + commands::UIPerformInteractionRequest, + commands::UISetGlobalPropertiesResponse, + commands::UISetGlobalPropertiesRequest, + commands::UIScrollableMessageResponse, + commands::UIScrollableMessageRequest, + commands::UISetAppIconResponse, + commands::UISetAppIconRequest, + commands::UIGetSupportedLanguagesResponse, + commands::UIGetSupportedLanguagesRequest, + commands::UIGetLanguageResponse, + commands::UIGetLanguageRequest, + commands::UIGetCapabilitiesResponse, + commands::UIGetCapabilitiesRequest, + commands::UIChangeRegistratioResponse> HMICommandsListFirst; + +typedef Types<commands::UIChangeRegistrationRequest, + commands::UIPerformAudioPassThruResponse, + commands::UIPerformAudioPassThruRequest, + commands::UIEndAudioPassThruResponse, + commands::UIEndAudioPassThruRequest, + commands::UIAlertResponse, + commands::UIAlertRequest, + commands::VRIsReadyResponse, + commands::VRIsReadyRequest, + commands::VRAddCommandResponse, + commands::VRAddCommandRequest, + commands::VRDeleteCommandResponse, + commands::VRDeleteCommandRequest, + commands::VRChangeRegistrationResponse, + commands::VRChangeRegistrationRequest, + commands::VRGetSupportedLanguagesResponse, + commands::VRGetSupportedLanguagesRequest, + commands::VRGetLanguageResponse, + commands::VRGetLanguageRequest, + commands::VRGetCapabilitiesResponse, + commands::VRGetCapabilitiesRequest, + commands::TTSIsReadyResponse, + commands::TTSIsReadyRequest, + commands::TTSChangeRegistratioResponse, + commands::TTSChangeRegistrationRequest, + commands::TTSGetSupportedLanguagesResponse, + commands::TTSGetSupportedLanguagesRequest, + commands::TTSStopSpeakingResponse, + commands::TTSStopSpeakingRequest, + commands::TTSGetLanguageResponse, + commands::TTSGetLanguageRequest, + commands::TTSSpeakResponse, + commands::TTSSpeakRequest, + commands::TTSSetGlobalPropertiesResponse, + commands::TTSSetGlobalPropertiesRequest, + commands::TTSGetCapabilitiesResponse, + commands::TTSGetCapabilitiesRequest, + commands::OnTTSStartedNotification, + commands::OnTTSStoppedNotification, + commands::OnAppActivatedNotification, + commands::OnExitApplicationNotification, + commands::UIShowResponse, + commands::UIShowRequest, + commands::UISliderResponse, + commands::UISliderRequest, + commands::ClosePopupResponse, + commands::ClosePopupRequest, + commands::UIIsReadyResponse, + commands::UIIsReadyRequest> HMICommandsListSecond; + +typedef Types<commands::NaviIsReadyResponse, + commands::NaviIsReadyRequest, + commands::NaviAlertManeuverResponse, + commands::NaviAlertManeuverRequest, + commands::NaviGetWayPointsResponse, + commands::NaviGetWayPointsRequest, + commands::NaviUpdateTurnListResponse, + commands::NaviUpdateTurnListRequest, + commands::NaviShowConstantTBTResponse, + commands::NaviShowConstantTBTRequest, + commands::NaviSubscribeWayPointsResponse, + commands::NaviSubscribeWayPointsRequest, + commands::NaviUnsubscribeWayPointsResponse, + commands::NaviUnSubscribeWayPointsRequest, + commands::ButtonGetCapabilitiesResponse, + commands::ButtonGetCapabilitiesRequest, + commands::OnAllowSDLFunctionalityNotification, + commands::OnSDLConsentNeededNotification, + commands::UpdateSDLResponse, + commands::UpdateSDLRequest, + commands::OnIgnitionCycleOverNotification, + commands::OnSystemInfoChangedNotification, + commands::OnReadyNotification, + commands::OnDeviceChosenNotification, + commands::OnSystemContextNotification, + sdl_rpc_plugin::commands::hmi::OnDriverDistractionNotification, + commands::OnUpdateDeviceList, + commands::OnAppRegisteredNotification, + commands::OnAppUnregisteredNotification, + commands::OnFindApplications, + commands::UpdateAppListResponse, + commands::UpdateAppListRequest, + commands::OnVRStartedNotification, + commands::OnVRStoppedNotification, + commands::OnVRCommandNotification, + commands::OnUICommandNotification, + commands::OnAppDeactivatedNotification> HMICommandsListThird; + +typedef Types<commands::hmi::OnButtonEventNotification, + commands::hmi::OnButtonPressNotification, + commands::hmi::OnButtonSubscriptionNotification, + commands::OnNaviTBTClientStateNotification, + commands::hmi::OnUIKeyBoardInputNotification, + commands::hmi::OnUITouchEventNotification, + commands::hmi::OnUIResetTimeoutNotification, + commands::NaviStartStreamResponse, + commands::NaviStartStreamRequest, + commands::NaviStopStreamResponse, + commands::NaviStopStreamRequest, + commands::AudioStartStreamResponse, + commands::AudioStartStreamRequest, + commands::AudioStopStreamResponse, + commands::AudioStopStreamRequest, + commands::OnAudioDataStreamingNotification, + commands::OnVideoDataStreamingNotification, + commands::VRPerformInteractionResponse, + commands::VRPerformInteractionRequest, + commands::OnSystemRequestNotification, + commands::OnPutFileNotification, + commands::OnResumeAudioSourceNotification, + commands::UiSetDisplayLayoutResponse, + commands::UiSetDisplayLayoutRequest, + commands::OnSDLCloseNotification, + commands::OnSDLPersistenceCompleteNotification, + commands::OnFileRemovedNotification, + commands::OnRecordStartdNotification, + commands::BasicCommunicationSystemResponse, + commands::BasicCommunicationSystemRequest, + commands::NaviSendLocationResponse, + commands::NaviSendLocationRequest, + commands::AddStatisticsInfoNotification, + commands::OnSystemErrorNotification, + commands::OnReceivedPolicyUpdate, + commands::OnPolicyUpdate, + commands::OnDeviceStateChangedNotification, + commands::hmi::OnTTSResetTimeoutNotification, + commands::hmi::DialNumberResponse, + commands::hmi::DialNumberRequest, + commands::OnEventChangedNotification, + commands::OnNaviWayPointChangeNotification, + commands::OnUILanguageChangeNotification, + commands::OnVRLanguageChangeNotification, + commands::OnTTSLanguageChangeNotification> HMICommandsListFourth; + +typedef Types<commands::OnVIGpsDataNotification, + commands::OnVISpeedNotification, + commands::OnVIRpmNotification, + commands::OnVIFuelLevelNotification, + commands::OnVIFuelLevelStateNotification, + commands::OnVIInstantFuelConsumptionNotification, + commands::OnVIExternalTemperatureNotification, + commands::OnVIVinNotification, + commands::OnVIPrndlNotification, + commands::OnVITirePressureNotification, + commands::OnVIOdometerNotification, + commands::OnVIBeltStatusNotification, + commands::OnVIBodyInformationNotification, + commands::OnVIDeviceStatusNotification, + commands::OnVIDriverBrakingNotification, + commands::OnVIWiperStatusNotification, + commands::OnVIHeadLampStatusNotification, + commands::OnVIEngineTorqueNotification, + commands::OnVIAccPedalPositionNotification, + commands::OnVISteeringWheelAngleNotification, + commands::OnVIMyKeyNotification, + commands::AllowAllAppsRequest, + commands::AllowAllAppsResponse, + commands::AllowAppRequest, + commands::AllowAppResponse> HMICommandsListFifth; + +TYPED_TEST_CASE(HMICommandsTestFirst, HMICommandsListFirst); +TYPED_TEST_CASE(HMICommandsTestSecond, HMICommandsListSecond); +TYPED_TEST_CASE(HMICommandsTestThird, HMICommandsListThird); +TYPED_TEST_CASE(HMICommandsTestFourth, HMICommandsListFourth); +TYPED_TEST_CASE(HMICommandsTestFifth, HMICommandsListFifth); + +TYPED_TEST(HMICommandsTestFirst, CtorAndDtorCall) { + utils::SharedPtr<typename TestFixture::CommandType> command = + this->template CreateCommand<typename TestFixture::CommandType>(); + UNUSED(command); +} + +TYPED_TEST(HMICommandsTestSecond, CtorAndDtorCall) { + utils::SharedPtr<typename TestFixture::CommandType> command = + this->template CreateCommand<typename TestFixture::CommandType>(); + UNUSED(command); +} +TYPED_TEST(HMICommandsTestThird, CtorAndDtorCall) { + utils::SharedPtr<typename TestFixture::CommandType> command = + this->template CreateCommand<typename TestFixture::CommandType>(); + UNUSED(command); +} + +TYPED_TEST(HMICommandsTestFourth, CtorAndDtorCall) { + utils::SharedPtr<typename TestFixture::CommandType> command = + this->template CreateCommand<typename TestFixture::CommandType>(); + UNUSED(command); +} + +TYPED_TEST(HMICommandsTestFifth, CtorAndDtorCall) { + utils::SharedPtr<typename TestFixture::CommandType> command = + this->template CreateCommand<typename TestFixture::CommandType>(); + UNUSED(command); +} + +} // namespace dummy_hmi_commands_test +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_request_test.cc new file mode 100644 index 0000000000..6262e1dd8a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_request_test.cc @@ -0,0 +1,99 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/request_to_hmi.h" +#include "hmi/get_system_info_request.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace get_system_info_request { + +using ::utils::SharedPtr; +namespace am = ::application_manager; +namespace strings = ::application_manager::strings; +using am::commands::RequestToHMI; +using sdl_rpc_plugin::commands::GetSystemInfoRequest; +using am::commands::CommandImpl; + +typedef SharedPtr<RequestToHMI> RequestToHMIPtr; + +namespace { +const uint32_t kConnectionKey = 2u; +const uint32_t kCorrelationId = 1u; +} // namespace + +class GetSystemInfoRequestTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(GetSystemInfoRequestTest, RUN_SendRequest_SUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::msg_params][strings::number] = "123"; + (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; + (*command_msg)[strings::params][strings::correlation_id] = kCorrelationId; + + RequestToHMIPtr command(CreateCommand<GetSystemInfoRequest>(command_msg)); + + const uint32_t kAppId = command->application_id(); + + EXPECT_CALL(app_mngr_, set_application_id(kCorrelationId, kAppId)); + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(command_msg)); + + command->Run(); + + EXPECT_EQ((*command_msg)[strings::msg_params][strings::app_id].asUInt(), + kAppId); + EXPECT_EQ((*command_msg)[strings::params][strings::correlation_id].asUInt(), + kCorrelationId); + + EXPECT_EQ((*command_msg)[strings::params][strings::protocol_type].asInt(), + CommandImpl::hmi_protocol_type_); + EXPECT_EQ((*command_msg)[strings::params][strings::protocol_version].asInt(), + CommandImpl::protocol_version_); +} + +} // namespace get_system_info_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc new file mode 100644 index 0000000000..3a68264e2a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc @@ -0,0 +1,140 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/application.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/response_from_hmi.h" +#include "hmi/get_system_info_response.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/commands/commands_test.h" +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace get_system_info_response { + +using ::testing::Return; +using ::utils::SharedPtr; +using ::testing::NiceMock; +namespace am = ::application_manager; +namespace strings = ::application_manager::strings; +namespace hmi_response = am::hmi_response; +using application_manager::commands::ResponseFromHMI; +using sdl_rpc_plugin::commands::GetSystemInfoResponse; +using sdl_rpc_plugin::commands::SystemInfo; +using am::commands::CommandImpl; + +typedef SharedPtr<ResponseFromHMI> ResponseFromHMIPtr; +typedef NiceMock< + ::test::components::application_manager_test::MockHMICapabilities> + MockHMICapabilities; + +namespace { +const uint32_t kConnectionKey = 2u; +const std::string ccpu_version("4.1.3.B_EB355B"); +const std::string wers_country_code("WAEGB"); +const uint32_t lang_code = 0u; +const std::string kLanguage = ""; +} // namespace + +class GetSystemInfoResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + MessageSharedPtr CreateCommandMsg() { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::msg_params][strings::number] = "123"; + (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; + (*command_msg)[strings::msg_params]["ccpu_version"] = ccpu_version; + (*command_msg)[strings::msg_params]["wersCountryCode"] = wers_country_code; + (*command_msg)[strings::msg_params]["language"] = lang_code; + + return command_msg; + } + + SmartObject capabilities_; +}; + +TEST_F(GetSystemInfoResponseTest, GetSystemInfo_SUCCESS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*command_msg)[strings::msg_params][hmi_response::capabilities] = + (capabilities_); + + ResponseFromHMIPtr command(CreateCommand<GetSystemInfoResponse>(command_msg)); + + std::string language; + EXPECT_CALL(mock_message_helper_, + CommonLanguageToString( + static_cast<hmi_apis::Common_Language::eType>(lang_code))) + .WillOnce(Return(language)); + EXPECT_EQ(kLanguage, language); + + EXPECT_CALL(mock_policy_handler_, + OnGetSystemInfo(ccpu_version, wers_country_code, kLanguage)); + + command->Run(); +} + +TEST_F(GetSystemInfoResponseTest, GetSystemInfo_UNSUCCESS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::WRONG_LANGUAGE; + (*command_msg)[strings::msg_params][hmi_response::capabilities] = + (capabilities_); + + ResponseFromHMIPtr command(CreateCommand<GetSystemInfoResponse>(command_msg)); + + EXPECT_CALL(mock_message_helper_, + CommonLanguageToString( + static_cast<hmi_apis::Common_Language::eType>(lang_code))) + .Times(0); + + EXPECT_CALL(mock_policy_handler_, OnGetSystemInfo("", "", "")); + + command->Run(); +} + +} // namespace get_system_info_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_response_test.cc new file mode 100644 index 0000000000..05169e5067 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_response_test.cc @@ -0,0 +1,90 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/command.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/response_to_hmi.h" +#include "hmi/get_urls_response.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace get_urls_response { + +using ::testing::_; +using ::testing::Return; +using ::utils::SharedPtr; +namespace am = ::application_manager; +namespace strings = ::application_manager::strings; +using sdl_rpc_plugin::commands::GetUrlsResponse; +using am::commands::ResponseToHMI; +using am::commands::CommandImpl; + +typedef SharedPtr<ResponseToHMI> ResponseToHMIPtr; + +namespace { +const uint32_t kConnectionKey = 2u; +} // namespace + +class GetUrlResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(GetUrlResponseTest, RUN_SendRequest_SUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::msg_params][strings::number] = "123"; + (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; + + ResponseToHMIPtr command(CreateCommand<GetUrlsResponse>(command_msg)); + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(command_msg)); + + command->Run(); + + EXPECT_EQ((*command_msg)[strings::params][strings::protocol_type].asInt(), + CommandImpl::hmi_protocol_type_); + EXPECT_EQ((*command_msg)[strings::params][strings::protocol_version].asInt(), + CommandImpl::protocol_version_); +} + +} // namespace get_urls_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_test.cc new file mode 100644 index 0000000000..7788cb2ebe --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_test.cc @@ -0,0 +1,336 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "application_manager/message.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/command.h" +#include "hmi/get_urls.h" +#include "application_manager/policies/policy_handler.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/request_from_hmi.h" +#include "policy/mock_policy_manager.h" +#include "application_manager/event_engine/event_dispatcher.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace get_urls { + +using namespace hmi_apis; +using namespace policy; +using ::utils::SharedPtr; +using ::testing::NiceMock; +using ::testing::_; +using ::testing::SetArgReferee; +using ::test::components::application_manager_test::MockApplication; +namespace am = ::application_manager; +namespace strings = ::application_manager::strings; +using am::commands::RequestFromHMI; +using sdl_rpc_plugin::commands::GetUrls; +using am::commands::CommandImpl; +using policy::PolicyHandler; +using policy_test::MockPolicyHandlerInterface; + +typedef SharedPtr<RequestFromHMI> RequestFromHMIPtr; + +namespace { +const uint32_t kInvalidAppId_ = 0u; +const uint32_t kAppIdForSending = 1u; +const uint32_t kConnectionKey = 2u; +const uint32_t kServiceType = 0u; +const std::string kInitialService = "0x0"; +const std::string kPolicyService = "7"; +const std::string kDefaultUrl = "URL is not found"; +const std::string kDefaultId = "default"; +const std::string kPolicyAppId = "policy_app_id"; +} // namespace + +class GetUrlsTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + MessageSharedPtr command_msg_; + RequestFromHMIPtr request_command_; + + GetUrlsTest() { + command_msg_ = + CreateMessage(NsSmartDeviceLink::NsSmartObjects::SmartType_Map); + (*command_msg_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = + kInitialService; + + request_command_ = CreateCommand<GetUrls>(command_msg_); + } +}; + +TEST_F(GetUrlsTest, RUN_SUCCESS) { + EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); + // EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(_, _)); + + request_command_->Run(); +} + +TEST_F(GetUrlsTest, RUN_PolicyNotEnabled_UNSUCCESS) { + EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(false)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_)) + .WillOnce(Return(true)); + + request_command_->Run(); + + EXPECT_EQ(am::MessageType::kResponse, + (*command_msg_)[strings::params][strings::message_type].asInt()); + EXPECT_EQ(Common_Result::DATA_NOT_AVAILABLE, + (*command_msg_)[strings::params][am::hmi_response::code].asInt()); +} + +TEST_F(GetUrlsTest, RUN_EmptyEndpoints_UNSUCCESS) { + EndpointUrls endpoints_; + EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kServiceType, _)) + .WillOnce(SetArgReferee<1>(endpoints_)); + EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_)) + .WillOnce(Return(true)); + + request_command_->Run(); + + EXPECT_EQ(am::MessageType::kResponse, + (*command_msg_)[strings::params][strings::message_type].asInt()); + EXPECT_EQ(Common_Result::DATA_NOT_AVAILABLE, + (*command_msg_)[strings::params][am::hmi_response::code].asInt()); +} + +#ifdef EXTENDED_POLICY +TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_SUCCESS) { + (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = + kPolicyService; + + EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); + + EndpointUrls endpoints_; + EndpointData data(kDefaultUrl); + endpoints_.push_back(data); + + EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _)) + .WillOnce(SetArgReferee<1>(endpoints_)); + + MockAppPtr mock_app = CreateMockApp(); + + EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) + .WillOnce(Return(kAppIdForSending)); + + EXPECT_CALL(app_mngr_, application(kAppIdForSending)) + .WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppIdForSending)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_)) + .WillOnce(Return(true)); + + request_command_->Run(); + + EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists( + am::hmi_request::service)); + + EXPECT_EQ(am::MessageType::kResponse, + (*command_msg_)[strings::params][strings::message_type].asInt()); + EXPECT_EQ(Common_Result::SUCCESS, + (*command_msg_)[strings::params][am::hmi_response::code].asInt()); + + EXPECT_EQ(kAppIdForSending, + (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] + [strings::app_id].asInt()); + EXPECT_EQ(kDefaultUrl, + (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] + [strings::url].asString()); +} + +TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_IncorrectIdForSending_UNSUCCESS) { + (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = + kPolicyService; + + EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); + + EndpointUrls endpoints_; + EndpointData data(kDefaultUrl); + endpoints_.push_back(data); + + EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _)) + .WillOnce(SetArgReferee<1>(endpoints_)); + + EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) + .WillOnce(Return(kInvalidAppId_)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_)) + .WillOnce(Return(true)); + + EXPECT_CALL(app_mngr_, application(kInvalidAppId_)).Times(0); + + request_command_->Run(); +} + +TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_ApplicationIsNotValid_UNSUCCESS) { + (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = + kPolicyService; + + EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); + + EndpointUrls endpoints_; + EndpointData data(kDefaultUrl); + endpoints_.push_back(data); + + EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _)) + .WillOnce(SetArgReferee<1>(endpoints_)); + + MockAppPtr invalid_mock_app; + + EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) + .WillOnce(Return(kAppIdForSending)); + + EXPECT_CALL(app_mngr_, application(kAppIdForSending)) + .WillOnce(Return(invalid_mock_app)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_)) + .WillOnce(Return(true)); + + request_command_->Run(); + + EXPECT_EQ(am::MessageType::kResponse, + (*command_msg_)[strings::params][strings::message_type].asInt()); + EXPECT_EQ(Common_Result::DATA_NOT_AVAILABLE, + (*command_msg_)[strings::params][am::hmi_response::code].asInt()); +} + +TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_FoundURLForApplication_SUCCESS) { + (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = + kPolicyService; + + EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); + + EndpointUrls endpoints_; + EndpointData data(kDefaultUrl); + data.app_id = kPolicyAppId; + endpoints_.push_back(data); + + EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _)) + .WillOnce(SetArgReferee<1>(endpoints_)); + + MockAppPtr mock_app = CreateMockApp(); + + EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) + .WillOnce(Return(kAppIdForSending)); + + EXPECT_CALL(app_mngr_, application(kAppIdForSending)) + .WillOnce(Return(mock_app)); + + EXPECT_CALL(*mock_app, policy_app_id()).WillOnce(Return(kPolicyAppId)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_)) + .WillOnce(Return(true)); + + request_command_->Run(); + + EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists( + am::hmi_request::service)); + + EXPECT_EQ(am::MessageType::kResponse, + (*command_msg_)[strings::params][strings::message_type].asInt()); + EXPECT_EQ(Common_Result::SUCCESS, + (*command_msg_)[strings::params][am::hmi_response::code].asInt()); +} +#endif + +TEST_F(GetUrlsTest, DISABLED_ProcessServiceURLs_SUCCESS) { + (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] = + kDefaultUrl; + (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] + [am::hmi_response::policy_app_id] = "1"; + + EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); + + EndpointUrls endpoints_; + EndpointData data(kDefaultUrl); + data.app_id = "1"; + endpoints_.push_back(data); + EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kServiceType, _)) + .WillOnce(SetArgReferee<1>(endpoints_)); + + request_command_->Run(); + + EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists( + am::hmi_request::service)); + EXPECT_EQ(kDefaultUrl, + (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] + [am::strings::url].asString()); + EXPECT_EQ(endpoints_[0].app_id, + (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] + [am::hmi_response::policy_app_id].asString()); +} + +TEST_F(GetUrlsTest, ProcessServiceURLs_PolicyDefaultId_SUCCESS) { + (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] = + kDefaultUrl; + (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] + [am::hmi_response::policy_app_id] = kDefaultId; + + EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); + EndpointUrls endpoints_; + EndpointData data(kDefaultUrl); + endpoints_.push_back(data); + EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kServiceType, _)) + .WillOnce(SetArgReferee<1>(endpoints_)); + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application_by_policy_id(_)) + .WillOnce(Return(mock_app)); + request_command_->Run(); + + EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists( + am::hmi_request::service)); + EXPECT_TRUE( + (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] + .keyExists(am::hmi_response::policy_app_id)); +} + +} // namespace get_urls +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc new file mode 100644 index 0000000000..b498d07d99 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc @@ -0,0 +1,1886 @@ +/* + * 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 <stdint.h> +#include <string> +#include <vector> +#include "gtest/gtest.h" +#include "application_manager/commands/commands_test.h" + +#include "sdl_rpc_plugin/commands/hmi/on_button_event_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_acc_pedal_position_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_belt_status_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_body_information_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_device_status_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_driver_braking_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_engine_torque_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_external_temperature_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_state_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_gps_data_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_head_lamp_status_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_instant_fuel_consumption_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_my_key_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_odometer_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_prndl_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_rpm_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_speed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_steering_wheel_angle_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_tire_pressure_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_vin_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vi_wiper_status_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_registered_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_audio_data_streaming_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_button_subscription_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_put_file_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_resume_audio_source_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_status_update_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_record_start_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_button_press_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ready_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_policy_update.h" +#include "sdl_rpc_plugin/commands/hmi/on_received_policy_update.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_error_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h" +#include "sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_context_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_request_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h" + +#include "utils/lock.h" +#include "utils/data_accessor.h" +#include "utils/signals.h" +#include "utils/shared_ptr.h" +#include "utils/make_shared.h" +#include "utils/file_system.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_rpc_plugin_manager.h" +#include "application_manager/mock_state_controller.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/hmi_capabilities_impl.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "transport_manager/mock_transport_manager.h" +#include "connection_handler/mock_connection_handler.h" +#include "connection_handler/mock_connection_handler_settings.h" +#include "test/application_manager/mock_application_manager_settings.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/mock_message_helper.h" +#include "protocol_handler/mock_session_observer.h" +#include "application_manager/mock_resume_ctrl.h" + +namespace am = application_manager; + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace hmi_notifications_test { + +using ::testing::_; +using ::testing::Test; +using ::testing::Types; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::NiceMock; +using ::testing::InSequence; +using ::utils::SharedPtr; +using ::smart_objects::SmartObject; +using ::application_manager::commands::MessageSharedPtr; +using ::test::components::application_manager_test::MockApplicationManager; +using ::test::components::application_manager_test:: + MockApplicationManagerSettings; +using ::application_manager::ApplicationSharedPtr; +using ::test::components::application_manager_test::MockApplication; +using ::test::components::event_engine_test::MockEventDispatcher; +using ::application_manager::MockMessageHelper; +using namespace sdl_rpc_plugin::commands; +using namespace am::commands; + +typedef SharedPtr<MockApplication> MockAppPtr; +typedef NiceMock< + ::test::components::application_manager_test::MockHMICapabilities> + MockHMICapabilities; + +#define MEDIA true +#define NOT_MEDIA false +#define VC true +#define NOT_VC false +#define NAVI true +#define NOT_NAVI false + +ACTION_P(GetEventId, event_id) { + *event_id = arg0.id(); +} +ACTION_P(GetArg, arg) { + *arg = arg0; +} + +ACTION_P(GetArg3, result) { + arg3 = *result; +} + +ACTION_P2(GetConnectIdPermissionConsent, connect_id, consent) { + *connect_id = arg0; + std::vector<policy::FunctionalGroupPermission>::const_iterator it = + arg1.group_permissions.begin(); + for (; it != arg1.group_permissions.end(); ++it) { + consent->group_permissions.push_back(*it); + } + consent->consent_source = arg1.consent_source; +} +ACTION_P2(GetBoolValueAndString, value, str) { + *value = arg0; + *str = arg1; +} +ACTION_P(GetMessage, message) { + (*message)[am::strings::params][am::strings::function_id] = + (*arg0)[am::strings::params][am::strings::function_id].asInt(); + (*message)[am::strings::params][am::strings::message_type] = + (*arg0)[am::strings::params][am::strings::message_type].asInt(); + (*message)[am::strings::params][am::strings::correlation_id] = + (*arg0)[am::strings::params][am::strings::correlation_id].asInt(); + (*message)[am::strings::params][am::strings::connection_key] = + (*arg0)[am::strings::params][am::strings::connection_key].asInt(); + return (*message)[am::strings::params][am::strings::correlation_id].asInt(); +} + +namespace { +const uint32_t kCountCommandsManageMobile_ = 22u; +const uint32_t kCountCommandsToHmi_ = 12u; +const int32_t kHmiProtocolType_ = 1; +const int32_t kMobileProtocolType_ = 0; +const int32_t kProtocolVersion_ = 3; +const uint32_t kCorrelationId_ = 1939u; +const uint32_t kAppId_ = 2014u; +} // namespace + +class HMICommandsNotificationsTest + : public components::commands_test::CommandsTest< + CommandsTestMocks::kIsNice> { + public: + HMICommandsNotificationsTest() + : applications_lock_(std::make_shared<sync_primitives::Lock>()) + , applications_(application_set_, applications_lock_) + , app_ptr_(NULL) {} + + ~HMICommandsNotificationsTest() { + // Fix DataAccessor release and WinQt crash + Mock::VerifyAndClearExpectations(&app_mngr_); + } + typedef Command CommandType; + + protected: + am::ApplicationSet application_set_; + std::shared_ptr<sync_primitives::Lock> applications_lock_; + DataAccessor<am::ApplicationSet> applications_; + + NiceMock<event_engine_test::MockEventDispatcher> mock_event_dispatcher_; + + application_manager_test::MockStateController mock_state_controller_; + + am::ApplicationSharedPtr app_; + NiceMock<MockApplication>* app_ptr_; + + typedef IsNiceMock<connection_handler_test::MockConnectionHandler, + kMocksAreNice>::Result MockConnectionHandler; + + typedef IsNiceMock<protocol_handler_test::MockSessionObserver, + kMocksAreNice>::Result MockSessionObserver; + + MockConnectionHandler mock_connection_handler_; + MockSessionObserver mock_session_observer_; + + void InitCommand(const uint32_t& default_timeout) OVERRIDE { + app_ = ConfigureApp(&app_ptr_, kAppId_, NOT_MEDIA, NOT_NAVI, NOT_VC); + EXPECT_CALL(app_mngr_, get_settings()) + .WillOnce(ReturnRef(app_mngr_settings_)); + EXPECT_CALL(app_mngr_settings_, default_timeout()) + .WillOnce(ReturnRef(default_timeout)); + ON_CALL(app_mngr_, event_dispatcher()) + .WillByDefault(ReturnRef(mock_event_dispatcher_)); + ON_CALL(app_mngr_, application_by_hmi_app(_)).WillByDefault(Return(app_)); + ON_CALL(*app_ptr_, app_id()).WillByDefault(Return(kAppId_)); + } + + am::ApplicationSharedPtr ConfigureApp(NiceMock<MockApplication>** app_mock, + uint32_t app_id, + bool media, + bool navi, + bool vc) { + *app_mock = new NiceMock<MockApplication>; + + Mock::AllowLeak(*app_mock); // WorkAround for gogletest bug + am::ApplicationSharedPtr app(*app_mock); + + ON_CALL(**app_mock, app_id()).WillByDefault(Return(app_id)); + ON_CALL(**app_mock, is_media_application()).WillByDefault(Return(media)); + ON_CALL(**app_mock, is_navi()).WillByDefault(Return(navi)); + ON_CALL(**app_mock, is_voice_communication_supported()) + .WillByDefault(Return(vc)); + ON_CALL(**app_mock, IsAudioApplication()) + .WillByDefault(Return(media || navi || vc)); + return app; + } +#if defined(OS_POSIX) + void SubscribeForSignal() { + sigset_t signal_set; + sigemptyset(&signal_set); + sigaddset(&signal_set, SIGINT); + sigaddset(&signal_set, SIGTERM); + pthread_sigmask(SIG_BLOCK, &signal_set, NULL); + } +#endif +}; + +namespace { +void sig_handler(int sig) { + switch (sig) { + case SIGINT: + break; + case SIGTERM: + break; + case SIGSEGV: + abort(); + default: + exit(EXIT_FAILURE); + } +} +} // namespace + +template <class Command> +class HMIOnViNotifications : public commands_test::CommandsTest<kIsNice> { + public: + typedef Command CommandType; +}; + +template <class Command> +class HMIOnNotificationsListToHMI + : public commands_test::CommandsTest<kIsNice> { + public: + typedef Command CommandType; +}; + +template <class CommandT, hmi_apis::FunctionID::eType kCommandId> +struct CommandPair { + typedef CommandT CommandType; + enum { kHMICommandId = kCommandId }; +}; + +template <class Command> +class HMIOnNotificationsEventDispatcher + : public commands_test::CommandsTest<kIsNice> { + public: + typedef Command CommandType; + NiceMock<event_engine_test::MockEventDispatcher> mock_event_dispatcher_; +}; + +typedef Types<OnAppPermissionChangedNotification, + OnAudioDataStreamingNotification, + hmi::OnButtonSubscriptionNotification, + OnFileRemovedNotification, + OnPutFileNotification, + OnResumeAudioSourceNotification, + OnSDLCloseNotification, + OnSDLConsentNeededNotification, + OnSDLPersistenceCompleteNotification, + OnStatusUpdateNotification, + OnVideoDataStreamingNotification, + OnRecordStartdNotification> HMIOnNotificationsListToHMITypes; + +typedef Types< + CommandPair<OnAppActivatedNotification, + hmi_apis::FunctionID::BasicCommunication_OnAppActivated>, + CommandPair<OnAppDeactivatedNotification, + hmi_apis::FunctionID::BasicCommunication_OnAppDeactivated>, + CommandPair<OnEventChangedNotification, + hmi_apis::FunctionID::BasicCommunication_OnEventChanged>, + CommandPair<hmi::OnTTSResetTimeoutNotification, + hmi_apis::FunctionID::TTS_OnResetTimeout>, + CommandPair<OnTTSStartedNotification, hmi_apis::FunctionID::TTS_Started>, + CommandPair<OnTTSStoppedNotification, hmi_apis::FunctionID::TTS_Stopped>, + CommandPair<hmi::OnUIResetTimeoutNotification, + hmi_apis::FunctionID::UI_OnResetTimeout>, + CommandPair<OnVRStartedNotification, hmi_apis::FunctionID::VR_Started>, + CommandPair<OnVRStoppedNotification, hmi_apis::FunctionID::VR_Stopped> > + HMIOnNotificationsEventDispatcherTypes; + +TYPED_TEST_CASE(HMIOnNotificationsListToHMI, HMIOnNotificationsListToHMITypes); +TYPED_TEST_CASE(HMIOnNotificationsEventDispatcher, + HMIOnNotificationsEventDispatcherTypes); + +TYPED_TEST(HMIOnNotificationsListToHMI, CommandsSendNotificationToHmi) { + MessageSharedPtr message = + commands_test::CommandsTest<kIsNice>::CreateMessage(); + utils::SharedPtr<typename TestFixture::CommandType> command = + this->template CreateCommand<typename TestFixture::CommandType>(message); + EXPECT_CALL(commands_test::CommandsTest<kIsNice>::mock_rpc_service_, + SendMessageToHMI(_)); + command->Run(); + EXPECT_EQ( + static_cast<int32_t>(kHmiProtocolType_), + (*message)[am::strings::params][am::strings::protocol_type].asInt()); + EXPECT_EQ( + static_cast<int32_t>(kProtocolVersion_), + (*message)[am::strings::params][am::strings::protocol_version].asInt()); +} + +TYPED_TEST(HMIOnNotificationsEventDispatcher, + CommandsNotificationEventDispatcher) { + int32_t event_id = hmi_apis::FunctionID::INVALID_ENUM; + MessageSharedPtr message = + commands_test::CommandsTest<kIsNice>::CreateMessage(); + utils::SharedPtr<typename TestFixture::CommandType::CommandType> command = + this->template CreateCommand< + typename TestFixture::CommandType::CommandType>(message); + EXPECT_CALL(commands_test::CommandsTest<kIsNice>::app_mngr_, + event_dispatcher()) + .WillOnce(ReturnRef(this->mock_event_dispatcher_)); + EXPECT_CALL(this->mock_event_dispatcher_, raise_event(_)) + .WillOnce(GetEventId(&event_id)); + command->Run(); + EXPECT_EQ(TestFixture::CommandType::kHMICommandId, event_id); +} + +// notifications(SendNotificationToMobile) +TEST_F(HMICommandsNotificationsTest, OnButtonEventSendNotificationToMobile) { + MessageSharedPtr message = CreateMessage(); + utils::SharedPtr<Command> command = + CreateCommand<hmi::OnButtonEventNotification>(message); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnButtonEventID), + (*message)[am::strings::params][am::strings::function_id].asInt()); + EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), + (*message)[am::strings::params][am::strings::message_type].asInt()); +} + +TEST_F(HMICommandsNotificationsTest, OnNaviTBTClientSendNotificationToMobile) { + MessageSharedPtr message = CreateMessage(); + utils::SharedPtr<Command> command = + CreateCommand<OnNaviTBTClientStateNotification>(message); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnTBTClientStateID), + (*message)[am::strings::params][am::strings::function_id].asInt()); + EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), + (*message)[am::strings::params][am::strings::message_type].asInt()); +} + +TEST_F(HMICommandsNotificationsTest, + OnNaviWayPointChangeSendNotificationToMobile) { + MessageSharedPtr message = CreateMessage(); + utils::SharedPtr<Command> command = + CreateCommand<OnNaviWayPointChangeNotification>(message); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnWayPointChangeID), + (*message)[am::strings::params][am::strings::function_id].asInt()); + EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), + (*message)[am::strings::params][am::strings::message_type].asInt()); +} + +TEST_F(HMICommandsNotificationsTest, OnUICommandSendNotificationToMobile) { + MessageSharedPtr message = CreateMessage(); + utils::SharedPtr<Command> command = + CreateCommand<OnUICommandNotification>(message); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::eType::OnCommandID), + (*message)[am::strings::params][am::strings::function_id].asInt()); + EXPECT_EQ( + static_cast<int32_t>(mobile_apis::TriggerSource::TS_MENU), + (*message)[am::strings::msg_params][am::strings::trigger_source].asInt()); + EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), + (*message)[am::strings::params][am::strings::message_type].asInt()); +} + +TEST_F(HMICommandsNotificationsTest, + OnUIKeyBoardInputSendNotificationToMobile) { + MessageSharedPtr message = CreateMessage(); + utils::SharedPtr<Command> command = + CreateCommand<hmi::OnUIKeyBoardInputNotification>(message); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnKeyboardInputID), + (*message)[am::strings::params][am::strings::function_id].asInt()); + EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), + (*message)[am::strings::params][am::strings::message_type].asInt()); +} + +TEST_F(HMICommandsNotificationsTest, OnUITouchEventSendNotificationToMobile) { + MessageSharedPtr message = CreateMessage(); + utils::SharedPtr<Command> command = + CreateCommand<hmi::OnUITouchEventNotification>(message); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnTouchEventID), + (*message)[am::strings::params][am::strings::function_id].asInt()); + EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), + (*message)[am::strings::params][am::strings::message_type].asInt()); +} + +TEST_F(HMICommandsNotificationsTest, + OnAppRegisteredNotificationSendNotificationToHmi) { + int32_t event_id = hmi_apis::FunctionID::INVALID_ENUM; + MessageSharedPtr message = CreateMessage(); + utils::SharedPtr<Command> command = + CreateCommand<OnAppRegisteredNotification>(message); + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(_)); + EXPECT_CALL(app_mngr_, event_dispatcher()); + EXPECT_CALL(mock_event_dispatcher_, raise_event(_)) + .WillOnce(GetEventId(&event_id)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>( + hmi_apis::FunctionID::BasicCommunication_OnAppRegistered), + event_id); + EXPECT_EQ( + kHmiProtocolType_, + (*message)[am::strings::params][am::strings::protocol_type].asInt()); + EXPECT_EQ( + kProtocolVersion_, + (*message)[am::strings::params][am::strings::protocol_version].asInt()); +} + +TEST_F(HMICommandsNotificationsTest, + OnAppUnregisteredNotificationEventDispatcher) { + int32_t event_id = hmi_apis::FunctionID::INVALID_ENUM; + MessageSharedPtr message = CreateMessage(); + utils::SharedPtr<Command> command = + CreateCommand<OnAppUnregisteredNotification>(message); + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(_)); + EXPECT_CALL(app_mngr_, event_dispatcher()); + EXPECT_CALL(mock_event_dispatcher_, raise_event(_)) + .WillOnce(GetEventId(&event_id)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>( + hmi_apis::FunctionID::BasicCommunication_OnAppUnregistered), + event_id); + EXPECT_EQ( + kHmiProtocolType_, + (*message)[am::strings::params][am::strings::protocol_type].asInt()); + EXPECT_EQ( + kProtocolVersion_, + (*message)[am::strings::params][am::strings::protocol_version].asInt()); +} + +TEST_F(HMICommandsNotificationsTest, OnButtonPressNotificationEventDispatcher) { + int32_t event_id = hmi_apis::FunctionID::INVALID_ENUM; + MessageSharedPtr message = CreateMessage(); + utils::SharedPtr<Command> command = + CreateCommand<hmi::OnButtonPressNotification>(message); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(app_mngr_, event_dispatcher()); + EXPECT_CALL(mock_event_dispatcher_, raise_event(_)) + .WillOnce(GetEventId(&event_id)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>(hmi_apis::FunctionID::Buttons_OnButtonPress), + event_id); + EXPECT_EQ(static_cast<int>(mobile_apis::FunctionID::eType::OnButtonPressID), + (*message)[am::strings::params][am::strings::function_id].asInt()); +} + +TEST_F(HMICommandsNotificationsTest, OnReadyNotificationEventDispatcher) { + int32_t event_id = hmi_apis::FunctionID::INVALID_ENUM; + MessageSharedPtr message = CreateMessage(); + utils::SharedPtr<Command> command = + CreateCommand<OnReadyNotification>(message); + + EXPECT_CALL(app_mngr_, OnHMIStartedCooperation()); + EXPECT_CALL(app_mngr_, event_dispatcher()); + EXPECT_CALL(mock_event_dispatcher_, raise_event(_)) + .WillOnce(GetEventId(&event_id)); + command->Run(); + EXPECT_EQ(hmi_apis::FunctionID::BasicCommunication_OnReady, event_id); +} + +// policy handler +TEST_F(HMICommandsNotificationsTest, + OnIgnitionCycleOverNotificationPolicyHandler) { + MessageSharedPtr message = CreateMessage(); + utils::SharedPtr<Command> command = + CreateCommand<OnIgnitionCycleOverNotification>(message); + + EXPECT_CALL(mock_policy_handler_, OnIgnitionCycleOver()); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, OnPolicyUpdateNotificationPolicyHandler) { + MessageSharedPtr message = CreateMessage(); + utils::SharedPtr<Command> command = CreateCommand<OnPolicyUpdate>(message); + + EXPECT_CALL(mock_policy_handler_, OnPTExchangeNeeded()); + command->Run(); +} + +#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) +TEST_F(HMICommandsNotificationsTest, + OnReceivePolicyUpdateNotification_SUCCESS) { + const std::string kFile = "./test_file.txt"; + EXPECT_TRUE(file_system::CreateFile(kFile)); + uint8_t tmp[] = {1u, 2u, 3u, 4u}; + std::vector<uint8_t> data(tmp, tmp + 4); + EXPECT_TRUE(file_system::WriteBinaryFile(kFile, data)); + + MessageSharedPtr message = CreateMessage(smart_objects::SmartType_String); + (*message)[am::strings::msg_params][am::hmi_notification::policyfile] = kFile; + utils::SharedPtr<Command> command = + CreateCommand<OnReceivedPolicyUpdate>(message); + + EXPECT_CALL(mock_policy_handler_, ReceiveMessageFromSDK(kFile, data)); + command->Run(); + EXPECT_TRUE(file_system::DeleteFile(kFile)); +} +#endif + +TEST_F(HMICommandsNotificationsTest, + OnReceivePolicyUpdateNotification_UNSUCCESS) { + MessageSharedPtr message = CreateMessage(smart_objects::SmartType_String); + utils::SharedPtr<Command> command = + CreateCommand<OnReceivedPolicyUpdate>(message); + + EXPECT_CALL(mock_policy_handler_, ReceiveMessageFromSDK(_, _)).Times(0); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnAppPermissionConsentNotificationPolicyHandlerNoAppId) { + MessageSharedPtr message = CreateMessage(smart_objects::SmartType_Map); + (*message)[am::strings::msg_params]["consentedFunctions"] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + SmartObject& applications = + (*message)[am::strings::msg_params]["consentedFunctions"]; + + smart_objects::SmartObject hmi_application_temp(smart_objects::SmartType_Map); + applications[0] = hmi_application_temp; + + utils::SharedPtr<Command> command = + CreateCommand<OnAppPermissionConsentNotification>(message); + + int32_t connection_id = -1; +#ifdef EXTERNAL_PROPRIETARY_MODE + EXPECT_CALL(mock_policy_handler_, OnAppPermissionConsent(_, _, _)) +#else + EXPECT_CALL(mock_policy_handler_, OnAppPermissionConsent(_, _)) +#endif + .WillOnce(GetArg(&connection_id)); + command->Run(); + EXPECT_EQ(0, connection_id); +} + +TEST_F(HMICommandsNotificationsTest, + OnAppPermissionConsentNotificationPolicyHandlerWithAppId) { + MessageSharedPtr message = CreateMessage(smart_objects::SmartType_Map); + (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; + (*message)[am::strings::msg_params]["consentedFunctions"] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + smart_objects::SmartObjectSPtr consented_function = + utils::MakeShared<smart_objects::SmartObject>(); + (*message)[am::strings::msg_params]["consentedFunctions"][0] = + *consented_function; + + utils::SharedPtr<Command> command = + CreateCommand<OnAppPermissionConsentNotification>(message); + + int32_t connection_id = -1; + policy::PermissionConsent permission_consent; +#ifdef EXTERNAL_PROPRIETARY_MODE + EXPECT_CALL(mock_policy_handler_, OnAppPermissionConsent(_, _, _)) +#else + EXPECT_CALL(mock_policy_handler_, OnAppPermissionConsent(_, _)) +#endif + .WillOnce( + GetConnectIdPermissionConsent(&connection_id, &permission_consent)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>(kAppId_), connection_id); + std::vector<policy::FunctionalGroupPermission>::const_iterator it = + permission_consent.group_permissions.begin(); + for (; it != permission_consent.group_permissions.end(); ++it) { + EXPECT_EQ(policy::kGroupUndefined, (*it).state); + } +} + +TEST_F(HMICommandsNotificationsTest, + OnAppPermissionConsentNotificationPolicyHandlerAppIdAllowTrue) { + MessageSharedPtr message = CreateMessage(smart_objects::SmartType_Map); + (*message)[am::strings::msg_params]["consentedFunctions"] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; + (*message)[am::strings::msg_params]["source"] = "test_content_source"; + + smart_objects::SmartObjectSPtr consented_function = + utils::MakeShared<smart_objects::SmartObject>(); + (*consented_function)["allowed"] = true; + (*consented_function)[am::strings::id] = 999; + (*consented_function)[am::strings::name] = "test_group_alias"; + (*message)[am::strings::msg_params]["consentedFunctions"][0] = + *consented_function; + + utils::SharedPtr<Command> command = + CreateCommand<OnAppPermissionConsentNotification>(message); + + int32_t connection_id = -1; + policy::PermissionConsent permission_consent; +#ifdef EXTERNAL_PROPRIETARY_MODE + EXPECT_CALL(mock_policy_handler_, OnAppPermissionConsent(_, _, _)) +#else + EXPECT_CALL(mock_policy_handler_, OnAppPermissionConsent(_, _)) +#endif + .WillOnce( + GetConnectIdPermissionConsent(&connection_id, &permission_consent)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>(kAppId_), connection_id); + + std::vector<policy::FunctionalGroupPermission>::const_iterator it = + permission_consent.group_permissions.begin(); + for (; it != permission_consent.group_permissions.end(); ++it) { + EXPECT_EQ(999, (*it).group_id); + EXPECT_EQ("test_group_alias", (*it).group_alias); + EXPECT_EQ(policy::kGroupAllowed, (*it).state); + } + EXPECT_EQ("test_content_source", permission_consent.consent_source); +} + +TEST_F(HMICommandsNotificationsTest, + OnAppPermissionConsentNotificationPolicyHandlerAppIdAllowFalse) { + MessageSharedPtr message = CreateMessage(smart_objects::SmartType_Map); + (*message)[am::strings::msg_params]["consentedFunctions"] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; + (*message)[am::strings::msg_params]["source"] = "test_content_source"; + + smart_objects::SmartObjectSPtr consented_function = + utils::MakeShared<smart_objects::SmartObject>(); + (*consented_function)["allowed"] = false; + (*consented_function)[am::strings::id] = 999; + (*consented_function)[am::strings::name] = "test_group_alias"; + (*message)[am::strings::msg_params]["consentedFunctions"][0] = + *consented_function; + + utils::SharedPtr<Command> command = + CreateCommand<OnAppPermissionConsentNotification>(message); + + int32_t connection_id = -1; + policy::PermissionConsent permission_consent; +#ifdef EXTERNAL_PROPRIETARY_MODE + EXPECT_CALL(mock_policy_handler_, OnAppPermissionConsent(_, _, _)) +#else + EXPECT_CALL(mock_policy_handler_, OnAppPermissionConsent(_, _)) +#endif + .WillOnce( + GetConnectIdPermissionConsent(&connection_id, &permission_consent)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>(kAppId_), connection_id); + + std::vector<policy::FunctionalGroupPermission>::const_iterator it = + permission_consent.group_permissions.begin(); + for (; it != permission_consent.group_permissions.end(); ++it) { + EXPECT_EQ(999, (*it).group_id); + EXPECT_EQ("test_group_alias", (*it).group_alias); + EXPECT_EQ(policy::kGroupDisallowed, (*it).state); + } + EXPECT_EQ("test_content_source", permission_consent.consent_source); +} + +TEST_F(HMICommandsNotificationsTest, + OnSystemErrorNotificationOnSystemErrorCode) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::hmi_notification::error] = + hmi_apis::Common_SystemError::SYNC_REBOOTED; + + utils::SharedPtr<Command> command = + CreateCommand<OnSystemErrorNotification>(message); + + int32_t code = hmi_apis::Common_SystemError::INVALID_ENUM; + EXPECT_CALL(mock_policy_handler_, OnSystemError(_)).WillOnce(GetArg(&code)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>(hmi_apis::Common_SystemError::SYNC_REBOOTED), + code); +} + +TEST_F(HMICommandsNotificationsTest, + OnSystemInfoChangedNotificationCheckLanguage) { + const uint32_t kLangCode = 5u; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::language] = kLangCode; + + utils::SharedPtr<Command> command = + CreateCommand<OnSystemInfoChangedNotification>(message); + + EXPECT_CALL(mock_message_helper_, CommonLanguageToString(_)); + EXPECT_CALL(mock_policy_handler_, OnSystemInfoChanged(_)); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnAllowSDLFunctionalityNotificationDeviceKeyNotExist) { + const std::string kDeviceId = ""; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::hmi_response::allowed] = true; + utils::SharedPtr<Command> command = + CreateCommand<OnAllowSDLFunctionalityNotification>(message); + + bool value = false; + std::string str; + EXPECT_CALL(mock_policy_handler_, OnAllowSDLFunctionalityNotification(_, _)) + .WillOnce(GetBoolValueAndString(&value, &str)); + command->Run(); + EXPECT_EQ(true, value); + EXPECT_EQ(kDeviceId, str); +} + +TEST_F(HMICommandsNotificationsTest, + OnAllowSDLFunctionalityNotificationDeviceKeyExist) { + const std::string kDeviceId = "device_id"; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::hmi_response::allowed] = true; + (*message)[am::strings::msg_params]["device"]["id"] = kDeviceId; + utils::SharedPtr<Command> command = + CreateCommand<OnAllowSDLFunctionalityNotification>(message); + + bool value; + std::string str; + EXPECT_CALL(mock_policy_handler_, OnAllowSDLFunctionalityNotification(_, _)) + .WillOnce(GetBoolValueAndString(&value, &str)); + command->Run(); + EXPECT_EQ(true, value); + EXPECT_EQ(kDeviceId, str); +} + +TEST_F(HMICommandsNotificationsTest, + OnDeviceStateChangedNotificationDeviceStateNotUnpaired) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params]["deviceState"] = + hmi_apis::Common_DeviceState::INVALID_ENUM; + utils::SharedPtr<Command> command = + CreateCommand<OnDeviceStateChangedNotification>(message); + + EXPECT_CALL(mock_policy_handler_, RemoveDevice(_)).Times(0); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnDeviceStateChangedNotificationDeviceStateUnpaired) { + // Random MAC adress for test. It must contain 12 symbols. + const std::string device_id = "AA15F2204D6B"; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params]["deviceState"] = + hmi_apis::Common_DeviceState::UNPAIRED; + (*message)[am::strings::msg_params]["deviceInternalId"] = device_id; + + utils::SharedPtr<Command> command = + CreateCommand<OnDeviceStateChangedNotification>(message); + + EXPECT_CALL(mock_policy_handler_, RemoveDevice(_)); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnDeviceStateChangedNotificationDeviceStateEmptyDeviceId) { + const std::string empty_device_id = ""; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params]["deviceState"] = + hmi_apis::Common_DeviceState::UNPAIRED; + (*message)[am::strings::msg_params]["deviceInternalId"] = empty_device_id; + + utils::SharedPtr<Command> command = + CreateCommand<OnDeviceStateChangedNotification>(message); + + std::string device_id = "default_id"; + EXPECT_CALL(mock_policy_handler_, RemoveDevice(_)) + .WillOnce(GetArg(&device_id)); + command->Run(); + EXPECT_EQ(empty_device_id, device_id); +} + +TEST_F(HMICommandsNotificationsTest, + OnDeviceStateChangedNotificationDeviceStateDeviceIdFromId) { + const std::string empty_device_id = ""; + const std::string id = "id_string"; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params]["deviceState"] = + hmi_apis::Common_DeviceState::UNPAIRED; + (*message)[am::strings::msg_params]["deviceInternalId"] = empty_device_id; + (*message)[am::strings::msg_params]["deviceId"]["id"] = id; + + utils::SharedPtr<Command> command = + CreateCommand<OnDeviceStateChangedNotification>(message); + + std::string device_id = "default_id"; + EXPECT_CALL(mock_policy_handler_, RemoveDevice(_)) + .WillOnce(GetArg(&device_id)); + command->Run(); + EXPECT_EQ(id, device_id); +} + +//~policy_handler +TEST_F(HMICommandsNotificationsTest, + OnExitAllApplicationsNotificationReasonIgnitionOff) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::hmi_request::reason] = + hmi_apis::Common_ApplicationsCloseReason::IGNITION_OFF; + + utils::SharedPtr<Command> command = + CreateCommand<OnExitAllApplicationsNotification>(message); +#if defined(OS_POSIX) + am::mobile_api::AppInterfaceUnregisteredReason::eType mob_reason; + + EXPECT_CALL(app_mngr_, SetUnregisterAllApplicationsReason(_)) + .WillOnce(GetArg(&mob_reason)); + EXPECT_CALL(app_mngr_, HeadUnitReset(_)).Times(0); + + SubscribeForSignal(); + command->Run(); + utils::WaitTerminationSignals(sig_handler); + + EXPECT_EQ(am::mobile_api::AppInterfaceUnregisteredReason::IGNITION_OFF, + mob_reason); +#endif +} + +TEST_F(HMICommandsNotificationsTest, + OnExitAllApplicationsNotificationReasonMasterResetAndFactoryDefaults) { + MessageSharedPtr message = CreateMessage(); + + std::vector<hmi_apis::Common_ApplicationsCloseReason::eType> reason_list; + reason_list.push_back(hmi_apis::Common_ApplicationsCloseReason::MASTER_RESET); + reason_list.push_back( + hmi_apis::Common_ApplicationsCloseReason::FACTORY_DEFAULTS); + + std::vector<mobile_apis::AppInterfaceUnregisteredReason::eType> + mob_reason_list; + mob_reason_list.push_back( + mobile_apis::AppInterfaceUnregisteredReason::MASTER_RESET); + mob_reason_list.push_back( + mobile_apis::AppInterfaceUnregisteredReason::FACTORY_DEFAULTS); + + std::vector<hmi_apis::Common_ApplicationsCloseReason::eType>::iterator + it_reason = reason_list.begin(); + std::vector<mobile_apis::AppInterfaceUnregisteredReason::eType>::iterator + it_mob_reason = mob_reason_list.begin(); + + for (; it_reason != reason_list.end(); ++it_reason, ++it_mob_reason) { + (*message)[am::strings::msg_params][am::hmi_request::reason] = *it_reason; + + utils::SharedPtr<Command> command = + CreateCommand<OnExitAllApplicationsNotification>(message); +#if defined(OS_POSIX) + am::mobile_api::AppInterfaceUnregisteredReason::eType mob_reason = + *it_mob_reason; + + EXPECT_CALL(app_mngr_, SetUnregisterAllApplicationsReason(mob_reason)); + EXPECT_CALL(app_mngr_, HeadUnitReset(mob_reason)); + + SubscribeForSignal(); + command->Run(); + utils::WaitTerminationSignals(sig_handler); +#endif + } +} + +TEST_F(HMICommandsNotificationsTest, + OnExitAllApplicationsNotificationReasonSuspend) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::hmi_request::reason] = + hmi_apis::Common_ApplicationsCloseReason::SUSPEND; + + utils::SharedPtr<Command> command = + CreateCommand<OnExitAllApplicationsNotification>(message); + + MessageSharedPtr ethalon_message = + CreateMessage(smart_objects::SmartType_Map); + (*ethalon_message)[am::strings::params][am::strings::function_id] = + hmi_apis::FunctionID::BasicCommunication_OnSDLPersistenceComplete; + (*ethalon_message)[am::strings::params][am::strings::message_type] = + am::MessageType::kNotification; + (*ethalon_message)[am::strings::params][am::strings::correlation_id] = + kCorrelationId_; + MessageSharedPtr temp_message = CreateMessage(); + + resumprion_test::MockResumeCtrl mock_resume_ctrl; + EXPECT_CALL(app_mngr_, resume_controller()) + .WillOnce(ReturnRef(mock_resume_ctrl)); + EXPECT_CALL(mock_resume_ctrl, OnSuspend()); + + EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillOnce(Return(kCorrelationId_)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillOnce(GetMessage(temp_message)); + + command->Run(); + EXPECT_EQ( + static_cast<uint32_t>( + hmi_apis::FunctionID::BasicCommunication_OnSDLPersistenceComplete), + (*temp_message)[am::strings::params][am::strings::function_id].asInt()); + EXPECT_EQ( + static_cast<uint32_t>(am::MessageType::kNotification), + (*temp_message)[am::strings::params][am::strings::message_type].asInt()); + EXPECT_EQ(static_cast<uint32_t>(kCorrelationId_), + (*temp_message)[am::strings::params][am::strings::correlation_id] + .asInt()); +} + +TEST_F(HMICommandsNotificationsTest, + OnExitAllApplicationsNotificationReasonInvalidEnum) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::hmi_request::reason] = + hmi_apis::Common_ApplicationsCloseReason::INVALID_ENUM; + + utils::SharedPtr<Command> command = + CreateCommand<OnExitAllApplicationsNotification>(message); + + EXPECT_CALL(app_mngr_, SetUnregisterAllApplicationsReason(_)).Times(0); + EXPECT_CALL(app_mngr_, HeadUnitReset(_)).Times(0); + EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnExitApplicationNotificationManageMobileCommand) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; + smart_objects::SmartObjectSPtr notification = + utils::MakeShared<smart_objects::SmartObject>(); + (*notification)[am::strings::params][am::strings::function_id] = + static_cast<int32_t>( + mobile_apis::FunctionID::OnAppInterfaceUnregisteredID); + (*notification)[am::strings::params][am::strings::message_type] = + static_cast<int32_t>(am::MessageType::kNotification); + (*notification)[am::strings::params][am::strings::connection_key] = kAppId_; + + std::vector<hmi_apis::Common_ApplicationExitReason::eType> reason_list; + reason_list.push_back(hmi_apis::Common_ApplicationExitReason:: + UNAUTHORIZED_TRANSPORT_REGISTRATION); + reason_list.push_back( + hmi_apis::Common_ApplicationExitReason::UNSUPPORTED_HMI_RESOURCE); + + std::vector<mobile_apis::AppInterfaceUnregisteredReason::eType> + mobile_reason_list; + mobile_reason_list.push_back( + mobile_apis::AppInterfaceUnregisteredReason::APP_UNAUTHORIZED); + mobile_reason_list.push_back( + mobile_apis::AppInterfaceUnregisteredReason::UNSUPPORTED_HMI_RESOURCE); + + std::vector<mobile_apis::AppInterfaceUnregisteredReason::eType>::iterator + it_mobile_reason = mobile_reason_list.begin(); + std::vector<hmi_apis::Common_ApplicationExitReason::eType>::iterator + it_reason = reason_list.begin(); + + for (; it_reason != reason_list.end(); ++it_reason, ++it_mobile_reason) { + (*message)[am::strings::msg_params][am::strings::reason] = *it_reason; + utils::SharedPtr<Command> command = + CreateCommand<OnExitApplicationNotification>(message); + + (*notification)[am::strings::msg_params][am::strings::reason] = + static_cast<int32_t>(*it_mobile_reason); + + am::plugin_manager::MockRPCPluginManager mock_rpc_plugin_manager_; + EXPECT_CALL(app_mngr_, GetPluginManager()) + .WillRepeatedly(ReturnRef(mock_rpc_plugin_manager_)); + + EXPECT_CALL(app_mngr_, application(kAppId_)).WillRepeatedly(Return(app_)); + EXPECT_CALL(mock_message_helper_, + GetOnAppInterfaceUnregisteredNotificationToMobile( + kAppId_, *it_mobile_reason)).WillOnce(Return(notification)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(notification, Command::SOURCE_SDL)); + EXPECT_CALL(app_mngr_, + UnregisterApplication( + kAppId_, mobile_apis::Result::SUCCESS, false, false)); + command->Run(); + } +} + +TEST_F(HMICommandsNotificationsTest, + OnExitApplicationNotificationUnhandledReason) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; + + (*message)[am::strings::msg_params][am::strings::reason] = + hmi_apis::Common_ApplicationExitReason::INVALID_ENUM; + + utils::SharedPtr<Command> command = + CreateCommand<OnExitApplicationNotification>(message); + + am::plugin_manager::MockRPCPluginManager mock_rpc_plugin_manager_; + + EXPECT_CALL(app_mngr_, application(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + EXPECT_CALL(app_mngr_, UnregisterApplication(_, _, _, _)).Times(0); + EXPECT_CALL(app_mngr_, state_controller()).Times(0); + EXPECT_CALL(app_mngr_, application(kAppId_)).WillOnce(Return(app_)); + EXPECT_CALL(app_mngr_, GetPluginManager()) + .WillOnce(ReturnRef(mock_rpc_plugin_manager_)); + EXPECT_CALL(mock_rpc_plugin_manager_, ForEachPlugin(_)).Times(1); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, OnExitApplicationNotificationInvalidApp) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; + + utils::SharedPtr<Command> command = + CreateCommand<OnExitApplicationNotification>(message); + + am::ApplicationSharedPtr invalid_app; + EXPECT_CALL(app_mngr_, application(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + EXPECT_CALL(app_mngr_, UnregisterApplication(_, _, _, _)).Times(0); + EXPECT_CALL(app_mngr_, state_controller()).Times(0); + EXPECT_CALL(app_mngr_, application(kAppId_)).WillOnce(Return(invalid_app)); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + DISABLED_OnExitApplicationNotificationDriverDistractionValidApp) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; + (*message)[am::strings::msg_params][am::strings::reason] = + hmi_apis::Common_ApplicationExitReason::DRIVER_DISTRACTION_VIOLATION; + utils::SharedPtr<Command> command = + CreateCommand<OnExitApplicationNotification>(message); + + EXPECT_CALL(app_mngr_, application(kAppId_)).WillRepeatedly(Return(app_)); + + EXPECT_CALL(app_mngr_, state_controller()) + .WillOnce(ReturnRef(mock_state_controller_)); + EXPECT_CALL(mock_state_controller_, + SetRegularState(app_, + mobile_apis::HMILevel::HMI_NONE, + mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, + false)); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnExitApplicationNotificationrUserExitValidApp) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; + (*message)[am::strings::msg_params][am::strings::reason] = + hmi_apis::Common_ApplicationExitReason::USER_EXIT; + utils::SharedPtr<Command> command = + CreateCommand<OnExitApplicationNotification>(message); + am::plugin_manager::MockRPCPluginManager mock_rpc_plugin_manager_; + EXPECT_CALL(app_mngr_, GetPluginManager()) + .WillOnce(ReturnRef(mock_rpc_plugin_manager_)); + EXPECT_CALL(mock_rpc_plugin_manager_, ForEachPlugin(_)).Times(1); + EXPECT_CALL(app_mngr_, application(kAppId_)).WillRepeatedly(Return(app_)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + EXPECT_CALL(app_mngr_, UnregisterApplication(_, _, _, _)).Times(0); + EXPECT_CALL(app_mngr_, state_controller()) + .WillOnce(ReturnRef(mock_state_controller_)); + EXPECT_CALL(mock_state_controller_, + SetRegularState(app_, + mobile_apis::HMILevel::HMI_NONE, + mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, + false)); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnVRCommandNotificationSwitchedAndValidApp) { + const uint32_t cmd_id = 12u; + const uint32_t max_cmd_id = 10u; + + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::cmd_id] = cmd_id; + utils::SharedPtr<Command> command = + CreateCommand<OnVRCommandNotification>(message); + + EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_)); + EXPECT_CALL(app_mngr_, state_controller()) + .WillOnce(ReturnRef(mock_state_controller_)); + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, mobile_apis::HMILevel::HMI_FULL, true)); + + EXPECT_CALL(app_mngr_, get_settings()) + .WillOnce(ReturnRef(app_mngr_settings_)); + EXPECT_CALL(app_mngr_settings_, max_cmd_id()).WillOnce(ReturnRef(max_cmd_id)); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnVRCommandNotificationSwitchedAndInvalidApp) { + const uint32_t kCmdId = 12u; + const uint32_t kMaxCmdId = 10u; + + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::cmd_id] = kCmdId; + utils::SharedPtr<Command> command = + CreateCommand<OnVRCommandNotification>(message); + + am::ApplicationSharedPtr invalid_app; + EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(invalid_app)); + EXPECT_CALL(app_mngr_, state_controller()).Times(0); + EXPECT_CALL(app_mngr_, get_settings()) + .WillOnce(ReturnRef(app_mngr_settings_)); + EXPECT_CALL(app_mngr_settings_, max_cmd_id()).WillOnce(ReturnRef(kMaxCmdId)); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnVRCommandNotificationCmdIdEqualToMaxCmdId) { + const uint32_t kCmdId = 11u; + const uint32_t kMaxCmdId = 10u; + + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::cmd_id] = kCmdId; + utils::SharedPtr<Command> command = + CreateCommand<OnVRCommandNotification>(message); + + EXPECT_CALL(app_mngr_, application(_)).Times(0); + EXPECT_CALL(app_mngr_settings_, max_cmd_id()).WillOnce(ReturnRef(kMaxCmdId)); + EXPECT_CALL(app_mngr_, get_settings()) + .WillOnce(ReturnRef(app_mngr_settings_)); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnVRCommandNotificationCmdIdLessMaxCmdIsInvalidApp) { + const uint32_t kCmdId = 8u; + const uint32_t kMaxCmdId = 10u; + + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::cmd_id] = kCmdId; + utils::SharedPtr<Command> command = + CreateCommand<OnVRCommandNotification>(message); + + am::ApplicationSharedPtr invalid_app; + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app)); + EXPECT_CALL(app_mngr_settings_, max_cmd_id()).WillOnce(ReturnRef(kMaxCmdId)); + EXPECT_CALL(app_mngr_, get_settings()) + .WillOnce(ReturnRef(app_mngr_settings_)); + EXPECT_CALL(app_mngr_, event_dispatcher()).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnVRCommandNotificationActivePerformIteraction) { + const uint32_t kCmdId = 8u; + const uint32_t kMaxCmdId = 10u; + const uint32_t kIsPerformInteractionActive = 1u; + int32_t event_id = hmi_apis::FunctionID::INVALID_ENUM; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::cmd_id] = kCmdId; + utils::SharedPtr<Command> command = + CreateCommand<OnVRCommandNotification>(message); + + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_)); + EXPECT_CALL(app_mngr_settings_, max_cmd_id()).WillOnce(ReturnRef(kMaxCmdId)); + EXPECT_CALL(app_mngr_, get_settings()) + .WillOnce(ReturnRef(app_mngr_settings_)); + EXPECT_CALL(*app_ptr_, is_perform_interaction_active()) + .WillOnce(Return(kIsPerformInteractionActive)); + EXPECT_CALL(app_mngr_, event_dispatcher()); + EXPECT_CALL(mock_event_dispatcher_, raise_event(_)) + .WillOnce(GetEventId(&event_id)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + command->Run(); + EXPECT_EQ(hmi_apis::FunctionID::VR_OnCommand, event_id); +} + +TEST_F(HMICommandsNotificationsTest, + OnVRCommandNotificationNotActivePerformIteraction) { + const uint32_t kCmdId = 8u; + const uint32_t kMaxCmdId = 10u; + const uint32_t kIsPerformInteractionActive = 0u; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::cmd_id] = kCmdId; + (*message)[am::strings::msg_params][am::strings::function_id] = + mobile_apis::FunctionID::eType::OnCommandID; + utils::SharedPtr<Command> command = + CreateCommand<OnVRCommandNotification>(message); + + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_)); + EXPECT_CALL(app_mngr_settings_, max_cmd_id()).WillOnce(ReturnRef(kMaxCmdId)); + EXPECT_CALL(app_mngr_, get_settings()) + .WillOnce(ReturnRef(app_mngr_settings_)); + EXPECT_CALL(*app_ptr_, is_perform_interaction_active()) + .WillOnce(Return(kIsPerformInteractionActive)); + + EXPECT_CALL(app_mngr_, event_dispatcher()).Times(0); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::eType::OnCommandID), + (*message)[am::strings::params][am::strings::function_id].asInt()); + EXPECT_EQ( + static_cast<int32_t>(mobile_apis::TriggerSource::TS_VR), + (*message)[am::strings::msg_params][am::strings::trigger_source].asInt()); + EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), + (*message)[am::strings::params][am::strings::message_type].asInt()); +} + +TEST_F(HMICommandsNotificationsTest, OnVRLanguageChangeNotificationEmptyData) { + const mobile_apis::Language::eType& kLang = mobile_apis::Language::EN_GB; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::language] = kLang; + utils::SharedPtr<Command> command = + CreateCommand<OnVRLanguageChangeNotification>(message); + + EXPECT_CALL(mock_hmi_capabilities_, active_ui_language()) + .WillOnce(Return(hmi_apis::Common_Language::EN_AU)); + EXPECT_CALL(mock_hmi_capabilities_, set_active_vr_language(_)); + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + EXPECT_CALL(*app_ptr_, app_id()).Times(0); + EXPECT_CALL(*app_ptr_, language()).Times(0); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnVRLanguageChangeNotificationAppLangEqualMessageLang) { + const mobile_apis::Language::eType& kLang = mobile_apis::Language::EN_GB; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::language] = kLang; + utils::SharedPtr<Command> command = + CreateCommand<OnVRLanguageChangeNotification>(message); + + application_set_.insert(app_); + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); + EXPECT_CALL(mock_hmi_capabilities_, active_ui_language()) + .WillOnce(Return(hmi_apis::Common_Language::EN_AU)); + EXPECT_CALL(mock_hmi_capabilities_, set_active_vr_language(_)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(*app_ptr_, app_id()).WillOnce(Return(kAppId_)); + EXPECT_CALL(*app_ptr_, language()).WillRepeatedly(ReturnRef(kLang)); + + command->Run(); + EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID), + (*message)[am::strings::params][am::strings::function_id].asInt()); + EXPECT_EQ( + static_cast<int32_t>(kAppId_), + (*message)[am::strings::params][am::strings::connection_key].asInt()); + EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), + (*message)[am::strings::params][am::strings::message_type].asInt()); + EXPECT_EQ( + static_cast<int32_t>(hmi_apis::Common_Language::EN_AU), + (*message)[am::strings::msg_params][am::strings::hmi_display_language] + .asInt()); +} + +TEST_F(HMICommandsNotificationsTest, + OnVRLanguageChangeNotificationAppLangNotEqualMessageLang) { + const mobile_apis::Language::eType& kLang = mobile_apis::Language::EN_GB; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::language] = + mobile_apis::Language::EN_US; + utils::SharedPtr<Command> command = + CreateCommand<OnVRLanguageChangeNotification>(message); + + application_set_.insert(app_); + smart_objects::SmartObjectSPtr notification = + utils::MakeShared<smart_objects::SmartObject>(); + (*notification)[am::strings::params][am::strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID); + (*notification)[am::strings::params][am::strings::message_type] = + static_cast<int32_t>(am::MessageType::kNotification); + (*notification)[am::strings::params][am::strings::connection_key] = kAppId_; + (*notification)[am::strings::msg_params][am::strings::reason] = + static_cast<int32_t>( + mobile_apis::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE); + + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); + EXPECT_CALL(mock_hmi_capabilities_, active_ui_language()) + .WillOnce(Return(hmi_apis::Common_Language::EN_AU)); + EXPECT_CALL(mock_hmi_capabilities_, set_active_vr_language(_)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(*app_ptr_, app_id()).WillRepeatedly(Return(kAppId_)); + EXPECT_CALL(*app_ptr_, language()).WillRepeatedly(ReturnRef(kLang)); + EXPECT_CALL(app_mngr_, state_controller()) + .WillOnce(ReturnRef(mock_state_controller_)); + EXPECT_CALL(mock_state_controller_, + SetRegularState(app_, mobile_apis::HMILevel::HMI_NONE, false)); + EXPECT_CALL(mock_message_helper_, + GetOnAppInterfaceUnregisteredNotificationToMobile( + kAppId_, + mobile_apis::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE)) + .WillOnce(Return(notification)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(notification, Command::SOURCE_SDL)); + EXPECT_CALL(app_mngr_, + UnregisterApplication( + kAppId_, mobile_apis::Result::SUCCESS, false, false)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID), + (*message)[am::strings::params][am::strings::function_id].asInt()); + EXPECT_EQ( + static_cast<int32_t>(kAppId_), + (*message)[am::strings::params][am::strings::connection_key].asInt()); + EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), + (*message)[am::strings::params][am::strings::message_type].asInt()); + EXPECT_EQ( + static_cast<int32_t>(hmi_apis::Common_Language::EN_AU), + (*message)[am::strings::msg_params][am::strings::hmi_display_language] + .asInt()); +} + +TEST_F(HMICommandsNotificationsTest, OnStartDeviceDiscoveryRun) { + MessageSharedPtr message = CreateMessage(); + utils::SharedPtr<Command> command = + CreateCommand<OnStartDeviceDiscovery>(message); + EXPECT_CALL(app_mngr_, StartDevicesDiscovery()); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnDeviceChosenNotificationDeviceInfoExists) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::device_info] + [am::strings::id] = "2014"; + utils::SharedPtr<Command> command = + CreateCommand<OnDeviceChosenNotification>(message); + EXPECT_CALL(app_mngr_, + ConnectToDevice( + (*message)[am::strings::msg_params][am::strings::device_info] + [am::strings::id].asString())); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnDeviceChosenNotificationDeviceInfoNotExists) { + MessageSharedPtr message = CreateMessage(); + utils::SharedPtr<Command> command = + CreateCommand<OnDeviceChosenNotification>(message); + EXPECT_CALL(app_mngr_, ConnectToDevice(_)).Times(0); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnSystemContextNotificationValidActiveApplication) { + MessageSharedPtr message = CreateMessage(); + std::vector<am::mobile_api::SystemContext::eType> system_context_list; + system_context_list.push_back( + am::mobile_api::SystemContext::SYSCTXT_VRSESSION); + system_context_list.push_back(am::mobile_api::SystemContext::SYSCTXT_MENU); + system_context_list.push_back( + am::mobile_api::SystemContext::SYSCTXT_HMI_OBSCURED); + + std::vector<am::mobile_api::SystemContext::eType>::iterator it = + system_context_list.begin(); + for (; it != system_context_list.end(); ++it) { + (*message)[am::strings::msg_params][am::hmi_notification::system_context] = + *it; + utils::SharedPtr<Command> command = + CreateCommand<OnSystemContextNotification>(message); + EXPECT_CALL(app_mngr_, active_application()).WillOnce(Return(app_)); + EXPECT_CALL(app_mngr_, state_controller()) + .WillOnce(ReturnRef(mock_state_controller_)); + EXPECT_CALL(mock_state_controller_, SetRegularState(app_, *it)); + command->Run(); + } +} + +TEST_F(HMICommandsNotificationsTest, + OnSystemContextNotificationInvalidActiveApplication) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::hmi_notification::system_context] = + am::mobile_api::SystemContext::SYSCTXT_VRSESSION; + utils::SharedPtr<Command> command = + CreateCommand<OnSystemContextNotification>(message); + ApplicationSharedPtr invalid_app; + EXPECT_CALL(app_mngr_, active_application()).WillOnce(Return(invalid_app)); + EXPECT_CALL(app_mngr_, state_controller()).Times(0); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnSystemContextNotificationInvalidSystemContext) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::hmi_notification::system_context] = + am::mobile_api::SystemContext::INVALID_ENUM; + utils::SharedPtr<Command> command = + CreateCommand<OnSystemContextNotification>(message); + EXPECT_CALL(app_mngr_, active_application()).Times(0); + EXPECT_CALL(app_mngr_, application(_)).Times(0); + EXPECT_CALL(app_mngr_, state_controller()).Times(0); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnSystemContextNotificationValidApplication) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; + std::vector<am::mobile_api::SystemContext::eType> system_context_list; + system_context_list.push_back(am::mobile_api::SystemContext::SYSCTXT_ALERT); + system_context_list.push_back(am::mobile_api::SystemContext::SYSCTXT_MAIN); + + std::vector<am::mobile_api::SystemContext::eType>::iterator it = + system_context_list.begin(); + for (; it != system_context_list.end(); ++it) { + (*message)[am::strings::msg_params][am::hmi_notification::system_context] = + *it; + utils::SharedPtr<Command> command = + CreateCommand<OnSystemContextNotification>(message); + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_)); + EXPECT_CALL(app_mngr_, state_controller()) + .WillOnce(ReturnRef(mock_state_controller_)); + EXPECT_CALL(mock_state_controller_, SetRegularState(app_, *it)); + command->Run(); + } +} + +TEST_F(HMICommandsNotificationsTest, + OnSystemContextNotificationAppIdDoesntExists) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::hmi_notification::system_context] = + am::mobile_api::SystemContext::SYSCTXT_ALERT; + utils::SharedPtr<Command> command = + CreateCommand<OnSystemContextNotification>(message); + EXPECT_CALL(app_mngr_, application(_)).Times(0); + EXPECT_CALL(app_mngr_, state_controller()).Times(0); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnSystemRequestNotificationAppIdExistsAndValidApp) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; + utils::SharedPtr<Command> command = + CreateCommand<OnSystemRequestNotification>(message); + + EXPECT_CALL(app_mngr_, application(kAppId_)).WillOnce(Return(app_)); + ON_CALL(app_mngr_, connection_handler()) + .WillByDefault(ReturnRef(mock_connection_handler_)); + ON_CALL(mock_connection_handler_, get_session_observer()) + .WillByDefault(ReturnRef(mock_session_observer_)); + const int32_t device_id = 1; + ON_CALL( + mock_session_observer_, + GetDataOnDeviceID( + testing::An<transport_manager::DeviceHandle>(), NULL, NULL, _, NULL)) + .WillByDefault(Return(device_id)); + + EXPECT_CALL(mock_policy_handler_, GetUserConsentForDevice(_)) + .WillOnce(Return(policy::kDeviceAllowed)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), + (*message)[am::strings::params][am::strings::message_type].asInt()); + EXPECT_EQ( + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnSystemRequestID), + (*message)[am::strings::params][am::strings::function_id].asInt()); + EXPECT_EQ( + static_cast<int32_t>(kAppId_), + (*message)[am::strings::params][am::strings::connection_key].asInt()); +} + +TEST_F(HMICommandsNotificationsTest, + OnSystemRequestNotificationAppIdExistsAndInvalidApp) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; + utils::SharedPtr<Command> command = + CreateCommand<OnSystemRequestNotification>(message); + ApplicationSharedPtr invalid_app; + EXPECT_CALL(app_mngr_, application(kAppId_)).WillOnce(Return(invalid_app)); + EXPECT_CALL(*app_ptr_, app_id()).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + command->Run(); + EXPECT_EQ( + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnSystemRequestID), + (*message)[am::strings::params][am::strings::function_id].asInt()); +} + +TEST_F(HMICommandsNotificationsTest, + OnSystemRequestNotificationAppIdDoesntExistsAndValidApp) { + MessageSharedPtr message = CreateMessage(); + utils::SharedPtr<Command> command = + CreateCommand<OnSystemRequestNotification>(message); + + EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) + .WillOnce(Return(kAppId_)); + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_)); + ON_CALL(app_mngr_, connection_handler()) + .WillByDefault(ReturnRef(mock_connection_handler_)); + ON_CALL(mock_connection_handler_, get_session_observer()) + .WillByDefault(ReturnRef(mock_session_observer_)); + const int32_t device_id = 1; + ON_CALL( + mock_session_observer_, + GetDataOnDeviceID( + testing::An<transport_manager::DeviceHandle>(), NULL, NULL, _, NULL)) + .WillByDefault(Return(device_id)); + + EXPECT_CALL(mock_policy_handler_, GetUserConsentForDevice(_)) + .WillOnce(Return(policy::kDeviceAllowed)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), + (*message)[am::strings::params][am::strings::message_type].asInt()); + EXPECT_EQ( + static_cast<int32_t>(mobile_apis::FunctionID::eType::OnSystemRequestID), + (*message)[am::strings::params][am::strings::function_id].asInt()); + EXPECT_EQ( + static_cast<int32_t>(kAppId_), + (*message)[am::strings::params][am::strings::connection_key].asInt()); +} + +TEST_F(HMICommandsNotificationsTest, + OnSystemRequestNotificationAppIdDoesntExistsAndNullAppId) { + const uint32_t kNullApppId = 0u; + MessageSharedPtr message = CreateMessage(); + utils::SharedPtr<Command> command = + CreateCommand<OnSystemRequestNotification>(message); + + EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) + .WillOnce(Return(kNullApppId)); + EXPECT_CALL(app_mngr_, application(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, OnTTSLanguageChangeNotificationEmptyData) { + const mobile_apis::Language::eType& kLang = mobile_apis::Language::EN_GB; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::language] = kLang; + utils::SharedPtr<Command> command = + CreateCommand<OnTTSLanguageChangeNotification>(message); + + EXPECT_CALL(mock_hmi_capabilities_, set_active_tts_language(_)); + EXPECT_CALL(mock_hmi_capabilities_, set_active_vr_language(_)); + EXPECT_CALL(mock_hmi_capabilities_, active_ui_language()) + .WillOnce(Return(hmi_apis::Common_Language::EN_AU)); + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + EXPECT_CALL(*app_ptr_, app_id()).Times(0); + EXPECT_CALL(*app_ptr_, language()).Times(0); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnTTSLanguageChangeNotificationAppLangEqualMessageLang) { + const mobile_apis::Language::eType& kLang = mobile_apis::Language::EN_GB; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::language] = kLang; + utils::SharedPtr<Command> command = + CreateCommand<OnTTSLanguageChangeNotification>(message); + + application_set_.insert(app_); + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); + EXPECT_CALL(mock_hmi_capabilities_, active_ui_language()) + .WillOnce(Return(hmi_apis::Common_Language::EN_AU)); + EXPECT_CALL(mock_hmi_capabilities_, set_active_vr_language(_)); + EXPECT_CALL(mock_hmi_capabilities_, set_active_tts_language(_)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(*app_ptr_, app_id()).WillOnce(Return(kAppId_)); + EXPECT_CALL(*app_ptr_, language()).WillRepeatedly(ReturnRef(kLang)); + + command->Run(); + EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID), + (*message)[am::strings::params][am::strings::function_id].asInt()); + EXPECT_EQ( + static_cast<int32_t>(kAppId_), + (*message)[am::strings::params][am::strings::connection_key].asInt()); + EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), + (*message)[am::strings::params][am::strings::message_type].asInt()); + EXPECT_EQ( + static_cast<int32_t>(hmi_apis::Common_Language::EN_AU), + (*message)[am::strings::msg_params][am::strings::hmi_display_language] + .asInt()); +} + +TEST_F(HMICommandsNotificationsTest, + OnTTSLanguageChangeNotificationAppLangNotEqualMessageLang) { + const mobile_apis::Language::eType& kLang = mobile_apis::Language::EN_GB; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::language] = + mobile_apis::Language::EN_US; + utils::SharedPtr<Command> command = + CreateCommand<OnTTSLanguageChangeNotification>(message); + + application_set_.insert(app_); + smart_objects::SmartObjectSPtr notification = + utils::MakeShared<smart_objects::SmartObject>(); + (*notification)[am::strings::params][am::strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID); + (*notification)[am::strings::params][am::strings::message_type] = + static_cast<int32_t>(am::MessageType::kNotification); + (*notification)[am::strings::params][am::strings::connection_key] = kAppId_; + (*notification)[am::strings::msg_params][am::strings::reason] = + static_cast<int32_t>( + mobile_apis::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE); + + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); + EXPECT_CALL(mock_hmi_capabilities_, active_ui_language()) + .WillOnce(Return(hmi_apis::Common_Language::EN_AU)); + EXPECT_CALL(mock_hmi_capabilities_, set_active_vr_language(_)); + EXPECT_CALL(mock_hmi_capabilities_, set_active_tts_language(_)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(*app_ptr_, app_id()).WillRepeatedly(Return(kAppId_)); + EXPECT_CALL(*app_ptr_, language()).WillRepeatedly(ReturnRef(kLang)); + EXPECT_CALL(mock_message_helper_, + GetOnAppInterfaceUnregisteredNotificationToMobile( + kAppId_, + mobile_apis::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE)) + .WillOnce(Return(notification)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(notification, Command::SOURCE_SDL)); + EXPECT_CALL(app_mngr_, + UnregisterApplication( + kAppId_, mobile_apis::Result::SUCCESS, false, false)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID), + (*message)[am::strings::params][am::strings::function_id].asInt()); + EXPECT_EQ( + static_cast<int32_t>(kAppId_), + (*message)[am::strings::params][am::strings::connection_key].asInt()); + EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), + (*message)[am::strings::params][am::strings::message_type].asInt()); + EXPECT_EQ( + static_cast<int32_t>(hmi_apis::Common_Language::EN_AU), + (*message)[am::strings::msg_params][am::strings::hmi_display_language] + .asInt()); +} + +TEST_F(HMICommandsNotificationsTest, OnUILanguageChangeNotificationEmptyData) { + const mobile_apis::Language::eType& kLang = mobile_apis::Language::EN_GB; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::language] = kLang; + utils::SharedPtr<Command> command = + CreateCommand<OnUILanguageChangeNotification>(message); + + EXPECT_CALL(mock_hmi_capabilities_, set_active_ui_language(_)); + EXPECT_CALL(mock_hmi_capabilities_, active_vr_language()) + .WillOnce(Return(hmi_apis::Common_Language::EN_AU)); + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + EXPECT_CALL(*app_ptr_, app_id()).Times(0); + EXPECT_CALL(*app_ptr_, ui_language()).Times(0); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnUILanguageChangeNotificationAppLangEqualMessageLang) { + const mobile_apis::Language::eType& kLang = mobile_apis::Language::EN_GB; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::language] = kLang; + utils::SharedPtr<Command> command = + CreateCommand<OnUILanguageChangeNotification>(message); + + application_set_.insert(app_); + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); + EXPECT_CALL(mock_hmi_capabilities_, active_vr_language()) + .WillOnce(Return(hmi_apis::Common_Language::EN_AU)); + EXPECT_CALL(mock_hmi_capabilities_, set_active_ui_language(_)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(*app_ptr_, app_id()).WillOnce(Return(kAppId_)); + EXPECT_CALL(*app_ptr_, ui_language()).WillRepeatedly(ReturnRef(kLang)); + + command->Run(); + EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID), + (*message)[am::strings::params][am::strings::function_id].asInt()); + EXPECT_EQ( + static_cast<int32_t>(kAppId_), + (*message)[am::strings::params][am::strings::connection_key].asInt()); + EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), + (*message)[am::strings::params][am::strings::message_type].asInt()); + EXPECT_EQ( + static_cast<int32_t>(kLang), + (*message)[am::strings::msg_params][am::strings::hmi_display_language] + .asInt()); +} + +TEST_F(HMICommandsNotificationsTest, + OnUILanguageChangeNotificationAppLangNotEqualMessageLang) { + const mobile_apis::Language::eType& kLang = mobile_apis::Language::EN_GB; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::language] = + mobile_apis::Language::EN_US; + utils::SharedPtr<Command> command = + CreateCommand<OnUILanguageChangeNotification>(message); + + application_set_.insert(app_); + smart_objects::SmartObjectSPtr notification = + utils::MakeShared<smart_objects::SmartObject>(); + (*notification)[am::strings::params][am::strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID); + (*notification)[am::strings::params][am::strings::message_type] = + static_cast<int32_t>(am::MessageType::kNotification); + (*notification)[am::strings::params][am::strings::connection_key] = kAppId_; + (*notification)[am::strings::msg_params][am::strings::reason] = + static_cast<int32_t>( + mobile_apis::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE); + + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); + EXPECT_CALL(mock_hmi_capabilities_, active_vr_language()) + .WillOnce(Return(hmi_apis::Common_Language::EN_AU)); + EXPECT_CALL(mock_hmi_capabilities_, set_active_ui_language(_)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(*app_ptr_, app_id()).WillRepeatedly(Return(kAppId_)); + EXPECT_CALL(*app_ptr_, ui_language()).WillRepeatedly(ReturnRef(kLang)); + EXPECT_CALL(mock_message_helper_, + GetOnAppInterfaceUnregisteredNotificationToMobile( + kAppId_, + mobile_apis::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE)) + .WillOnce(Return(notification)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(notification, Command::SOURCE_SDL)); + EXPECT_CALL(app_mngr_, + UnregisterApplication( + kAppId_, mobile_apis::Result::SUCCESS, false, false)); + command->Run(); + EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID), + (*message)[am::strings::params][am::strings::function_id].asInt()); + EXPECT_EQ( + static_cast<int32_t>(kAppId_), + (*message)[am::strings::params][am::strings::connection_key].asInt()); + EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), + (*message)[am::strings::params][am::strings::message_type].asInt()); + EXPECT_EQ( + static_cast<int32_t>(mobile_apis::Language::EN_US), + (*message)[am::strings::msg_params][am::strings::hmi_display_language] + .asInt()); +} + +TEST_F(HMICommandsNotificationsTest, OnDriverDistractionNotificationEmptyData) { + const hmi_apis::Common_DriverDistractionState::eType state = + hmi_apis::Common_DriverDistractionState::DD_ON; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::hmi_notification::state] = state; + utils::SharedPtr<Command> command = + CreateCommand<hmi::OnDriverDistractionNotification>(message); + + EXPECT_CALL(app_mngr_, set_driver_distraction_state(state)); + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + EXPECT_CALL(*app_ptr_, app_id()).Times(0); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, + OnDriverDistractionNotificationInvalidApp) { + const hmi_apis::Common_DriverDistractionState::eType state = + hmi_apis::Common_DriverDistractionState::DD_ON; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::hmi_notification::state] = state; + utils::SharedPtr<Command> command = + CreateCommand<hmi::OnDriverDistractionNotification>(message); + + ApplicationSharedPtr invalid_app; + application_set_.insert(invalid_app); + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + EXPECT_CALL(*app_ptr_, app_id()).Times(0); + command->Run(); +} + +TEST_F(HMICommandsNotificationsTest, OnDriverDistractionNotificationValidApp) { + const hmi_apis::Common_DriverDistractionState::eType state = + hmi_apis::Common_DriverDistractionState::DD_ON; + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::mobile_notification::state] = state; + utils::SharedPtr<Command> command = + CreateCommand<hmi::OnDriverDistractionNotification>(message); + + application_set_.insert(app_); + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); + policy::CheckPermissionResult result; + result.hmi_level_permitted = policy::kRpcAllowed; + EXPECT_CALL(app_mngr_, GetPolicyHandler()) + .WillOnce(ReturnRef(mock_policy_handler_)); + EXPECT_CALL(mock_policy_handler_, CheckPermissions(_, _, _, _)) + .WillOnce(GetArg3(&result)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)) + .WillOnce(GetMessage(message)); + EXPECT_CALL(*app_ptr_, app_id()).WillRepeatedly(Return(kAppId_)); + + command->Run(); + EXPECT_EQ( + static_cast<int32_t>(am::mobile_api::FunctionID::OnDriverDistractionID), + (*message)[am::strings::params][am::strings::function_id].asInt()); + EXPECT_EQ( + static_cast<int32_t>(kAppId_), + (*message)[am::strings::params][am::strings::connection_key].asInt()); + EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), + (*message)[am::strings::params][am::strings::message_type].asInt()); +} + +} // namespace hmi_notifications_test +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_request_test.cc new file mode 100644 index 0000000000..7759dace96 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_request_test.cc @@ -0,0 +1,91 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/request_to_hmi.h" +#include "hmi/mixing_audio_supported_request.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace mixing_audio_supported_request { + +using ::testing::_; +using ::testing::Return; +using ::utils::SharedPtr; +namespace am = ::application_manager; +namespace strings = ::application_manager::strings; +using am::commands::RequestToHMI; +using sdl_rpc_plugin::commands::MixingAudioSupportedRequest; +using am::commands::CommandImpl; + +typedef SharedPtr<RequestToHMI> RequestToHMIPtr; + +namespace { +const uint32_t kConnectionKey = 2u; +} // namespace + +class MixingAudioSupportedRequestTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(MixingAudioSupportedRequestTest, RUN_SendRequest_SUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[am::strings::msg_params][am::strings::number] = "123"; + (*command_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + RequestToHMIPtr command( + CreateCommand<MixingAudioSupportedRequest>(command_msg)); + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(command_msg)); + + command->Run(); + + EXPECT_EQ((*command_msg)[strings::params][strings::protocol_type].asInt(), + CommandImpl::hmi_protocol_type_); + EXPECT_EQ((*command_msg)[strings::params][strings::protocol_version].asInt(), + CommandImpl::protocol_version_); +} + +} // namespace mixing_audio_supported_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_response_test.cc new file mode 100644 index 0000000000..9c8c30f493 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_response_test.cc @@ -0,0 +1,102 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/command.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/response_from_hmi.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "sdl_rpc_plugin/commands/hmi/mixing_audio_supported_response.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace mixing_audio_supported_response { + +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::NiceMock; +using ::utils::SharedPtr; +namespace am = ::application_manager; +namespace strings = ::application_manager::strings; +using sdl_rpc_plugin::commands::MixingAudioSupportedResponse; +using application_manager::commands::ResponseFromHMI; +using am::commands::CommandImpl; +using am::HMICapabilities; +namespace hmi_response = ::application_manager::hmi_response; + +typedef SharedPtr<ResponseFromHMI> ResponseFromHMIPtr; +typedef NiceMock< + ::test::components::application_manager_test::MockHMICapabilities> + MockHMICapabilities; + +namespace { +const uint32_t kConnectionKey = 2u; +} // namespace + +class MixingAudioSupportedResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(MixingAudioSupportedResponseTest, RUN_SUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[am::strings::msg_params][am::strings::number] = "123"; + (*command_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + ResponseFromHMIPtr command( + CreateCommand<MixingAudioSupportedResponse>(command_msg)); + + const bool hmiResponse = + (*command_msg)[strings::msg_params][hmi_response::attenuated_supported] + .asBool(); + + EXPECT_CALL(mock_hmi_capabilities_, set_attenuated_supported(hmiResponse)); + + command->Run(); +} + +} // namespace mixing_audio_supported_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_audio_start_stream_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_audio_start_stream_request_test.cc new file mode 100644 index 0000000000..69cb04f073 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_audio_start_stream_request_test.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 <utility> + +#include "hmi/navi_audio_start_stream_request.h" + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/hmi_interfaces.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/commands/commands_test.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace navi_audio_start_stream_request { + +using ::testing::_; +using ::testing::ReturnRef; +namespace am = ::application_manager; +namespace commands = am::commands; +using commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::AudioStartStreamRequest; +using am::event_engine::Event; + +namespace { +const uint32_t kHmiAppId = 13u; +const am::HmiInterfaces::InterfaceID kHmiInterface = + am::HmiInterfaces::HMI_INTERFACE_Navigation; +} // namespace + +class AudioStartStreamRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + AudioStartStreamRequestTest() { + ON_CALL(app_mngr_settings_, start_stream_retry_amount()) + .WillByDefault(ReturnRef(start_stream_retry_amount_)); + msg_ = CreateMessage(); + command_ = CreateCommand<AudioStartStreamRequest>(msg_); + } + + std::pair<uint32_t, int32_t> start_stream_retry_amount_; + MessageSharedPtr msg_; + SharedPtr<AudioStartStreamRequest> command_; +}; + +TEST_F(AudioStartStreamRequestTest, Run_HmiInterfaceNotAvailable_NoRequest) { + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(kHmiInterface)) + .WillOnce(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(_)).Times(0); + + command_->Run(); +} + +TEST_F(AudioStartStreamRequestTest, + Run_HmiInterfaceAvailableButNoApp_NoRequest) { + (*msg_)[am::strings::msg_params][am::strings::app_id] = kHmiAppId; + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(kHmiInterface)) + .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL(app_mngr_, application_by_hmi_app(kHmiAppId)) + .WillOnce(Return(ApplicationSharedPtr())); + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(_)).Times(0); + + command_->Run(); +} + +TEST_F(AudioStartStreamRequestTest, Run_HmiInterfaceAvailable_SentRequest) { + (*msg_)[am::strings::msg_params][am::strings::app_id] = kHmiAppId; + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(kHmiInterface)) + .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application_by_hmi_app(kHmiAppId)) + .WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, set_audio_streaming_allowed(true)); + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(msg_)); + + command_->Run(); +} + +} // namespace navi_audio_start_stream_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_request_test.cc new file mode 100644 index 0000000000..49145d1644 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_request_test.cc @@ -0,0 +1,135 @@ +/* + * 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 "hmi/navi_is_ready_request.h" + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/hmi_interfaces.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/commands/commands_test.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace navi_is_ready_request { + +using ::testing::_; +using ::testing::ReturnRef; +namespace am = ::application_manager; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::NaviIsReadyRequest; +using am::event_engine::Event; + +namespace { +const hmi_apis::FunctionID::eType kEventID = + hmi_apis::FunctionID::Navigation_IsReady; +} // namespace + +typedef SharedPtr<NaviIsReadyRequest> NaviIsReadyRequestPtr; + +class NaviIsReadyRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + NaviIsReadyRequestTest() : command_(CreateCommand<NaviIsReadyRequest>()) {} + + NaviIsReadyRequestPtr command_; +}; + +TEST_F(NaviIsReadyRequestTest, + OnEvent_HmiInterfaceIsAvailable_NaviCooperatingIsAvailable) { + const bool is_hmi_interface_available = true; + + MessageSharedPtr event_msg = CreateMessage(); + (*event_msg)[am::strings::msg_params][am::strings::available] = + is_hmi_interface_available; + + Event event(kEventID); + event.set_smart_object(*event_msg); + + EXPECT_CALL(mock_hmi_interfaces_, + SetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation, + am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL(mock_hmi_capabilities_, + set_is_navi_cooperating(is_hmi_interface_available)); + + command_->on_event(event); +} + +TEST_F(NaviIsReadyRequestTest, + OnEvent_HmiInterfaceIsNotAvailable_NaviCooperatingIsNotAvailable) { + const bool is_hmi_interface_available = false; + + MessageSharedPtr event_msg = CreateMessage(); + (*event_msg)[am::strings::msg_params][am::strings::available] = + is_hmi_interface_available; + + Event event(kEventID); + event.set_smart_object(*event_msg); + + EXPECT_CALL(mock_hmi_interfaces_, + SetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation, + am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + EXPECT_CALL(mock_hmi_capabilities_, + set_is_navi_cooperating(is_hmi_interface_available)); + + command_->on_event(event); +} + +TEST_F(NaviIsReadyRequestTest, + OnEvent_AvailabilityFieldMissing_NaviCooperatingIsNotAvailable) { + const bool is_hmi_interface_available = false; + + MessageSharedPtr event_msg = CreateMessage(); + Event event(kEventID); + event.set_smart_object(*event_msg); + + EXPECT_CALL(mock_hmi_capabilities_, + set_is_navi_cooperating(is_hmi_interface_available)); + + command_->on_event(event); +} + +} // namespace navi_is_ready_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_response_test.cc new file mode 100644 index 0000000000..3bcea20be7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_response_test.cc @@ -0,0 +1,76 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_event_dispatcher.h" +#include "hmi/navi_is_ready_response.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace navi_is_ready_responce { + +namespace am = ::application_manager; +namespace commands = sdl_rpc_plugin::commands; + +using ::testing::ReturnRef; +using ::utils::SharedPtr; +using application_manager::commands::ResponseFromHMI; +using test::components::event_engine_test::MockEventDispatcher; + +typedef SharedPtr<ResponseFromHMI> ResponseFromHMIPtr; + +class NaviIsReadyResponseTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(NaviIsReadyResponseTest, NaviIsReadyResponse_Run_SUCCESS) { + ResponseFromHMIPtr command(CreateCommand<commands::NaviIsReadyResponse>()); + MockEventDispatcher mock_event_dispatcher; + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher)); + EXPECT_CALL(mock_event_dispatcher, raise_event(_)); + command->Run(); +} + +} // namespace navi_is_ready_responce +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_request_test.cc new file mode 100644 index 0000000000..c7287c024a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_request_test.cc @@ -0,0 +1,216 @@ +/* + * 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 names of the copyright holders nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <algorithm> + +#include "hmi/navi_set_video_config_request.h" + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/hmi_interfaces.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_event_dispatcher.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace navi_set_video_config_request { + +using ::testing::_; +using ::testing::ReturnRef; +namespace am = ::application_manager; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::NaviSetVideoConfigRequest; +using am::event_engine::Event; + +namespace { +const uint32_t kAppId = 1u; +const uint32_t kHmiAppId = 13u; +const hmi_apis::FunctionID::eType kEventID = + hmi_apis::FunctionID::Navigation_SetVideoConfig; +} // namespace + +typedef SharedPtr<NaviSetVideoConfigRequest> NaviSetVideoConfigRequestPtr; + +class NaviSetVideoConfigRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + NaviSetVideoConfigRequestTest() { + mock_app_ptr_ = CreateMockApp(); + ON_CALL(app_mngr_, hmi_interfaces()) + .WillByDefault(ReturnRef(mock_hmi_interfaces_)); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_ptr_)); + ON_CALL(app_mngr_, application_by_hmi_app(_)) + .WillByDefault(Return(mock_app_ptr_)); + ON_CALL(app_mngr_, event_dispatcher()) + .WillByDefault(ReturnRef(mock_event_dispatcher_)); + ON_CALL(*mock_app_ptr_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app_ptr_, hmi_app_id()).WillByDefault(Return(kHmiAppId)); + } + + MOCK(am::MockHmiInterfaces) mock_hmi_interfaces_; + MockAppPtr mock_app_ptr_; + MockEventDispatcher mock_event_dispatcher_; +}; + +TEST_F(NaviSetVideoConfigRequestTest, OnEventWithSuccessResponse) { + MessageSharedPtr request_msg = CreateMessage(); + (*request_msg)[am::strings::msg_params][am::strings::app_id] = kAppId; + + NaviSetVideoConfigRequestPtr command = + CreateCommand<NaviSetVideoConfigRequest>(request_msg); + + MessageSharedPtr event_msg = CreateMessage(); + (*event_msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + Event event(kEventID); + event.set_smart_object(*event_msg); + + std::vector<std::string> empty; + EXPECT_CALL( + app_mngr_, + OnStreamingConfigured( + kAppId, protocol_handler::ServiceType::kMobileNav, true, empty)) + .Times(1); + + command->on_event(event); +} + +static bool ValidateList(std::vector<std::string>& expected, + std::vector<std::string>& actual) { + std::sort(expected.begin(), expected.end()); + std::sort(actual.begin(), actual.end()); + return std::equal(expected.begin(), expected.end(), actual.begin()); +} + +TEST_F(NaviSetVideoConfigRequestTest, OnEventWithRejectedResponse) { + MessageSharedPtr request_msg = CreateMessage(); + (*request_msg)[am::strings::msg_params][am::strings::app_id] = kAppId; + (*request_msg)[am::strings::msg_params][am::strings::config] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + (*request_msg)[am::strings::msg_params][am::strings::config] + [am::strings::protocol] = + hmi_apis::Common_VideoStreamingProtocol::RTP; + (*request_msg)[am::strings::msg_params][am::strings::config] + [am::strings::codec] = + hmi_apis::Common_VideoStreamingCodec::H265; + (*request_msg)[am::strings::msg_params][am::strings::config] + [am::strings::height] = 640; + (*request_msg)[am::strings::msg_params][am::strings::config] + [am::strings::width] = 480; + + NaviSetVideoConfigRequestPtr command = + CreateCommand<NaviSetVideoConfigRequest>(request_msg); + + MessageSharedPtr event_msg = CreateMessage(); + (*event_msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::REJECTED; + + (*event_msg)[am::strings::msg_params][am::strings::rejected_params] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + (*event_msg)[am::strings::msg_params][am::strings::rejected_params][0] = + "codec"; + (*event_msg)[am::strings::msg_params][am::strings::rejected_params][1] = + "protocol"; + Event event(kEventID); + event.set_smart_object(*event_msg); + + std::vector<std::string> rejected_params; + EXPECT_CALL(app_mngr_, + OnStreamingConfigured( + kAppId, protocol_handler::ServiceType::kMobileNav, false, _)) + .WillOnce(SaveArg<3>(&rejected_params)); + + command->on_event(event); + + ASSERT_EQ(2u, rejected_params.size()); + std::vector<std::string> expected_list; + expected_list.push_back(std::string("protocol")); + expected_list.push_back(std::string("codec")); + ASSERT_TRUE(ValidateList(expected_list, rejected_params)); +} + +TEST_F(NaviSetVideoConfigRequestTest, + OnEventWithRejectedResponseWithoutParams) { + MessageSharedPtr request_msg = CreateMessage(); + (*request_msg)[am::strings::msg_params][am::strings::app_id] = kAppId; + + NaviSetVideoConfigRequestPtr command = + CreateCommand<NaviSetVideoConfigRequest>(request_msg); + + MessageSharedPtr event_msg = CreateMessage(); + (*event_msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::REJECTED; + + Event event(kEventID); + event.set_smart_object(*event_msg); + + std::vector<std::string> empty; + EXPECT_CALL( + app_mngr_, + OnStreamingConfigured( + kAppId, protocol_handler::ServiceType::kMobileNav, false, empty)) + .WillOnce(Return()); + + command->on_event(event); +} + +TEST_F(NaviSetVideoConfigRequestTest, OnTimeout) { + MessageSharedPtr request_msg = CreateMessage(); + (*request_msg)[am::strings::msg_params][am::strings::app_id] = kAppId; + + NaviSetVideoConfigRequestPtr command = + CreateCommand<NaviSetVideoConfigRequest>(request_msg); + + std::vector<std::string> empty; + EXPECT_CALL( + app_mngr_, + OnStreamingConfigured( + kAppId, protocol_handler::ServiceType::kMobileNav, false, empty)) + .WillOnce(Return()); + + EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)).Times(1); + + command->onTimeOut(); +} + +} // namespace navi_set_video_config_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_response_test.cc new file mode 100644 index 0000000000..6469966ca2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_response_test.cc @@ -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 names of the copyright holders nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "gtest/gtest.h" +#include "application_manager/commands/commands_test.h" +#include "hmi/navi_set_video_config_response.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/smart_object_keys.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace navi_set_video_config_response { + +using utils::SharedPtr; +using sdl_rpc_plugin::commands::NaviSetVideoConfigResponse; +using test::components::event_engine_test::MockEventDispatcher; +using testing::_; +using testing::ReturnRef; +using ::testing::NiceMock; + +typedef NiceMock< + ::test::components::application_manager_test::MockHMICapabilities> + MockHMICapabilities; + +class NaviSetVideoConfigResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(NaviSetVideoConfigResponseTest, RUN_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + + SharedPtr<NaviSetVideoConfigResponse> command( + CreateCommand<NaviSetVideoConfigResponse>(msg)); + + MockEventDispatcher mock_event_dispatcher; + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher)); + EXPECT_CALL(mock_event_dispatcher, raise_event(_)); + + command->Run(); +} + +} // namespace navi_set_video_config_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_start_stream_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_start_stream_request_test.cc new file mode 100644 index 0000000000..6700aa68ab --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_start_stream_request_test.cc @@ -0,0 +1,120 @@ +/* + * 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 <utility> + +#include "hmi/navi_start_stream_request.h" + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/hmi_interfaces.h" +#include "application_manager/mock_hmi_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace navi_start_stream_request { + +using ::testing::_; +using ::testing::ReturnRef; +namespace am = ::application_manager; +namespace commands = am::commands; +using commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::NaviStartStreamRequest; +using am::event_engine::Event; + +namespace { +const uint32_t kHmiAppId = 13u; +const am::HmiInterfaces::InterfaceID kHmiInterface = + am::HmiInterfaces::HMI_INTERFACE_Navigation; +} // namespace + +class NaviStartStreamRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + NaviStartStreamRequestTest() { + ON_CALL(app_mngr_settings_, start_stream_retry_amount()) + .WillByDefault(ReturnRef(start_stream_retry_amount_)); + msg_ = CreateMessage(); + command_ = CreateCommand<NaviStartStreamRequest>(msg_); + } + + std::pair<uint32_t, int32_t> start_stream_retry_amount_; + MessageSharedPtr msg_; + SharedPtr<NaviStartStreamRequest> command_; +}; + +TEST_F(NaviStartStreamRequestTest, Run_HmiInterfaceNotAvailable_NoRequest) { + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(kHmiInterface)) + .WillOnce(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(_)).Times(0); + + command_->Run(); +} + +TEST_F(NaviStartStreamRequestTest, + Run_HmiInterfaceAvailableButNoApp_NoRequest) { + (*msg_)[am::strings::msg_params][am::strings::app_id] = kHmiAppId; + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(kHmiInterface)) + .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL(app_mngr_, application_by_hmi_app(kHmiAppId)) + .WillOnce(Return(ApplicationSharedPtr())); + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(_)).Times(0); + + command_->Run(); +} + +TEST_F(NaviStartStreamRequestTest, Run_HmiInterfaceAvailable_SentRequest) { + (*msg_)[am::strings::msg_params][am::strings::app_id] = kHmiAppId; + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(kHmiInterface)) + .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application_by_hmi_app(kHmiAppId)) + .WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, set_video_streaming_allowed(true)); + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(msg_)); + + command_->Run(); +} + +} // namespace navi_start_stream_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_stop_stream_requests_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_stop_stream_requests_test.cc new file mode 100644 index 0000000000..0ef903224b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_stop_stream_requests_test.cc @@ -0,0 +1,105 @@ +/* + * 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 "hmi/navi_stop_stream_request.h" +#include "hmi/navi_audio_stop_stream_request.h" + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/hmi_interfaces.h" +#include "application_manager/mock_hmi_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace navi_stop_stream_requests { + +using ::testing::_; +using ::testing::ReturnRef; +namespace am = ::application_manager; +namespace commands = sdl_rpc_plugin::commands; +using am::commands::MessageSharedPtr; +using am::event_engine::Event; + +namespace { +const am::HmiInterfaces::InterfaceID kHmiInterface = + am::HmiInterfaces::HMI_INTERFACE_Navigation; +} // namespace + +template <typename Command> +class NaviStopStreamRequestsTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + NaviStopStreamRequestsTest() { + ON_CALL(this->app_mngr_, hmi_interfaces()) + .WillByDefault(ReturnRef(mock_hmi_interfaces_)); + msg_ = CreateMessage(); + command_ = CreateCommand<Command>(msg_); + } + + MessageSharedPtr msg_; + SharedPtr<Command> command_; +}; + +typedef testing::Types<commands::AudioStopStreamRequest, + commands::NaviStopStreamRequest> RequestCommandsList; +TYPED_TEST_CASE(NaviStopStreamRequestsTest, RequestCommandsList); + +TYPED_TEST(NaviStopStreamRequestsTest, Run_HmiInterfaceNotAvailable_NoRequest) { + EXPECT_CALL(TestFixture::mock_hmi_interfaces_, + GetInterfaceState(kHmiInterface)) + .WillOnce(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + EXPECT_CALL(TestFixture::mock_rpc_service_, SendMessageToHMI(_)).Times(0); + + TestFixture::command_->Run(); +} + +TYPED_TEST(NaviStopStreamRequestsTest, Run_HmiInterfaceAvailable_SentRequest) { + EXPECT_CALL(TestFixture::mock_hmi_interfaces_, + GetInterfaceState(kHmiInterface)) + .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE)); + EXPECT_CALL(TestFixture::mock_rpc_service_, + SendMessageToHMI(TestFixture::msg_)); + + TestFixture::command_->Run(); +} + +} // namespace navi_stop_stream_requests +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_driver_distraction_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_driver_distraction_notification_test.cc new file mode 100644 index 0000000000..60a7b01612 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_driver_distraction_notification_test.cc @@ -0,0 +1,163 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "utils/shared_ptr.h" +#include "utils/lock.h" +#include "utils/make_shared.h" +#include "utils/data_accessor.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "hmi/on_driver_distraction_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace on_driver_distraction_notification { + +using ::testing::_; +using ::testing::Return; +using ::testing::Eq; +using ::utils::SharedPtr; + +namespace am = ::application_manager; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::hmi::OnDriverDistractionNotification; +using namespace am::commands; + +typedef ::utils::SharedPtr<OnDriverDistractionNotification> NotificationPtr; + +class HMIOnDriverDistractionNotificationTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + HMIOnDriverDistractionNotificationTest() + : app_set_lock_(std::make_shared<sync_primitives::Lock>()) {} + std::shared_ptr<sync_primitives::Lock> app_set_lock_; + policy_test::MockPolicyHandlerInterface mock_policy_handler_interface_; +}; + +MATCHER_P2(CheckNotificationParams, function_id, state, "") { + bool is_function_id_matched = + function_id == + static_cast<am::mobile_api::FunctionID::eType>( + (*arg)[am::strings::params][am::strings::function_id].asInt()); + bool is_state_matched = + state == + static_cast<hmi_apis::Common_DriverDistractionState::eType>( + (*arg)[am::strings::msg_params][am::mobile_notification::state] + .asInt()); + return is_function_id_matched && is_state_matched; +} + +ACTION_P(GetArg3, result) { + arg3 = *result; +} + +TEST_F(HMIOnDriverDistractionNotificationTest, Run_PushMobileMessage_SUCCESS) { + const hmi_apis::Common_DriverDistractionState::eType state = + hmi_apis::Common_DriverDistractionState::DD_ON; + MessageSharedPtr commands_msg(CreateMessage(smart_objects::SmartType_Map)); + (*commands_msg)[am::strings::msg_params][am::hmi_notification::state] = state; + + NotificationPtr command( + CreateCommand<OnDriverDistractionNotification>(commands_msg)); + + EXPECT_CALL(app_mngr_, set_driver_distraction_state(Eq(state))); + + MockAppPtr mock_app = CreateMockApp(); + am::ApplicationSet app_set; + app_set.insert(mock_app); + + DataAccessor<am::ApplicationSet> accessor(app_set, app_set_lock_); + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); + policy::CheckPermissionResult result; + result.hmi_level_permitted = policy::kRpcDisallowed; + EXPECT_CALL(app_mngr_, GetPolicyHandler()) + .WillOnce(ReturnRef(mock_policy_handler_interface_)); + EXPECT_CALL(mock_policy_handler_interface_, CheckPermissions(_, _, _, _)) + .WillOnce(GetArg3(&result)); + + EXPECT_CALL(*mock_app, + PushMobileMessage(CheckNotificationParams( + am::mobile_api::FunctionID::OnDriverDistractionID, state))); + + command->Run(); +} + +TEST_F(HMIOnDriverDistractionNotificationTest, + Run_SendNotificationToMobile_SUCCESS) { + const hmi_apis::Common_DriverDistractionState::eType state = + hmi_apis::Common_DriverDistractionState::DD_ON; + MessageSharedPtr commands_msg(CreateMessage(smart_objects::SmartType_Map)); + (*commands_msg)[am::strings::msg_params][am::hmi_notification::state] = state; + + NotificationPtr command( + CreateCommand<OnDriverDistractionNotification>(commands_msg)); + + EXPECT_CALL(app_mngr_, set_driver_distraction_state(Eq(state))); + + MockAppPtr mock_app = CreateMockApp(); + am::ApplicationSet app_set; + app_set.insert(mock_app); + + DataAccessor<am::ApplicationSet> accessor(app_set, app_set_lock_); + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); + + policy::CheckPermissionResult result; + result.hmi_level_permitted = policy::kRpcAllowed; + EXPECT_CALL(app_mngr_, GetPolicyHandler()) + .WillOnce(ReturnRef(mock_policy_handler_interface_)); + EXPECT_CALL(mock_policy_handler_interface_, CheckPermissions(_, _, _, _)) + .WillOnce(GetArg3(&result)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + CheckNotificationParams( + am::mobile_api::FunctionID::OnDriverDistractionID, state), + Command::CommandSource::SOURCE_SDL)); + + command->Run(); +} + +} // on_driver_distraction_notification +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_system_time_ready_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_system_time_ready_notification_test.cc new file mode 100644 index 0000000000..2d50ec2b72 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_system_time_ready_notification_test.cc @@ -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 names of the copyright holders nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "gtest/gtest.h" +#include "application_manager/commands/commands_test.h" +#include "hmi/on_system_time_ready_notification.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/smart_object_keys.h" +#include "interfaces/HMI_API.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace on_system_time_ready_notification { + +using sdl_rpc_plugin::commands::OnSystemTimeReadyNotification; +using test::components::event_engine_test::MockEventDispatcher; +using testing::ReturnRef; + +class OnSystemTimeReadyNotificationTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +ACTION_P(GetEventId, event_id) { + *event_id = arg0.id(); +} + +TEST_F(OnSystemTimeReadyNotificationTest, Run_SUCCESS) { + int32_t event_id = hmi_apis::FunctionID::INVALID_ENUM; + MessageSharedPtr msg = CreateMessage(); + MockEventDispatcher mock_event_dispatcher; + + auto command(CreateCommand<OnSystemTimeReadyNotification>(msg)); + + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher)); + EXPECT_CALL(mock_event_dispatcher, raise_event(_)) + .WillOnce(GetEventId(&event_id)); + + command->Run(); + + EXPECT_EQ(hmi_apis::FunctionID::BasicCommunication_OnSystemTimeReady, + event_id); +} + +} // namespace on_system_time_ready_notification +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_get_capabilities_response_test.cc new file mode 100644 index 0000000000..bbd5920f9f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_get_capabilities_response_test.cc @@ -0,0 +1,177 @@ +/* + * 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 <stdint.h> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "interfaces/MOBILE_API.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_impl.h" +#include "hmi/rc_get_capabilities_response.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace rc_get_capabilities_response { + +using ::utils::SharedPtr; +using ::testing::NiceMock; +namespace am = ::application_manager; +namespace strings = am::strings; +namespace hmi_response = am::hmi_response; +using sdl_rpc_plugin::commands::RCGetCapabilitiesResponse; +using am::commands::CommandImpl; + +typedef SharedPtr<RCGetCapabilitiesResponse> RCGetCapabilitiesResponsePtr; +typedef NiceMock< + ::test::components::application_manager_test::MockHMICapabilities> + MockHMICapabilities; + +namespace { +const uint32_t kConnectionKey = 2u; +} // namespace + +class RCGetCapabilitiesResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + MessageSharedPtr CreateCommandMsg() { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::msg_params][strings::number] = "123"; + (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*command_msg)[strings::msg_params][strings::rc_capability] = + (capabilities_); + + return command_msg; + } + + SmartObject capabilities_; +}; + +TEST_F(RCGetCapabilitiesResponseTest, RUN_SUCCESSS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + + (*command_msg)[strings::msg_params][strings::system_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + (*command_msg)[strings::msg_params][strings::system_capabilities] + [strings::rc_capability] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + smart_objects::SmartObject& remote_control_capability = + (*command_msg)[strings::msg_params][strings::system_capabilities] + [strings::rc_capability]; + + remote_control_capability["climateControlCapabilities"] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + remote_control_capability["climateControlCapabilities"][0] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + smart_objects::SmartObject& climate_control_capability = + remote_control_capability["climateControlCapabilities"][0]; + + climate_control_capability["moduleName"] = "Climate"; + climate_control_capability["fanSpeedAvailable"] = true; + climate_control_capability["desiredTemperatureAvailable"] = true; + climate_control_capability["acEnableAvailable"] = true; + climate_control_capability["acMaxEnableAvailable"] = true; + climate_control_capability["circulateAirEnableAvailable"] = true; + climate_control_capability["autoModeEnableAvailable"] = true; + climate_control_capability["dualModeEnableAvailable"] = true; + + climate_control_capability["defrostZoneAvailable"] = true; + climate_control_capability["defrostZone"] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + climate_control_capability["defrostZone"][0] = "ALL"; + + climate_control_capability["ventilationModeAvailable"] = true; + climate_control_capability["ventilationMode"] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + climate_control_capability["ventilationMode"][0] = "BOTH"; + + remote_control_capability["radioControlCapabilities"] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + remote_control_capability["radioControlCapabilities"][0] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + smart_objects::SmartObject& radio_control_capability = + remote_control_capability["radioControlCapabilities"][0]; + + radio_control_capability["moduleName"] = "Radio"; + radio_control_capability["radioEnableAvailable"] = true; + radio_control_capability["radioBandAvailable"] = true; + radio_control_capability["radioFrequencyAvailable"] = true; + radio_control_capability["hdChannelAvailable"] = true; + radio_control_capability["rdsDataAvailable"] = true; + radio_control_capability["availableHDsAvailable"] = true; + radio_control_capability["stateAvailable"] = true; + radio_control_capability["signalStrengthAvailable"] = true; + radio_control_capability["signalChangeThresholdAvailable"] = true; + + remote_control_capability[hmi_response::button_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + remote_control_capability[hmi_response::button_capabilities][0] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + smart_objects::SmartObject& button_capability = + remote_control_capability[hmi_response::button_capabilities][0]; + + button_capability[strings::button_name] = "OK"; + button_capability["shortPressAvailable"] = true; + button_capability["longPressAvailable"] = true; + button_capability["upDownAvailable"] = true; + + RCGetCapabilitiesResponsePtr command( + CreateCommand<RCGetCapabilitiesResponse>(command_msg)); + + smart_objects::SmartObject rc_capability_so = + (*command_msg)[strings::msg_params][strings::rc_capability]; + + EXPECT_CALL(mock_hmi_capabilities_, set_rc_capability(rc_capability_so)); + EXPECT_CALL(mock_hmi_capabilities_, set_rc_supported(true)); + + command->Run(); +} + +} // namespace rc_get_capabilities_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_request_test.cc new file mode 100644 index 0000000000..41acf67116 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_request_test.cc @@ -0,0 +1,168 @@ +/* + * 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 "hmi/rc_is_ready_request.h" + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/hmi_interfaces.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace rc_is_ready_request { + +using ::testing::_; +using ::testing::ReturnRef; +namespace am = ::application_manager; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::RCIsReadyRequest; +using am::event_engine::Event; + +typedef SharedPtr<RCIsReadyRequest> RCIsReadyRequestPtr; + +class RCIsReadyRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + RCIsReadyRequestTest() : command_(CreateCommand<RCIsReadyRequest>()) {} + + void SetUpExpectations(bool is_rc_cooperating_available, + bool is_send_message_to_hmi, + bool is_message_contain_param, + am::HmiInterfaces::InterfaceState state) { + if (is_send_message_to_hmi) { + ExpectSendMessagesToHMI(); + } + EXPECT_CALL(mock_hmi_capabilities_, + set_is_rc_cooperating(is_rc_cooperating_available)); + if (!is_rc_cooperating_available) { + EXPECT_CALL(mock_hmi_capabilities_, set_rc_supported(false)); + } + + if (is_message_contain_param) { + EXPECT_CALL(app_mngr_, hmi_interfaces()) + .WillRepeatedly(ReturnRef(mock_hmi_interfaces_)); + EXPECT_CALL( + mock_hmi_interfaces_, + SetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_RC, state)); + } else { + EXPECT_CALL(app_mngr_, hmi_interfaces()) + .WillOnce(ReturnRef(mock_hmi_interfaces_)); + EXPECT_CALL(mock_hmi_interfaces_, SetInterfaceState(_, _)).Times(0); + } + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_RC)) + .WillOnce(Return(state)); + } + + void ExpectSendMessagesToHMI() { + smart_objects::SmartObjectSPtr capabilities( + new smart_objects::SmartObject(smart_objects::SmartType_Map)); + EXPECT_CALL(mock_message_helper_, + CreateModuleInfoSO(hmi_apis::FunctionID::RC_GetCapabilities, _)) + .WillOnce(Return(capabilities)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(capabilities)); + } + + void PrepareEvent(bool is_message_contain_param, + Event& event, + bool is_rc_cooperating_available = false) { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + if (is_message_contain_param) { + (*msg)[am::strings::msg_params][am::strings::available] = + is_rc_cooperating_available; + } + event.set_smart_object(*msg); + } + + RCIsReadyRequestPtr command_; + am::MockHmiInterfaces mock_hmi_interfaces_; +}; + +TEST_F(RCIsReadyRequestTest, Run_NoKeyAvailableInMessage_HmiInterfacesIgnored) { + const bool is_rc_cooperating_available = false; + const bool is_send_message_to_hmi = true; + const bool is_message_contain_param = false; + Event event(hmi_apis::FunctionID::RC_IsReady); + PrepareEvent(is_message_contain_param, event); + SetUpExpectations(is_rc_cooperating_available, + is_send_message_to_hmi, + is_message_contain_param, + am::HmiInterfaces::STATE_NOT_RESPONSE); + command_->on_event(event); +} + +TEST_F(RCIsReadyRequestTest, Run_KeyAvailableEqualToFalse_StateNotAvailable) { + const bool is_rc_cooperating_available = false; + const bool is_send_message_to_hmi = false; + const bool is_message_contain_param = true; + Event event(hmi_apis::FunctionID::RC_IsReady); + PrepareEvent(is_message_contain_param, event); + SetUpExpectations(is_rc_cooperating_available, + is_send_message_to_hmi, + is_message_contain_param, + am::HmiInterfaces::STATE_NOT_AVAILABLE); + command_->on_event(event); +} + +TEST_F(RCIsReadyRequestTest, Run_KeyAvailableEqualToTrue_StateAvailable) { + const bool is_rc_cooperating_available = true; + const bool is_send_message_to_hmi = true; + const bool is_message_contain_param = true; + Event event(hmi_apis::FunctionID::RC_IsReady); + PrepareEvent(is_message_contain_param, event, is_rc_cooperating_available); + SetUpExpectations(is_rc_cooperating_available, + is_send_message_to_hmi, + is_message_contain_param, + am::HmiInterfaces::STATE_AVAILABLE); + command_->on_event(event); +} + +TEST_F(RCIsReadyRequestTest, Run_HMIDoestRespond_SendMessageToHMIByTimeout) { + ExpectSendMessagesToHMI(); + command_->onTimeOut(); +} + +} // namespace rc_is_ready_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_response_test.cc new file mode 100644 index 0000000000..e07a0c1538 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_response_test.cc @@ -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. + */ + +#include <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "hmi/rc_is_ready_response.h" +#include "application_manager/mock_event_dispatcher.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace rc_is_ready_response { + +using ::testing::Return; +using ::utils::SharedPtr; +using ::testing::NiceMock; +namespace am = ::application_manager; +namespace strings = ::application_manager::strings; +namespace hmi_response = am::hmi_response; +using sdl_rpc_plugin::commands::RCIsReadyResponse; +using test::components::event_engine_test::MockEventDispatcher; + +typedef SharedPtr<RCIsReadyResponse> RCIsReadyResponsePtr; + +class RCIsReadyResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> { +}; + +TEST_F(RCIsReadyResponseTest, RUN_SUCCESS) { + RCIsReadyResponsePtr command(CreateCommand<RCIsReadyResponse>()); + + MockEventDispatcher mock_event_dispatcher; + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher)); + EXPECT_CALL(mock_event_dispatcher, raise_event(_)); + + command->Run(); +} + +} // namespace rc_is_ready_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/response_from_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/response_from_hmi_test.cc new file mode 100644 index 0000000000..c5b0c2ba24 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/response_from_hmi_test.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 <stdint.h> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/test/include/application_manager/commands/commands_test.h" +#include "application_manager/commands/command.h" +#include "application_manager/test/include/application_manager/mock_event_dispatcher.h" +#include "application_manager/commands/response_from_hmi.h" +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace response_from_hmi { + +using ::testing::_; +using ::testing::Return; +using ::testing::SaveArg; +using ::testing::DoAll; + +using ::utils::SharedPtr; +using ::test::components::event_engine_test::MockEventDispatcher; + +namespace am = ::application_manager; +using application_manager::commands::ResponseFromHMI; + +typedef SharedPtr<ResponseFromHMI> ResponseFromHMIPtr; + +class ResponseFromHMITest : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(ResponseFromHMITest, BasicMethodsOverloads_SUCCESS) { + ResponseFromHMIPtr command(CreateCommand<ResponseFromHMI>()); + + // Current implementation always return `true` + EXPECT_TRUE(command->Init()); + EXPECT_NO_THROW(command->Run()); + EXPECT_TRUE(command->CleanUp()); +} + +TEST_F(ResponseFromHMITest, SendResponseToMobile_SUCCESS) { + ResponseFromHMIPtr command(CreateCommand<ResponseFromHMI>()); + + MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(msg, _)); + + command->SendResponseToMobile(msg, app_mngr_); + + const application_manager::MessageType received_message_tipe = + static_cast<application_manager::MessageType>( + (*msg)[am::strings::params][am::strings::message_type].asInt()); + + EXPECT_EQ(application_manager::MessageType::kResponse, received_message_tipe); +} + +TEST_F(ResponseFromHMITest, CreateHMIRequest_SUCCESS) { + ResponseFromHMIPtr command(CreateCommand<ResponseFromHMI>()); + + MessageSharedPtr result_msg; + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&result_msg), Return(true))); + + const hmi_apis::FunctionID::eType posted_function_id = + hmi_apis::FunctionID::INVALID_ENUM; + MessageSharedPtr dummy_msg_params = CreateMessage(); + command->CreateHMIRequest(posted_function_id, *dummy_msg_params); + + ASSERT_TRUE(result_msg); + + const application_manager::MessageType received_message_tipe = + static_cast<application_manager::MessageType>( + (*result_msg)[am::strings::params][am::strings::message_type] + .asInt()); + + EXPECT_EQ(am::MessageType::kRequest, received_message_tipe); + + const hmi_apis::FunctionID::eType received_function_id = + static_cast<hmi_apis::FunctionID::eType>( + (*result_msg)[am::strings::params][am::strings::function_id].asInt()); + + EXPECT_EQ(posted_function_id, received_function_id); +} + +TEST_F(ResponseFromHMITest, CreateHMIRequest_CantManageCommand_Covering) { + ResponseFromHMIPtr command(CreateCommand<ResponseFromHMI>()); + + MessageSharedPtr result_msg; + ON_CALL(app_mngr_, GetNextHMICorrelationID()).WillByDefault(Return(1u)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&result_msg), Return(false))); + + const hmi_apis::FunctionID::eType posted_function_id = + hmi_apis::FunctionID::INVALID_ENUM; + MessageSharedPtr dummy_msg_params = CreateMessage(); + command->CreateHMIRequest(posted_function_id, *dummy_msg_params); +} + +} // namespace response_from_hmi +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc new file mode 100644 index 0000000000..c21791e913 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc @@ -0,0 +1,500 @@ +/* + * 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 <stdint.h> + +#include "gtest/gtest.h" +#include "utils/lock.h" +#include "utils/helpers.h" +#include "hmi/sdl_activate_app_request.h" +#include "application_manager/mock_application.h" +#include "application_manager/application_manager.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_state_controller.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace sdl_activate_app_request { + +namespace am = ::application_manager; +namespace strings = am::strings; +namespace hmi_response = am::hmi_response; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::SDLActivateAppRequest; +using am::ApplicationSet; +using testing::Mock; +using testing::Return; +using testing::ReturnRef; +using testing::Mock; +using ::testing::NiceMock; +using policy_test::MockPolicyHandlerInterface; +using am::event_engine::Event; + +namespace { +const uint32_t kCorrelationID = 1u; +const uint32_t kAppID = 2u; +const uint32_t kAppIDFirst = 1u; +const connection_handler::DeviceHandle kHandle = 2u; +} // namespace + +MATCHER_P2(CheckMsgParams, result, corr_id, "") { + const bool is_func_id_valid = + hmi_apis::FunctionID::SDL_ActivateApp == + static_cast<int32_t>( + (*arg)[strings::params][strings::function_id].asInt()); + + const bool is_result_code_valid = + hmi_apis::Common_Result::APPLICATION_NOT_REGISTERED == + static_cast<int32_t>( + (*arg)[strings::msg_params][strings::result_code].asInt()); + + const bool is_result_valid = + result == (*arg)[strings::msg_params][strings::success].asBool(); + + const bool is_corr_id_valid = + corr_id == ((*arg)[strings::params][strings::correlation_id].asUInt()); + + using namespace helpers; + return Compare<bool, EQ, ALL>(true, + is_func_id_valid, + is_result_code_valid, + is_result_valid, + is_corr_id_valid); +} + +class SDLActivateAppRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + SDLActivateAppRequestTest() + : lock_(std::make_shared<sync_primitives::Lock>()) {} + + protected: + ~SDLActivateAppRequestTest() { + // Fix DataAccessor release and WinQt crash + Mock::VerifyAndClearExpectations(&app_mngr_); + } + + void InitCommand(const uint32_t& timeout) OVERRIDE { + MockAppPtr mock_app = CreateMockApp(); + CommandRequestTest<CommandsTestMocks::kIsNice>::InitCommand(timeout); + ON_CALL((*mock_app), app_id()).WillByDefault(Return(kAppID)); + ON_CALL(app_mngr_, application_by_hmi_app(kAppID)) + .WillByDefault(Return(mock_app)); + } + void SetCorrelationAndAppID(MessageSharedPtr msg) { + (*msg)[strings::params][strings::correlation_id] = kCorrelationID; + (*msg)[strings::msg_params][strings::app_id] = kAppID; + } + + ApplicationSet app_list_; + std::shared_ptr<sync_primitives::Lock> lock_; + policy_test::MockPolicyHandlerInterface policy_handler_; + application_manager_test::MockStateController mock_state_controller_; + NiceMock<event_engine_test::MockEventDispatcher> mock_event_dispatcher_; +}; + +#ifdef EXTERNAL_PROPRIETARY_MODE + +TEST_F(SDLActivateAppRequestTest, Run_ActivateApp_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + SetCorrelationAndAppID(msg); + + SharedPtr<SDLActivateAppRequest> command( + CreateCommand<SDLActivateAppRequest>(msg)); + + EXPECT_CALL(app_mngr_, state_controller()) + .WillOnce(ReturnRef(mock_state_controller_)); + EXPECT_CALL(mock_state_controller_, + IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) + .WillOnce(Return(false)); + + EXPECT_CALL(mock_policy_handler_, OnActivateApp(kAppID, kCorrelationID)); + + command->Run(); +} + +TEST_F(SDLActivateAppRequestTest, DISABLED_Run_DactivateApp_REJECTED) { + MessageSharedPtr msg = CreateMessage(); + SetCorrelationAndAppID(msg); + (*msg)[strings::msg_params][strings::function_id] = + hmi_apis::FunctionID::SDL_ActivateApp; + + SharedPtr<SDLActivateAppRequest> command( + CreateCommand<SDLActivateAppRequest>(msg)); + + EXPECT_CALL(app_mngr_, state_controller()) + .WillOnce(ReturnRef(mock_state_controller_)); + EXPECT_CALL(mock_state_controller_, + IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) + .WillOnce(Return(true)); + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::SDL_ActivateApp))) + .WillOnce(Return(true)); + + command->Run(); +} +#else + +TEST_F(SDLActivateAppRequestTest, FindAppToRegister_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + SetCorrelationAndAppID(msg); + + SharedPtr<SDLActivateAppRequest> command( + CreateCommand<SDLActivateAppRequest>(msg)); + + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kAppID)).WillOnce(Return(mock_app)); + + EXPECT_CALL(app_mngr_, state_controller()) + .WillOnce(ReturnRef(mock_state_controller_)); + EXPECT_CALL(mock_state_controller_, + IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) + .WillOnce(Return(false)); + + EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(false)); + ON_CALL(*mock_app, device()).WillByDefault(Return(kHandle)); + + MockAppPtr mock_app_first(CreateMockApp()); + ON_CALL(*mock_app_first, device()).WillByDefault(Return(kHandle)); + ON_CALL(*mock_app_first, is_foreground()).WillByDefault(Return(false)); + + app_list_.insert(mock_app_first); + DataAccessor<ApplicationSet> accessor(app_list_, lock_); + EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor)); + + ON_CALL(*mock_app_first, device()).WillByDefault(Return(kHandle)); + EXPECT_CALL(*mock_app_first, is_foreground()).WillOnce(Return(false)); + ON_CALL(*mock_app_first, protocol_version()) + .WillByDefault( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5)); + ON_CALL(*mock_app, protocol_version()) + .WillByDefault( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5)); + + const std::string url = "url"; + ON_CALL(*mock_app_first, SchemaUrl()).WillByDefault(Return(url)); + const std::string package = "package"; + ON_CALL(*mock_app_first, PackageName()).WillByDefault(Return(package)); + + EXPECT_CALL(mock_message_helper_, SendLaunchApp(_, _, _, _)); + + command->Run(); +} + +TEST_F(SDLActivateAppRequestTest, AppIdNotFound_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + SetCorrelationAndAppID(msg); + + SharedPtr<SDLActivateAppRequest> command( + CreateCommand<SDLActivateAppRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kAppID)) + .WillOnce(Return(ApplicationSharedPtr())); + EXPECT_CALL(app_mngr_, WaitingApplicationByID(kAppID)) + .WillOnce(Return(ApplicationSharedPtr())); + + command->Run(); +} + +TEST_F(SDLActivateAppRequestTest, DevicesAppsEmpty_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + SetCorrelationAndAppID(msg); + + SharedPtr<SDLActivateAppRequest> command( + CreateCommand<SDLActivateAppRequest>(msg)); + + MockAppPtr mock_app(CreateMockApp()); + ON_CALL(app_mngr_, application(kAppID)).WillByDefault(Return(mock_app)); + + EXPECT_CALL(app_mngr_, state_controller()) + .WillOnce(ReturnRef(mock_state_controller_)); + EXPECT_CALL(mock_state_controller_, + IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) + .WillOnce(Return(false)); + + EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(false)); + ON_CALL(*mock_app, device()).WillByDefault(Return(kHandle)); + + DataAccessor<ApplicationSet> accessor(app_list_, lock_); + EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor)); + app_list_ = accessor.GetData(); + + command->Run(); +} + +TEST_F(SDLActivateAppRequestTest, FirstAppActive_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + SetCorrelationAndAppID(msg); + + SharedPtr<SDLActivateAppRequest> command( + CreateCommand<SDLActivateAppRequest>(msg)); + + MockAppPtr mock_app(CreateMockApp()); + ON_CALL(app_mngr_, application(kAppID)).WillByDefault(Return(mock_app)); + EXPECT_CALL(app_mngr_, state_controller()) + .WillOnce(ReturnRef(mock_state_controller_)); + EXPECT_CALL(mock_state_controller_, + IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) + .WillOnce(Return(false)); + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); + + DataAccessor<ApplicationSet> accessor(app_list_, lock_); + EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor)); + + app_list_ = accessor.GetData(); + + MockAppPtr mock_app_first(CreateMockApp()); + ON_CALL(app_mngr_, application(kAppIDFirst)) + .WillByDefault(Return(mock_app_first)); + + app_list_.insert(mock_app_first); + ON_CALL(*mock_app_first, protocol_version()) + .WillByDefault( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5)); + + ON_CALL(*mock_app_first, device()).WillByDefault(Return(kHandle)); + EXPECT_CALL(*mock_app_first, is_foreground()).WillRepeatedly(Return(true)); + + EXPECT_CALL(mock_message_helper_, SendLaunchApp(_, _, _, _)); + + command->Run(); +} + +TEST_F(SDLActivateAppRequestTest, FirstAppNotActive_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + SetCorrelationAndAppID(msg); + + SharedPtr<SDLActivateAppRequest> command( + CreateCommand<SDLActivateAppRequest>(msg)); + + MockAppPtr mock_app(CreateMockApp()); + ON_CALL(app_mngr_, application(kAppID)).WillByDefault(Return(mock_app)); + EXPECT_CALL(app_mngr_, state_controller()) + .WillOnce(ReturnRef(mock_state_controller_)); + EXPECT_CALL(mock_state_controller_, + IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) + .WillOnce(Return(false)); + EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(true)); + + EXPECT_CALL(mock_policy_handler_, OnActivateApp(kAppID, kCorrelationID)); + + command->Run(); +} + +TEST_F(SDLActivateAppRequestTest, FirstAppIsForeground_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + SetCorrelationAndAppID(msg); + + SharedPtr<SDLActivateAppRequest> command( + CreateCommand<SDLActivateAppRequest>(msg)); + + MockAppPtr mock_app(CreateMockApp()); + + const std::string schema("schema"); + mock_app->SetShemaUrl(schema); + const std::string package_name("package_name"); + mock_app->SetPackageName(package_name); + + ON_CALL(app_mngr_, application(kAppID)).WillByDefault(Return(mock_app)); + + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); + EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(false)); + EXPECT_CALL(app_mngr_, state_controller()) + .WillOnce(ReturnRef(mock_state_controller_)); + EXPECT_CALL(mock_state_controller_, + IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) + .WillOnce(Return(false)); + MockAppPtr mock_app_first(CreateMockApp()); + ON_CALL(*mock_app_first, is_foreground()).WillByDefault(Return(false)); + + app_list_.insert(mock_app_first); + DataAccessor<ApplicationSet> accessor(app_list_, lock_); + EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor)); + ON_CALL(*mock_app_first, protocol_version()) + .WillByDefault( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5)); + ON_CALL(*mock_app_first, device()).WillByDefault(Return(kHandle)); + EXPECT_CALL(*mock_app_first, is_foreground()).WillOnce(Return(true)); + + EXPECT_CALL(mock_message_helper_, SendLaunchApp(_, schema, package_name, _)); + + command->Run(); +} + +TEST_F(SDLActivateAppRequestTest, FirstAppNotRegisteredAndEmpty_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + SetCorrelationAndAppID(msg); + + SharedPtr<SDLActivateAppRequest> command( + CreateCommand<SDLActivateAppRequest>(msg)); + + MockAppPtr mock_app(CreateMockApp()); + ON_CALL(app_mngr_, application(kAppID)).WillByDefault(Return(mock_app)); + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); + EXPECT_CALL(app_mngr_, state_controller()) + .WillOnce(ReturnRef(mock_state_controller_)); + EXPECT_CALL(mock_state_controller_, + IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) + .WillOnce(Return(false)); + + MockAppPtr mock_app_first(CreateMockApp()); + ON_CALL(*mock_app_first, device()).WillByDefault(Return(kHandle)); + ON_CALL(*mock_app_first, is_foreground()).WillByDefault(Return(false)); + + app_list_.insert(mock_app_first); + DataAccessor<ApplicationSet> accessor(app_list_, lock_); + EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor)); + ON_CALL(*mock_app_first, protocol_version()) + .WillByDefault( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5)); + EXPECT_CALL(*mock_app_first, is_foreground()).WillOnce(Return(false)); + + EXPECT_CALL(mock_message_helper_, SendLaunchApp(_, _, _, _)); + + command->Run(); +} + +TEST_F(SDLActivateAppRequestTest, FirstAppNotRegistered_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + SetCorrelationAndAppID(msg); + + SharedPtr<SDLActivateAppRequest> command( + CreateCommand<SDLActivateAppRequest>(msg)); + + MockAppPtr mock_app(CreateMockApp()); + ON_CALL(app_mngr_, application(kAppID)).WillByDefault(Return(mock_app)); + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); + EXPECT_CALL(app_mngr_, state_controller()) + .WillOnce(ReturnRef(mock_state_controller_)); + EXPECT_CALL(mock_state_controller_, + IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) + .WillOnce(Return(false)); + DataAccessor<ApplicationSet> accessor(app_list_, lock_); + EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor)); + + app_list_ = accessor.GetData(); + + MockAppPtr mock_app_first(CreateMockApp()); + ON_CALL(*mock_app_first, device()).WillByDefault(Return(kHandle)); + ON_CALL(*mock_app_first, is_foreground()).WillByDefault(Return(false)); + + app_list_.insert(mock_app_first); + ON_CALL(*mock_app_first, protocol_version()) + .WillByDefault( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5)); + EXPECT_CALL(*mock_app_first, is_foreground()).WillRepeatedly(Return(true)); + + EXPECT_CALL(mock_message_helper_, SendLaunchApp(_, _, _, _)); + + command->Run(); +} +#endif + +TEST_F(SDLActivateAppRequestTest, OnTimeout_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + SetCorrelationAndAppID(msg); + + SharedPtr<SDLActivateAppRequest> command( + CreateCommand<SDLActivateAppRequest>(msg)); + ON_CALL(mock_event_dispatcher_, remove_observer(_, _)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); + + command->onTimeOut(); +} + +TEST_F(SDLActivateAppRequestTest, OnEvent_InvalidEventId_UNSUCCESS) { + MessageSharedPtr event_msg = CreateMessage(); + (*event_msg)[strings::params][strings::correlation_id] = kCorrelationID; + + SharedPtr<SDLActivateAppRequest> command( + CreateCommand<SDLActivateAppRequest>()); + + Event event(hmi_apis::FunctionID::INVALID_ENUM); + event.set_smart_object(*event_msg); + EXPECT_CALL(app_mngr_, application_by_hmi_app(_)).Times(0); + + command->on_event(event); +} + +TEST_F(SDLActivateAppRequestTest, OnEvent_InvalidAppId_UNSUCCESS) { + MessageSharedPtr event_msg = CreateMessage(); + (*event_msg)[strings::msg_params][strings::application][strings::app_id] = + kAppID; + + SharedPtr<SDLActivateAppRequest> command( + CreateCommand<SDLActivateAppRequest>()); + + Event event(hmi_apis::FunctionID::BasicCommunication_OnAppRegistered); + event.set_smart_object(*event_msg); + + MockAppPtr invalid_mock_app; + EXPECT_CALL(app_mngr_, application_by_hmi_app(_)) + .WillOnce(Return(invalid_mock_app)); + + command->on_event(event); +} + +TEST_F(SDLActivateAppRequestTest, OnEvent_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::correlation_id] = kCorrelationID; + SharedPtr<SDLActivateAppRequest> command( + CreateCommand<SDLActivateAppRequest>(msg)); + + MessageSharedPtr event_msg = CreateMessage(); + (*event_msg)[strings::msg_params][strings::application][strings::app_id] = + kAppID; + + Event event(hmi_apis::FunctionID::BasicCommunication_OnAppRegistered); + event.set_smart_object(*event_msg); + + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application_by_hmi_app(_)).WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppID)); + + EXPECT_CALL(mock_policy_handler_, OnActivateApp(kAppID, kCorrelationID)); + + command->on_event(event); +} + +} // namespace sdl_activate_app_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_response_test.cc new file mode 100644 index 0000000000..716c818269 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_response_test.cc @@ -0,0 +1,87 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/application.h" +#include "hmi/sdl_activate_app_response.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace sdl_activate_app_response { + +using ::utils::SharedPtr; +namespace am = ::application_manager; +namespace strings = ::application_manager::strings; +using sdl_rpc_plugin::commands::SDLActivateAppResponse; +using am::commands::CommandImpl; + +typedef SharedPtr<SDLActivateAppResponse> SDLActivateAppResponsePtr; + +namespace { +const uint32_t kConnectionKey = 2u; +const std::string kStrNumber = "123"; +} // namespace + +class SDLActivateAppResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(SDLActivateAppResponseTest, RUN_SendRequest_SUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::msg_params][strings::number] = kStrNumber; + (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; + + SDLActivateAppResponsePtr command( + CreateCommand<SDLActivateAppResponse>(command_msg)); + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(command_msg)); + + command->Run(); + + EXPECT_EQ((*command_msg)[strings::params][strings::protocol_type].asInt(), + CommandImpl::hmi_protocol_type_); + EXPECT_EQ((*command_msg)[strings::params][strings::protocol_version].asInt(), + CommandImpl::protocol_version_); +} + +} // namespace sdl_activate_app_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_list_of_permisssions_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_list_of_permisssions_request_test.cc new file mode 100644 index 0000000000..e5f9845b74 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_list_of_permisssions_request_test.cc @@ -0,0 +1,111 @@ +/* + * 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 <stdint.h> + +#include "gtest/gtest.h" +#include "hmi/sdl_get_list_of_permissions_request.h" +#include "application_manager/mock_application.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/commands/command_request_test.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace sdl_get_list_of_permissions_request { + +using application_manager::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::SDLGetListOfPermissionsRequest; +using test::components::policy_test::MockPolicyHandlerInterface; +using smart_objects::SmartObject; +using testing::Return; +using testing::ReturnRef; + +namespace { +const uint32_t kCorrelationID = 1u; +const uint32_t kAppID = 2u; +const uint32_t kConnectionKey = 0u; +} // namespace + +namespace strings = ::application_manager::strings; +namespace hmi_response = ::application_manager::hmi_response; + +class SDLGetListOfPermissionsRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + protected: + void SetUp() OVERRIDE { + mock_app_ = CreateMockApp(); + } + + void InitCommand(const uint32_t& timeout) OVERRIDE { + CommandRequestTest<CommandsTestMocks::kIsNice>::InitCommand(timeout); + ON_CALL((*mock_app_), app_id()).WillByDefault(Return(kAppID)); + } + MockAppPtr mock_app_; +}; + +TEST_F(SDLGetListOfPermissionsRequestTest, Run_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::correlation_id] = kCorrelationID; + (*msg)[strings::msg_params][strings::app_id] = kAppID; + + EXPECT_CALL(app_mngr_, application_by_hmi_app(kAppID)) + .WillOnce(Return(mock_app_)); + + SharedPtr<SDLGetListOfPermissionsRequest> command( + CreateCommand<SDLGetListOfPermissionsRequest>(msg)); + + EXPECT_CALL(mock_policy_handler_, + OnGetListOfPermissions(kAppID, kCorrelationID)); + + command->Run(); +} + +TEST_F(SDLGetListOfPermissionsRequestTest, Run_KeyDoesntExist_SUCCESS) { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Binary); + (*msg)[strings::params][strings::correlation_id] = kCorrelationID; + + SharedPtr<SDLGetListOfPermissionsRequest> command( + CreateCommand<SDLGetListOfPermissionsRequest>(msg)); + + EXPECT_CALL(mock_policy_handler_, + OnGetListOfPermissions(kConnectionKey, kCorrelationID)); + + command->Run(); +} + +} // namespace sdl_get_list_of_permissions_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_status_update_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_status_update_request_test.cc new file mode 100644 index 0000000000..7cfd7e49e2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_status_update_request_test.cc @@ -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. + */ + +#include <stdint.h> + +#include "gtest/gtest.h" +#include "hmi/sdl_get_status_update_request.h" +#include "application_manager/mock_application.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/commands/command_request_test.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace sdl_get_status_update_request { + +using application_manager::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::SDLGetStatusUpdateRequest; +using test::components::policy_test::MockPolicyHandlerInterface; +using testing::Return; +using testing::ReturnRef; + +namespace { +const uint32_t kCorrelationID = 1u; +} // namespace + +namespace strings = ::application_manager::strings; +namespace hmi_response = ::application_manager::hmi_response; + +class SDLGetStatusUpdateRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(SDLGetStatusUpdateRequestTest, Run_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::correlation_id] = kCorrelationID; + + SharedPtr<SDLGetStatusUpdateRequest> command( + CreateCommand<SDLGetStatusUpdateRequest>(msg)); + + EXPECT_CALL(mock_policy_handler_, OnGetStatusUpdate(kCorrelationID)); + + command->Run(); +} + +} // namespace sdl_get_status_update_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_user_friendly_message_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_user_friendly_message_request_test.cc new file mode 100644 index 0000000000..0ec40f896a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_user_friendly_message_request_test.cc @@ -0,0 +1,160 @@ +/* + * 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 <stdint.h> +#include <string> +#include <vector> + +#include "gtest/gtest.h" +#include "hmi/sdl_get_user_friendly_message_request.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_state_controller.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "smart_objects/smart_object.h" +#include "application_manager/commands/command_request_test.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace sdl_get_user_friendly_message_request { + +using application_manager::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::SDLGetUserFriendlyMessageRequest; +using application_manager::MockMessageHelper; +using test::components::policy_test::MockPolicyHandlerInterface; +using test::components::application_manager_test::MockHMICapabilities; +using testing::_; +using testing::Return; +using testing::ReturnRef; + +namespace { +const uint32_t kCorrelationID = 1u; +const uint32_t kAppID = 2u; +const std::string kLanguageDe = "de-de"; +const std::string kLanguageEn = "en-gb"; +const std::string kMessageCodes = "messageCodes"; +const hmi_apis::Common_Language::eType kLanguage = + hmi_apis::Common_Language::EN_GB; +} // namespace + +namespace strings = ::application_manager::strings; + +class SDLGetUserFriendlyMessageRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + protected: + void SetUp() OVERRIDE { + mock_app_ = CreateMockApp(); + } + + void InitCommand(const uint32_t& timeout) OVERRIDE { + CommandRequestTest<CommandsTestMocks::kIsNice>::InitCommand(timeout); + ON_CALL((*mock_app_), app_id()).WillByDefault(Return(kAppID)); + EXPECT_CALL(app_mngr_, application_by_hmi_app(kAppID)) + .WillOnce(Return(mock_app_)); + } + MockAppPtr mock_app_; +}; + +TEST_F(SDLGetUserFriendlyMessageRequestTest, Run_LanguageSet_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::correlation_id] = kCorrelationID; + (*msg)[strings::msg_params][strings::app_id] = kAppID; + + (*msg)[strings::msg_params][kMessageCodes] = + SmartObject(smart_objects::SmartType_Array); + (*msg)[strings::msg_params][kMessageCodes][0] = SmartObject(kLanguageDe); + (*msg)[strings::msg_params][kMessageCodes][1] = SmartObject(kLanguageEn); + + (*msg)[strings::msg_params][strings::language] = kLanguage; + + SharedPtr<SDLGetUserFriendlyMessageRequest> command( + CreateCommand<SDLGetUserFriendlyMessageRequest>(msg)); + + EXPECT_CALL(mock_message_helper_, CommonLanguageToString(kLanguage)) + .WillOnce(Return(kLanguageEn)); + std::vector<std::string> msg_codes; + msg_codes.push_back(kLanguageDe); + msg_codes.push_back(kLanguageEn); + EXPECT_CALL(mock_policy_handler_, + OnGetUserFriendlyMessage(msg_codes, kLanguageEn, kCorrelationID)); + + command->Run(); +} + +TEST_F(SDLGetUserFriendlyMessageRequestTest, Run_LanguageNotSet_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::correlation_id] = kCorrelationID; + (*msg)[strings::msg_params][strings::app_id] = kAppID; + + (*msg)[strings::msg_params][kMessageCodes] = + SmartObject(smart_objects::SmartType_Array); + (*msg)[strings::msg_params][kMessageCodes][0] = SmartObject(kLanguageDe); + (*msg)[strings::msg_params][kMessageCodes][1] = SmartObject(kLanguageEn); + + SharedPtr<SDLGetUserFriendlyMessageRequest> command( + CreateCommand<SDLGetUserFriendlyMessageRequest>(msg)); + + EXPECT_CALL(mock_hmi_capabilities_, active_ui_language()) + .WillOnce(Return(kLanguage)); + EXPECT_CALL(mock_message_helper_, CommonLanguageToString(kLanguage)) + .WillOnce(Return(kLanguageEn)); + std::vector<std::string> msg_codes; + msg_codes.push_back(kLanguageDe); + msg_codes.push_back(kLanguageEn); + EXPECT_CALL(mock_policy_handler_, + OnGetUserFriendlyMessage(msg_codes, kLanguageEn, kCorrelationID)); + + command->Run(); +} + +TEST_F(SDLGetUserFriendlyMessageRequestTest, Run_NoMsgCodes_Canceled) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::correlation_id] = kCorrelationID; + (*msg)[strings::msg_params][strings::app_id] = kAppID; + + SharedPtr<SDLGetUserFriendlyMessageRequest> command( + CreateCommand<SDLGetUserFriendlyMessageRequest>(msg)); + + EXPECT_CALL(mock_message_helper_, CommonLanguageToString(_)).Times(0); + EXPECT_CALL(mock_policy_handler_, OnGetUserFriendlyMessage(_, _, _)).Times(0); + + command->Run(); +} + +} // namespace sdl_get_user_friendly_message_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_notifications_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_notifications_test.cc new file mode 100644 index 0000000000..d25c9b41e8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_notifications_test.cc @@ -0,0 +1,77 @@ +/* + * 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 "gtest/gtest.h" + +#include "application_manager/commands/commands_test.h" + +#include "application_manager/commands/notification_to_hmi.h" +#include "application_manager/commands/command_notification_impl.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace simple_notifications_test { + +using namespace application_manager; + +using ::testing::Types; +using commands::NotificationToHMI; +template <typename Command> +class SimpleNotificationsTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + typedef Command CommandType; +}; + +typedef Types<commands::CommandNotificationImpl, NotificationToHMI> + CommandsList; + +TYPED_TEST_CASE(SimpleNotificationsTest, CommandsList); + +TYPED_TEST(SimpleNotificationsTest, Run_SendMessageToHMI_SUCCESS) { + typedef typename TestFixture::CommandType CommandType; + + SharedPtr<CommandType> command = this->template CreateCommand<CommandType>(); + + // Current implementation always return `true` + EXPECT_TRUE(command->Init()); + EXPECT_NO_THROW(command->Run()); + EXPECT_TRUE(command->CleanUp()); +} + +} // namespace simple_notifications_test +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_request_from_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_request_from_hmi_test.cc new file mode 100644 index 0000000000..e47009583f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_request_from_hmi_test.cc @@ -0,0 +1,99 @@ +/* + * 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 "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/commands/request_from_hmi.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace simple_requests_from_hmi_test { + +using ::testing::_; +using ::testing::Types; +using ::testing::NotNull; +using ::testing::NiceMock; + +using ::utils::SharedPtr; +namespace commands = ::application_manager::commands; +using commands::MessageSharedPtr; +using ::application_manager::event_engine::EventObserver; +using ::test::components::event_engine_test::MockEventDispatcher; + +class RequestFromHMITest : public CommandsTest<CommandsTestMocks::kIsNice> { + protected: + void SetUp() OVERRIDE { + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher_)); + } + NiceMock<event_engine_test::MockEventDispatcher> mock_event_dispatcher_; +}; + +TEST_F(RequestFromHMITest, BasicMethodsOverloads_SUCCESS) { + SharedPtr<commands::RequestFromHMI> command( + CreateCommand<commands::RequestFromHMI>()); + application_manager::event_engine::Event event( + hmi_apis::FunctionID::BasicCommunication_ActivateApp); + // Current implementation always return `true` + EXPECT_TRUE(command->Init()); + EXPECT_TRUE(command->CleanUp()); + EXPECT_NO_THROW(command->Run()); + EXPECT_NO_THROW(command->on_event(event)); +} + +TEST_F(RequestFromHMITest, SendResponse_SUCCESS) { + SharedPtr<commands::RequestFromHMI> command( + CreateCommand<commands::RequestFromHMI>()); + + const bool success = false; + const uint32_t correlation_id = 1u; + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(NotNull())); + + command->SendResponse(success, + correlation_id, + hmi_apis::FunctionID::BasicCommunication_ActivateApp, + hmi_apis::Common_Result::SUCCESS); +} + +} // namespace simple_requests_to_hmi_test +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc new file mode 100644 index 0000000000..c24cfc48db --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc @@ -0,0 +1,267 @@ +/* + * 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 copyright holders nor the names of their contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/command.h" +#include "sdl_rpc_plugin/commands/hmi/allow_app_request.h" +#include "sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h" +#include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_send_location_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h" +#include "application_manager/commands/request_to_hmi.h" +#include "sdl_rpc_plugin/commands/hmi/dial_number_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_speak_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/close_popup_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_add_command_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_add_submenu_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_alert_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_change_registration_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_delete_submenu_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_show_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_slider_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_add_command_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_change_registration_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_perform_interaction_request.h" +#include "sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h" +#include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/allow_app_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_send_location_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_policy_update.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_icon_request.h" +#include "sdl_rpc_plugin/commands/hmi/dial_number_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h" + +#include "application_manager/mock_event_dispatcher.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace simple_requests_to_hmi_test { + +using ::testing::_; +using ::testing::Types; +using ::testing::NotNull; + +using ::utils::SharedPtr; + +namespace am_commands = application_manager::commands; +using am_commands::MessageSharedPtr; +using event_engine_test::MockEventDispatcher; + +class RequestToHMITest : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(RequestToHMITest, BasicMethodsOverloads_SUCCESS) { + SharedPtr<am_commands::RequestToHMI> command( + CreateCommand<am_commands::RequestToHMI>()); + + // Current implementation always return `true` + EXPECT_TRUE(command->Init()); + EXPECT_NO_THROW(command->Run()); + EXPECT_TRUE(command->CleanUp()); +} + +TEST_F(RequestToHMITest, SendRequest_SUCCESS) { + SharedPtr<am_commands::RequestToHMI> command( + CreateCommand<am_commands::RequestToHMI>()); + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(NotNull())); + + command->SendRequest(); +} + +template <typename Command> +class RequestToHMICommandsTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + typedef Command CommandType; +}; + +template <typename Command> +class RequestToHMICommandsTest2 : public RequestToHMICommandsTest<Command> {}; + +template <typename Command> +class RequestToHMICommandsTest3 + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + typedef Command CommandType; +}; + +typedef Types<sdl_rpc_plugin::commands::hmi::DialNumberRequest, + sdl_rpc_plugin::commands::ClosePopupRequest, + sdl_rpc_plugin::commands::TTSSetGlobalPropertiesRequest, + sdl_rpc_plugin::commands::TTSSpeakRequest, + sdl_rpc_plugin::commands::TTSStopSpeakingRequest, + sdl_rpc_plugin::commands::TTSGetSupportedLanguagesRequest, + sdl_rpc_plugin::commands::UIAddCommandRequest, + sdl_rpc_plugin::commands::UIAddSubmenuRequest, + sdl_rpc_plugin::commands::UIAlertRequest, + sdl_rpc_plugin::commands::UIChangeRegistrationRequest, + sdl_rpc_plugin::commands::UIDeleteCommandRequest, + sdl_rpc_plugin::commands::UIDeleteSubmenuRequest, + sdl_rpc_plugin::commands::UIEndAudioPassThruRequest, + sdl_rpc_plugin::commands::UIGetCapabilitiesRequest, + sdl_rpc_plugin::commands::UIGetLanguageRequest, + sdl_rpc_plugin::commands::UIGetSupportedLanguagesRequest, + sdl_rpc_plugin::commands::UIPerformAudioPassThruRequest, + sdl_rpc_plugin::commands::UIPerformInteractionRequest, + sdl_rpc_plugin::commands::UISetMediaClockTimerRequest, + sdl_rpc_plugin::commands::UIShowRequest, + sdl_rpc_plugin::commands::VRAddCommandRequest, + sdl_rpc_plugin::commands::VRChangeRegistrationRequest, + sdl_rpc_plugin::commands::VRDeleteCommandRequest, + sdl_rpc_plugin::commands::UISliderRequest, + sdl_rpc_plugin::commands::TTSChangeRegistrationRequest, + sdl_rpc_plugin::commands::TTSGetCapabilitiesRequest, + sdl_rpc_plugin::commands::TTSGetLanguageRequest, + sdl_rpc_plugin::commands::AllowAllAppsRequest, + sdl_rpc_plugin::commands::BasicCommunicationSystemRequest, + sdl_rpc_plugin::commands::ButtonGetCapabilitiesRequest, + sdl_rpc_plugin::commands::NaviSendLocationRequest, + sdl_rpc_plugin::commands::NaviUnSubscribeWayPointsRequest, + sdl_rpc_plugin::commands::NaviUpdateTurnListRequest, + sdl_rpc_plugin::commands::NaviShowConstantTBTRequest, + sdl_rpc_plugin::commands::NaviStopStreamRequest, + sdl_rpc_plugin::commands::NaviSubscribeWayPointsRequest, + sdl_rpc_plugin::commands::NaviAlertManeuverRequest, + sdl_rpc_plugin::commands::AudioStopStreamRequest, + sdl_rpc_plugin::commands::NaviGetWayPointsRequest, + sdl_rpc_plugin::commands::UISetGlobalPropertiesRequest, + sdl_rpc_plugin::commands::UISendHapticDataRequest> + RequestCommandsList; + +typedef Types<sdl_rpc_plugin::commands::UIScrollableMessageRequest, + sdl_rpc_plugin::commands::VRGetCapabilitiesRequest, + sdl_rpc_plugin::commands::UISetAppIconRequest, + sdl_rpc_plugin::commands::UiSetDisplayLayoutRequest, + sdl_rpc_plugin::commands::VRGetSupportedLanguagesRequest, + sdl_rpc_plugin::commands::VRGetLanguageRequest, + sdl_rpc_plugin::commands::VRPerformInteractionRequest, + sdl_rpc_plugin::commands::AllowAppRequest, +// TODO (OKozlov). Need to clarify why UT fails +// for UISetIconRequest +// am_commands::UISetIconRequest, +#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) + sdl_rpc_plugin::commands::SDLPolicyUpdate, +#endif + sdl_rpc_plugin::commands::hmi::DialNumberRequest> + RequestCommandsList2; + +typedef Types<sdl_rpc_plugin::commands::TTSIsReadyRequest, + sdl_rpc_plugin::commands::UIIsReadyRequest, + sdl_rpc_plugin::commands::NaviIsReadyRequest, + sdl_rpc_plugin::commands::VRIsReadyRequest> RequestCommandsList3; + +TYPED_TEST_CASE(RequestToHMICommandsTest, RequestCommandsList); +TYPED_TEST_CASE(RequestToHMICommandsTest2, RequestCommandsList2); +TYPED_TEST_CASE(RequestToHMICommandsTest3, RequestCommandsList3); + +TYPED_TEST(RequestToHMICommandsTest, Run_SendMessageToHMI_SUCCESS) { + typedef typename TestFixture::CommandType CommandType; + + SharedPtr<CommandType> command = this->template CreateCommand<CommandType>(); + + EXPECT_CALL(this->mock_rpc_service_, SendMessageToHMI(NotNull())); + + command->Run(); +} + +TYPED_TEST(RequestToHMICommandsTest2, Run_SendMessageToHMI_SUCCESS) { + typedef typename TestFixture::CommandType CommandType; + + SharedPtr<CommandType> command = this->template CreateCommand<CommandType>(); + EXPECT_CALL(this->mock_rpc_service_, SendMessageToHMI(NotNull())); + + command->Run(); +} + +TYPED_TEST(RequestToHMICommandsTest3, Run_SendMessageToHMI_SUCCESS) { + typedef typename TestFixture::CommandType CommandType; + + SharedPtr<CommandType> command = this->template CreateCommand<CommandType>(); + EXPECT_CALL(this->mock_rpc_service_, SendMessageToHMI(NotNull())); + + command->Run(); +} + +} // namespace simple_requests_to_hmi_test +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc new file mode 100644 index 0000000000..229f48b5e1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc @@ -0,0 +1,325 @@ +/* + * 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 copyright holders nor the names of their contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <stdint.h> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command.h" +#include "hmi/activate_app_response.h" +#include "hmi/basic_communication_system_response.h" +#include "hmi/navi_alert_maneuver_response.h" +#include "hmi/navi_audio_start_stream_response.h" +#include "hmi/navi_audio_stop_stream_response.h" +#include "hmi/navi_get_way_points_response.h" +#include "hmi/navi_send_location_response.h" +#include "hmi/navi_show_constant_tbt_response.h" +#include "hmi/navi_start_stream_response.h" +#include "hmi/navi_stop_stream_response.h" +#include "hmi/navi_subscribe_way_points_response.h" +#include "hmi/navi_unsubscribe_way_points_response.h" +#include "hmi/navi_update_turn_list_response.h" +#include "hmi/tts_change_registration_response.h" +#include "hmi/ui_set_app_icon_response.h" +#include "hmi/ui_set_display_layout_response.h" +#include "hmi/ui_set_global_properties_response.h" +#include "hmi/ui_scrollable_message_response.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "hmi/dial_number_response.h" +#include "hmi/close_popup_response.h" +#include "hmi/tts_set_global_properties_response.h" +#include "hmi/tts_speak_response.h" +#include "hmi/tts_stop_speaking_response.h" +#include "hmi/tts_change_registration_response.h" +#include "hmi/ui_add_command_response.h" +#include "hmi/ui_add_submenu_response.h" +#include "hmi/ui_alert_response.h" +#include "hmi/ui_change_registration_response.h" +#include "hmi/ui_delete_command_response.h" +#include "hmi/ui_delete_submenu_response.h" +#include "hmi/ui_end_audio_pass_thru_response.h" +#include "hmi/ui_perform_audio_pass_thru_response.h" +#include "hmi/ui_perform_interaction_response.h" +#include "hmi/ui_set_media_clock_timer_response.h" +#include "hmi/ui_show_response.h" +#include "hmi/ui_slider_response.h" +#include "hmi/vr_add_command_response.h" +#include "hmi/vr_change_registration_response.h" +#include "hmi/vr_delete_command_response.h" +#include "hmi/vr_perform_interaction_response.h" +#include "hmi/activate_app_response.h" +#include "hmi/basic_communication_system_response.h" +#include "hmi/navi_unsubscribe_way_points_response.h" +#include "hmi/navi_update_turn_list_response.h" +#include "hmi/navi_send_location_response.h" +#include "hmi/navi_show_constant_tbt_response.h" +#include "hmi/navi_start_stream_response.h" +#include "hmi/navi_subscribe_way_points_response.h" +#include "hmi/on_find_applications.h" +#include "hmi/on_update_device_list.h" +#include "hmi/sdl_policy_update_response.h" +#include "hmi/update_app_list_response.h" +#include "hmi/update_device_list_response.h" +#include "application_manager/commands/notification_from_hmi.h" +#include "hmi/ui_send_haptic_data_response.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace simple_response_from_hmi_test { + +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::Types; +using ::testing::Eq; + +using ::utils::SharedPtr; +using ::test::components::event_engine_test::MockEventDispatcher; + +namespace am = ::application_manager; +namespace commands = sdl_rpc_plugin::commands; +using am::commands::MessageSharedPtr; +template <class CommandD> +class ResponseFromHMICommandsTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + typedef CommandD CommandData; + MockEventDispatcher event_dispatcher_; + + ResponseFromHMICommandsTest() { + ON_CALL(app_mngr_, event_dispatcher()) + .WillByDefault(ReturnRef(event_dispatcher_)); + } +}; + +template <class Command> +class EmptyResponseFromHMICommandsTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + typedef Command CommandType; +}; + +template <class Command, hmi_apis::FunctionID::eType kExpectedEventId> +struct CommandData { + typedef Command CommandType; + enum { kEventId = kExpectedEventId }; +}; + +typedef Types< + CommandData<sdl_rpc_plugin::commands::TTSSpeakResponse, + hmi_apis::FunctionID::TTS_Speak>, + CommandData<sdl_rpc_plugin::commands::hmi::DialNumberResponse, + hmi_apis::FunctionID::BasicCommunication_DialNumber>, + CommandData<sdl_rpc_plugin::commands::UIDeleteSubmenuResponse, + hmi_apis::FunctionID::UI_DeleteSubMenu>, + CommandData<sdl_rpc_plugin::commands::UIEndAudioPassThruResponse, + hmi_apis::FunctionID::UI_EndAudioPassThru>, + CommandData<sdl_rpc_plugin::commands::TTSSetGlobalPropertiesResponse, + hmi_apis::FunctionID::TTS_SetGlobalProperties>, + CommandData<sdl_rpc_plugin::commands::TTSStopSpeakingResponse, + hmi_apis::FunctionID::TTS_StopSpeaking>, + CommandData<sdl_rpc_plugin::commands::UIAddCommandResponse, + hmi_apis::FunctionID::UI_AddCommand>, + CommandData<sdl_rpc_plugin::commands::UIAddSubmenuResponse, + hmi_apis::FunctionID::UI_AddSubMenu>, + CommandData<sdl_rpc_plugin::commands::UIAlertResponse, + hmi_apis::FunctionID::UI_Alert>, + CommandData<sdl_rpc_plugin::commands::UIChangeRegistratioResponse, + hmi_apis::FunctionID::UI_ChangeRegistration>, + CommandData<sdl_rpc_plugin::commands::UIDeleteCommandResponse, + hmi_apis::FunctionID::UI_DeleteCommand>, + CommandData<sdl_rpc_plugin::commands::UIPerformAudioPassThruResponse, + hmi_apis::FunctionID::UI_PerformAudioPassThru>, + CommandData<sdl_rpc_plugin::commands::UIPerformInteractionResponse, + hmi_apis::FunctionID::UI_PerformInteraction>, + CommandData<sdl_rpc_plugin::commands::UIDeleteSubmenuResponse, + hmi_apis::FunctionID::UI_DeleteSubMenu>, + CommandData<sdl_rpc_plugin::commands::UIEndAudioPassThruResponse, + hmi_apis::FunctionID::UI_EndAudioPassThru>, + CommandData<sdl_rpc_plugin::commands::UISetMediaClockTimerResponse, + hmi_apis::FunctionID::UI_SetMediaClockTimer>, + CommandData<sdl_rpc_plugin::commands::UIShowResponse, + hmi_apis::FunctionID::UI_Show>, + CommandData<sdl_rpc_plugin::commands::VRAddCommandResponse, + hmi_apis::FunctionID::VR_AddCommand>, + CommandData<sdl_rpc_plugin::commands::VRChangeRegistrationResponse, + hmi_apis::FunctionID::VR_ChangeRegistration>, + CommandData<sdl_rpc_plugin::commands::VRDeleteCommandResponse, + hmi_apis::FunctionID::VR_DeleteCommand>, + CommandData<sdl_rpc_plugin::commands::UISliderResponse, + hmi_apis::FunctionID::UI_Slider>, + CommandData<sdl_rpc_plugin::commands::TTSChangeRegistratioResponse, + hmi_apis::FunctionID::TTS_ChangeRegistration>, + CommandData<sdl_rpc_plugin::commands::ActivateAppResponse, + hmi_apis::FunctionID::BasicCommunication_ActivateApp>, + CommandData<sdl_rpc_plugin::commands::BasicCommunicationSystemResponse, + hmi_apis::FunctionID::BasicCommunication_SystemRequest>, + CommandData<sdl_rpc_plugin::commands::NaviAlertManeuverResponse, + hmi_apis::FunctionID::Navigation_AlertManeuver>, + CommandData<sdl_rpc_plugin::commands::AudioStartStreamResponse, + hmi_apis::FunctionID::Navigation_StartAudioStream>, + CommandData<sdl_rpc_plugin::commands::NaviGetWayPointsResponse, + hmi_apis::FunctionID::Navigation_GetWayPoints>, + CommandData<sdl_rpc_plugin::commands::NaviSendLocationResponse, + hmi_apis::FunctionID::Navigation_SendLocation>, + CommandData<sdl_rpc_plugin::commands::NaviShowConstantTBTResponse, + hmi_apis::FunctionID::Navigation_ShowConstantTBT>, + CommandData<sdl_rpc_plugin::commands::NaviStartStreamResponse, + hmi_apis::FunctionID::Navigation_StartStream>, + CommandData<sdl_rpc_plugin::commands::NaviSubscribeWayPointsResponse, + hmi_apis::FunctionID::Navigation_SubscribeWayPoints>, + CommandData<sdl_rpc_plugin::commands::NaviUnsubscribeWayPointsResponse, + hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints>, + CommandData<sdl_rpc_plugin::commands::NaviUpdateTurnListResponse, + hmi_apis::FunctionID::Navigation_UpdateTurnList>, + CommandData<sdl_rpc_plugin::commands::UISetAppIconResponse, + hmi_apis::FunctionID::UI_SetAppIcon>, + CommandData<sdl_rpc_plugin::commands::UiSetDisplayLayoutResponse, + hmi_apis::FunctionID::UI_SetDisplayLayout>, + CommandData<sdl_rpc_plugin::commands::UISetGlobalPropertiesResponse, + hmi_apis::FunctionID::UI_SetGlobalProperties>, + CommandData<sdl_rpc_plugin::commands::UISetGlobalPropertiesResponse, + hmi_apis::FunctionID::UI_SetGlobalProperties>, + CommandData<sdl_rpc_plugin::commands::VRPerformInteractionResponse, + hmi_apis::FunctionID::VR_PerformInteraction>, + CommandData<sdl_rpc_plugin::commands::UIScrollableMessageResponse, + hmi_apis::FunctionID::UI_ScrollableMessage>, + CommandData<sdl_rpc_plugin::commands::UISendHapticDataResponse, + hmi_apis::FunctionID::UI_SendHapticData> > ResponseCommandsList; + +typedef Types<sdl_rpc_plugin::commands::AudioStopStreamResponse, + sdl_rpc_plugin::commands::NaviStopStreamResponse, + sdl_rpc_plugin::commands::OnFindApplications, + sdl_rpc_plugin::commands::OnUpdateDeviceList, + sdl_rpc_plugin::commands::SDLPolicyUpdateResponse, + sdl_rpc_plugin::commands::UpdateAppListResponse, + sdl_rpc_plugin::commands::UpdateDeviceListResponse> + EmptyResponseCommandsList; + +TYPED_TEST_CASE(ResponseFromHMICommandsTest, ResponseCommandsList); + +TYPED_TEST_CASE(EmptyResponseFromHMICommandsTest, EmptyResponseCommandsList); + +MATCHER_P(EventIdIsEqualTo, function_id, "") { + return static_cast<hmi_apis::FunctionID::eType>(function_id) == arg.id(); +} + +TYPED_TEST(ResponseFromHMICommandsTest, Run_SendMessageToHMI_SUCCESS) { + typedef typename TestFixture::CommandData CommandData; + typedef typename CommandData::CommandType CommandType; + + SharedPtr<CommandType> command = this->template CreateCommand<CommandType>(); + + EXPECT_CALL(this->event_dispatcher_, + raise_event(EventIdIsEqualTo(CommandData::kEventId))); + + command->Run(); +} + +TYPED_TEST(EmptyResponseFromHMICommandsTest, Run_SUCCESS) { + typedef typename TestFixture::CommandType CommandType; + + SharedPtr<CommandType> command = this->template CreateCommand<CommandType>(); + + command->Run(); +} + +class OtherResponseFromHMICommandsTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +MATCHER_P(VehicleTypeIsEqualTo, vehicle_type, "") { + return (*vehicle_type) == arg.asString(); +} + +MATCHER_P(CheckMsgType, msg_type, "") { + return msg_type == + static_cast<int32_t>( + (*arg)[am::strings::params][am::strings::message_type].asInt()); +} + +class NotificationFromHMITest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(NotificationFromHMITest, BasicMethodsOverloads_SUCCESS) { + SharedPtr<application_manager::commands::NotificationFromHMI> command( + CreateCommand<application_manager::commands::NotificationFromHMI>()); + // Current implementation always return `true` + EXPECT_TRUE(command->Init()); + EXPECT_TRUE(command->CleanUp()); + EXPECT_NO_THROW(command->Run()); +} + +TEST_F(NotificationFromHMITest, SendNotificationToMobile_SUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[am::strings::params][am::strings::message_type] = + static_cast<int32_t>(am::MessageType::kNotification); + + SharedPtr<application_manager::commands::NotificationFromHMI> command( + CreateCommand<application_manager::commands::NotificationFromHMI>()); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(CheckMsgType(am::MessageType::kNotification), + am::commands::Command::CommandSource::SOURCE_SDL)); + + command->SendNotificationToMobile(command_msg); +} + +TEST_F(NotificationFromHMITest, CreateHMIRequest_UNSUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[am::strings::msg_params] = 0; + SharedPtr<application_manager::commands::NotificationFromHMI> command( + CreateCommand<application_manager::commands::NotificationFromHMI>( + command_msg)); + + const uint32_t correlation_id = 1u; + EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillOnce(Return(correlation_id)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(CheckMsgType(am::MessageType::kRequest))) + .WillOnce(Return(false)); + + command->CreateHMIRequest(hmi_apis::FunctionID::INVALID_ENUM, + (*command_msg)[am::strings::msg_params]); +} + +} // namespace simple_response_from_hmi_test +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_to_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_to_hmi_test.cc new file mode 100644 index 0000000000..ef8978c34c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_to_hmi_test.cc @@ -0,0 +1,105 @@ +/* + * 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 "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/command.h" +#include "application_manager/commands/commands_test.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h" +#include "application_manager/commands/response_to_hmi.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace simple_response_to_hmi_test { + +using ::testing::_; +using ::testing::Types; +using ::testing::NotNull; +using ::utils::SharedPtr; + +namespace commands = sdl_rpc_plugin::commands; +using application_manager::commands::MessageSharedPtr; + +template <class Command> +class ResponseToHMICommandsTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + typedef Command CommandType; +}; + +typedef Types<commands::SDLActivateAppResponse, + commands::SDLGetListOfPermissionsResponse, + commands::SDLGetStatusUpdateResponse, + commands::SDLGetUserFriendlyMessageResponse> ResponseCommandsList; + +TYPED_TEST_CASE(ResponseToHMICommandsTest, ResponseCommandsList); + +TYPED_TEST(ResponseToHMICommandsTest, Run_SendMessageToHMI_SUCCESS) { + typedef typename TestFixture::CommandType CommandType; + + SharedPtr<CommandType> command = this->template CreateCommand<CommandType>(); + EXPECT_CALL(this->mock_rpc_service_, SendMessageToHMI(NotNull())); + + command->Run(); +} + +class ResponseToHMITest : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(ResponseToHMITest, BasicMethodsOverloads_SUCCESS) { + SharedPtr<application_manager::commands::ResponseToHMI> command( + CreateCommand<application_manager::commands::ResponseToHMI>()); + + // Current implementation always return `true` + EXPECT_TRUE(command->Init()); + EXPECT_TRUE(command->CleanUp()); +} + +TEST_F(ResponseToHMITest, Run_SUCCESS) { + SharedPtr<application_manager::commands::ResponseToHMI> command( + CreateCommand<application_manager::commands::ResponseToHMI>()); + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(NotNull())); + + command->Run(); +} + +} // namespace simple_response_to_hmi_test +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_capabilities_response_test.cc new file mode 100644 index 0000000000..afc18114de --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_capabilities_response_test.cc @@ -0,0 +1,125 @@ +/* + * 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 <string> + +#include "gtest/gtest.h" +#include "hmi/tts_get_capabilities_response.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "smart_objects/smart_object.h" +#include "application_manager/commands/commands_test.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace tts_get_capabilities_response { + +using application_manager::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::TTSGetCapabilitiesResponse; +using test::components::application_manager_test::MockHMICapabilities; +using utils::SharedPtr; +using testing::_; + +namespace strings = ::application_manager::strings; +namespace hmi_response = ::application_manager::hmi_response; + +namespace { +const std::string kText = "TEXT"; +} + +class TTSGetCapabilitiesResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(TTSGetCapabilitiesResponseTest, Run_BothExist_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::msg_params][hmi_response::speech_capabilities] = kText; + (*msg)[strings::msg_params][hmi_response::prerecorded_speech_capabilities] = + kText; + + EXPECT_CALL(mock_hmi_capabilities_, + set_speech_capabilities(SmartObject(kText))); + EXPECT_CALL(mock_hmi_capabilities_, + set_prerecorded_speech(SmartObject(kText))); + + SharedPtr<TTSGetCapabilitiesResponse> command( + CreateCommand<TTSGetCapabilitiesResponse>(msg)); + + command->Run(); +} + +TEST_F(TTSGetCapabilitiesResponseTest, Run_OnlySpeech_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::msg_params][hmi_response::speech_capabilities] = kText; + + EXPECT_CALL(mock_hmi_capabilities_, + set_speech_capabilities(SmartObject(kText))); + EXPECT_CALL(mock_hmi_capabilities_, set_prerecorded_speech(_)).Times(0); + + SharedPtr<TTSGetCapabilitiesResponse> command( + CreateCommand<TTSGetCapabilitiesResponse>(msg)); + + command->Run(); +} + +TEST_F(TTSGetCapabilitiesResponseTest, Run_OnlyPrerecorded_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::msg_params][hmi_response::prerecorded_speech_capabilities] = + kText; + + EXPECT_CALL(mock_hmi_capabilities_, set_speech_capabilities(_)).Times(0); + EXPECT_CALL(mock_hmi_capabilities_, + set_prerecorded_speech(SmartObject(kText))); + + SharedPtr<TTSGetCapabilitiesResponse> command( + CreateCommand<TTSGetCapabilitiesResponse>(msg)); + + command->Run(); +} + +TEST_F(TTSGetCapabilitiesResponseTest, Run_Nothing_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + + EXPECT_CALL(mock_hmi_capabilities_, set_speech_capabilities(_)).Times(0); + EXPECT_CALL(mock_hmi_capabilities_, set_prerecorded_speech(_)).Times(0); + + SharedPtr<TTSGetCapabilitiesResponse> command( + CreateCommand<TTSGetCapabilitiesResponse>(msg)); + + command->Run(); +} + +} // namespace tts_get_capabilities_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_language_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_language_response_test.cc new file mode 100644 index 0000000000..5f2fe1beda --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_language_response_test.cc @@ -0,0 +1,103 @@ +/* + * 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 "gtest/gtest.h" +#include "hmi/tts_get_language_response.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/commands/commands_test.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace tts_get_language_response { + +using utils::SharedPtr; +using sdl_rpc_plugin::commands::TTSGetLanguageResponse; +using test::components::application_manager_test::MockHMICapabilities; +using test::components::event_engine_test::MockEventDispatcher; +using testing::_; +using testing::ReturnRef; + +namespace strings = application_manager::strings; +namespace hmi_response = application_manager::hmi_response; +using namespace hmi_apis; + +namespace { +const Common_Language::eType kLanguage = Common_Language::EN_GB; +} // namespace + +class TTSGetLanguageResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(TTSGetLanguageResponseTest, Run_LanguageSet_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::msg_params][hmi_response::language] = kLanguage; + + SharedPtr<TTSGetLanguageResponse> command( + CreateCommand<TTSGetLanguageResponse>(msg)); + + EXPECT_CALL(mock_hmi_capabilities_, set_active_tts_language(kLanguage)); + + MockEventDispatcher mock_event_dispatcher; + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher)); + EXPECT_CALL(mock_event_dispatcher, raise_event(_)); + + command->Run(); +} + +TEST_F(TTSGetLanguageResponseTest, Run_LanguageNotSet_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + + SharedPtr<TTSGetLanguageResponse> command( + CreateCommand<TTSGetLanguageResponse>(msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + set_active_tts_language(Common_Language::INVALID_ENUM)); + + MockEventDispatcher mock_event_dispatcher; + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher)); + EXPECT_CALL(mock_event_dispatcher, raise_event(_)); + + command->Run(); +} + +} // namespace tts_get_language_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_supported_languages_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_supported_languages_response_test.cc new file mode 100644 index 0000000000..2672062aab --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_supported_languages_response_test.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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/application.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/response_from_hmi.h" +#include "hmi/tts_get_supported_languages_response.h" +#include "application_manager/policies/mock_policy_handler_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace tts_get_supported_languages_response { + +using ::testing::_; +using ::testing::Return; +using ::utils::SharedPtr; +using ::testing::NiceMock; +namespace am = ::application_manager; +namespace strings = ::application_manager::strings; +namespace hmi_response = am::hmi_response; +using application_manager::commands::ResponseFromHMI; +using sdl_rpc_plugin::commands::TTSGetSupportedLanguagesResponse; +using am::commands::CommandImpl; + +typedef SharedPtr<ResponseFromHMI> ResponseFromHMIPtr; +typedef NiceMock< + ::test::components::application_manager_test::MockHMICapabilities> + MockHMICapabilities; + +namespace { +const uint32_t kConnectionKey = 2u; +} // namespace + +class TTSGetSupportedLanguageResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + SmartObject capabilities_; +}; + +TEST_F(TTSGetSupportedLanguageResponseTest, RUN_SUCCESS) { + smart_objects::SmartObject supported_languages("EN_US"); + + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::msg_params][strings::number] = "123"; + (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*command_msg)[strings::msg_params][hmi_response::capabilities] = + (capabilities_); + (*command_msg)[strings::msg_params][hmi_response::languages] = + supported_languages; + + ResponseFromHMIPtr command( + CreateCommand<TTSGetSupportedLanguagesResponse>(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + set_tts_supported_languages(( + *command_msg)[strings::msg_params][hmi_response::languages])); + + command->Run(); +} +TEST_F(TTSGetSupportedLanguageResponseTest, RUN_UNSUCCESS) { + smart_objects::SmartObject supported_languages("EN_US"); + + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::msg_params][strings::number] = "123"; + (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::WRONG_LANGUAGE; + (*command_msg)[strings::msg_params][hmi_response::capabilities] = + (capabilities_); + + ResponseFromHMIPtr command( + CreateCommand<TTSGetSupportedLanguagesResponse>(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + set_tts_supported_languages(supported_languages)).Times(0); + + command->Run(); + + EXPECT_FALSE((*command_msg)[am::strings::msg_params].keyExists( + am::hmi_response::languages)); +} + +} // namespace tts_get_supported_languages_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_is_ready_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_is_ready_response_test.cc new file mode 100644 index 0000000000..d6d74d18bd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_is_ready_response_test.cc @@ -0,0 +1,99 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/application.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/response_from_hmi.h" +#include "hmi/tts_is_ready_response.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/mock_event_dispatcher.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace tts_is_ready_response { + +using ::testing::_; +using ::testing::Return; +using ::utils::SharedPtr; +using ::testing::NiceMock; +namespace am = ::application_manager; +namespace strings = ::application_manager::strings; +namespace hmi_response = am::hmi_response; +using application_manager::commands::ResponseFromHMI; +using sdl_rpc_plugin::commands::TTSIsReadyResponse; +using am::commands::CommandImpl; +using test::components::event_engine_test::MockEventDispatcher; + +typedef SharedPtr<ResponseFromHMI> ResponseFromHMIPtr; +typedef NiceMock< + ::test::components::application_manager_test::MockHMICapabilities> + MockHMICapabilities; + +namespace { +const uint32_t kConnectionKey = 2u; +const bool kIsAvailable = true; +const bool kIsNotAvailable = false; +} // namespace + +class TTSIsReadyResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + MockHMICapabilities mock_hmi_capabilities_; + SmartObject capabilities_; +}; + +TEST_F(TTSIsReadyResponseTest, RUN_SUCCESS) { + ResponseFromHMIPtr command(CreateCommand<TTSIsReadyResponse>()); + MockEventDispatcher mock_event_dispatcher; + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher)); + EXPECT_CALL(mock_event_dispatcher, raise_event(_)); + + command->Run(); +} + +} // namespace tts_is_ready_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc new file mode 100644 index 0000000000..8dbc09fc4f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc @@ -0,0 +1,314 @@ +/* + * 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 copyright holders nor the names of their contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <stdint.h> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "utils/make_shared.h" +#include "smart_objects/smart_object.h" +#include "interfaces/MOBILE_API.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_impl.h" +#include "hmi/ui_get_capabilities_response.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace ui_get_capabilities_response { + +using ::utils::SharedPtr; +using ::testing::NiceMock; +namespace am = ::application_manager; +namespace strings = am::strings; +namespace hmi_response = am::hmi_response; +using application_manager::commands::ResponseFromHMI; +using sdl_rpc_plugin::commands::UIGetCapabilitiesResponse; +using am::commands::CommandImpl; + +typedef SharedPtr<ResponseFromHMI> ResponseFromHMIPtr; +typedef NiceMock< + ::test::components::application_manager_test::MockHMICapabilities> + MockHMICapabilities; + +namespace { +const uint32_t kConnectionKey = 2u; +} // namespace + +class UIGetCapabilitiesResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + MessageSharedPtr CreateCommandMsg() { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::msg_params][strings::number] = "123"; + (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*command_msg)[strings::msg_params][hmi_response::capabilities] = + (capabilities_); + + return command_msg; + } + + SmartObject capabilities_; +}; + +TEST_F(UIGetCapabilitiesResponseTest, RUN_SetDisplay_SUCCESSS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::msg_params][hmi_response::display_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + (*command_msg)[strings::msg_params][hmi_response::display_capabilities] + [hmi_response::display_type] = "GEN2_8_DMA"; + (*command_msg)[strings::msg_params][hmi_response::display_capabilities] + [hmi_response::display_name] = "GENERIC_DISPLAY"; + + ResponseFromHMIPtr command( + CreateCommand<UIGetCapabilitiesResponse>(command_msg)); + + smart_objects::SmartObject display_capabilities_so = + (*command_msg)[strings::msg_params][hmi_response::display_capabilities]; + + EXPECT_CALL(mock_hmi_capabilities_, + set_display_capabilities(display_capabilities_so)); + + command->Run(); +} + +TEST_F(UIGetCapabilitiesResponseTest, SetSoftButton_SUCCESS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::msg_params][hmi_response::soft_button_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + (*command_msg)[strings::msg_params][hmi_response::soft_button_capabilities] + [hmi_response::image_supported] = true; + + ResponseFromHMIPtr command( + CreateCommand<UIGetCapabilitiesResponse>(command_msg)); + + smart_objects::SmartObject soft_button_capabilities_so = (*command_msg) + [strings::msg_params][hmi_response::soft_button_capabilities]; + + EXPECT_CALL(mock_hmi_capabilities_, + set_soft_button_capabilities(soft_button_capabilities_so)); + + command->Run(); +} + +TEST_F(UIGetCapabilitiesResponseTest, SetHmiZone_SUCCESS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::msg_params][hmi_response::hmi_zone_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + (*command_msg)[strings::msg_params][hmi_response::hmi_zone_capabilities][0] = + "FRONT"; + + ResponseFromHMIPtr command( + CreateCommand<UIGetCapabilitiesResponse>(command_msg)); + + smart_objects::SmartObject hmi_zone_capabilities_so = + (*command_msg)[strings::msg_params][hmi_response::hmi_zone_capabilities]; + + EXPECT_CALL(mock_hmi_capabilities_, + set_hmi_zone_capabilities(hmi_zone_capabilities_so)); + + command->Run(); +} + +TEST_F(UIGetCapabilitiesResponseTest, SetAudioPassThru_SUCCESS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::msg_params][strings::audio_pass_thru_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + ResponseFromHMIPtr command( + CreateCommand<UIGetCapabilitiesResponse>(command_msg)); + + smart_objects::SmartObject audio_pass_thru_capabilities_so = (*command_msg) + [strings::msg_params][strings::audio_pass_thru_capabilities]; + EXPECT_CALL( + mock_hmi_capabilities_, + set_audio_pass_thru_capabilities(audio_pass_thru_capabilities_so)); + + command->Run(); +} + +TEST_F(UIGetCapabilitiesResponseTest, SetNavigation_SUCCESS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::msg_params][strings::hmi_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + (*command_msg)[strings::msg_params][strings::hmi_capabilities] + [strings::navigation] = true; + + ResponseFromHMIPtr command( + CreateCommand<UIGetCapabilitiesResponse>(command_msg)); + + smart_objects::SmartObject hmi_capabilities_so = + (*command_msg)[strings::msg_params][strings::hmi_capabilities]; + EXPECT_CALL(mock_hmi_capabilities_, + set_navigation_supported( + hmi_capabilities_so[strings::navigation].asBool())); + + command->Run(); +} + +TEST_F(UIGetCapabilitiesResponseTest, SetPhoneCall_SUCCESS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::msg_params][strings::hmi_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + (*command_msg)[strings::msg_params][strings::hmi_capabilities] + [strings::phone_call] = true; + + ResponseFromHMIPtr command( + CreateCommand<UIGetCapabilitiesResponse>(command_msg)); + + smart_objects::SmartObject hmi_capabilities_so = + (*command_msg)[strings::msg_params][strings::hmi_capabilities]; + EXPECT_CALL(mock_hmi_capabilities_, + set_phone_call_supported( + hmi_capabilities_so[strings::phone_call].asBool())); + + command->Run(); +} + +TEST_F(UIGetCapabilitiesResponseTest, SetVideoStreaming_SUCCESS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::msg_params][strings::hmi_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + (*command_msg)[strings::msg_params][strings::hmi_capabilities] + [strings::video_streaming] = true; + + ResponseFromHMIPtr command( + CreateCommand<UIGetCapabilitiesResponse>(command_msg)); + + smart_objects::SmartObject hmi_capabilities_so = + (*command_msg)[strings::msg_params][strings::hmi_capabilities]; + EXPECT_CALL(mock_hmi_capabilities_, + set_video_streaming_supported( + hmi_capabilities_so[strings::video_streaming].asBool())); + + command->Run(); +} + +TEST_F(UIGetCapabilitiesResponseTest, SetNavigationCapability_SUCCESS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::msg_params][strings::system_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + (*command_msg)[strings::msg_params][strings::system_capabilities] + [strings::navigation_capability]["sendLocationEnabled"] = true; + + (*command_msg)[strings::msg_params][strings::system_capabilities] + [strings::navigation_capability]["getWayPointsEnabled"] = true; + + ResponseFromHMIPtr command( + CreateCommand<UIGetCapabilitiesResponse>(command_msg)); + + smart_objects::SmartObject navigation_capability_so = + (*command_msg)[strings::msg_params][strings::system_capabilities] + [strings::navigation_capability]; + + EXPECT_CALL(mock_hmi_capabilities_, + set_navigation_capability(navigation_capability_so)); + + command->Run(); +} + +TEST_F(UIGetCapabilitiesResponseTest, SetPhonenCapability_SUCCESS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::msg_params][strings::system_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + (*command_msg)[strings::msg_params][strings::system_capabilities] + [strings::phone_capability]["dialNumberEnabled"] = true; + + ResponseFromHMIPtr command( + CreateCommand<UIGetCapabilitiesResponse>(command_msg)); + + smart_objects::SmartObject phone_capability_so = + (*command_msg)[strings::msg_params][strings::system_capabilities] + [strings::phone_capability]; + + EXPECT_CALL(mock_hmi_capabilities_, + set_phone_capability(phone_capability_so)); + + command->Run(); +} + +TEST_F(UIGetCapabilitiesResponseTest, SetVideoStreamingCapability_SUCCESS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::msg_params][strings::system_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + (*command_msg)[strings::msg_params][strings::system_capabilities] + [strings::video_streaming_capability] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + smart_objects::SmartObject& video_streaming_capability = + (*command_msg)[strings::msg_params][strings::system_capabilities] + [strings::video_streaming_capability]; + + video_streaming_capability[strings::preferred_resolution] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + video_streaming_capability[strings::preferred_resolution] + [strings::resolution_width] = 800; + video_streaming_capability[strings::preferred_resolution] + [strings::resolution_height] = 350; + + video_streaming_capability[strings::max_bitrate] = 10000; + + video_streaming_capability[strings::supported_formats] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + video_streaming_capability[strings::supported_formats][0] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + video_streaming_capability[strings::supported_formats][0][strings::protocol] = + hmi_apis::Common_VideoStreamingProtocol::RAW; + + video_streaming_capability[strings::supported_formats][0][strings::codec] = + hmi_apis::Common_VideoStreamingCodec::H264; + + video_streaming_capability[strings::haptic_spatial_data_supported] = true; + + ResponseFromHMIPtr command( + CreateCommand<UIGetCapabilitiesResponse>(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + set_video_streaming_capability(video_streaming_capability)); + + command->Run(); +} + +} // namespace ui_get_capabilities_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_language_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_language_response_test.cc new file mode 100644 index 0000000000..285024ed40 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_language_response_test.cc @@ -0,0 +1,107 @@ +/* + * 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 "gtest/gtest.h" +#include "hmi/ui_get_language_response.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_application_manager.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace ui_get_language_response { + +using utils::SharedPtr; +using sdl_rpc_plugin::commands::UIGetLanguageResponse; +using test::components::event_engine_test::MockEventDispatcher; +using testing::_; +using testing::ReturnRef; +using ::testing::NiceMock; + +namespace strings = application_manager::strings; +namespace hmi_response = application_manager::hmi_response; +using namespace hmi_apis; + +typedef NiceMock< + ::test::components::application_manager_test::MockHMICapabilities> + MockHMICapabilities; + +namespace { +const hmi_apis::Common_Language::eType kLanguage = Common_Language::EN_GB; +} // namespace + +class UIGetLanguageResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(UIGetLanguageResponseTest, Run_LanguageSet_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::msg_params][hmi_response::language] = kLanguage; + + SharedPtr<UIGetLanguageResponse> command( + CreateCommand<UIGetLanguageResponse>(msg)); + + EXPECT_CALL(mock_hmi_capabilities_, set_active_ui_language(kLanguage)); + + MockEventDispatcher mock_event_dispatcher; + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher)); + EXPECT_CALL(mock_event_dispatcher, raise_event(_)); + + command->Run(); +} + +TEST_F(UIGetLanguageResponseTest, Run_LanguageNotSet_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + + SharedPtr<UIGetLanguageResponse> command( + CreateCommand<UIGetLanguageResponse>(msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + set_active_ui_language(Common_Language::INVALID_ENUM)); + + MockEventDispatcher mock_event_dispatcher; + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher)); + EXPECT_CALL(mock_event_dispatcher, raise_event(_)); + + command->Run(); +} + +} // namespace ui_get_language_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_supported_languages_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_supported_languages_response_test.cc new file mode 100644 index 0000000000..021ef4fdb6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_supported_languages_response_test.cc @@ -0,0 +1,124 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/application.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_application_manager.h" +#include "hmi/ui_get_supported_languages_response.h" +#include "application_manager/policies/mock_policy_handler_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace ui_get_supported_languages_response { + +using ::testing::Return; +using ::utils::SharedPtr; +using ::testing::NiceMock; +namespace am = ::application_manager; +namespace strings = ::application_manager::strings; +namespace hmi_response = am::hmi_response; +using sdl_rpc_plugin::commands::UIGetSupportedLanguagesResponse; + +typedef SharedPtr<UIGetSupportedLanguagesResponse> + UIGetSupportedLanguagesResponsePtr; +typedef NiceMock< + ::test::components::application_manager_test::MockHMICapabilities> + MockHMICapabilities; + +namespace { +const uint32_t kConnectionKey = 2u; +const std::string kStringNum = "123"; +const std::string kLanguage = "EN_US"; +const smart_objects::SmartObject supported_languages(kLanguage); +} // namespace + +class UIGetSupportedLanguagesResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + SmartObject capabilities_; +}; + +TEST_F(UIGetSupportedLanguagesResponseTest, RUN_SUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::msg_params][strings::number] = kStringNum; + (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*command_msg)[strings::msg_params][hmi_response::capabilities] = + (capabilities_); + (*command_msg)[strings::msg_params][hmi_response::languages] = + supported_languages; + + UIGetSupportedLanguagesResponsePtr command( + CreateCommand<UIGetSupportedLanguagesResponse>(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + set_ui_supported_languages((supported_languages))); + + command->Run(); +} +TEST_F(UIGetSupportedLanguagesResponseTest, RUN_UNSUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::msg_params][strings::number] = kStringNum; + (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::WRONG_LANGUAGE; + (*command_msg)[strings::msg_params][hmi_response::capabilities] = + (capabilities_); + + UIGetSupportedLanguagesResponsePtr command( + CreateCommand<UIGetSupportedLanguagesResponse>(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + set_ui_supported_languages(supported_languages)).Times(0); + + command->Run(); + + EXPECT_FALSE((*command_msg)[am::strings::msg_params].keyExists( + am::hmi_response::languages)); +} + +} // namespace ui_get_supported_languages_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_request_test.cc new file mode 100644 index 0000000000..b8fc839f12 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_request_test.cc @@ -0,0 +1,199 @@ +/* + * 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 "hmi/ui_is_ready_request.h" + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/hmi_interfaces.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace ui_is_ready_request { + +namespace am = ::application_manager; + +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::UIIsReadyRequest; +using am::event_engine::Event; + +typedef SharedPtr<UIIsReadyRequest> UIIsReadyRequestPtr; + +class UIIsReadyRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + UIIsReadyRequestTest() : command_(CreateCommand<UIIsReadyRequest>()) {} + + void SetUpExpectations(bool is_ui_cooperating_available, + bool is_send_message_to_hmi, + bool is_message_contain_param, + am::HmiInterfaces::InterfaceState state) { + EXPECT_CALL(mock_hmi_capabilities_, + set_is_ui_cooperating(is_ui_cooperating_available)); + + if (is_message_contain_param) { + EXPECT_CALL(app_mngr_, hmi_interfaces()) + .WillRepeatedly(ReturnRef(mock_hmi_interfaces_)); + EXPECT_CALL( + mock_hmi_interfaces_, + SetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI, state)); + } else { + EXPECT_CALL(app_mngr_, hmi_interfaces()) + .WillOnce(ReturnRef(mock_hmi_interfaces_)); + EXPECT_CALL(mock_hmi_interfaces_, SetInterfaceState(_, _)).Times(0); + } + + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillOnce(Return(state)); + + if (is_send_message_to_hmi) { + ExpectSendMessagesToHMI(); + } + } + + void ExpectSendMessagesToHMI() { + smart_objects::SmartObjectSPtr get_language(CreateMessage()); + (*get_language)[am::strings::params][am::strings::message_type] = + static_cast<int>(am::MessageType::kRequest); + (*get_language)[am::strings::msg_params] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + EXPECT_CALL(mock_message_helper_, + CreateModuleInfoSO(hmi_apis::FunctionID::UI_GetLanguage, _)) + .WillOnce(Return(get_language)); + + smart_objects::SmartObjectSPtr get_all_language(CreateMessage()); + (*get_all_language)[am::strings::params][am::strings::message_type] = + static_cast<int>(am::MessageType::kRequest); + (*get_all_language)[am::strings::msg_params] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + EXPECT_CALL( + mock_message_helper_, + CreateModuleInfoSO(hmi_apis::FunctionID::UI_GetSupportedLanguages, _)) + .WillOnce(Return(get_all_language)); + + smart_objects::SmartObjectSPtr get_capabilities(CreateMessage()); + (*get_capabilities)[am::strings::params][am::strings::message_type] = + static_cast<int>(am::MessageType::kRequest); + (*get_capabilities)[am::strings::msg_params] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + EXPECT_CALL(mock_message_helper_, + CreateModuleInfoSO(hmi_apis::FunctionID::UI_GetCapabilities, _)) + .WillOnce(Return(get_capabilities)); + + EXPECT_CALL(mock_hmi_capabilities_, set_handle_response_for(*get_language)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(get_language)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(get_all_language)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(get_capabilities)); + } + + void PrepareEvent(bool is_message_contain_param, + Event& event, + bool is_ui_cooperating_available = false) { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + if (is_message_contain_param) { + (*msg)[am::strings::msg_params][am::strings::available] = + is_ui_cooperating_available; + } + event.set_smart_object(*msg); + } + + UIIsReadyRequestPtr command_; + policy_test::MockPolicyHandlerInterface mock_policy_handler_interface_; +}; + +TEST_F(UIIsReadyRequestTest, + OnEvent_NoKeyAvailableInMessage_HmiInterfacesIgnored) { + const bool is_ui_cooperating_available = false; + const bool is_send_message_to_hmi = true; + const bool is_message_contain_param = false; + Event event(hmi_apis::FunctionID::UI_IsReady); + PrepareEvent(is_message_contain_param, event); + SetUpExpectations(is_ui_cooperating_available, + is_send_message_to_hmi, + is_message_contain_param, + am::HmiInterfaces::STATE_NOT_RESPONSE); + + command_->on_event(event); +} + +TEST_F(UIIsReadyRequestTest, + OnEvent_KeyAvailableEqualToFalse_StateNotAvailable) { + const bool is_ui_cooperating_available = false; + const bool is_send_message_to_hmi = false; + const bool is_message_contain_param = true; + Event event(hmi_apis::FunctionID::UI_IsReady); + PrepareEvent(is_message_contain_param, event); + SetUpExpectations(is_ui_cooperating_available, + is_send_message_to_hmi, + is_message_contain_param, + am::HmiInterfaces::STATE_NOT_AVAILABLE); + command_->on_event(event); +} + +TEST_F(UIIsReadyRequestTest, OnEvent_KeyAvailableEqualToTrue_StateAvailable) { + const bool is_ui_cooperating_available = true; + const bool is_send_message_to_hmi = true; + const bool is_message_contain_param = true; + Event event(hmi_apis::FunctionID::UI_IsReady); + PrepareEvent(is_message_contain_param, event, is_ui_cooperating_available); + SetUpExpectations(is_ui_cooperating_available, + is_send_message_to_hmi, + is_message_contain_param, + am::HmiInterfaces::STATE_AVAILABLE); + command_->on_event(event); +} + +TEST_F(UIIsReadyRequestTest, OnTimeout_SUCCESS) { + ExpectSendMessagesToHMI(); + command_->onTimeOut(); +} + +} // namespace ui_is_ready_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_response_test.cc new file mode 100644 index 0000000000..6817c5ef0e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_response_test.cc @@ -0,0 +1,92 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "hmi/ui_is_ready_response.h" +#include "application_manager/mock_event_dispatcher.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace ui_is_ready_response { + +using ::testing::Return; +using ::utils::SharedPtr; +using ::testing::NiceMock; +namespace am = ::application_manager; +namespace strings = ::application_manager::strings; +namespace hmi_response = am::hmi_response; +using sdl_rpc_plugin::commands::UIIsReadyResponse; +using test::components::event_engine_test::MockEventDispatcher; + +typedef SharedPtr<UIIsReadyResponse> UIIsReadyResponsePtr; +typedef NiceMock< + ::test::components::application_manager_test::MockHMICapabilities> + MockHMICapabilities; + +namespace { +const uint32_t kConnectionKey = 2u; +const std::string kStringNum = "123"; +const bool kIsAvailable = true; +const bool kIsNotAvailable = false; +} // namespace + +class UIIsReadyResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + MockHMICapabilities mock_hmi_capabilities_; + SmartObject capabilities_; +}; + +TEST_F(UIIsReadyResponseTest, RUN_SUCCESS) { + UIIsReadyResponsePtr command(CreateCommand<UIIsReadyResponse>()); + + MockEventDispatcher mock_event_dispatcher; + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher)); + EXPECT_CALL(mock_event_dispatcher, raise_event(_)); + + command->Run(); +} + +} // namespace ui_is_ready_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc new file mode 100644 index 0000000000..2ce7d9e8f0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc @@ -0,0 +1,173 @@ +/* + * 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 <stdint.h> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "interfaces/HMI_API.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/application_manager.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_application.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/request_controller_settings.h" +#include "application_manager/mock_application_manager_settings.h" +#include "hmi/update_device_list_request.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace update_device_list_request { + +using ::utils::SharedPtr; +using testing::_; +using testing::ReturnRef; +using testing::Return; +using test::components::event_engine_test::MockEventDispatcher; +using ::test::components::application_manager_test:: + MockApplicationManagerSettings; +namespace am = ::application_manager; +namespace strings = am::strings; +namespace hmi_response = am::hmi_response; +using am::event_engine::Event; +using sdl_rpc_plugin::commands::UpdateDeviceListRequest; +using am::commands::CommandImpl; + +typedef SharedPtr<UpdateDeviceListRequest> UpdateDeviceListRequestPtr; + +namespace { +const uint32_t kConnectionKey = 2u; +} // namespace + +class UpdateDeviceListRequestTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + MessageSharedPtr CreateCommandMsg() { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::msg_params][strings::number] = "123"; + (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + + return command_msg; + } + + MockApplicationManagerSettings settings_; + MockEventDispatcher mock_event_dispatcher_; +}; + +TEST_F(UpdateDeviceListRequestTest, RUN_LaunchHMIReturnsFalse) { + MessageSharedPtr command_msg = CreateCommandMsg(); + + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher_)); + EXPECT_CALL(mock_event_dispatcher_, remove_observer(_)); + + UpdateDeviceListRequestPtr command( + CreateCommand<UpdateDeviceListRequest>(command_msg)); + + EXPECT_CALL(app_mngr_, get_settings()).WillOnce(ReturnRef(settings_)); + + EXPECT_CALL(settings_, launch_hmi()).WillOnce(Return(false)); + + EXPECT_CALL(app_mngr_, IsHMICooperating()).Times(0); + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(command_msg)); + + command->Run(); + + EXPECT_EQ((*command_msg)[strings::params][strings::protocol_type].asInt(), + CommandImpl::hmi_protocol_type_); + EXPECT_EQ((*command_msg)[strings::params][strings::protocol_version].asInt(), + CommandImpl::protocol_version_); +} + +TEST_F(UpdateDeviceListRequestTest, RUN_HMICooperatingReturnsTrue_SUCCESSS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher_)); + EXPECT_CALL(mock_event_dispatcher_, remove_observer(_)); + + UpdateDeviceListRequestPtr command( + CreateCommand<UpdateDeviceListRequest>(command_msg)); + + EXPECT_CALL(app_mngr_, get_settings()).WillOnce(ReturnRef(settings_)); + + EXPECT_CALL(settings_, launch_hmi()).WillOnce(Return(true)); + + EXPECT_CALL(app_mngr_, IsHMICooperating()).WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(command_msg)); + + command->Run(); + + EXPECT_EQ((*command_msg)[strings::params][strings::protocol_type].asInt(), + CommandImpl::hmi_protocol_type_); + EXPECT_EQ((*command_msg)[strings::params][strings::protocol_version].asInt(), + CommandImpl::protocol_version_); +} + +TEST_F(UpdateDeviceListRequestTest, OnEvent_WrongEventId_UNSUCCESS) { + Event event(Event::EventID::INVALID_ENUM); + + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher_)); + EXPECT_CALL(mock_event_dispatcher_, remove_observer(_)); + + UpdateDeviceListRequestPtr command(CreateCommand<UpdateDeviceListRequest>()); + + command->on_event(event); +} + +TEST_F(UpdateDeviceListRequestTest, OnEvent_SUCCESS) { + Event event(Event::EventID::BasicCommunication_OnReady); + + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher_)); + EXPECT_CALL(mock_event_dispatcher_, remove_observer(_, _)); + EXPECT_CALL(mock_event_dispatcher_, remove_observer(_)); + + UpdateDeviceListRequestPtr command(CreateCommand<UpdateDeviceListRequest>()); + + command->on_event(event); +} + +} // namespace update_device_list_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_request_test.cc new file mode 100644 index 0000000000..2b079a21e0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_request_test.cc @@ -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. + */ + +#include <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/application.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "hmi/update_sdl_request.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace update_sdl_request { + +using ::utils::SharedPtr; +using ::testing::ReturnRef; +using ::testing::NiceMock; +namespace am = ::application_manager; +namespace strings = ::application_manager::strings; +using sdl_rpc_plugin::commands::UpdateSDLRequest; + +typedef SharedPtr<UpdateSDLRequest> UpdateSDLRequestPtr; + +namespace { +const uint32_t kConnectionKey = 2u; +const uint32_t kCorrelationId = 1u; +const std::string kStrNumber = "123"; +} // namespace + +class UpdateSDLRequestTest : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(UpdateSDLRequestTest, RUN_SUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::msg_params][strings::number] = kStrNumber; + (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; + (*command_msg)[strings::params][strings::correlation_id] = kCorrelationId; + + UpdateSDLRequestPtr command(CreateCommand<UpdateSDLRequest>(command_msg)); + + EXPECT_CALL(mock_policy_handler_, PTExchangeAtUserRequest(kCorrelationId)); + + command->Run(); + + EXPECT_EQ(kCorrelationId, + (*command_msg)[strings::params][strings::correlation_id].asUInt()); +} + +} // namespace update_sdl_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_response_test.cc new file mode 100644 index 0000000000..0035637605 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_response_test.cc @@ -0,0 +1,86 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/application.h" +#include "hmi/update_sdl_response.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace update_sdl_response { + +using ::utils::SharedPtr; +namespace am = ::application_manager; +namespace strings = ::application_manager::strings; +using sdl_rpc_plugin::commands::UpdateSDLResponse; +using am::commands::CommandImpl; + +typedef SharedPtr<UpdateSDLResponse> UpdateSDLResponsePtr; + +namespace { +const uint32_t kConnectionKey = 2u; +const std::string kStrNumber = "123"; +} // namespace + +class UpdateSDLResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> { +}; + +TEST_F(UpdateSDLResponseTest, RUN_SendRequest_SUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::msg_params][strings::number] = kStrNumber; + (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; + + UpdateSDLResponsePtr command(CreateCommand<UpdateSDLResponse>(command_msg)); + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(command_msg)); + + command->Run(); + + EXPECT_EQ((*command_msg)[strings::params][strings::protocol_type].asInt(), + CommandImpl::hmi_protocol_type_); + EXPECT_EQ((*command_msg)[strings::params][strings::protocol_version].asInt(), + CommandImpl::protocol_version_); +} + +} // namespace update_sdl_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_capabilities_response_test.cc new file mode 100644 index 0000000000..0163fdd1d1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_capabilities_response_test.cc @@ -0,0 +1,108 @@ +/* + * 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 <stdint.h> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "interfaces/MOBILE_API.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_impl.h" +#include "hmi/vr_get_capabilities_response.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace vr_get_capabilities_response { + +using ::utils::SharedPtr; +using ::testing::NiceMock; +namespace am = ::application_manager; +namespace strings = am::strings; +namespace hmi_response = am::hmi_response; +using sdl_rpc_plugin::commands::VRGetCapabilitiesResponse; +using am::commands::CommandImpl; + +typedef SharedPtr<VRGetCapabilitiesResponse> VRGetCapabilitiesResponsePtr; +typedef NiceMock< + ::test::components::application_manager_test::MockHMICapabilities> + MockHMICapabilities; + +namespace { +const uint32_t kConnectionKey = 2u; +} // namespace + +class VRGetCapabilitiesResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + MessageSharedPtr CreateCommandMsg() { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::msg_params][strings::number] = "123"; + (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*command_msg)[strings::msg_params][hmi_response::capabilities] = + (capabilities_); + + return command_msg; + } + + SmartObject capabilities_; +}; + +TEST_F(VRGetCapabilitiesResponseTest, RUN_SUCCESSS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::msg_params][strings::vr_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + (*command_msg)[strings::msg_params][strings::vr_capabilities][0] = + "vrCapabilities"; + + VRGetCapabilitiesResponsePtr command( + CreateCommand<VRGetCapabilitiesResponse>(command_msg)); + + smart_objects::SmartObject vr_capabilities_so = + (*command_msg)[strings::msg_params][strings::vr_capabilities]; + + EXPECT_CALL(mock_hmi_capabilities_, set_vr_capabilities(vr_capabilities_so)); + + command->Run(); +} + +} // namespace vr_get_capabilities_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_language_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_language_response_test.cc new file mode 100644 index 0000000000..845324925f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_language_response_test.cc @@ -0,0 +1,107 @@ +/* + * 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 "gtest/gtest.h" +#include "hmi/vr_get_language_response.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_application_manager.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace vr_get_language_response { + +using utils::SharedPtr; +using sdl_rpc_plugin::commands::VRGetLanguageResponse; +using test::components::event_engine_test::MockEventDispatcher; +using testing::_; +using testing::ReturnRef; +using ::testing::NiceMock; + +namespace strings = application_manager::strings; +namespace hmi_response = application_manager::hmi_response; +using namespace hmi_apis; + +typedef NiceMock< + ::test::components::application_manager_test::MockHMICapabilities> + MockHMICapabilities; + +namespace { +const hmi_apis::Common_Language::eType kLanguage = Common_Language::EN_GB; +} // namespace + +class VRGetLanguageResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(VRGetLanguageResponseTest, Run_LanguageSet_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::msg_params][hmi_response::language] = kLanguage; + + SharedPtr<VRGetLanguageResponse> command( + CreateCommand<VRGetLanguageResponse>(msg)); + + EXPECT_CALL(mock_hmi_capabilities_, set_active_vr_language(kLanguage)); + + MockEventDispatcher mock_event_dispatcher; + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher)); + EXPECT_CALL(mock_event_dispatcher, raise_event(_)); + + command->Run(); +} + +TEST_F(VRGetLanguageResponseTest, Run_LanguageNotSet_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + + SharedPtr<VRGetLanguageResponse> command( + CreateCommand<VRGetLanguageResponse>(msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + set_active_vr_language(Common_Language::INVALID_ENUM)); + + MockEventDispatcher mock_event_dispatcher; + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher)); + EXPECT_CALL(mock_event_dispatcher, raise_event(_)); + + command->Run(); +} + +} // namespace vr_get_language_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_supported_languages_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_supported_languages_response_test.cc new file mode 100644 index 0000000000..0ac0d8e118 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_supported_languages_response_test.cc @@ -0,0 +1,124 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/application.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_application_manager.h" +#include "hmi/vr_get_supported_languages_response.h" +#include "application_manager/policies/mock_policy_handler_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace vr_get_supported_languages_response { + +using ::testing::Return; +using ::utils::SharedPtr; +using ::testing::NiceMock; +namespace am = ::application_manager; +namespace strings = ::application_manager::strings; +namespace hmi_response = am::hmi_response; +using sdl_rpc_plugin::commands::VRGetSupportedLanguagesResponse; + +typedef SharedPtr<VRGetSupportedLanguagesResponse> + VRGetSupportedLanguagesResponsePtr; +typedef NiceMock< + ::test::components::application_manager_test::MockHMICapabilities> + MockHMICapabilities; + +namespace { +const uint32_t kConnectionKey = 2u; +const std::string kStringNum = "123"; +const std::string kLanguage = "EN_US"; +const smart_objects::SmartObject supported_languages(kLanguage); +} // namespace + +class VRGetSupportedLanguagesResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + SmartObject capabilities_; +}; + +TEST_F(VRGetSupportedLanguagesResponseTest, RUN_SUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::msg_params][strings::number] = kStringNum; + (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*command_msg)[strings::msg_params][hmi_response::capabilities] = + (capabilities_); + (*command_msg)[strings::msg_params][hmi_response::languages] = + supported_languages; + + VRGetSupportedLanguagesResponsePtr command( + CreateCommand<VRGetSupportedLanguagesResponse>(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + set_vr_supported_languages((supported_languages))); + + command->Run(); +} +TEST_F(VRGetSupportedLanguagesResponseTest, RUN_UNSUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[strings::msg_params][strings::number] = kStringNum; + (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::WRONG_LANGUAGE; + (*command_msg)[strings::msg_params][hmi_response::capabilities] = + (capabilities_); + + VRGetSupportedLanguagesResponsePtr command( + CreateCommand<VRGetSupportedLanguagesResponse>(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, + set_vr_supported_languages(supported_languages)).Times(0); + + command->Run(); + + EXPECT_FALSE((*command_msg)[am::strings::msg_params].keyExists( + am::hmi_response::languages)); +} + +} // namespace vr_get_supported_languages_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_request_test.cc new file mode 100644 index 0000000000..1ec0adb5e0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_request_test.cc @@ -0,0 +1,182 @@ +/* + * 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 "hmi/vr_is_ready_request.h" + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/hmi_interfaces.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace vr_is_ready_request { + +using ::testing::_; +using ::testing::ReturnRef; +namespace am = ::application_manager; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::VRIsReadyRequest; +using am::event_engine::Event; + +typedef SharedPtr<VRIsReadyRequest> VRIsReadyRequestPtr; + +class VRIsReadyRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + VRIsReadyRequestTest() : command_(CreateCommand<VRIsReadyRequest>()) {} + + void SetUpExpectations(bool is_vr_cooperating_available, + bool is_send_message_to_hmi, + bool is_message_contain_param, + am::HmiInterfaces::InterfaceState state) { + const bool is_send_message_by_timeout = false; + if (is_send_message_to_hmi) { + ExpectSendMessagesToHMI(is_send_message_by_timeout); + } + EXPECT_CALL(mock_hmi_capabilities_, + set_is_vr_cooperating(is_vr_cooperating_available)); + + if (is_message_contain_param) { + EXPECT_CALL(app_mngr_, hmi_interfaces()) + .WillRepeatedly(ReturnRef(mock_hmi_interfaces_)); + EXPECT_CALL( + mock_hmi_interfaces_, + SetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR, state)); + } else { + EXPECT_CALL(app_mngr_, hmi_interfaces()) + .WillOnce(ReturnRef(mock_hmi_interfaces_)); + EXPECT_CALL(mock_hmi_interfaces_, SetInterfaceState(_, _)).Times(0); + } + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) + .WillOnce(Return(state)); + } + + void ExpectSendMessagesToHMI(bool is_send_message_by_timeout) { + smart_objects::SmartObjectSPtr language( + new smart_objects::SmartObject(smart_objects::SmartType_Map)); + EXPECT_CALL(mock_message_helper_, + CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetLanguage, _)) + .WillOnce(Return(language)); + EXPECT_CALL(mock_hmi_capabilities_, set_handle_response_for(*language)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(language)); + + smart_objects::SmartObjectSPtr support_language( + new smart_objects::SmartObject(smart_objects::SmartType_Map)); + EXPECT_CALL( + mock_message_helper_, + CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetSupportedLanguages, _)) + .WillOnce(Return(support_language)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(support_language)); + + smart_objects::SmartObjectSPtr capabilities( + new smart_objects::SmartObject(smart_objects::SmartType_Map)); + EXPECT_CALL(mock_message_helper_, + CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetCapabilities, _)) + .WillOnce(Return(capabilities)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(capabilities)); + } + + void PrepareEvent(bool is_message_contain_param, + Event& event, + bool is_vr_cooperating_available = false) { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + if (is_message_contain_param) { + (*msg)[am::strings::msg_params][am::strings::available] = + is_vr_cooperating_available; + } + event.set_smart_object(*msg); + } + + VRIsReadyRequestPtr command_; +}; + +TEST_F(VRIsReadyRequestTest, Run_NoKeyAvailableInMessage_HmiInterfacesIgnored) { + const bool is_vr_cooperating_available = false; + const bool is_send_message_to_hmi = true; + const bool is_message_contain_param = false; + Event event(hmi_apis::FunctionID::VR_IsReady); + PrepareEvent(is_message_contain_param, event); + SetUpExpectations(is_vr_cooperating_available, + is_send_message_to_hmi, + is_message_contain_param, + am::HmiInterfaces::STATE_NOT_RESPONSE); + command_->on_event(event); +} + +TEST_F(VRIsReadyRequestTest, Run_KeyAvailableEqualToFalse_StateNotAvailable) { + const bool is_vr_cooperating_available = false; + const bool is_send_message_to_hmi = false; + const bool is_message_contain_param = true; + Event event(hmi_apis::FunctionID::VR_IsReady); + PrepareEvent(is_message_contain_param, event); + SetUpExpectations(is_vr_cooperating_available, + is_send_message_to_hmi, + is_message_contain_param, + am::HmiInterfaces::STATE_NOT_AVAILABLE); + command_->on_event(event); +} + +TEST_F(VRIsReadyRequestTest, Run_KeyAvailableEqualToTrue_StateAvailable) { + const bool is_vr_cooperating_available = true; + const bool is_send_message_to_hmi = true; + const bool is_message_contain_param = true; + Event event(hmi_apis::FunctionID::VR_IsReady); + PrepareEvent(is_message_contain_param, event, is_vr_cooperating_available); + SetUpExpectations(is_vr_cooperating_available, + is_send_message_to_hmi, + is_message_contain_param, + am::HmiInterfaces::STATE_AVAILABLE); + command_->on_event(event); +} + +TEST_F(VRIsReadyRequestTest, Run_HMIDoestRespond_SendMessageToHMIByTimeout) { + const bool is_send_message_by_timeout = true; + ExpectSendMessagesToHMI(is_send_message_by_timeout); + command_->onTimeOut(); +} + +} // namespace vr_is_ready_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_response_test.cc new file mode 100644 index 0000000000..452679e189 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_response_test.cc @@ -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. + */ + +#include <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "hmi/vr_is_ready_response.h" +#include "application_manager/mock_event_dispatcher.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace vr_is_ready_response { + +using ::testing::Return; +using ::utils::SharedPtr; +using ::testing::NiceMock; +namespace am = ::application_manager; +namespace strings = ::application_manager::strings; +namespace hmi_response = am::hmi_response; +using sdl_rpc_plugin::commands::VRIsReadyResponse; +using test::components::event_engine_test::MockEventDispatcher; + +typedef SharedPtr<VRIsReadyResponse> VRIsReadyResponsePtr; + +class VRIsReadyResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> { +}; + +TEST_F(VRIsReadyResponseTest, RUN_SUCCESS) { + VRIsReadyResponsePtr command(CreateCommand<VRIsReadyResponse>()); + + MockEventDispatcher mock_event_dispatcher; + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher)); + EXPECT_CALL(mock_event_dispatcher, raise_event(_)); + + command->Run(); +} + +} // namespace vr_is_ready_response +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc new file mode 100644 index 0000000000..0067be3f1b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc @@ -0,0 +1,1112 @@ +/* + * 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 <stdint.h> +#include <string> +#include <set> + +#include "mobile/add_command_request.h" + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "utils/helpers.h" +#include "utils/make_shared.h" +#include "smart_objects/smart_object.h" +#include "utils/custom_string.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace add_command_request { + +namespace am = application_manager; +using am::commands::CommandImpl; +using am::ApplicationManager; +using am::commands::MessageSharedPtr; +using am::ApplicationSharedPtr; +using ::testing::_; +using ::utils::SharedPtr; +using ::testing::Return; +using ::testing::InSequence; +using sdl_rpc_plugin::commands::AddCommandRequest; +using NsSmartDeviceLink::NsSmartObjects::SmartObjectSPtr; +using ::test::components::application_manager_test::MockApplication; +using am::event_engine::EventObserver; +using namespace smart_objects; + +namespace custom_str = utils::custom_string; +namespace strings = ::application_manager::strings; +namespace mobile_result = mobile_apis::Result; +namespace hmi_response = ::application_manager::hmi_response; +namespace hmi_request = ::application_manager::hmi_request; +using namespace strings; + +namespace { +const hmi_apis::FunctionID::eType kInvalidFunctionId = + hmi_apis::FunctionID::INVALID_ENUM; +const uint32_t kAppId = 1u; +const uint32_t kCmdId = 1u; +const uint32_t kConnectionKey = 2u; +const std::string kMenuName = "LG"; +const uint32_t kFirstParentId = 10u; +const uint32_t kSecondParentId = 1u; +const std::string kErroredVRCommand = "l\namer"; +const std::string kFirstVrCommand = "lamer"; +const std::string kSecondVrCommand = "hacker"; +const uint32_t kFirstCommandId = 10u; +const uint32_t kSecondCommandId = 11u; +const int32_t kType = 34; +const int32_t kGrammarId = 12; +const int32_t kPosition = 10; +} // namespace + +class AddCommandRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + AddCommandRequestTest() + : msg_(CreateMessage()) + , default_app_name_("test_default_app_name_") + , lock_ptr_(std::make_shared<sync_primitives::Lock>()) + , mock_app_(CreateMockApp()) { + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillRepeatedly(Return(mock_app_)); + InitGetters(); + InitBasicMessage(); + } + + protected: + void InitBasicMessage() { + (*msg_)[params][connection_key] = kConnectionKey; + (*msg_)[msg_params][app_id] = kAppId; + (*msg_)[msg_params][app_name] = default_app_name_; + } + + void InitGetters() { + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app_, FindCommand(kCmdId)) + .WillByDefault(Return(so_ptr_.get())); + } + + void CreateBasicParamsUIRequest() { + SmartObject menu_params = SmartObject(SmartType_Map); + menu_params[position] = kPosition; + menu_params[menu_name] = kMenuName; + SmartObject& msg_params = (*msg_)[strings::msg_params]; + msg_params[cmd_id] = kCmdId; + msg_params[strings::menu_params] = menu_params; + msg_params[cmd_icon] = 1; + msg_params[cmd_icon][value] = "10"; + msg_params[info] = "UI info"; + } + + void CreateBasicParamsVRRequest() { + SmartObject& msg_params = (*msg_)[strings::msg_params]; + msg_params[cmd_id] = kCmdId; + msg_params[vr_commands] = SmartObject(SmartType_Array); + msg_params[vr_commands][0] = kFirstVrCommand; + msg_params[type] = kPosition; + msg_params[grammar_id] = kGrammarId; + msg_params[info] = "VR info"; + } + + const am::CommandsMap CreateCommandsMap(SmartObject& first_command, + SmartObject& second_command) { + second_command[menu_params] = SmartObject(SmartType_Map); + second_command[menu_params][hmi_request::parent_id] = kFirstParentId; + second_command[menu_params][menu_name] = kMenuName; + second_command[vr_commands] = SmartObject(SmartType_Array); + second_command[vr_commands][0] = kSecondVrCommand; + am::CommandsMap commands_map; + commands_map.insert(std::make_pair(kFirstCommandId, &first_command)); + commands_map.insert(std::make_pair(kSecondCommandId, &second_command)); + return commands_map; + } + + void CheckOnTimeOutCommandDeletion( + const hmi_apis::FunctionID::eType incoming_cmd, + const hmi_apis::FunctionID::eType cmd_to_delete) { + CreateBasicParamsVRRequest(); + CreateBasicParamsUIRequest(); + SmartObject& msg_params = (*msg_)[strings::msg_params]; + msg_params[menu_params][hmi_request::parent_id] = kSecondParentId; + SmartObject& image = msg_params[cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(*mock_app_, FindCommand(kCmdId)) + .WillOnce(Return(so_ptr_.get())); + SmartObject first_command = SmartObject(SmartType_Map); + SmartObject second_command = SmartObject(SmartType_Map); + const am::CommandsMap commands_map = + CreateCommandsMap(first_command, second_command); + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + so_ptr_ = utils::MakeShared<SmartObject>(SmartType_Map); + EXPECT_CALL(*mock_app_, FindSubMenu(kSecondParentId)) + .WillOnce(Return(so_ptr_.get())); + { + InSequence dummy; + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + .WillOnce(Return(true)); + } + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); + Event event(incoming_cmd); + event.set_smart_object(*msg_); + request_ptr->on_event(event); + EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(cmd_to_delete))) + + .WillOnce(Return(true)); + SmartObjectSPtr response = utils::MakeShared<SmartObject>(SmartType_Map); + (*response)[strings::msg_params][strings::info] = "info"; + EXPECT_CALL( + mock_message_helper_, + CreateNegativeResponse(_, _, _, mobile_apis::Result::GENERIC_ERROR)) + .WillOnce(Return(response)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(response, + am::commands::Command::CommandSource::SOURCE_SDL)); + utils::SharedPtr<CommandRequestImpl> base_class_request = + static_cast<utils::SharedPtr<CommandRequestImpl> >(request_ptr); + base_class_request->onTimeOut(); + } + + MessageSharedPtr msg_; + SmartObjectSPtr so_ptr_; + const utils::custom_string::CustomString default_app_name_; + std::shared_ptr<sync_primitives::Lock> lock_ptr_; + MockAppPtr mock_app_; +}; + +TEST_F(AddCommandRequestTest, Run_AppNotExisted_EXPECT_AppNotRegistered) { + CreateBasicParamsUIRequest(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(ApplicationSharedPtr())); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); +} + +TEST_F(AddCommandRequestTest, Run_ImageVerificationFailed_EXPECT_INVALID_DATA) { + CreateBasicParamsUIRequest(); + SmartObject& msg_params = (*msg_)[strings::msg_params]; + SmartObject& image = msg_params[cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::INVALID_DATA)); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::INVALID_DATA), _)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); +} + +TEST_F(AddCommandRequestTest, Run_MenuNameHasSyntaxError_EXPECT_INVALID_DATA) { + CreateBasicParamsUIRequest(); + SmartObject& msg_params = (*msg_)[strings::msg_params]; + msg_params[menu_params][hmi_request::parent_id] = kFirstParentId; + const std::string errored_menu_name = "L\nG"; + msg_params[menu_params][menu_name] = errored_menu_name; + SmartObject& image = msg_params[cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get())); + am::CommandsMap commands_map; + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + SmartObject parent = SmartObject(SmartType_Map); + EXPECT_CALL(*mock_app_, FindSubMenu(kFirstParentId)) + .WillOnce(Return(&parent)); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::INVALID_DATA), _)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); +} + +TEST_F(AddCommandRequestTest, + Run_VRCommandsHaveSyntaxError_EXPECT_INVALID_DATA) { + CreateBasicParamsVRRequest(); + SmartObject& msg_params = (*msg_)[strings::msg_params]; + msg_params[vr_commands][0] = kErroredVRCommand; + EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get())); + am::CommandsMap commands_map; + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::INVALID_DATA), _)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); +} + +TEST_F(AddCommandRequestTest, Run_CMDIconHasError_EXPECT_INVALID_DATA) { + MessageSharedPtr msg = CreateMessage(); + SmartObject& msg_params = (*msg)[strings::msg_params]; + (*msg)[params][connection_key] = kConnectionKey; + msg_params[cmd_id] = kCmdId; + msg_params[cmd_icon] = 1; + const std::string errored_cmd_icon_value = "1\n0"; + msg_params[cmd_icon][value] = errored_cmd_icon_value; + msg_params[vr_commands][0] = kFirstVrCommand; + SmartObject& image = msg_params[cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get())); + am::CommandsMap commands_map; + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::INVALID_DATA), _)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg); + request_ptr->Run(); +} + +TEST_F(AddCommandRequestTest, Run_CommandIDAlreadyExists_EXPECT_INVALID_ID) { + CreateBasicParamsUIRequest(); + SmartObject& msg_params = (*msg_)[strings::msg_params]; + SmartObject& image = msg_params[cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + so_ptr_ = utils::MakeShared<SmartObject>(SmartType_Map); + EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get())); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::INVALID_ID), _)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); +} + +TEST_F(AddCommandRequestTest, + Run_CommandNameAlreadyExists_EXPECT_DUPLICATE_NAME) { + CreateBasicParamsUIRequest(); + SmartObject& msg_params = (*msg_)[strings::msg_params]; + msg_params[menu_params][hmi_request::parent_id] = kFirstParentId; + SmartObject& image = msg_params[cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get())); + SmartObject first_command = SmartObject(SmartType_Map); + SmartObject second_command = SmartObject(SmartType_Map); + const am::CommandsMap commands_map = + CreateCommandsMap(first_command, second_command); + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::DUPLICATE_NAME), _)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); +} + +TEST_F(AddCommandRequestTest, + Run_CmdAndMsgParentIDsAreDifferentSubmenuNotExisted_EXPECT_INVALID_ID) { + CreateBasicParamsUIRequest(); + SmartObject& msg_params = (*msg_)[strings::msg_params]; + msg_params[menu_params][hmi_request::parent_id] = kSecondParentId; + SmartObject& image = msg_params[cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get())); + SmartObject first_command = SmartObject(SmartType_Map); + SmartObject second_command = SmartObject(SmartType_Map); + const am::CommandsMap commands_map = + CreateCommandsMap(first_command, second_command); + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + EXPECT_CALL(*mock_app_, FindSubMenu(kSecondParentId)) + .WillOnce(Return(so_ptr_.get())); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::INVALID_ID), _)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); +} + +TEST_F(AddCommandRequestTest, + Run_CmdAndMsgVrSynonymsAreTheSame_EXPECT_DUPLICATE_NAME) { + CreateBasicParamsVRRequest(); + SmartObject& msg_params = (*msg_)[strings::msg_params]; + msg_params[menu_params][hmi_request::parent_id] = kSecondParentId; + msg_params[vr_commands][0] = kSecondVrCommand; + SmartObject& image = msg_params[cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get())); + + SmartObject first_command = SmartObject(SmartType_Map); + SmartObject second_command = SmartObject(SmartType_Map); + const am::CommandsMap commands_map = + CreateCommandsMap(first_command, second_command); + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + so_ptr_ = utils::MakeShared<SmartObject>(SmartType_Map); + EXPECT_CALL(*mock_app_, FindSubMenu(kSecondParentId)) + .WillOnce(Return(so_ptr_.get())); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::DUPLICATE_NAME), _)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); +} + +TEST_F(AddCommandRequestTest, Run_MsgDataEmpty_EXPECT_INVALID_DATA) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[params][connection_key] = kConnectionKey; + SmartObject& msg_params = (*msg)[strings::msg_params]; + msg_params[app_id] = kAppId; + msg_params[cmd_id] = kCmdId; + EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get())); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::INVALID_DATA), _)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg); + request_ptr->Run(); +} + +TEST_F(AddCommandRequestTest, + Run_CmdAndMsg_UI_and_Vr_AreCorrect_EXPECT_VR_AND_UI_SENT) { + CreateBasicParamsVRRequest(); + CreateBasicParamsUIRequest(); + SmartObject& msg_params = (*msg_)[strings::msg_params]; + msg_params[menu_params][hmi_request::parent_id] = kSecondParentId; + SmartObject& image = msg_params[cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get())); + SmartObject first_command = SmartObject(SmartType_Map); + SmartObject second_command = SmartObject(SmartType_Map); + const am::CommandsMap commands_map = + CreateCommandsMap(first_command, second_command); + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + so_ptr_ = utils::MakeShared<SmartObject>(SmartType_Map); + EXPECT_CALL(*mock_app_, FindSubMenu(kSecondParentId)) + .WillOnce(Return(so_ptr_.get())); + { + InSequence dummy; + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + .WillOnce(Return(true)); + } + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); +} + +TEST_F(AddCommandRequestTest, GetRunMethods_SUCCESS) { + CreateBasicParamsUIRequest(); + SmartObject& image = (*msg_)[msg_params][cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get())); + EXPECT_CALL(*mock_app_, AddCommand(kCmdId, (*msg_)[msg_params])); + + am::CommandsMap commands_map; + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + .WillOnce(Return(true)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); +} + +TEST_F(AddCommandRequestTest, OnEvent_UI_SUCCESS) { + CreateBasicParamsUIRequest(); + (*msg_)[params][hmi_response::code] = hmi_apis::Common_Result::SUCCESS; + SmartObject& image = (*msg_)[msg_params][cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(*mock_app_, AddCommand(kCmdId, (*msg_)[msg_params])); + + am::CommandsMap commands_map; + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly( + Return(DataAccessor<am::CommandsMap>(commands_map, lock_ptr_))); + + Event event(hmi_apis::FunctionID::UI_AddCommand); + event.set_smart_object(*msg_); + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + .WillOnce(Return(true)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); + request_ptr->on_event(event); +} + +TEST_F(AddCommandRequestTest, OnEvent_VR_SUCCESS) { + CreateBasicParamsVRRequest(); + MessageSharedPtr msg = CreateMessage(SmartType_Map); + (*msg)[params][hmi_response::code] = hmi_apis::Common_Result::SUCCESS; + (*msg)[msg_params][cmd_id] = kCmdId; + + Event event(hmi_apis::FunctionID::VR_AddCommand); + event.set_smart_object(*msg); + EXPECT_CALL(*mock_app_, AddCommand(kCmdId, (*msg_)[msg_params])); + + am::CommandsMap commands_map; + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly( + Return(DataAccessor<am::CommandsMap>(commands_map, lock_ptr_))); + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + .WillOnce(Return(true)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); + request_ptr->on_event(event); +} + +TEST_F(AddCommandRequestTest, OnTimeOut_EXPECT_VR_DeleteCommand) { + CheckOnTimeOutCommandDeletion(hmi_apis::FunctionID::VR_AddCommand, + hmi_apis::FunctionID::VR_DeleteCommand); +} + +TEST_F(AddCommandRequestTest, OnTimeOut_EXPECT_UI_DeleteCommand) { + CheckOnTimeOutCommandDeletion(hmi_apis::FunctionID::UI_AddCommand, + hmi_apis::FunctionID::UI_DeleteCommand); +} + +TEST_F(AddCommandRequestTest, OnEvent_BothSend_SUCCESS) { + MessageSharedPtr command_msg = CreateMessage(SmartType_Map); + (*command_msg)[params][connection_key] = kConnectionKey; + MessageSharedPtr event_msg = CreateMessage(SmartType_Map); + (*event_msg)[params][hmi_response::code] = hmi_apis::Common_Result::SUCCESS; + (*event_msg)[msg_params][cmd_id] = kCmdId; + + Event event_ui(hmi_apis::FunctionID::UI_AddCommand); + event_ui.set_smart_object(*event_msg); + + Event event_vr(hmi_apis::FunctionID::VR_AddCommand); + event_vr.set_smart_object(*event_msg); + + EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)).Times(0); + + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(command_msg); + request_ptr->Run(); + request_ptr->on_event(event_ui); + request_ptr->on_event(event_vr); +} + +TEST_F(AddCommandRequestTest, OnEvent_UnknownEvent_UNSUCCESS) { + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + Event event(hmi_apis::FunctionID::INVALID_ENUM); + request_ptr->on_event(event); +} + +TEST_F(AddCommandRequestTest, OnEvent_AppNotExisted_UNSUCCESS) { + CreateBasicParamsUIRequest(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(ApplicationSharedPtr())); + Event event(hmi_apis::FunctionID::UI_AddCommand); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->on_event(event); +} + +TEST_F(AddCommandRequestTest, + OnEvent_HmiResponseCodeIsRejected_ExpectUICommandRemoved) { + CreateBasicParamsUIRequest(); + SmartObject& params = (*msg_)[strings::params]; + params[hmi_response::code] = hmi_apis::Common_Result::REJECTED; + SmartObject& image = (*msg_)[msg_params][cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + am::CommandsMap commands_map; + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + .WillOnce(Return(true)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); + EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::REJECTED), _)); + Event event(hmi_apis::FunctionID::UI_AddCommand); + event.set_smart_object(*msg_); + request_ptr->on_event(event); +} + +TEST_F(AddCommandRequestTest, + OnEvent_HmiResponseCodeIsWarnings_ExpectCommandUpdated) { + CreateBasicParamsVRRequest(); + CreateBasicParamsUIRequest(); + SmartObject& params = (*msg_)[strings::params]; + params[hmi_response::code] = hmi_apis::Common_Result::WARNINGS; + SmartObject& image = (*msg_)[msg_params][cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + am::CommandsMap commands_map; + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + { + InSequence dummy; + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + .WillOnce(Return(true)); + } + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::WARNINGS), _)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); + Event event_ui(hmi_apis::FunctionID::UI_AddCommand); + event_ui.set_smart_object(*msg_); + Event event_vr(hmi_apis::FunctionID::VR_AddCommand); + event_vr.set_smart_object(*msg_); + request_ptr->on_event(event_ui); + request_ptr->on_event(event_vr); +} + +TEST_F( + AddCommandRequestTest, + OnEvent_UI_HmiResponseCodeIsGenericError_VR_HmiResponseCodeIsUnsupportedResourse_ExpectCommandRemoved) { + CreateBasicParamsVRRequest(); + CreateBasicParamsUIRequest(); + SmartObject& params = (*msg_)[strings::params]; + params[hmi_response::code] = hmi_apis::Common_Result::GENERIC_ERROR; + SmartObject& image = (*msg_)[msg_params][cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + am::CommandsMap commands_map; + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + { + InSequence dummy; + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + .WillOnce(Return(true)); + } + + EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); + + Event event_ui(hmi_apis::FunctionID::UI_AddCommand); + event_ui.set_smart_object(*msg_); + request_ptr->on_event(event_ui); + + Event event_vr(hmi_apis::FunctionID::VR_AddCommand); + MessageSharedPtr msg_vr = CreateMessage(SmartType_Map); + (*msg_vr)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*msg_vr)[msg_params][cmd_id] = kCmdId; + event_vr.set_smart_object(*msg_vr); + request_ptr->on_event(event_vr); +} + +TEST_F( + AddCommandRequestTest, + OnEvent_VR_HmiResponseCodeIsGenericError_UI_HmiResponseCodeIsUnsupportedResourse_ExpectCommandRemoved) { + CreateBasicParamsVRRequest(); + CreateBasicParamsUIRequest(); + SmartObject& params = (*msg_)[strings::params]; + params[hmi_response::code] = hmi_apis::Common_Result::GENERIC_ERROR; + SmartObject& image = (*msg_)[msg_params][cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + am::CommandsMap commands_map; + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + { + InSequence dummy; + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + .WillOnce(Return(true)); + } + + EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); + + Event event_vr(hmi_apis::FunctionID::VR_AddCommand); + event_vr.set_smart_object(*msg_); + request_ptr->on_event(event_vr); + + Event event_ui(hmi_apis::FunctionID::UI_AddCommand); + MessageSharedPtr msg_ui = CreateMessage(SmartType_Map); + (*msg_ui)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*msg_ui)[msg_params][cmd_id] = kCmdId; + event_ui.set_smart_object(*msg_ui); + request_ptr->on_event(event_ui); +} + +TEST_F( + AddCommandRequestTest, + OnEvent_UI_VR_HmiResponseCodeIsUnsupportedResourse_UI_NotAvailableInterfaceState_ExpectCommandRemoved) { + CreateBasicParamsVRRequest(); + CreateBasicParamsUIRequest(); + SmartObject& params = (*msg_)[strings::params]; + params[hmi_response::code] = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + SmartObject& image = (*msg_)[msg_params][cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + am::CommandsMap commands_map; + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + { + InSequence dummy; + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + .WillOnce(Return(true)); + } + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); + + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillRepeatedly( + Return(am::HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE)); + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), _)); + EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); + Event event_ui(hmi_apis::FunctionID::UI_AddCommand); + event_ui.set_smart_object(*msg_); + Event event_vr(hmi_apis::FunctionID::VR_AddCommand); + event_vr.set_smart_object(*msg_); + request_ptr->on_event(event_ui); + request_ptr->on_event(event_vr); +} + +TEST_F( + AddCommandRequestTest, + OnEvent_UI_VR_HmiResponseCodeIsUnsupportedResourse_VR_NotAvailableInterfaceState_ExpectCommandRemoved) { + CreateBasicParamsVRRequest(); + CreateBasicParamsUIRequest(); + SmartObject& params = (*msg_)[strings::params]; + params[hmi_response::code] = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + SmartObject& image = (*msg_)[msg_params][cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + am::CommandsMap commands_map; + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + { + InSequence dummy; + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + .WillOnce(Return(true)); + } + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); + + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) + .WillRepeatedly( + Return(am::HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE)); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), _)); + EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); + Event event_ui(hmi_apis::FunctionID::UI_AddCommand); + event_ui.set_smart_object(*msg_); + Event event_vr(hmi_apis::FunctionID::VR_AddCommand); + event_vr.set_smart_object(*msg_); + request_ptr->on_event(event_ui); + request_ptr->on_event(event_vr); +} + +TEST_F( + AddCommandRequestTest, + OnEvent_UI_HmiResponseCodeIsUnsupportedResource_NotAvailableInterfaceState_ExpectCommandRemoved) { + CreateBasicParamsUIRequest(); + SmartObject& params = (*msg_)[strings::params]; + params[hmi_response::code] = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + SmartObject& image = (*msg_)[msg_params][cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + am::CommandsMap commands_map; + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + .WillOnce(Return(true)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillRepeatedly( + Return(am::HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE)); + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) + .WillRepeatedly( + Return(am::HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE)); + EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), _)); + Event event(hmi_apis::FunctionID::UI_AddCommand); + event.set_smart_object(*msg_); + request_ptr->on_event(event); +} + +TEST_F( + AddCommandRequestTest, + OnEvent_VR_HmiResponseCodeIsUnsupportedResource_NotAvailableInterfaceState_ExpectCommandRemoved) { + CreateBasicParamsVRRequest(); + SmartObject& params = (*msg_)[strings::params]; + params[hmi_response::code] = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + am::CommandsMap commands_map; + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + .WillOnce(Return(true)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillRepeatedly( + Return(am::HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE)); + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) + .WillRepeatedly( + Return(am::HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE)); + EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), _)); + Event event(hmi_apis::FunctionID::VR_AddCommand); + event.set_smart_object(*msg_); + request_ptr->on_event(event); +} + +TEST_F(AddCommandRequestTest, + OnEvent_UI_EventWithNotSuccesResponseCode_ExpectVRCommandDelete) { + CreateBasicParamsVRRequest(); + CreateBasicParamsUIRequest(); + SmartObject& params = (*msg_)[strings::params]; + params[hmi_response::code] = hmi_apis::Common_Result::SUCCESS; + SmartObject& image = (*msg_)[msg_params][cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + am::CommandsMap commands_map; + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + { + InSequence dummy; + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + .WillOnce(Return(true)); + } + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::GENERIC_ERROR), _)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); + + MessageSharedPtr msg_ui = CreateMessage(SmartType_Map); + (*msg_ui)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::ABORTED; + (*msg_ui)[msg_params][cmd_id] = kCmdId; + Event event_ui(hmi_apis::FunctionID::UI_AddCommand); + event_ui.set_smart_object(*msg_ui); + Event event_vr(hmi_apis::FunctionID::VR_AddCommand); + event_vr.set_smart_object(*msg_); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_DeleteCommand))) + .WillOnce(Return(true)); + EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)).Times(2); + request_ptr->on_event(event_ui); + request_ptr->on_event(event_vr); +} + +TEST_F(AddCommandRequestTest, + OnEvent_UI_VR_Events_VRErrorPresent_ExpectRemoveCommand) { + CreateBasicParamsVRRequest(); + CreateBasicParamsUIRequest(); + SmartObject& params = (*msg_)[strings::params]; + params[hmi_response::code] = hmi_apis::Common_Result::SUCCESS; + SmartObject& image = (*msg_)[msg_params][cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + am::CommandsMap commands_map; + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + { + InSequence dummy; + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + .WillOnce(Return(true)); + } + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::GENERIC_ERROR), _)); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); + + Event event_ui(hmi_apis::FunctionID::UI_AddCommand); + event_ui.set_smart_object(*msg_); + request_ptr->on_event(event_ui); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteCommand))) + .WillOnce(Return(true)); + EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)).Times(2); + Event event_vr(hmi_apis::FunctionID::VR_AddCommand); + MessageSharedPtr msg_vr = CreateMessage(SmartType_Map); + (*msg_vr)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::ABORTED; + (*msg_vr)[msg_params][cmd_id] = kCmdId; + event_vr.set_smart_object(*msg_vr); + request_ptr->on_event(event_vr); +} + +TEST_F(AddCommandRequestTest, + OnTimeOut_AppNotExisted_NoAppRemoveCommandCalled) { + CreateBasicParamsUIRequest(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(ApplicationSharedPtr())); + EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)).Times(0); + SmartObjectSPtr response = utils::MakeShared<SmartObject>(SmartType_Map); + (*response)[strings::msg_params][strings::info] = "info"; + EXPECT_CALL( + mock_message_helper_, + CreateNegativeResponse(_, _, _, mobile_apis::Result::GENERIC_ERROR)) + .WillOnce(Return(response)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + response, am::commands::Command::CommandSource::SOURCE_SDL)); + utils::SharedPtr<CommandRequestImpl> base_class_request = + static_cast<utils::SharedPtr<CommandRequestImpl> >( + CreateCommand<AddCommandRequest>(msg_)); + base_class_request->onTimeOut(); +} + +TEST_F(AddCommandRequestTest, OnTimeOut_AppRemoveCommandCalled) { + CreateBasicParamsVRRequest(); + CreateBasicParamsUIRequest(); + SmartObject& msg_params = (*msg_)[strings::msg_params]; + SmartObject& image = msg_params[cmd_icon]; + msg_params[menu_params][hmi_request::parent_id] = kSecondParentId; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(so_ptr_.get())); + SmartObject first_command = SmartObject(SmartType_Map); + SmartObject second_command = SmartObject(SmartType_Map); + const am::CommandsMap commands_map = + CreateCommandsMap(first_command, second_command); + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + so_ptr_ = utils::MakeShared<SmartObject>(SmartType_Map); + EXPECT_CALL(*mock_app_, FindSubMenu(kSecondParentId)) + .WillOnce(Return(so_ptr_.get())); + { + InSequence dummy; + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + .WillOnce(Return(true)); + } + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + utils::SharedPtr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); + EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); + SmartObjectSPtr response = utils::MakeShared<SmartObject>(SmartType_Map); + (*response)[strings::msg_params][strings::info] = "info"; + EXPECT_CALL( + mock_message_helper_, + CreateNegativeResponse(_, _, _, mobile_apis::Result::GENERIC_ERROR)) + .WillOnce(Return(response)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + response, am::commands::Command::CommandSource::SOURCE_SDL)); + utils::SharedPtr<CommandRequestImpl> base_class_request = + static_cast<utils::SharedPtr<CommandRequestImpl> >(request_ptr); + base_class_request->onTimeOut(); +} + +} // namespace add_command_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_sub_menu_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_sub_menu_request_test.cc new file mode 100644 index 0000000000..9fad021c3e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_sub_menu_request_test.cc @@ -0,0 +1,158 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "mobile/add_sub_menu_request.h" + +#include "gtest/gtest.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace add_sub_menu_request { + +namespace am = ::application_manager; +using sdl_rpc_plugin::commands::AddSubMenuRequest; +using am::commands::MessageSharedPtr; +using am::event_engine::Event; +using ::testing::_; +using ::testing::Return; + +typedef SharedPtr<AddSubMenuRequest> AddSubMenuPtr; + +namespace { +const uint32_t kConnectionKey = 2u; +const uint32_t kAppId = 1u; +} // namespace + +class AddSubMenuRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + AddSubMenuRequestTest() : mock_app(CreateMockApp()) { + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillRepeatedly(Return(mock_app)); + } + + MockAppPtr mock_app; + + MessageSharedPtr CreateMsgParams() { + MessageSharedPtr msg = CreateMessage(); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg)[am::strings::msg_params][am::strings::app_id] = kAppId; + return msg; + } +}; + +TEST_F(AddSubMenuRequestTest, Run_ImageVerificationFailed_EXPECT_INVALID_DATA) { + const uint32_t menu_id = 10u; + MessageSharedPtr msg = CreateMsgParams(); + SmartObject& msg_params = (*msg)[am::strings::msg_params]; + + msg_params[am::strings::menu_icon] = 1; + msg_params[am::strings::menu_icon][am::strings::value] = "10"; + msg_params[am::strings::menu_id] = menu_id; + msg_params[am::strings::menu_name] = "test"; + SmartObject& image = msg_params[am::strings::menu_icon]; + + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::INVALID_DATA)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::INVALID_DATA), _)); + utils::SharedPtr<AddSubMenuRequest> request_ptr = + CreateCommand<AddSubMenuRequest>(msg); + + request_ptr->Run(); +} + +TEST_F(AddSubMenuRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) { + const uint32_t menu_id = 10u; + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg)[am::strings::msg_params][am::strings::menu_id] = menu_id; + + utils::SharedPtr<AddSubMenuRequest> command = + CreateCommand<AddSubMenuRequest>(msg); + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app)); + ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey)); + EXPECT_CALL(*mock_app, AddSubMenu(menu_id, _)); + EXPECT_CALL(*mock_app, UpdateHash()); + + MessageSharedPtr ev_msg = CreateMessage(smart_objects::SmartType_Map); + (*ev_msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*ev_msg)[am::strings::msg_params][am::strings::info] = "info"; + + Event event(hmi_apis::FunctionID::UI_AddSubMenu); + event.set_smart_object(*ev_msg); + + MessageSharedPtr ui_command_result; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true))); + command->Init(); + command->on_event(event); + + EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success] + .asBool(), + true); + EXPECT_EQ( + (*ui_command_result)[am::strings::msg_params][am::strings::result_code] + .asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + if ((*ui_command_result)[am::strings::msg_params].keyExists( + am::strings::info)) { + EXPECT_FALSE( + (*ui_command_result)[am::strings::msg_params][am::strings::info] + .asString() + .empty()); + } +} + +} // namespace add_sub_menu_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_maneuver_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_maneuver_request_test.cc new file mode 100644 index 0000000000..ac870e7001 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_maneuver_request_test.cc @@ -0,0 +1,256 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" +#include "mobile/alert_maneuver_request.h" +#include "interfaces/MOBILE_API.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/mock_hmi_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace alert_maneuver_request { + +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; +namespace am = ::application_manager; +using sdl_rpc_plugin::commands::AlertManeuverRequest; +using am::commands::MessageSharedPtr; +using am::event_engine::Event; + +typedef SharedPtr<AlertManeuverRequest> CommandPtr; + +class AlertManeuverRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + void CheckExpectations(const hmi_apis::Common_Result::eType hmi_response, + const mobile_apis::Result::eType mobile_response, + const am::HmiInterfaces::InterfaceState state, + const bool success) { + MessageSharedPtr response = CreateMessage(smart_objects::SmartType_Map); + (*response)[am::strings::params][am::hmi_response::code] = hmi_response; + (*response)[am::strings::msg_params][am::strings::info] = "test"; + + am::event_engine::Event event(hmi_apis::FunctionID::TTS_Speak); + event.set_smart_object(*response); + + utils::SharedPtr<AlertManeuverRequest> command = + CreateCommand<AlertManeuverRequest>(response); + + MockAppPtr mock_app(CreateMockApp()); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); + + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(state)); + + MessageSharedPtr response_to_mobile; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + _, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + command->on_event(event); + + EXPECT_EQ( + (*response_to_mobile)[am::strings::msg_params][am::strings::success] + .asBool(), + success); + EXPECT_EQ( + (*response_to_mobile)[am::strings::msg_params][am::strings::result_code] + .asInt(), + static_cast<int32_t>(mobile_response)); + } +}; + +TEST_F(AlertManeuverRequestTest, Run_RequiredFieldsDoesNotExist_UNSUCCESS) { + CommandPtr command(CreateCommand<AlertManeuverRequest>()); + EXPECT_CALL(app_mngr_, application(_)).Times(0); + MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command))); + EXPECT_EQ(mobile_apis::Result::INVALID_DATA, + static_cast<mobile_apis::Result::eType>( + (*result_msg)[am::strings::msg_params][am::strings::result_code] + .asInt())); +} + +TEST_F(AlertManeuverRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::msg_params][am::strings::soft_buttons] = 0; + (*msg)[am::strings::msg_params][am::strings::tts_chunks] = 0; + + CommandPtr command(CreateCommand<AlertManeuverRequest>(msg)); + + ON_CALL(app_mngr_, application(_)) + .WillByDefault(Return(ApplicationSharedPtr())); + + MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command))); + EXPECT_EQ(mobile_apis::Result::APPLICATION_NOT_REGISTERED, + static_cast<mobile_apis::Result::eType>( + (*result_msg)[am::strings::msg_params][am::strings::result_code] + .asInt())); +} + +TEST_F(AlertManeuverRequestTest, Run_ProcessingResult_UNSUCCESS) { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::msg_params][am::strings::soft_buttons][0] + [am::strings::text] = "text"; + + CommandPtr command(CreateCommand<AlertManeuverRequest>(msg)); + + MockAppPtr app(CreateMockApp()); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + + const mobile_apis::Result::eType kProcessingResult = + mobile_apis::Result::ABORTED; + + EXPECT_CALL(mock_message_helper_, ProcessSoftButtons(_, _, _, _)) + .WillOnce(Return(kProcessingResult)); + + MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command))); + EXPECT_EQ(kProcessingResult, + static_cast<mobile_apis::Result::eType>( + (*result_msg)[am::strings::msg_params][am::strings::result_code] + .asInt())); +} + +TEST_F(AlertManeuverRequestTest, Run_IsWhiteSpaceExist_UNSUCCESS) { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::msg_params][am::strings::soft_buttons] = 0; + (*msg)[am::strings::msg_params][am::strings::tts_chunks] = + SmartObject(smart_objects::SmartType_Array); + + SmartObject tts_chunk(smart_objects::SmartType_Map); + tts_chunk[am::strings::text] = "wrong chunk syntax\t\n"; + + (*msg)[am::strings::msg_params][am::strings::tts_chunks].asArray()->push_back( + tts_chunk); + + CommandPtr command(CreateCommand<AlertManeuverRequest>(msg)); + + MockAppPtr app(CreateMockApp()); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + + MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command))); + EXPECT_EQ(mobile_apis::Result::INVALID_DATA, + static_cast<mobile_apis::Result::eType>( + (*result_msg)[am::strings::msg_params][am::strings::result_code] + .asInt())); +} + +TEST_F(AlertManeuverRequestTest, Run_ProcessingResult_SUCCESS) { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::msg_params][am::strings::soft_buttons][0] + [am::strings::text] = "text"; + + CommandPtr command(CreateCommand<AlertManeuverRequest>(msg)); + + MockAppPtr app(CreateMockApp()); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + + EXPECT_CALL(mock_message_helper_, ProcessSoftButtons(_, _, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceFromFunction(_)) + .WillRepeatedly( + Return(am::HmiInterfaces::InterfaceID::HMI_INTERFACE_TTS)); + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL(mock_message_helper_, SubscribeApplicationToSoftButton(_, _, _)); + + MessageSharedPtr result_msg(CatchHMICommandResult(CallRun(*command))); + EXPECT_EQ(hmi_apis::FunctionID::Navigation_AlertManeuver, + static_cast<hmi_apis::FunctionID::eType>( + (*result_msg)[am::strings::params][am::strings::function_id] + .asInt())); +} + +TEST_F(AlertManeuverRequestTest, OnEvent_ReceivedUnknownEvent_UNSUCCESS) { + CommandPtr command(CreateCommand<AlertManeuverRequest>()); + Event event(hmi_apis::FunctionID::INVALID_ENUM); + + MessageSharedPtr result_msg( + CatchMobileCommandResult(CallOnEvent(*command, event))); + EXPECT_EQ(mobile_apis::Result::INVALID_ENUM, + static_cast<mobile_apis::Result::eType>( + (*result_msg)[am::strings::msg_params][am::strings::result_code] + .asInt())); +} + +TEST_F(AlertManeuverRequestTest, OnEvent_SUCCESS) { + CheckExpectations(hmi_apis::Common_Result::SUCCESS, + mobile_apis::Result::SUCCESS, + am::HmiInterfaces::STATE_AVAILABLE, + true); +} + +TEST_F(AlertManeuverRequestTest, OnEvent_UNSUPPORTED_RESOURCE) { + CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + am::HmiInterfaces::STATE_AVAILABLE, + false); +} + +TEST_F(AlertManeuverRequestTest, OnEvent_WARNINGS) { + CheckExpectations(hmi_apis::Common_Result::WARNINGS, + mobile_apis::Result::WARNINGS, + am::HmiInterfaces::STATE_NOT_RESPONSE, + true); +} + +TEST_F(AlertManeuverRequestTest, OnEvent_GENERIC_ERROR) { + CheckExpectations(hmi_apis::Common_Result::GENERIC_ERROR, + mobile_apis::Result::GENERIC_ERROR, + am::HmiInterfaces::STATE_NOT_RESPONSE, + false); +} + +} // namespace alert_maneuver_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc new file mode 100644 index 0000000000..5835cbff81 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc @@ -0,0 +1,810 @@ +/* + * 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 <stdint.h> +#include <string> +#include <set> + +#include "mobile/alert_request.h" + +#include "gtest/gtest.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/policies/mock_policy_handler_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace alert_request { + +namespace am = application_manager; +using sdl_rpc_plugin::commands::AlertRequest; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using am::MockMessageHelper; +using ::utils::SharedPtr; +using am::event_engine::Event; +using policy_test::MockPolicyHandlerInterface; +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +typedef SharedPtr<AlertRequest> CommandPtr; + +namespace { +const int32_t kCommandId = 1; +const uint32_t kAppId = 1u; +const uint32_t kCmdId = 1u; +const uint32_t kConnectionKey = 2u; +const uint32_t kDefaultTimeout = 1000u; +const uint32_t kCorrelationId = 2u; +const mobile_apis::FunctionID::eType kFunctionId = + mobile_apis::FunctionID::AlertID; +} // namespace + +class AlertRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + AlertRequestTest() : mock_app_(CreateMockApp()), msg_(CreateMessage()) {} + + protected: + MessageSharedPtr CreateFullParamsUISO() { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + smart_objects::SmartObject menu_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + menu_params[am::strings::position] = 10; + menu_params[am::strings::menu_name] = "LG"; + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[am::strings::cmd_id] = kCmdId; + msg_params[am::strings::menu_params] = menu_params; + msg_params[am::strings::app_id] = kAppId; + msg_params[am::strings::cmd_icon] = 1; + msg_params[am::strings::cmd_icon][am::strings::value] = "10"; + (*msg)[am::strings::msg_params] = msg_params; + + return msg; + } + + void ResultCommandExpectations(MessageSharedPtr msg, + const std::string& info) { + EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(), + true); + EXPECT_EQ( + (*msg)[am::strings::msg_params][am::strings::result_code].asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(), + info); + } + + void PreConditions() { + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault( + Return(am::HmiInterfaces::InterfaceState::STATE_AVAILABLE)); + + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS)) + .WillByDefault( + Return(am::HmiInterfaces::InterfaceState::STATE_AVAILABLE)); + } + + void Expectations() { + (*msg_)[am::strings::params][am::strings::function_id] = kFunctionId; + (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg_)[am::strings::params][am::strings::correlation_id] = kCorrelationId; + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL( + *mock_app_, + AreCommandLimitsExceeded(kFunctionId, am::TLimitSource::POLICY_TABLE)) + .WillByDefault(Return(false)); + ON_CALL(*mock_app_, hmi_level()) + .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); + ON_CALL(*mock_app_, hmi_level()) + .WillByDefault(Return(mobile_apis::HMILevel::HMI_BACKGROUND)); + } + + void AddAlertTextsToMsg() { + (*msg_)[am::strings::msg_params][am::strings::alert_text1] = "alert_text1"; + (*msg_)[am::strings::msg_params][am::strings::alert_text2] = "alert_text2"; + (*msg_)[am::strings::msg_params][am::strings::alert_text3] = "alert_text3"; + } + void AddTTSChunkToMsg() { + (*msg_)[am::strings::msg_params][am::strings::tts_chunks][0] + [am::strings::text] = "tts_chunk_text"; + } + + void ExpectCallHmiLevel(const mobile_apis::HMILevel::eType level) { + EXPECT_CALL(*mock_app_, hmi_level()).WillRepeatedly(Return(level)); + } + + void ExpectManageMobileCommandWithResultCode( + const mobile_apis::Result::eType code) { + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(code), + am::commands::Command::CommandSource::SOURCE_SDL)); + } + + void ExpectManageHmiCommandTTSAndUI() { + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_Alert))) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak))) + .WillOnce(Return(true)); + } + sync_primitives::Lock lock_; + + MockAppPtr mock_app_; + MessageSharedPtr msg_; +}; + +TEST_F(AlertRequestTest, OnTimeout_GENERIC_ERROR) { + PreConditions(); + MessageSharedPtr command_msg = CreateMessage(smart_objects::SmartType_Map); + (*command_msg)[am::strings::msg_params][am::strings::result_code] = + am::mobile_api::Result::GENERIC_ERROR; + (*command_msg)[am::strings::msg_params][am::strings::success] = false; + (*command_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + utils::SharedPtr<AlertRequest> command = CreateCommand<AlertRequest>(); + + EXPECT_CALL( + mock_message_helper_, + CreateNegativeResponse(_, _, _, am::mobile_api::Result::GENERIC_ERROR)) + .WillOnce(Return(command_msg)); + + MessageSharedPtr ui_command_result; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true))); + + command->onTimeOut(); + EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success] + .asBool(), + false); + EXPECT_EQ( + (*ui_command_result)[am::strings::msg_params][am::strings::result_code] + .asInt(), + static_cast<int32_t>(am::mobile_api::Result::GENERIC_ERROR)); +} + +TEST_F(AlertRequestTest, OnEvent_UI_HmiSendSuccess_UNSUPPORTED_RESOURCE) { + PreConditions(); + MessageSharedPtr command_msg = CreateFullParamsUISO(); + (*command_msg)[am::strings::msg_params][am::strings::menu_params] + [am::hmi_request::parent_id] = 10u; + (*command_msg)[am::strings::msg_params][am::strings::menu_params] + [am::strings::menu_name] = "menu_name"; + + utils::SharedPtr<AlertRequest> command = + CreateCommand<AlertRequest>(command_msg); + + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId; + (*msg)[am::strings::msg_params][am::strings::info] = + "UI is not supported by system"; + + MessageSharedPtr msg_tts = CreateMessage(); + (*msg_tts)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + Event event_vr(hmi_apis::FunctionID::TTS_Speak); + event_vr.set_smart_object(*msg_tts); + + command->on_event(event_vr); + + Event event(hmi_apis::FunctionID::UI_Alert); + event.set_smart_object(*msg); + + MessageSharedPtr ui_command_result; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true))); + + command->on_event(event); + + ResultCommandExpectations(ui_command_result, "UI is not supported by system"); +} + +class CallOnTimeOut { + public: + CallOnTimeOut(CommandRequestImpl& command) : command_(command) {} + + void operator()() { + command_.onTimeOut(); + } + + CommandRequestImpl& command_; +}; + +TEST_F(AlertRequestTest, Init_DurationExists_SUCCESS) { + Expectations(); + (*msg_)[am::strings::msg_params][am::strings::duration] = kDefaultTimeout; + (*msg_)[am::strings::msg_params][am::strings::soft_buttons] = "soft_buttons"; + + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + EXPECT_TRUE(command->Init()); +} + +TEST_F(AlertRequestTest, Init_DurationNotExists_SUCCESS) { + Expectations(); + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + EXPECT_TRUE(command->Init()); +} + +TEST_F(AlertRequestTest, OnTimeOut_SUCCESS) { + Expectations(); + MessageSharedPtr result_msg(CreateMessage(smart_objects::SmartType_Null)); + EXPECT_CALL( + mock_message_helper_, + CreateNegativeResponse(_, _, _, mobile_apis::Result::GENERIC_ERROR)) + .WillOnce(Return(result_msg)); + + CommandPtr command(CreateCommand<AlertRequest>()); + MessageSharedPtr received_result_msg( + CatchMobileCommandResult(CallOnTimeOut(*command))); + EXPECT_EQ(result_msg, received_result_msg); +} + +TEST_F(AlertRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { + Expectations(); + MockAppPtr invalid_app; + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(invalid_app)); + + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + ExpectManageMobileCommandWithResultCode( + mobile_apis::Result::APPLICATION_NOT_REGISTERED); + command->Run(); +} + +TEST_F(AlertRequestTest, Run_AlertFrequencyIsTooHigh_UNSUCCESS) { + Expectations(); + EXPECT_CALL( + *mock_app_, + AreCommandLimitsExceeded(kFunctionId, am::TLimitSource::POLICY_TABLE)) + .WillOnce(Return(true)); + + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command))); + EXPECT_EQ(mobile_apis::Result::REJECTED, + static_cast<mobile_apis::Result::eType>( + (*result_msg)[am::strings::msg_params][am::strings::result_code] + .asInt())); +} + +TEST_F(AlertRequestTest, Run_FailToProcessSoftButtons_UNSUCCESS) { + Expectations(); + const mobile_apis::Result::eType result_code = + mobile_apis::Result::INVALID_ENUM; + + EXPECT_CALL(mock_message_helper_, + ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _)) + .WillOnce(Return(result_code)); + + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command))); + EXPECT_EQ(result_code, + static_cast<mobile_apis::Result::eType>( + (*result_msg)[am::strings::msg_params][am::strings::result_code] + .asInt())); +} + +TEST_F(AlertRequestTest, Run_MandatoryParametersAreMissed_UNSUCCESS) { + Expectations(); + EXPECT_CALL(mock_message_helper_, + ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA); + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + command->Run(); +} + +TEST_F(AlertRequestTest, Run_MandatoryParametersAreInvalid_UNSUCCESS) { + Expectations(); + AddAlertTextsToMsg(); + (*msg_)[am::strings::msg_params][am::strings::alert_text2] = + "invalid\t\nParam"; + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA); + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + command->Run(); +} + +TEST_F(AlertRequestTest, Run_SUCCESS) { + Expectations(); + AddAlertTextsToMsg(); + AddTTSChunkToMsg(); + + (*msg_)[am::strings::msg_params][am::strings::soft_buttons] = "soft_buttons"; + (*msg_)[am::strings::msg_params][am::strings::progress_indicator] = + "progress_indicator"; + (*msg_)[am::strings::msg_params][am::strings::play_tone] = true; + + EXPECT_CALL(mock_message_helper_, + ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + + EXPECT_CALL(mock_message_helper_, + SubscribeApplicationToSoftButton( + (*msg_)[am::strings::msg_params], _, kFunctionId)); + + EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + + ExpectManageHmiCommandTTSAndUI(); + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + command->Run(); +} + +TEST_F(AlertRequestTest, OnEvent_InvalidEventId_UNSUCCESS) { + Expectations(); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + + Event event(hmi_apis::FunctionID::INVALID_ENUM); + event.set_smart_object(*msg_); + + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + command->on_event(event); +} + +TEST_F(AlertRequestTest, DISABLED_OnEvent_UI_OnResetTimeout_SUCCESS) { + PreConditions(); + Expectations(); + AddAlertTextsToMsg(); + + (*msg_)[am::strings::msg_params][am::strings::duration] = kDefaultTimeout; + + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + EXPECT_TRUE(command->Init()); + + EXPECT_CALL( + app_mngr_, + updateRequestTimeout(kConnectionKey, kCorrelationId, kDefaultTimeout)); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_ENUM); + + Event event(hmi_apis::FunctionID::UI_OnResetTimeout); + event.set_smart_object(*msg_); + command->on_event(event); +} + +TEST_F(AlertRequestTest, OnEvent_UIAlertHasHmiResponsesToWait_UNSUCCESS) { + Expectations(); + AddAlertTextsToMsg(); + AddTTSChunkToMsg(); + + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::WARNINGS; + (*msg_)[am::strings::msg_params][am::strings::play_tone] = true; + + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + + ExpectCallHmiLevel(mobile_apis::HMILevel::HMI_FULL); + + EXPECT_CALL(mock_message_helper_, + ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + + ExpectManageHmiCommandTTSAndUI(); + + command->Run(); + + Event event(hmi_apis::FunctionID::UI_Alert); + event.set_smart_object(*msg_); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking))); + + command->on_event(event); +} + +TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSWarnings_SUCCESS) { + PreConditions(); + Expectations(); + AddTTSChunkToMsg(); + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::WARNINGS; + (*msg_)[am::strings::msg_params][am::strings::play_tone] = true; + + ExpectCallHmiLevel(mobile_apis::HMILevel::HMI_FULL); + + EXPECT_CALL(mock_message_helper_, + ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + + EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak))) + .WillOnce(Return(true)); + + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + command->Run(); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::WARNINGS); + + Event event(hmi_apis::FunctionID::TTS_Speak); + event.set_smart_object(*msg_); + command->on_event(event); +} + +TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSUnsupportedResource_SUCCESS) { + Expectations(); + AddTTSChunkToMsg(); + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*msg_)[am::strings::msg_params][am::strings::play_tone] = true; + + ExpectCallHmiLevel(mobile_apis::HMILevel::HMI_FULL); + + EXPECT_CALL(mock_message_helper_, + ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak))) + .WillOnce(Return(true)); + + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + command->Run(); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::WARNINGS); + + Event event(hmi_apis::FunctionID::TTS_Speak); + event.set_smart_object(*msg_); + PreConditions(); + + command->on_event(event); +} + +TEST_F(AlertRequestTest, + DISABLED_OnEvent_TTSUnsupportedResourceUiAlertSent_SUCCESS) { + PreConditions(); + + Expectations(); + AddAlertTextsToMsg(); + AddTTSChunkToMsg(); + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*msg_)[am::strings::msg_params][am::strings::play_tone] = true; + (*msg_)[am::strings::msg_params][am::strings::soft_buttons] = "soft_buttons"; + + ExpectCallHmiLevel(mobile_apis::HMILevel::HMI_FULL); + EXPECT_CALL(mock_message_helper_, + ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(mock_message_helper_, + SubscribeApplicationToSoftButton( + (*msg_)[am::strings::msg_params], _, kFunctionId)); + + ExpectManageHmiCommandTTSAndUI(); + + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + command->Run(); + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking))) + .WillOnce(Return(true)); + + Event ui_event(hmi_apis::FunctionID::UI_Alert); + ui_event.set_smart_object(*msg_); + command->on_event(ui_event); + + Event tts_stop_event(hmi_apis::FunctionID::TTS_StopSpeaking); + tts_stop_event.set_smart_object(*msg_); + command->on_event(tts_stop_event); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::WARNINGS); + + Event event(hmi_apis::FunctionID::TTS_Speak); + event.set_smart_object(*msg_); + command->on_event(event); +} + +TEST_F(AlertRequestTest, OnEvent_TTSUnsupportedResourceUiAlertSuccess_SUCCESS) { + Expectations(); + AddAlertTextsToMsg(); + AddTTSChunkToMsg(); + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*msg_)[am::strings::msg_params][am::strings::play_tone] = true; + (*msg_)[am::strings::msg_params][am::strings::soft_buttons] = "soft_buttons"; + + ExpectCallHmiLevel(mobile_apis::HMILevel::HMI_FULL); + EXPECT_CALL(mock_message_helper_, + ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(mock_message_helper_, + SubscribeApplicationToSoftButton( + (*msg_)[am::strings::msg_params], _, kFunctionId)); + ExpectManageHmiCommandTTSAndUI(); + + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + command->Run(); + + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking))) + .WillOnce(Return(true)); + + Event ui_event(hmi_apis::FunctionID::UI_Alert); + ui_event.set_smart_object(*msg_); + command->on_event(ui_event); + + Event tts_stop_event(hmi_apis::FunctionID::TTS_StopSpeaking); + tts_stop_event.set_smart_object(*msg_); + command->on_event(tts_stop_event); + + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::WARNINGS); + + Event event(hmi_apis::FunctionID::TTS_Speak); + event.set_smart_object(*msg_); + command->on_event(event); +} + +TEST_F(AlertRequestTest, OnEvent_TTSSuccesUiAlertInvalidEnum_SUCCESS) { + Expectations(); + AddTTSChunkToMsg(); + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*msg_)[am::strings::msg_params][am::strings::play_tone] = true; + + ExpectCallHmiLevel(mobile_apis::HMILevel::HMI_FULL); + EXPECT_CALL(mock_message_helper_, + ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak))) + .WillOnce(Return(true)); + + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + command->Run(); + + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::INVALID_ENUM; + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking))) + .WillOnce(Return(true)); + + Event ui_event(hmi_apis::FunctionID::UI_Alert); + ui_event.set_smart_object(*msg_); + command->on_event(ui_event); + + Event tts_stop_event(hmi_apis::FunctionID::TTS_StopSpeaking); + tts_stop_event.set_smart_object(*msg_); + command->on_event(tts_stop_event); + + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::SUCCESS); + + Event event(hmi_apis::FunctionID::TTS_Speak); + event.set_smart_object(*msg_); + command->on_event(event); +} + +TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSAbortedUiAlertNotSent_SUCCESS) { + Expectations(); + AddTTSChunkToMsg(); + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*msg_)[am::strings::msg_params][am::strings::play_tone] = true; + + ExpectCallHmiLevel(mobile_apis::HMILevel::HMI_FULL); + EXPECT_CALL(mock_message_helper_, + ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak))) + .WillOnce(Return(true)); + + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + command->Run(); + + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::INVALID_ENUM; + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking))) + .WillOnce(Return(true)); + + Event ui_event(hmi_apis::FunctionID::UI_Alert); + ui_event.set_smart_object(*msg_); + command->on_event(ui_event); + + Event tts_stop_event(hmi_apis::FunctionID::TTS_StopSpeaking); + tts_stop_event.set_smart_object(*msg_); + command->on_event(tts_stop_event); + + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::ABORTED; + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::ABORTED); + + Event event(hmi_apis::FunctionID::TTS_Speak); + event.set_smart_object(*msg_); + command->on_event(event); +} + +TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSWarningUiAlertWarning_SUCCESS) { + Expectations(); + AddAlertTextsToMsg(); + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::WARNINGS; + (*msg_)[am::strings::msg_params][am::strings::play_tone] = true; + + ExpectCallHmiLevel(mobile_apis::HMILevel::HMI_FULL); + EXPECT_CALL(mock_message_helper_, + ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + ExpectManageHmiCommandTTSAndUI(); + + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + command->Run(); + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking))) + .WillOnce(Return(true)); + + Event ui_event(hmi_apis::FunctionID::UI_Alert); + ui_event.set_smart_object(*msg_); + command->on_event(ui_event); + + Event tts_stop_event(hmi_apis::FunctionID::TTS_StopSpeaking); + tts_stop_event.set_smart_object(*msg_); + command->on_event(tts_stop_event); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::WARNINGS); + + Event event(hmi_apis::FunctionID::TTS_Speak); + event.set_smart_object(*msg_); + command->on_event(event); +} + +TEST_F(AlertRequestTest, Run_InvalidAlert2_UNSUCCESS) { + Expectations(); + AddAlertTextsToMsg(); + (*msg_)[am::strings::msg_params][am::strings::alert_text2] = + "invalid_text_with_empty_str\\n"; + + EXPECT_CALL(mock_message_helper_, ProcessSoftButtons(_, _, _, _)).Times(0); + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA); + + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + command->Run(); +} + +TEST_F(AlertRequestTest, Run_InvalidAlert3_UNSUCCESS) { + Expectations(); + AddAlertTextsToMsg(); + (*msg_)[am::strings::msg_params][am::strings::alert_text3] = + "invalid_text_with_empty_str\\n"; + + EXPECT_CALL(mock_message_helper_, ProcessSoftButtons(_, _, _, _)).Times(0); + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA); + + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + command->Run(); +} + +TEST_F(AlertRequestTest, Run_InvalidTTSChunk_UNSUCCESS) { + Expectations(); + AddAlertTextsToMsg(); + (*msg_)[am::strings::msg_params][am::strings::tts_chunks][0] + [am::strings::text] = "invalid_text_with_empty_str\\n"; + + EXPECT_CALL(mock_message_helper_, ProcessSoftButtons(_, _, _, _)).Times(0); + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA); + + CommandPtr command(CreateCommand<AlertRequest>(msg_)); + command->Run(); +} + +} // namespace alert_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/change_registration_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/change_registration_test.cc new file mode 100644 index 0000000000..3d6a345ced --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/change_registration_test.cc @@ -0,0 +1,562 @@ +/* + * 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 <stdint.h> +#include <string> +#include <set> + +#include "mobile/change_registration_request.h" + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "utils/helpers.h" +#include "utils/make_shared.h" +#include "utils/custom_string.h" +#include "smart_objects/smart_object.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/smart_object_keys.h" +#include "policy/policy_regular/policy/usage_statistics/mock_statistics_manager.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/policies/mock_policy_handler_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace change_registration_request { + +namespace am = application_manager; +using am::commands::CommandImpl; +using am::ApplicationManager; +using am::commands::MessageSharedPtr; +using am::ApplicationSharedPtr; +using am::MockMessageHelper; +using ::testing::_; +using ::utils::SharedPtr; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::SetArgPointee; +using sdl_rpc_plugin::commands::ChangeRegistrationRequest; +using policy_test::MockPolicyHandlerInterface; +using ::test::components::application_manager_test::MockApplication; + +namespace custom_str = utils::custom_string; +namespace strings = ::application_manager::strings; +namespace hmi_response = ::application_manager::hmi_response; + +namespace { +const uint32_t kAppId = 1u; +const uint32_t kCmdId = 1u; +const uint32_t kConnectionKey = 2u; +} // namespace + +class ChangeRegistrationRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + ChangeRegistrationRequestTest() + : app_set_lock_ptr_(std::make_shared<sync_primitives::Lock>()) + , mock_app_(CreateMockApp()) + , supported_languages_(CreateMessage(smart_objects::SmartType_Array)) {} + + MessageSharedPtr CreateMsgFromMobile() { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[strings::params][strings::connection_key] = kConnectionKey; + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[strings::hmi_display_language] = mobile_apis::Language::EN_US; + msg_params[strings::language] = mobile_apis::Language::EN_US; + (*msg)[strings::msg_params] = msg_params; + return msg; + } + void PrepareExpectationBeforeRun() { + (*supported_languages_)[0] = + static_cast<int32_t>(mobile_apis::Language::EN_US); + EXPECT_CALL(mock_hmi_capabilities_, ui_supported_languages()) + .WillOnce(Return(supported_languages_.get())); + EXPECT_CALL(mock_hmi_capabilities_, vr_supported_languages()) + .WillOnce(Return(supported_languages_.get())); + EXPECT_CALL(mock_hmi_capabilities_, tts_supported_languages()) + .WillOnce(Return(supported_languages_.get())); + + EXPECT_CALL(app_mngr_, hmi_interfaces()) + .WillRepeatedly(ReturnRef(mock_hmi_interfaces_)); + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_ChangeRegistration)) + .WillRepeatedly(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration)) + .WillRepeatedly(Return(am::HmiInterfaces::HMI_INTERFACE_VR)); + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_ChangeRegistration)) + .WillRepeatedly(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); + } + + void CheckExpectations(const hmi_apis::Common_Result::eType hmi_response, + const mobile_apis::Result::eType mobile_response, + const am::HmiInterfaces::InterfaceState state, + const bool success, + const hmi_apis::Common_Result::eType ui_hmi_response = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + const hmi_apis::Common_Result::eType vr_hmi_response = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE) { + MessageSharedPtr msg_from_mobile = CreateMsgFromMobile(); + + utils::SharedPtr<ChangeRegistrationRequest> command = + CreateCommand<ChangeRegistrationRequest>(msg_from_mobile); + MockAppPtr mock_app = CreateMockApp(); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); + ON_CALL(*mock_app, app_id()).WillByDefault(Return(1)); + am::ApplicationSet application_set; + const utils::custom_string::CustomString name("name"); + MockAppPtr app = CreateMockApp(); + app->set_name(name); + + DataAccessor<am::ApplicationSet> accessor(application_set, + app_set_lock_ptr_); + + application_set.insert(app); + + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); + EXPECT_CALL(*app, name()).WillOnce(ReturnRef(name)); + PrepareExpectationBeforeRun(); + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(state)); + command->Run(); + + MessageSharedPtr ui_response = CreateMessage(smart_objects::SmartType_Map); + MessageSharedPtr vr_response = CreateMessage(smart_objects::SmartType_Map); + MessageSharedPtr tts_response = CreateMessage(smart_objects::SmartType_Map); + CreateResponseFromHMI(ui_response, ui_hmi_response, "ui_info"); + CreateResponseFromHMI(vr_response, vr_hmi_response, "unsupported_resource"); + + (*tts_response)[strings::params][hmi_response::code] = hmi_response; + (*tts_response)[strings::msg_params] = 0; + + am::event_engine::Event event_ui( + hmi_apis::FunctionID::UI_ChangeRegistration); + event_ui.set_smart_object(*ui_response); + am::event_engine::Event event_vr( + hmi_apis::FunctionID::VR_ChangeRegistration); + event_vr.set_smart_object(*vr_response); + am::event_engine::Event event_tts( + hmi_apis::FunctionID::TTS_ChangeRegistration); + event_tts.set_smart_object(*tts_response); + + MessageSharedPtr response_to_mobile; + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + _, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command->on_event(event_ui); + command->on_event(event_vr); + command->on_event(event_tts); + + EXPECT_EQ( + (*response_to_mobile)[strings::msg_params][strings::success].asBool(), + success); + EXPECT_EQ((*response_to_mobile)[strings::msg_params][strings::result_code] + .asInt(), + static_cast<int32_t>(mobile_response)); + } + + void CreateResponseFromHMI(MessageSharedPtr msg, + hmi_apis::Common_Result::eType result, + const std::string& info) { + (*msg)[strings::params][hmi_response::code] = static_cast<int32_t>(result); + (*msg)[strings::msg_params][strings::info] = info; + } + + MessageSharedPtr CreateFullParamsUISO() { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + smart_objects::SmartObject menu_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + menu_params[am::strings::position] = 10; + menu_params[am::strings::menu_name] = "LG"; + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[am::strings::cmd_id] = kCmdId; + msg_params[am::strings::menu_params] = menu_params; + msg_params[am::strings::app_id] = kAppId; + msg_params[am::strings::cmd_icon] = 1; + msg_params[am::strings::cmd_icon][am::strings::value] = "10"; + (*msg)[am::strings::msg_params] = msg_params; + + return msg; + } + + void SetUp() OVERRIDE { + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + } + + void ExpectationsHmiCapabilities( + smart_objects::SmartObjectSPtr supported_languages) { + EXPECT_CALL(mock_hmi_capabilities_, ui_supported_languages()) + .WillOnce(Return(supported_languages.get())); + EXPECT_CALL(mock_hmi_capabilities_, vr_supported_languages()) + .WillOnce(Return(supported_languages.get())); + EXPECT_CALL(mock_hmi_capabilities_, tts_supported_languages()) + .WillOnce(Return(supported_languages.get())); + } + + void ResultCommandExpectations(MessageSharedPtr msg, + const std::string& info) { + EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(), + true); + EXPECT_EQ( + (*msg)[am::strings::msg_params][am::strings::result_code].asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(), + info); + } + + typedef TypeIf<kMocksAreNice, + NiceMock<application_manager_test::MockHMICapabilities>, + application_manager_test::MockHMICapabilities>::Result + MockHMICapabilities; + std::shared_ptr<sync_primitives::Lock> app_set_lock_ptr_; + MockHMICapabilities hmi_capabilities_; + MockAppPtr mock_app_; + MessageSharedPtr supported_languages_; + MockPolicyHandlerInterface mock_policy_handler_; +}; + +typedef ChangeRegistrationRequestTest::MockHMICapabilities MockHMICapabilities; + +TEST_F(ChangeRegistrationRequestTest, + OnEvent_VRHmiSendSuccess_UNSUPPORTED_RESOURCE) { + MessageSharedPtr msg_from_mobile = CreateMsgFromMobile(); + utils::SharedPtr<ChangeRegistrationRequest> command = + CreateCommand<ChangeRegistrationRequest>(msg_from_mobile); + + am::ApplicationSet application_set; + const utils::custom_string::CustomString name("name"); + MockAppPtr app = CreateMockApp(); + app->set_name(name); + + DataAccessor<am::ApplicationSet> accessor(application_set, app_set_lock_ptr_); + + application_set.insert(app); + + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); + EXPECT_CALL(*app, name()).WillOnce(ReturnRef(name)); + + smart_objects::SmartObjectSPtr supported_languages( + CreateMessage(smart_objects::SmartType_Array)); + (*supported_languages)[0] = + static_cast<int32_t>(mobile_apis::Language::EN_US); + + ExpectationsHmiCapabilities(supported_languages); + + ON_CALL(mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_ChangeRegistration)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + ON_CALL(mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_RESPONSE)); + + ON_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_ChangeRegistration)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + command->Run(); + + MessageSharedPtr ui_response = CreateMessage(smart_objects::SmartType_Map); + MessageSharedPtr vr_response = CreateMessage(smart_objects::SmartType_Map); + MessageSharedPtr tts_response = CreateMessage(smart_objects::SmartType_Map); + CreateResponseFromHMI( + ui_response, hmi_apis::Common_Result::WARNINGS, "ui_info"); + CreateResponseFromHMI(vr_response, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + "VR is not supported by system"); + CreateResponseFromHMI( + tts_response, hmi_apis::Common_Result::SUCCESS, "tts_info"); + (*ui_response)[am::strings::msg_params][am::strings::app_id] = kConnectionKey; + (*vr_response)[am::strings::msg_params][am::strings::app_id] = kConnectionKey; + (*tts_response)[am::strings::msg_params][am::strings::app_id] = + kConnectionKey; + am::event_engine::Event event_ui(hmi_apis::FunctionID::UI_ChangeRegistration); + event_ui.set_smart_object(*ui_response); + am::event_engine::Event event_vr(hmi_apis::FunctionID::VR_ChangeRegistration); + event_vr.set_smart_object(*vr_response); + am::event_engine::Event event_tts( + hmi_apis::FunctionID::TTS_ChangeRegistration); + event_tts.set_smart_object(*tts_response); + + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + MessageSharedPtr response_to_mobile; + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command->on_event(event_ui); + command->on_event(event_tts); + command->on_event(event_vr); + + ResultCommandExpectations(response_to_mobile, + "ui_info, VR is not supported by system, tts_info"); +} + +TEST_F(ChangeRegistrationRequestTest, + OnEvent_TTS_UNSUPPORTED_RESOURCE_STATE_NOT_AVAILABLE_Expect_false) { + MessageSharedPtr msg_from_mobile = CreateMsgFromMobile(); + utils::SharedPtr<ChangeRegistrationRequest> command = + CreateCommand<ChangeRegistrationRequest>(msg_from_mobile); + MockAppPtr mock_app = CreateMockApp(); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); + ON_CALL(*mock_app, app_id()).WillByDefault(Return(1)); + am::ApplicationSet application_set; + const utils::custom_string::CustomString name("name"); + MockAppPtr app = CreateMockApp(); + app->set_name(name); + DataAccessor<am::ApplicationSet> accessor(application_set, app_set_lock_ptr_); + application_set.insert(app); + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); + EXPECT_CALL(*app, name()).WillOnce(ReturnRef(name)); + + (*supported_languages_)[0] = + static_cast<int32_t>(mobile_apis::Language::EN_US); + EXPECT_CALL(mock_hmi_capabilities_, ui_supported_languages()) + .WillOnce(Return(supported_languages_.get())); + EXPECT_CALL(mock_hmi_capabilities_, vr_supported_languages()) + .WillOnce(Return(supported_languages_.get())); + EXPECT_CALL(mock_hmi_capabilities_, tts_supported_languages()) + .WillOnce(Return(supported_languages_.get())); + + EXPECT_CALL(app_mngr_, hmi_interfaces()) + .WillRepeatedly(ReturnRef(mock_hmi_interfaces_)); + + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + MessageSharedPtr response_to_mobile; + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + command->Run(); + + EXPECT_EQ( + (*response_to_mobile)[strings::msg_params][strings::success].asBool(), + false); + EXPECT_EQ( + (*response_to_mobile)[strings::msg_params][strings::result_code].asInt(), + static_cast<int32_t>(mobile_apis::Result::UNSUPPORTED_RESOURCE)); +} + +TEST_F(ChangeRegistrationRequestTest, + OnEvent_TTS_UNSUPPORTED_RESOURCE_STATE_NOT_RESPONSE_Expect_false) { + CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + am::HmiInterfaces::STATE_NOT_RESPONSE, + false); +} + +TEST_F(ChangeRegistrationRequestTest, + OnEvent_TTS_UNSUPPORTED_RESOURCE_STATE_AVAILABLE_Expect_false) { + CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + am::HmiInterfaces::STATE_AVAILABLE, + false); +} + +TEST_F(ChangeRegistrationRequestTest, + OnEvent_TTS_UNSUPPORTED_RESOURCE_SUCCESS_STATE_AVAILABLE_Expect_true) { + CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + am::HmiInterfaces::STATE_AVAILABLE, + true, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::SUCCESS); +} + +TEST_F(ChangeRegistrationRequestTest, + OnEvent_TTS_SUCCESS_STATE_AVAILABLE_Expect_true) { + CheckExpectations(hmi_apis::Common_Result::SUCCESS, + mobile_apis::Result::SUCCESS, + am::HmiInterfaces::STATE_AVAILABLE, + true, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::SUCCESS); +} + +TEST_F(ChangeRegistrationRequestTest, + OnEvent_TTS_WRONG_LANGUAGE_STATE_AVAILABLE_Expect_true) { + CheckExpectations(hmi_apis::Common_Result::WRONG_LANGUAGE, + mobile_apis::Result::WRONG_LANGUAGE, + am::HmiInterfaces::STATE_AVAILABLE, + true, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::SUCCESS); +} + +TEST_F(ChangeRegistrationRequestTest, + OnEvent_TTS_INVALID_DATA_STATE_AVAILABLE_Expect_false) { + CheckExpectations(hmi_apis::Common_Result::INVALID_DATA, + mobile_apis::Result::INVALID_DATA, + am::HmiInterfaces::STATE_AVAILABLE, + false, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::SUCCESS); +} + +TEST_F(ChangeRegistrationRequestTest, + OnEvent_UIHmiSendSuccess_UNSUPPORTED_RESOURCE) { + MessageSharedPtr msg_from_mobile = CreateMsgFromMobile(); + + utils::SharedPtr<ChangeRegistrationRequest> command = + CreateCommand<ChangeRegistrationRequest>(msg_from_mobile); + + am::ApplicationSet application_set; + const utils::custom_string::CustomString name("name"); + MockAppPtr app = CreateMockApp(); + app->set_name(name); + + DataAccessor<am::ApplicationSet> accessor(application_set, app_set_lock_ptr_); + + application_set.insert(app); + + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); + EXPECT_CALL(*app, name()).WillOnce(ReturnRef(name)); + + smart_objects::SmartObjectSPtr supported_languages( + CreateMessage(smart_objects::SmartType_Array)); + (*supported_languages)[0] = + static_cast<int32_t>(mobile_apis::Language::EN_US); + + ExpectationsHmiCapabilities(supported_languages); + + ON_CALL(mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_ChangeRegistration)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + ON_CALL(mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + ON_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_ChangeRegistration)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + command->Run(); + + MessageSharedPtr ui_response = CreateMessage(smart_objects::SmartType_Map); + MessageSharedPtr vr_response = CreateMessage(smart_objects::SmartType_Map); + MessageSharedPtr tts_response = CreateMessage(smart_objects::SmartType_Map); + CreateResponseFromHMI(ui_response, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + "unsupported_resource"); + CreateResponseFromHMI( + vr_response, hmi_apis::Common_Result::WARNINGS, "vr_info"); + CreateResponseFromHMI( + tts_response, hmi_apis::Common_Result::SUCCESS, "tts_info"); + (*ui_response)[am::strings::msg_params][am::strings::app_id] = kConnectionKey; + (*vr_response)[am::strings::msg_params][am::strings::app_id] = kConnectionKey; + (*tts_response)[am::strings::msg_params][am::strings::app_id] = + kConnectionKey; + am::event_engine::Event event_ui(hmi_apis::FunctionID::UI_ChangeRegistration); + event_ui.set_smart_object(*ui_response); + am::event_engine::Event event_vr(hmi_apis::FunctionID::VR_ChangeRegistration); + event_vr.set_smart_object(*vr_response); + am::event_engine::Event event_tts( + hmi_apis::FunctionID::TTS_ChangeRegistration); + event_tts.set_smart_object(*tts_response); + + MessageSharedPtr response_to_mobile; + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command->on_event(event_vr); + command->on_event(event_tts); + command->on_event(event_ui); + + ResultCommandExpectations(response_to_mobile, + "unsupported_resource, vr_info, tts_info"); +} + +} // namespace change_registration_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc new file mode 100644 index 0000000000..10ffbded09 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc @@ -0,0 +1,826 @@ +/* + * 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 <stdint.h> +#include <string> +#include <set> + +#include "mobile/create_interaction_choice_set_request.h" +#include "mobile/create_interaction_choice_set_response.h" + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "utils/helpers.h" +#include "utils/make_shared.h" +#include "smart_objects/smart_object.h" +#include "utils/custom_string.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_hmi_capabilities.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace create_interaction_choice_set_request { + +namespace am = application_manager; +using am::commands::CommandImpl; +using am::ApplicationManager; +using am::commands::MessageSharedPtr; +using am::ApplicationSharedPtr; +using am::MockMessageHelper; +using ::testing::_; +using ::utils::SharedPtr; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::AtLeast; +using sdl_rpc_plugin::commands::CreateInteractionChoiceSetRequest; +using sdl_rpc_plugin::commands::CreateInteractionChoiceSetResponse; +using ::test::components::application_manager_test::MockApplication; + +namespace custom_str = utils::custom_string; +namespace strings = ::application_manager::strings; +namespace hmi_response = ::application_manager::hmi_response; + +typedef SharedPtr<CreateInteractionChoiceSetRequest> + CreateInteractionChoiceSetRequestPtr; +typedef SharedPtr<CreateInteractionChoiceSetResponse> + CreateInteractionChoiceSetResponsePtr; + +typedef NiceMock< + ::test::components::application_manager_test::MockHMICapabilities> + MockHMICapabilities; + +namespace { +const hmi_apis::FunctionID::eType kInvalidFunctionId = + hmi_apis::FunctionID::INVALID_ENUM; +const int32_t kCommandId = 1; +const uint32_t kAppId = 1u; +const uint32_t kCmdId = 1u; +const uint32_t kConnectionKey = 2u; +const uint32_t kCorrelationId = 10u; +const uint32_t kGrammarId = 10u; +const int32_t kMenuId = 5; +const uint32_t kChoiceSetId = 1u; +const uint32_t kChoiceId1 = 2u; +const uint32_t kChoiceId2 = 3u; +const std::string kImage = "image"; +const std::string kSecondImage = "second_image"; +const std::string kVrCommands1 = "vr_commands_1"; +const std::string kVrCommands2 = "vr_commands_2"; +const std::string kMenuName = "menu_name"; + +} // namespace + +class CreateInteractionChoiceSetRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + CreateInteractionChoiceSetRequestTest() + : message_(CreateMessage()) + , command_(CreateCommand<CreateInteractionChoiceSetRequest>(message_)) + , mock_app_(CreateMockApp()) + , lock_(std::make_shared<sync_primitives::Lock>()) {} + + MessageSharedPtr CreateFullParamsVRSO() { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[strings::params][strings::connection_key] = kConnectionKey; + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[strings::cmd_id] = kCmdId; + msg_params[strings::vr_commands] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + msg_params[strings::vr_commands][0] = "lamer"; + msg_params[strings::type] = 34; + msg_params[strings::grammar_id] = 12; + msg_params[strings::app_id] = kAppId; + (*msg)[strings::msg_params] = msg_params; + + return msg; + } + + void FillMessageFieldsItem1(MessageSharedPtr message) { + (*message)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::menu_name] = kMenuName; + (*message)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::image][am::strings::value] = kImage; + (*message)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::choice_id] = kChoiceId1; + (*message)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::vr_commands][0] = kVrCommands1; + (*message)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::secondary_image][am::strings::value] = kSecondImage; + } + void FillMessageFieldsItem2(MessageSharedPtr message) { + (*message)[am::strings::msg_params][am::strings::choice_set][1] + [am::strings::choice_id] = kChoiceId2; + (*message)[am::strings::msg_params][am::strings::choice_set][1] + [am::strings::menu_name] = kMenuName; + (*message)[am::strings::msg_params][am::strings::choice_set][1] + [am::strings::vr_commands][0] = kVrCommands2; + (*message)[am::strings::msg_params] + [am::strings::interaction_choice_set_id] = kChoiceSetId; + } + + MessageSharedPtr message_; + CreateInteractionChoiceSetRequestPtr command_; + MockAppPtr mock_app_; + std::shared_ptr<sync_primitives::Lock> lock_; +}; + +class CreateInteractionChoiceSetResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(CreateInteractionChoiceSetRequestTest, OnTimeout_GENERIC_ERROR) { + MessageSharedPtr msg_vr = CreateMessage(smart_objects::SmartType_Map); + (*msg_vr)[strings::msg_params][strings::result_code] = + am::mobile_api::Result::GENERIC_ERROR; + (*msg_vr)[strings::msg_params][strings::success] = false; + + utils::SharedPtr<CreateInteractionChoiceSetRequest> req_vr = + CreateCommand<CreateInteractionChoiceSetRequest>(); + + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app)); + ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(*mock_app, get_grammar_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(*mock_app, RemoveCommand(_)).WillByDefault(Return()); + + MessageSharedPtr vr_command_result; + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true))); + + req_vr->onTimeOut(); + EXPECT_EQ( + (*vr_command_result)[strings::msg_params][strings::success].asBool(), + false); + EXPECT_EQ( + (*vr_command_result)[strings::msg_params][strings::result_code].asInt(), + static_cast<int32_t>(am::mobile_api::Result::GENERIC_ERROR)); +} + +TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) { + MessageSharedPtr msg_vr = CreateFullParamsVRSO(); + (*msg_vr)[strings::msg_params][strings::choice_set][0][strings::choice_id] = + 10; + (*msg_vr)[strings::msg_params][strings::choice_set][0][strings::menu_name] = + "menu_name"; + (*msg_vr)[strings::msg_params][strings::interaction_choice_set_id] = 11; + utils::SharedPtr<CreateInteractionChoiceSetRequest> req_vr = + CreateCommand<CreateInteractionChoiceSetRequest>(msg_vr); + + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); + + smart_objects::SmartObject* null_obj = NULL; + ON_CALL(*mock_app_, FindChoiceSet(_)).WillByDefault(Return(null_obj)); + + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*msg)[strings::msg_params][strings::info] = "VR is not supported by system"; + (*msg)[strings::msg_params][strings::cmd_id] = kCommandId; + + am::event_engine::Event event(hmi_apis::FunctionID::VR_AddCommand); + event.set_smart_object(*msg); + + smart_objects::SmartObject* ptr = NULL; + ON_CALL(*mock_app_, FindCommand(kCmdId)).WillByDefault(Return(ptr)); + EXPECT_EQ(NULL, ptr); + + am::CommandsMap commands_map; + ON_CALL(*mock_app_, commands_map()) + .WillByDefault( + Return(DataAccessor<am::CommandsMap>(commands_map, lock_))); + + ON_CALL(mock_hmi_interfaces_, GetInterfaceFromFunction(_)) + .WillByDefault( + Return(am::HmiInterfaces::HMI_INTERFACE_BasicCommunication)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); + + req_vr->Run(); + + MessageSharedPtr vr_command_result; + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true))); + + req_vr->on_event(event); + + EXPECT_EQ( + (*vr_command_result)[strings::msg_params][strings::success].asBool(), + false); + EXPECT_EQ( + (*vr_command_result)[strings::msg_params][strings::result_code].asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + if ((*vr_command_result)[strings::msg_params].keyExists(strings::info)) { + EXPECT_EQ( + (*vr_command_result)[strings::msg_params][strings::info].asString(), + (*msg)[strings::msg_params][strings::info].asString()); + } +} + +TEST_F(CreateInteractionChoiceSetRequestTest, Run_InvalidApp_UNSUCCESS) { + MockAppPtr invalid_app; + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app)); + EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0); + + command_->Run(); +} + +TEST_F(CreateInteractionChoiceSetRequestTest, Run_VerifyImageFail_UNSUCCESS) { + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::image] = kImage; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::secondary_image] = kSecondImage; + + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)) + .WillRepeatedly(Return(mobile_apis::Result::INVALID_DATA)); + EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0); + + command_->Run(); +} + +TEST_F(CreateInteractionChoiceSetRequestTest, Run_FindChoiceSetFail_UNSUCCESS) { + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::image] = kImage; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::secondary_image] = kSecondImage; + (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] = + kChoiceSetId; + + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)) + .WillRepeatedly(Return(mobile_apis::Result::SUCCESS)); + + smart_objects::SmartObject* invalid_choice_set_id = + &((*message_)[am::strings::msg_params] + [am::strings::interaction_choice_set_id]); + EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) + .WillOnce(Return(invalid_choice_set_id)); + EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0); + + command_->Run(); +} + +TEST_F(CreateInteractionChoiceSetRequestTest, + Run_CheckChoiceSet_InvalidChoiceId_UNSUCCESS) { + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::menu_name] = kMenuName; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::image][am::strings::value] = kImage; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::choice_id] = kChoiceId1; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::secondary_image][am::strings::value] = kSecondImage; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::vr_commands][0] = kVrCommands1; + + FillMessageFieldsItem2(message_); + (*message_)[am::strings::msg_params][am::strings::choice_set][1] + [am::strings::vr_commands][0] = kVrCommands1; + (*message_)[am::strings::msg_params][am::strings::choice_set][1] + [am::strings::vr_commands][1] = " kVrCommands2\t"; + (*message_)[am::strings::msg_params][am::strings::choice_set][1] + [am::strings::vr_commands][0] = kVrCommands1; + + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_)); + + EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)) + .WillRepeatedly(Return(mobile_apis::Result::SUCCESS)); + + smart_objects::SmartObject* choice_set_id = NULL; + EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) + .WillOnce(Return(choice_set_id)); + + EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0); + command_->Run(); +} + +TEST_F(CreateInteractionChoiceSetRequestTest, + Run_IsWhiteSpaceVRCommandsExist_InvalidMenuName_UNSUCCESS) { + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::menu_name] = "menu_name\t"; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::secondary_text] = "secondary_text\t"; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::tertiary_text] = "tertiary_text\t"; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::image][am::strings::value] = "image\t"; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::choice_id] = kChoiceId1; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::secondary_image][am::strings::value] = + "second_image\t"; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::vr_commands][0] = "vr_commands_1\t"; + + (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] = + kChoiceSetId; + + smart_objects::SmartObject* choice_set_id = NULL; + EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) + .WillRepeatedly(Return(choice_set_id)); + EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app_)); + + EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)) + .WillRepeatedly(Return(mobile_apis::Result::SUCCESS)); + + if ((*message_)[am::strings::msg_params][am::strings::choice_set][0] + .keyExists(am::strings::menu_name)) { + CreateInteractionChoiceSetRequestPtr command( + CreateCommand<CreateInteractionChoiceSetRequest>(message_)); + + EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0); + command->Run(); + } + if ((*message_)[am::strings::msg_params][am::strings::choice_set][0] + .keyExists(am::strings::secondary_text)) { + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::menu_name] = kMenuName; + CreateInteractionChoiceSetRequestPtr command( + CreateCommand<CreateInteractionChoiceSetRequest>(message_)); + + EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0); + command->Run(); + } + if ((*message_)[am::strings::msg_params][am::strings::choice_set][0] + .keyExists(am::strings::tertiary_text)) { + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::secondary_text] = "secondary_text"; + CreateInteractionChoiceSetRequestPtr command( + CreateCommand<CreateInteractionChoiceSetRequest>(message_)); + + EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0); + command->Run(); + } + if ((*message_)[am::strings::msg_params][am::strings::choice_set][0] + .keyExists(am::strings::vr_commands)) { + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::tertiary_text] = "tertiary_text"; + CreateInteractionChoiceSetRequestPtr command( + CreateCommand<CreateInteractionChoiceSetRequest>(message_)); + + EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0); + command->Run(); + } + if ((*message_)[am::strings::msg_params][am::strings::choice_set][0] + .keyExists(am::strings::image)) { + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::vr_commands][0] = "vr_commands"; + CreateInteractionChoiceSetRequestPtr command( + CreateCommand<CreateInteractionChoiceSetRequest>(message_)); + + EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0); + command->Run(); + } + if ((*message_)[am::strings::msg_params][am::strings::choice_set][0] + .keyExists(am::strings::secondary_image)) { + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::image][am::strings::value] = kImage; + CreateInteractionChoiceSetRequestPtr command( + CreateCommand<CreateInteractionChoiceSetRequest>(message_)); + + EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0); + command->Run(); + } +} + +TEST_F(CreateInteractionChoiceSetRequestTest, + Run_ValidAmountVrCommands_SUCCESS) { + FillMessageFieldsItem1(message_); + FillMessageFieldsItem2(message_); + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_)); + + EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)) + .WillRepeatedly(Return(mobile_apis::Result::SUCCESS)); + + smart_objects::SmartObject* choice_set_id = NULL; + EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) + .WillOnce(Return(choice_set_id)); + + EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId)); + EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)); + EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) + .Times(AtLeast(2)) + .WillOnce(Return(kConnectionKey)) + .WillOnce(Return(kConnectionKey)); + + command_->Run(); +} + +TEST_F(CreateInteractionChoiceSetRequestTest, + Run_EmptyAmountVrCommands_SUCCESS) { + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::menu_name] = kMenuName; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::image][am::strings::value] = kImage; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::choice_id] = kChoiceId1; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::secondary_image][am::strings::value] = kSecondImage; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::vr_commands][0] = kVrCommands1; + (*message_)[am::strings::msg_params][am::strings::choice_set][1] + [am::strings::choice_id] = kChoiceId2; + (*message_)[am::strings::msg_params][am::strings::choice_set][1] + [am::strings::menu_name] = kMenuName; + (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] = + kChoiceSetId; + (*message_)[am::strings::msg_params][am::strings::choice_set][1] + [am::strings::vr_commands][0] = kVrCommands2; + + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_)); + + EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)) + .WillRepeatedly(Return(mobile_apis::Result::SUCCESS)); + + smart_objects::SmartObject* choice_set_id = NULL; + EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) + .WillOnce(Return(choice_set_id)); + + EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)); + + command_->Run(); +} + +TEST_F(CreateInteractionChoiceSetRequestTest, + OnEvent_InvalidEventId_UNSUCCESS) { + Event event(hmi_apis::FunctionID::INVALID_ENUM); + + EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)).Times(0); + command_->on_event(event); +} + +TEST_F(CreateInteractionChoiceSetRequestTest, + OnEvent_InvalidVrCommand_UNSUCCESS) { + (*message_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::WARNINGS; + (*message_)[am::strings::params][am::strings::correlation_id] = + kCorrelationId; + + Event event(hmi_apis::FunctionID::VR_AddCommand); + event.set_smart_object(*message_); + + EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)).Times(0); + command_->on_event(event); +} + +TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_ValidVrNoError_SUCCESS) { + Event event(hmi_apis::FunctionID::VR_AddCommand); + + (*message_)[am::strings::params][am::strings::correlation_id] = + kCorrelationId; + (*message_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::WARNINGS; + + FillMessageFieldsItem1(message_); + FillMessageFieldsItem2(message_); + + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_)); + + EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)) + .WillRepeatedly(Return(mobile_apis::Result::SUCCESS)); + + smart_objects::SmartObject* choice_set_id = NULL; + EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) + .WillOnce(Return(choice_set_id)); + + EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId)); + EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)); + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + + command_->Run(); + + EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); + EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)).Times(0); + event.set_smart_object(*message_); + + command_->on_event(event); +} + +TEST_F(CreateInteractionChoiceSetRequestTest, + OnEvent_InValidVrNoError_UNSUCCESS) { + Event event(hmi_apis::FunctionID::VR_AddCommand); + + (*message_)[am::strings::params][am::strings::correlation_id] = + kCorrelationId; + (*message_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::INVALID_DATA; + + FillMessageFieldsItem1(message_); + FillMessageFieldsItem2(message_); + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_)); + + EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)) + .WillRepeatedly(Return(mobile_apis::Result::SUCCESS)); + + smart_objects::SmartObject* choice_set_id = NULL; + EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) + .WillOnce(Return(choice_set_id)); + + EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId)); + EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)); + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + + command_->Run(); + EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); + EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)).Times(0); + event.set_smart_object(*message_); + + command_->on_event(event); +} + +TEST_F(CreateInteractionChoiceSetRequestTest, + OnEvent_ValidVrNoErrorAndExpectedChoiceLessThanReceiveChoice_SUCCESS) { + Event event(hmi_apis::FunctionID::VR_AddCommand); + + (*message_)[am::strings::params][am::strings::correlation_id] = + kCorrelationId; + (*message_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::WARNINGS; + + FillMessageFieldsItem1(message_); + + (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] = + kChoiceSetId; + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); + + EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)) + .WillRepeatedly(Return(mobile_apis::Result::SUCCESS)); + + smart_objects::SmartObject* choice_set_id = NULL; + EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) + .WillOnce(Return(choice_set_id)); + + EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId)); + EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)); + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + + command_->Run(); + + FillMessageFieldsItem2(message_); + + EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)); + event.set_smart_object(*message_); + command_->on_event(event); +} + +TEST_F(CreateInteractionChoiceSetRequestTest, + OnTimeOut_InvalidErrorFromHMI_UNSUCCESS) { + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_)); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::GENERIC_ERROR), + am::commands::Command::SOURCE_SDL)); + + EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)); + command_->onTimeOut(); +} + +TEST_F(CreateInteractionChoiceSetRequestTest, + OnTimeOut_ValidErrorFromHMI_SUCCESS) { + (*message_)[am::strings::params][am::strings::correlation_id] = + kCorrelationId; + (*message_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::INVALID_ENUM; + + FillMessageFieldsItem1(message_); + (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] = + kChoiceSetId; + + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); + + EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)) + .WillRepeatedly(Return(mobile_apis::Result::SUCCESS)); + + smart_objects::SmartObject* choice_set_id = NULL; + EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) + .WillOnce(Return(choice_set_id)); + + EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId)); + EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)); + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + + command_->Run(); + + FillMessageFieldsItem2(message_); + EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)); + Event event(hmi_apis::FunctionID::VR_AddCommand); + event.set_smart_object(*message_); + command_->on_event(event); + + EXPECT_CALL(*mock_app_, RemoveChoiceSet(kChoiceSetId)); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)); + command_->onTimeOut(); +} + +TEST_F(CreateInteractionChoiceSetRequestTest, OnTimeOut_InvalidApp_UNSUCCESS) { + (*message_)[am::strings::params][am::strings::correlation_id] = + kCorrelationId; + (*message_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*message_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::INVALID_ENUM; + + FillMessageFieldsItem1(message_); + (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] = + kChoiceSetId; + + EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app_)); + + EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)) + .WillRepeatedly(Return(mobile_apis::Result::SUCCESS)); + + smart_objects::SmartObject* choice_set_id = NULL; + EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) + .WillOnce(Return(choice_set_id)); + + EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId)); + EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)); + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + + command_->Run(); + + FillMessageFieldsItem2(message_); + EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)).Times(2); + Event event(hmi_apis::FunctionID::VR_AddCommand); + event.set_smart_object(*message_); + command_->on_event(event); + + MockAppPtr invalid_app; + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(invalid_app)); + EXPECT_CALL(*mock_app_, RemoveChoiceSet(_)).Times(0); + command_->onTimeOut(); +} + +TEST_F(CreateInteractionChoiceSetRequestTest, + OnTimeOut_SuccessfulResponseReceived_UNSUCCESS) { + (*message_)[am::strings::params][am::strings::correlation_id] = + kCorrelationId; + (*message_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*message_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::SUCCESS; + + FillMessageFieldsItem1(message_); + (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] = + kChoiceSetId; + + EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)) + .WillRepeatedly(Return(mobile_apis::Result::SUCCESS)); + + smart_objects::SmartObject* choice_set_id = NULL; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId)); + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + + EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) + .WillOnce(Return(choice_set_id)); + EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)); + + command_->Run(); + + FillMessageFieldsItem2(message_); + + EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)); + + Event event(hmi_apis::FunctionID::VR_AddCommand); + event.set_smart_object(*message_); + + command_->on_event(event); + + EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(*mock_app_, RemoveChoiceSet(_)); + + command_->onTimeOut(); +} + +TEST_F(CreateInteractionChoiceSetResponseTest, Run_SuccessFalse_UNSUCCESS) { + MessageSharedPtr message(CreateMessage()); + (*message)[am::strings::msg_params][am::strings::success] = false; + (*message)[am::strings::msg_params][am::strings::result_code] = + mobile_apis::Result::INVALID_ENUM; + CreateInteractionChoiceSetResponsePtr command( + CreateCommand<CreateInteractionChoiceSetResponse>(message)); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(message, false)); + command->Run(); +} + +TEST_F(CreateInteractionChoiceSetResponseTest, Run_SuccessTrue_SUCCESS) { + MessageSharedPtr message(CreateMessage()); + (*message)[am::strings::msg_params][am::strings::success] = true; + (*message)[am::strings::msg_params][am::strings::result_code] = + mobile_apis::Result::SUCCESS; + CreateInteractionChoiceSetResponsePtr command( + CreateCommand<CreateInteractionChoiceSetResponse>(message)); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(message, false)); + command->Run(); +} + +TEST_F(CreateInteractionChoiceSetRequestTest, Run_ErrorFromHmiFalse_UNSUCCESS) { + Event event(hmi_apis::FunctionID::VR_AddCommand); + + (*message_)[am::strings::params][am::strings::correlation_id] = + kCorrelationId; + (*message_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::GENERIC_ERROR; + + FillMessageFieldsItem1(message_); + + (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] = + kChoiceSetId; + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); + + EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)) + .WillRepeatedly(Return(mobile_apis::Result::GENERIC_ERROR)); + + smart_objects::SmartObject* choice_set_id = NULL; + EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) + .WillRepeatedly(Return(choice_set_id)); + + EXPECT_CALL(app_mngr_, GenerateGrammarID()) + .WillRepeatedly(Return(kGrammarId)); + EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)).Times(2); + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + + command_->Run(); + + FillMessageFieldsItem2(message_); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::GENERIC_ERROR), + am::commands::Command::SOURCE_SDL)); + EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)); + event.set_smart_object(*message_); + command_->on_event(event); + command_->Run(); +} + +} // namespace create_interaction_choice_set_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace tests diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc new file mode 100644 index 0000000000..ac8803c2ca --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc @@ -0,0 +1,256 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "mobile/delete_command_request.h" + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/event_engine/event.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace delete_command_request { + +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; +namespace am = ::application_manager; +using sdl_rpc_plugin::commands::DeleteCommandRequest; +using am::commands::MessageSharedPtr; +using am::event_engine::Event; +using am::MockMessageHelper; +using am::MockHmiInterfaces; + +typedef SharedPtr<DeleteCommandRequest> DeleteCommandPtr; + +namespace { +const int32_t kCommandId = 1; +const uint32_t kAppId = 1u; +const uint32_t kCmdId = 1u; +const uint32_t kConnectionKey = 2u; +} // namespace + +class DeleteCommandRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + DeleteCommandRequestTest() : mock_app_(CreateMockApp()) {} + MessageSharedPtr CreateFullParamsUISO() { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + smart_objects::SmartObject menu_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + menu_params[am::strings::position] = 10; + menu_params[am::strings::menu_name] = "LG"; + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[am::strings::cmd_id] = kCmdId; + msg_params[am::strings::menu_params] = menu_params; + msg_params[am::strings::app_id] = kAppId; + msg_params[am::strings::cmd_icon] = 1; + msg_params[am::strings::cmd_icon][am::strings::value] = "10"; + (*msg)[am::strings::msg_params] = msg_params; + + return msg; + } + + MessageSharedPtr CreateFullParamsVRSO() { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[am::strings::cmd_id] = kCmdId; + msg_params[am::strings::vr_commands] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + msg_params[am::strings::vr_commands][0] = "lamer"; + msg_params[am::strings::type] = 34; + msg_params[am::strings::grammar_id] = 12; + msg_params[am::strings::app_id] = kAppId; + (*msg)[am::strings::msg_params] = msg_params; + + return msg; + } + + void ResultCommandExpectations(MessageSharedPtr msg, + const std::string& info) { + EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(), + true); + EXPECT_EQ( + (*msg)[am::strings::msg_params][am::strings::result_code].asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(), + info); + } + + void SetUp() OVERRIDE { + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(app_mngr_, hmi_interfaces()) + .WillByDefault(ReturnRef(hmi_interfaces_)); + } + + NiceMock<MockHmiInterfaces> hmi_interfaces_; + MockAppPtr mock_app_; +}; + +TEST_F(DeleteCommandRequestTest, + OnEvent_VrHmiSendUnsupportedResource_UNSUPPORTED_RESOURCE) { + MessageSharedPtr command_msg = CreateFullParamsVRSO(); + (*command_msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId; + (*command_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + DeleteCommandPtr command(CreateCommand<DeleteCommandRequest>(command_msg)); + + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); + + MessageSharedPtr test_msg(CreateMessage(smart_objects::SmartType_Map)); + (*test_msg)[am::strings::vr_commands] = 0; + (*test_msg)[am::strings::menu_params] = 0; + + ON_CALL(hmi_interfaces_, GetInterfaceFromFunction(_)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR)); + ON_CALL(hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + ON_CALL(hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + ON_CALL(*mock_app_, FindCommand(kCommandId)) + .WillByDefault(Return(test_msg.get())); + ON_CALL(*mock_app_, get_grammar_id()).WillByDefault(Return(kConnectionKey)); + MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map)); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + Event event_ui(hmi_apis::FunctionID::UI_DeleteCommand); + event_ui.set_smart_object(*msg); + command->Init(); + command->Run(); + command->on_event(event_ui); + + MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map)); + (*event_msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*event_msg)[am::strings::msg_params][am::strings::info] = + "VR is not supported by system"; + Event event_vr(hmi_apis::FunctionID::VR_DeleteCommand); + event_vr.set_smart_object(*event_msg); + + EXPECT_CALL(*mock_app_, RemoveCommand(kCommandId)); + + EXPECT_CALL(*mock_app_, UpdateHash()); + + MessageSharedPtr vr_command_result; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true))); + + command->on_event(event_vr); + + ResultCommandExpectations(vr_command_result, "VR is not supported by system"); +} + +TEST_F(DeleteCommandRequestTest, + OnEvent_UIHmiSendUnsupportedResource_UNSUPPORTED_RESOURCE) { + MessageSharedPtr command_msg = CreateFullParamsUISO(); + (*command_msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId; + (*command_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + DeleteCommandPtr command(CreateCommand<DeleteCommandRequest>(command_msg)); + + MockAppPtr app = CreateMockApp(); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + + MessageSharedPtr test_msg(CreateMessage(smart_objects::SmartType_Map)); + (*test_msg)[am::strings::vr_commands] = 0; + (*test_msg)[am::strings::menu_params] = 0; + + ON_CALL(hmi_interfaces_, GetInterfaceFromFunction(_)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + ON_CALL(hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + ON_CALL(*app, FindCommand(kCommandId)).WillByDefault(Return(test_msg.get())); + ON_CALL(*app, get_grammar_id()).WillByDefault(Return(kConnectionKey)); + MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map)); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + Event event_vr(hmi_apis::FunctionID::VR_DeleteCommand); + event_vr.set_smart_object(*msg); + + command->Init(); + command->Run(); + command->on_event(event_vr); + + MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map)); + (*event_msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*event_msg)[am::strings::msg_params][am::strings::info] = + "UI is not supported by system"; + Event event_ui(hmi_apis::FunctionID::UI_DeleteCommand); + event_ui.set_smart_object(*event_msg); + + EXPECT_CALL(*app, RemoveCommand(kCommandId)); + + EXPECT_CALL(*app, UpdateHash()); + + MessageSharedPtr result_msg( + CatchMobileCommandResult(CallOnEvent(*command, event_ui))); + + ASSERT_TRUE(result_msg); + + ResultCommandExpectations(result_msg, "UI is not supported by system"); +} + +} // namespace delete_command_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_file_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_file_test.cc new file mode 100644 index 0000000000..5cc9dcf543 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_file_test.cc @@ -0,0 +1,250 @@ +/* + * 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 <stdint.h> +#include <vector> +#include <string> +#include <map> + +#include "mobile/delete_file_request.h" +#include "mobile/delete_file_response.h" + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "utils/file_system.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/mock_application_manager_settings.h" + +#include "interfaces/MOBILE_API.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/policies/policy_handler.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace delete_file { + +using ::testing::_; +using ::testing::Test; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::SetArgReferee; +using ::testing::AtLeast; +namespace am = ::application_manager; +using sdl_rpc_plugin::commands::DeleteFileRequest; +using sdl_rpc_plugin::commands::DeleteFileResponse; +using am::commands::MessageSharedPtr; +using am::event_engine::Event; +using am::MockMessageHelper; + +typedef SharedPtr<DeleteFileRequest> DeleteFileRequestPtr; +typedef SharedPtr<DeleteFileResponse> DeleteFileResponsePtr; +typedef NiceMock< + ::test::components::application_manager_test::MockHMICapabilities> + MockHMICapabilities; + +ACTION_TEMPLATE(SetArgPointer, + HAS_1_TEMPLATE_PARAMS(int, k), + AND_1_VALUE_PARAMS(vec)) { + *std::tr1::get<k>(args) = *vec; +} + +MATCHER_P(CheckMessageResultCode, result_code, "") { + return (*arg)[am::strings::msg_params][am::strings::result_code].asInt() == + result_code; +} + +namespace { +const uint32_t kConnectionKey = 1u; +const uint32_t kCorrelationId = 10u; +const int32_t kMenuId = 5; +} // namespace + +class DeleteFileRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + protected: + void SetUp() OVERRIDE { + message_ = CreateMessage(); + command_ = CreateCommand<DeleteFileRequest>(message_); + mock_app_ = CreateMockApp(); + } + DeleteFileRequestPtr command_; + MessageSharedPtr message_; + MockAppPtr mock_app_; +}; + +class DeleteFileResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> { +}; + +TEST_F(DeleteFileRequestTest, Run_InvalidApp_UNSUCCESS) { + MockAppPtr invalid_app; + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(app_mngr_, get_settings()).Times(0); + + command_->Run(); +} + +TEST_F(DeleteFileRequestTest, Run_HMILevelNone_UNSUCCESS) { + (*message_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(*mock_app_, hmi_level()) + .WillOnce(Return(am::mobile_api::HMILevel::HMI_NONE)); + + EXPECT_CALL(app_mngr_, get_settings()) + .WillOnce(ReturnRef(app_mngr_settings_)); + const uint32_t num = 0; + EXPECT_CALL(app_mngr_settings_, delete_file_in_none()) + .WillOnce(ReturnRef(num)); + EXPECT_CALL(*mock_app_, delete_file_in_none_count()).WillOnce(Return(1)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(CheckMessageResultCode(mobile_apis::Result::REJECTED), + am::commands::Command::CommandSource::SOURCE_SDL)); + + command_->Run(); +} + +TEST_F(DeleteFileRequestTest, Run_ValidFileName_SUCCESS) { + const std::string file_name = "test_file.txt"; + EXPECT_TRUE(file_system::CreateFile(file_name)); + (*message_)[am::strings::msg_params][am::strings::sync_file_name] = file_name; + (*message_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillRepeatedly(Return(mock_app_)); + EXPECT_CALL(*mock_app_, hmi_level()) + .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); + + EXPECT_CALL(app_mngr_, get_settings()) + .WillOnce(ReturnRef(app_mngr_settings_)); + const std::string kFullFilePath = file_system::CurrentWorkingDirectory(); + EXPECT_CALL(app_mngr_settings_, app_storage_folder()) + .WillOnce(ReturnRef(kFullFilePath)); + + am::AppFile file; + file.file_name = file_name; + file.file_type = mobile_apis::FileType::BINARY; + + EXPECT_CALL(*mock_app_, GetFile(_)).WillOnce(Return(&file)); + EXPECT_CALL(*mock_app_, DeleteFile(_)); + EXPECT_CALL(*mock_app_, increment_delete_file_in_none_count()); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(CheckMessageResultCode(mobile_apis::Result::SUCCESS), + am::commands::Command::CommandSource::SOURCE_SDL)); + + command_->Run(); +} + +TEST_F(DeleteFileRequestTest, Run_InvalidFile_UNSUCCESS) { + const std::string file_name = "test_file.txt"; + (*message_)[am::strings::msg_params][am::strings::sync_file_name] = file_name; + + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_)); + EXPECT_CALL(*mock_app_, hmi_level()) + .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); + + EXPECT_CALL(app_mngr_, get_settings()) + .WillOnce(ReturnRef(app_mngr_settings_)); + const std::string kFullFilePath = file_system::CurrentWorkingDirectory(); + EXPECT_CALL(app_mngr_settings_, app_storage_folder()) + .WillOnce(ReturnRef(kFullFilePath)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::REJECTED), + am::commands::Command::CommandSource::SOURCE_SDL)); + command_->Run(); +} + +TEST_F(DeleteFileResponseTest, Run_InvalidApp_UNSUCCESS) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::params][am::strings::connection_key] = kConnectionKey; + DeleteFileResponsePtr command = CreateCommand<DeleteFileResponse>(message); + MockAppPtr invalid_app; + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(invalid_app)); + + EXPECT_CALL( + mock_rpc_service_, + SendMessageToMobile(CheckMessageResultCode( + mobile_apis::Result::APPLICATION_NOT_REGISTERED), + false)); + + command->Run(); +} + +TEST_F(DeleteFileResponseTest, Run_ValidApp_SUCCESS) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*message)[am::strings::msg_params][am::strings::success] = true; + + DeleteFileResponsePtr command = CreateCommand<DeleteFileResponse>(message); + MockAppPtr app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); + const uint32_t kAvailableDiskSpace = 10u; + EXPECT_CALL(*app, GetAvailableDiskSpace()) + .WillOnce(Return(kAvailableDiskSpace)); + + EXPECT_CALL(mock_rpc_service_, + SendMessageToMobile( + CheckMessageResultCode(mobile_apis::Result::SUCCESS), _)); + + command->Run(); +} + +} // namespace delete_file +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc new file mode 100644 index 0000000000..b2daef9cd2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc @@ -0,0 +1,296 @@ +/* + * 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 <stdint.h> +#include <map> + +#include "mobile/delete_interaction_choice_set_request.h" +#include "mobile/delete_interaction_choice_set_response.h" + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application.h" +#include "application_manager/event_engine/event.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace delete_interaction_choice_set { + +using ::testing::_; +using ::testing::Return; +using ::testing::InSequence; + +namespace am = ::application_manager; + +using sdl_rpc_plugin::commands::DeleteInteractionChoiceSetRequest; +using sdl_rpc_plugin::commands::DeleteInteractionChoiceSetResponse; +using am::commands::MessageSharedPtr; +using am::event_engine::Event; + +typedef SharedPtr<DeleteInteractionChoiceSetRequest> + DeleteInteractionChoiceSetRequestPtr; +typedef SharedPtr<DeleteInteractionChoiceSetResponse> + DeleteInteractionChoiceSetResponsePtr; + +MATCHER_P(CheckMessageSuccess, success, "") { + return success == + (*arg)[am::strings::msg_params][am::strings::success].asBool(); +} + +namespace { +const uint32_t kConnectionKey = 2u; +const uint32_t kChoiceSetId = 11u; +const uint32_t kChoiceId = 110u; +const uint32_t kGrammarId = 101u; +} // namespace + +class DeleteInteractionChoiceSetRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + DeleteInteractionChoiceSetRequestTest() + : performinteraction_choice_set_lock_( + std::make_shared<sync_primitives::Lock>()) + , accessor_(choice_set_map_, performinteraction_choice_set_lock_) {} + + ~DeleteInteractionChoiceSetRequestTest() { + // Fix DataAccessor release and WinQt crash + Mock::VerifyAndClearExpectations(&app_mngr_); + } + + am::PerformChoiceSetMap choice_set_map_; + mutable std::shared_ptr<sync_primitives::Lock> + performinteraction_choice_set_lock_; + DataAccessor<am::PerformChoiceSetMap> accessor_; + + protected: + void SetUp() OVERRIDE { + message_ = CreateMessage(); + command_ = CreateCommand<DeleteInteractionChoiceSetRequest>(message_); + app_ = CreateMockApp(); + } + + DeleteInteractionChoiceSetRequestPtr command_; + MessageSharedPtr message_; + MockAppPtr app_; +}; + +class DeleteInteractionChoiceSetResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + protected: + void SetUp() OVERRIDE { + message_ = CreateMessage(); + command_ = CreateCommand<DeleteInteractionChoiceSetResponse>(message_); + app_ = CreateMockApp(); + } + DeleteInteractionChoiceSetResponsePtr command_; + MessageSharedPtr message_; + MockAppPtr app_; +}; + +TEST_F(DeleteInteractionChoiceSetRequestTest, Run_InvalidApp_UNSUCCESS) { + MockAppPtr invalid_app; + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(*app_, FindChoiceSet(_)).Times(0); + command_->Run(); +} + +TEST_F(DeleteInteractionChoiceSetRequestTest, Run_FindChoiceSetFail_UNSUCCESS) { + (*message_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] = + kChoiceSetId; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_)); + + smart_objects::SmartObject* choice_set_id = NULL; + EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId)) + .WillOnce(Return(choice_set_id)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)); + + command_->Run(); +} + +TEST_F(DeleteInteractionChoiceSetRequestTest, Run_ChoiceSetInUse_SUCCESS) { + (*message_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] = + kChoiceSetId; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_)); + + smart_objects::SmartObject* choice_set_id = + &((*message_)[am::strings::msg_params] + [am::strings::interaction_choice_set_id]); + + choice_set_map_[0].insert( + std::make_pair(kChoiceSetId, + &((*message_)[am::strings::msg_params] + [am::strings::interaction_choice_set_id]))); + + EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId)) + .WillOnce(Return(choice_set_id)); + EXPECT_CALL(*app_, is_perform_interaction_active()).WillOnce(Return(true)); + EXPECT_CALL(*app_, performinteraction_choice_set_map()) + .WillOnce(Return(accessor_)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)); + + command_->Run(); +} + +TEST_F(DeleteInteractionChoiceSetRequestTest, + Run_SendVrDeleteCommand_PerformInteractionFalse_UNSUCCESS) { + (*message_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] = + kChoiceSetId; + smart_objects::SmartObject* choice_set_id = + &((*message_)[am::strings::msg_params] + [am::strings::interaction_choice_set_id]); + smart_objects::SmartObject* invalid_choice_set_id = NULL; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillRepeatedly(Return(app_)); + + { + InSequence seq; + + EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId)) + .WillOnce(Return(choice_set_id)); + EXPECT_CALL(*app_, is_perform_interaction_active()).WillOnce(Return(false)); + EXPECT_CALL(*app_, performinteraction_choice_set_map()).Times(0); + + EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId)) + .WillOnce(Return(invalid_choice_set_id)); + + EXPECT_CALL(*app_, app_id()).WillOnce(Return(kConnectionKey)); + EXPECT_CALL(*app_, RemoveChoiceSet(kChoiceSetId)); + EXPECT_CALL(*app_, UpdateHash()); + } + + DeleteInteractionChoiceSetRequestPtr command = + CreateCommand<DeleteInteractionChoiceSetRequest>(message_); + + command->Init(); + command->Run(); +} + +TEST_F(DeleteInteractionChoiceSetRequestTest, Run_SendVrDeleteCommand_SUCCESS) { + (*message_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] = + kChoiceSetId; + (*message_)[am::strings::msg_params][am::strings::grammar_id] = kGrammarId; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::choice_id] = kChoiceId; + smart_objects::SmartObject* choice_set_id = + &((*message_)[am::strings::msg_params]); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillRepeatedly(Return(app_)); + + { + InSequence seq; + + EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId)) + .WillOnce(Return(choice_set_id)); + EXPECT_CALL(*app_, is_perform_interaction_active()).WillOnce(Return(false)); + EXPECT_CALL(*app_, performinteraction_choice_set_map()).Times(0); + + EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId)) + .WillOnce(Return(choice_set_id)); + + EXPECT_CALL(*app_, app_id()) + .WillOnce(Return(kConnectionKey)) + .WillOnce(Return(kConnectionKey)); + EXPECT_CALL(*app_, RemoveChoiceSet(kChoiceSetId)); + EXPECT_CALL(*app_, UpdateHash()); + } + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); + + DeleteInteractionChoiceSetRequestPtr command = + CreateCommand<DeleteInteractionChoiceSetRequest>(message_); + + command->Init(); + command->Run(); +} + +TEST_F(DeleteInteractionChoiceSetResponseTest, Run_SuccessFalse_UNSUCCESS) { + (*message_)[am::strings::msg_params][am::strings::success] = false; + + EXPECT_CALL(mock_rpc_service_, + SendMessageToMobile(CheckMessageSuccess(false), false)); + command_->Run(); +} + +TEST_F(DeleteInteractionChoiceSetResponseTest, Run_ValidResultCode_SUCCESS) { + (*message_)[am::strings::msg_params][am::strings::result_code] = + hmi_apis::Common_Result::SUCCESS; + + EXPECT_CALL(mock_rpc_service_, + SendMessageToMobile(CheckMessageSuccess(true), false)); + command_->Run(); +} + +TEST_F(DeleteInteractionChoiceSetResponseTest, + Run_InvalidResultCode_UNSUCCESS) { + (*message_)[am::strings::msg_params][am::strings::result_code] = + hmi_apis::Common_Result::INVALID_ENUM; + + EXPECT_CALL(mock_rpc_service_, + SendMessageToMobile(CheckMessageSuccess(false), false)); + command_->Run(); +} + +} // namespace delete_interaction_choice_set +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc new file mode 100644 index 0000000000..7a187c46d1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc @@ -0,0 +1,366 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "mobile/delete_sub_menu_request.h" +#include "mobile/delete_sub_menu_response.h" + +#include "gtest/gtest.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace delete_sub_menu_request { + +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::InSequence; +namespace am = ::application_manager; +using am::commands::MessageSharedPtr; +using am::event_engine::Event; +using am::MockHmiInterfaces; +using am::MockMessageHelper; + +using sdl_rpc_plugin::commands::DeleteSubMenuRequest; +using sdl_rpc_plugin::commands::DeleteSubMenuResponse; + +typedef SharedPtr<DeleteSubMenuRequest> DeleteSubMenuRequestPtr; +typedef SharedPtr<DeleteSubMenuResponse> DeleteSubMenuResponsePtr; + +MATCHER_P(CheckMessageResultCode, result_code, "") { + return (*arg)[am::strings::msg_params][am::strings::result_code].asInt() == + result_code; +} + +MATCHER_P(CheckMessageConnectionKey, connection_key, "") { + return (*arg)[am::strings::msg_params][am::strings::connection_key].asInt() == + connection_key; +} + +ACTION_P(DeleteCommand, commands_map) { + am::CommandsMap::iterator it = (*commands_map).begin(); + if ((*commands_map).end() != it) { + (*commands_map).erase(it); + } +} + +namespace { +const uint32_t kConnectionKey = 2u; +const uint32_t kCorrelationId = 10u; +const uint32_t kMenuId = 100u; +const uint32_t kGrammarId = 101u; +const int32_t kCmdId = 102; +} // namespace + +class DeleteSubMenuRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + DeleteSubMenuRequestTest() + : commands_lock_(std::make_shared<sync_primitives::Lock>()) + , accessor_(commands_map_, commands_lock_) + , message_(CreateMessage()) + , command_(CreateCommand<DeleteSubMenuRequest>(message_)) + , app_(CreateMockApp()) {} + + am::CommandsMap commands_map_; + mutable std::shared_ptr<sync_primitives::Lock> commands_lock_; + DataAccessor<am::CommandsMap> accessor_; + + MessageSharedPtr message_; + DeleteSubMenuRequestPtr command_; + MockAppPtr app_; +}; + +class DeleteSubMenuResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(DeleteSubMenuRequestTest, DISABLED_OnEvent_UI_UNSUPPORTED_RESOURCE) { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg)[am::strings::msg_params][am::strings::menu_id] = 10u; + + utils::SharedPtr<DeleteSubMenuRequest> command = + CreateCommand<DeleteSubMenuRequest>(msg); + + MockAppPtr mock_app = CreateMockApp(); + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app)); + ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey)); + EXPECT_CALL(*mock_app, RemoveSubMenu(_)); + + MessageSharedPtr ev_msg = CreateMessage(smart_objects::SmartType_Map); + (*ev_msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*ev_msg)[am::strings::msg_params][am::strings::info] = "info"; + + Event event(hmi_apis::FunctionID::UI_DeleteSubMenu); + event.set_smart_object(*ev_msg); + + MockHmiInterfaces hmi_interfaces; + ON_CALL(app_mngr_, hmi_interfaces()).WillByDefault(ReturnRef(hmi_interfaces)); + EXPECT_CALL(hmi_interfaces, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + am::CommandsMap commands_map; + smart_objects::SmartObject commands_msg(smart_objects::SmartType_Map); + commands_map.insert(std::pair<uint32_t, SmartObject*>(1u, &commands_msg)); + DataAccessor<am::CommandsMap> accessor( + commands_map, std::make_shared<sync_primitives::Lock>()); + EXPECT_CALL(*mock_app, commands_map()) + .WillOnce(Return(accessor)) + .WillOnce(Return(accessor)); + + MessageSharedPtr ui_command_result; + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true))); + + command->on_event(event); + + EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success] + .asBool(), + true); + EXPECT_EQ( + (*ui_command_result)[am::strings::msg_params][am::strings::result_code] + .asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + if ((*ui_command_result)[am::strings::msg_params].keyExists( + am::strings::info)) { + EXPECT_FALSE( + (*ui_command_result)[am::strings::msg_params][am::strings::info] + .asString() + .empty()); + } +} + +TEST_F(DeleteSubMenuRequestTest, Run_InvalidApp_UNSUCCESS) { + MockAppPtr invalid_app; + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(CheckMessageResultCode( + mobile_apis::Result::APPLICATION_NOT_REGISTERED), + am::commands::Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(*app_, FindSubMenu(_)).Times(0); + command_->Run(); +} + +TEST_F(DeleteSubMenuRequestTest, Run_FindSubMenuFalse_UNSUCCESS) { + (*message_)[am::strings::msg_params][am::strings::menu_id] = kMenuId; + (*message_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + smart_objects::SmartObject* invalid_sub_menu = NULL; + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_)); + EXPECT_CALL(*app_, FindSubMenu(kMenuId)).WillOnce(Return(invalid_sub_menu)); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + CheckMessageResultCode(mobile_apis::Result::INVALID_ID), + am::commands::Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(*app_, app_id()).Times(0); + command_->Run(); +} + +TEST_F(DeleteSubMenuRequestTest, Run_SendHMIRequest_SUCCESS) { + (*message_)[am::strings::msg_params][am::strings::menu_id] = kMenuId; + (*message_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + smart_objects::SmartObject* sub_menu = + &((*message_)[am::strings::msg_params][am::strings::menu_id]); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_)); + EXPECT_CALL(*app_, FindSubMenu(kMenuId)).WillOnce(Return(sub_menu)); + + EXPECT_CALL(*app_, app_id()).WillOnce(Return(kConnectionKey)); + EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillOnce(Return(kCorrelationId)); + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteSubMenu))) + .WillOnce(Return(true)); + command_->Run(); +} + +TEST_F(DeleteSubMenuRequestTest, OnEvent_UnknownEventId_UNSUCCESS) { + Event event(hmi_apis::FunctionID::INVALID_ENUM); + EXPECT_CALL(app_mngr_, application(_)).Times(0); + command_->on_event(event); +} + +TEST_F(DeleteSubMenuRequestTest, OnEvent_InvalidApp_UNSUCCESS) { + Event event(hmi_apis::FunctionID::UI_DeleteSubMenu); + (*message_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::SUCCESS; + event.set_smart_object(*message_); + MockAppPtr invalid_app; + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app)); + EXPECT_CALL(*app_, RemoveSubMenu(_)).Times(0); + command_->on_event(event); +} + +TEST_F(DeleteSubMenuRequestTest, OnEvent_DeleteSubmenu_SUCCESS) { + Event event(hmi_apis::FunctionID::UI_DeleteSubMenu); + (*message_)[am::strings::msg_params][am::strings::menu_id] = kMenuId; + (*message_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*message_)[am::strings::msg_params][am::strings::vr_commands] = + "vr_commands"; + (*message_)[am::strings::msg_params][am::strings::cmd_id] = kCmdId; + (*message_)[am::strings::msg_params][am::strings::menu_params] + [am::hmi_request::parent_id] = kMenuId; + const hmi_apis::Common_Result::eType result_code = + hmi_apis::Common_Result::SUCCESS; + (*message_)[am::strings::params][am::hmi_response::code] = result_code; + event.set_smart_object(*message_); + + commands_map_.insert( + std::make_pair(0, &((*message_)[am::strings::msg_params]))); + + EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_)); + + InSequence seq; + EXPECT_CALL(*app_, commands_map()).WillOnce(Return(accessor_)); + EXPECT_CALL(*app_, app_id()).WillOnce(Return(kConnectionKey)); + EXPECT_CALL(*app_, get_grammar_id()).WillOnce(Return(kGrammarId)); + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_DeleteCommand))) + .WillOnce(Return(true)); + + EXPECT_CALL(*app_, commands_map()).WillOnce(Return(accessor_)); + EXPECT_CALL(*app_, app_id()).WillOnce(Return(kConnectionKey)); + EXPECT_CALL(*app_, RemoveCommand(_)).WillOnce(DeleteCommand(&commands_map_)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteCommand))) + .WillOnce(Return(true)); + + EXPECT_CALL(*app_, RemoveSubMenu(_)); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), + am::commands::Command::SOURCE_SDL)); + EXPECT_CALL(*app_, UpdateHash()); + DeleteSubMenuRequestPtr command = + CreateCommand<DeleteSubMenuRequest>(message_); + + command->Init(); + command->on_event(event); +} + +TEST_F(DeleteSubMenuResponseTest, Run_SUCCESS) { + MessageSharedPtr message(CreateMessage()); + (*message)[am::strings::msg_params][am::strings::connection_key] = + kConnectionKey; + DeleteSubMenuResponsePtr command( + CreateCommand<DeleteSubMenuResponse>(message)); + + EXPECT_CALL( + mock_rpc_service_, + SendMessageToMobile(CheckMessageConnectionKey(kConnectionKey), _)); + command->Run(); +} + +TEST_F(DeleteSubMenuRequestTest, + DeleteSubmenu_CommandhaventVrCommadsAndMenuParams_DontSendHMIRequest) { + Event event(hmi_apis::FunctionID::UI_DeleteSubMenu); + (*message_)[am::strings::msg_params][am::strings::menu_id] = kMenuId; + (*message_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*message_)[am::strings::params][am::hmi_response::code] = + am::mobile_api::Result::SUCCESS; + event.set_smart_object(*message_); + + commands_map_.insert( + std::make_pair(0, &((*message_)[am::strings::msg_params]))); + + EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(*app_, commands_map()).Times(2).WillRepeatedly(Return(accessor_)); + EXPECT_CALL(*app_, RemoveCommand(_)).Times(0); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), + am::commands::Command::SOURCE_SDL)); + command_->on_event(event); +} + +TEST_F(DeleteSubMenuRequestTest, + DeleteSubmenu_NotAChildOfMenupartam_DontSendHMIRequest) { + Event event(hmi_apis::FunctionID::UI_DeleteSubMenu); + (*message_)[am::strings::msg_params][am::strings::menu_id] = kMenuId; + (*message_)[am::strings::msg_params][am::strings::menu_params] + [am::hmi_request::parent_id] = kMenuId + 1; + (*message_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*message_)[am::strings::params][am::hmi_response::code] = + am::mobile_api::Result::SUCCESS; + event.set_smart_object(*message_); + + commands_map_.insert( + std::make_pair(0, &((*message_)[am::strings::msg_params]))); + + EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(*app_, commands_map()).Times(2).WillRepeatedly(Return(accessor_)); + EXPECT_CALL(*app_, RemoveCommand(_)).Times(0); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), + am::commands::Command::SOURCE_SDL)); + command_->on_event(event); +} + +} // namespace delete_sub_menu_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dial_number_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dial_number_request_test.cc new file mode 100644 index 0000000000..bf689629b4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dial_number_request_test.cc @@ -0,0 +1,190 @@ +/* + * 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 <stdint.h> +#include <string> +#include <vector> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application.h" +#include "application_manager/event_engine/event.h" +#include "mobile/dial_number_request.h" +#include "interfaces/MOBILE_API.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace dial_number_request { + +using ::testing::_; +using ::testing::Return; +namespace am = ::application_manager; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::DialNumberRequest; +using am::event_engine::Event; +namespace mobile_result = mobile_apis::Result; + +typedef SharedPtr<DialNumberRequest> DialNumberRequestPtr; + +namespace { +const uint32_t kConnectionKey = 2u; +} // namespace + +class DialNumberRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(DialNumberRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { + DialNumberRequestPtr command(CreateCommand<DialNumberRequest>()); + + EXPECT_CALL(app_mngr_, application(_)) + .WillOnce(Return(ApplicationSharedPtr())); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _)); + + command->Run(); +} + +TEST_F(DialNumberRequestTest, Run_InvalidNumber_UNSUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[am::strings::msg_params][am::strings::number] = "\t\n"; + (*command_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + DialNumberRequestPtr command(CreateCommand<DialNumberRequest>(command_msg)); + + MockAppPtr app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _)); + + command->Run(); +} + +TEST_F(DialNumberRequestTest, Run_EmptyNumber_UNSUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[am::strings::msg_params][am::strings::number] = "NotANumber"; + (*command_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + DialNumberRequestPtr command(CreateCommand<DialNumberRequest>(command_msg)); + + MockAppPtr app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _)); + + command->Run(); +} + +TEST_F(DialNumberRequestTest, Run_SUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[am::strings::msg_params][am::strings::number] = "123"; + (*command_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + DialNumberRequestPtr command(CreateCommand<DialNumberRequest>(command_msg)); + + MockAppPtr app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::BasicCommunication_DialNumber))); + + command->Run(); +} + +TEST_F(DialNumberRequestTest, OnEvent_UnknownEvent_UNSUCCESS) { + // MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + // (*command_msg)[am::strings::params][am::strings::connection_key] = + // kConnectionKey; + + // DialNumberRequestPtr + // command(CreateCommand<DialNumberRequest>(command_msg)); + + // MockAppPtr app(CreateMockApp()); + // EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); + + // Event event(hmi_apis::FunctionID::INVALID_ENUM); + // EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + + // command->on_event(event); +} + +TEST_F(DialNumberRequestTest, OnEvent_SUCCESS) { + // MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map)); + // (*event_msg)[am::strings::params][am::hmi_response::code] = + // mobile_apis::Result::SUCCESS; + // (*event_msg)[am::strings::params][am::strings::info] = "test_info"; + + // Event event(hmi_apis::FunctionID::BasicCommunication_DialNumber); + // event.set_smart_object(*event_msg); + + // MockAppPtr app(CreateMockApp()); + // EXPECT_CALL(app_mngr_, application(kConnectionKey)) + // .WillRepeatedly(Return(app)); + // ON_CALL(app_mngr_, + // GetRPCService()).WillByDefault(ReturnRef(mock_rpc_service_)); + // EXPECT_CALL( + // mock_rpc_service_, + // ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), + // _)); + + // MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + // (*command_msg)[am::strings::params][am::strings::connection_key] = + // kConnectionKey; + + // DialNumberRequestPtr + // command(CreateCommand<DialNumberRequest>(command_msg)); + // command->on_event(event); +} + +} // namespace dial_number_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc new file mode 100644 index 0000000000..a8afe4007f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc @@ -0,0 +1,315 @@ +/* + * 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 "application_manager/commands/command_request_test.h" + +#include <stdint.h> +#include <string> +#include <vector> +#include "gtest/gtest.h" + +#include "mobile/add_command_request.h" +#include "mobile/add_command_response.h" +#include "mobile/add_sub_menu_request.h" +#include "mobile/add_sub_menu_response.h" +#include "mobile/alert_maneuver_request.h" +#include "mobile/alert_maneuver_response.h" +#include "mobile/alert_request.h" +#include "mobile/alert_response.h" +#include "mobile/change_registration_request.h" +#include "mobile/change_registration_response.h" +#include "mobile/create_interaction_choice_set_request.h" +#include "mobile/create_interaction_choice_set_response.h" +#include "mobile/delete_command_request.h" +#include "mobile/delete_command_response.h" +#include "mobile/delete_file_request.h" +#include "mobile/delete_file_response.h" +#include "mobile/delete_interaction_choice_set_request.h" +#include "mobile/delete_interaction_choice_set_response.h" +#include "mobile/delete_sub_menu_request.h" +#include "mobile/delete_sub_menu_response.h" +#include "mobile/dial_number_request.h" +#include "mobile/dial_number_response.h" +#include "mobile/end_audio_pass_thru_request.h" +#include "mobile/end_audio_pass_thru_response.h" +#include "mobile/generic_response.h" +#include "mobile/get_way_points_request.h" +#include "mobile/get_way_points_response.h" +#include "mobile/list_files_request.h" +#include "mobile/list_files_response.h" +#include "mobile/on_app_interface_unregistered_notification.h" +#include "mobile/on_audio_pass_thru_notification.h" +#include "mobile/on_button_event_notification.h" +#include "mobile/on_button_press_notification.h" +#include "mobile/on_command_notification.h" +#include "mobile/on_driver_distraction_notification.h" +#include "mobile/on_hash_change_notification.h" +#include "mobile/on_hmi_status_notification.h" +#include "mobile/on_hmi_status_notification_from_mobile.h" +#include "mobile/on_keyboard_input_notification.h" +#include "mobile/on_language_change_notification.h" +#include "mobile/on_permissions_change_notification.h" +#include "mobile/on_system_request_notification.h" +#include "mobile/on_tbt_client_state_notification.h" +#include "mobile/on_touch_event_notification.h" +#include "mobile/on_way_point_change_notification.h" +#include "mobile/perform_audio_pass_thru_request.h" +#include "mobile/perform_audio_pass_thru_response.h" +#include "mobile/perform_interaction_request.h" +#include "mobile/perform_interaction_response.h" +#include "mobile/put_file_request.h" +#include "mobile/put_file_response.h" +#include "mobile/register_app_interface_request.h" +#include "mobile/register_app_interface_response.h" +#include "mobile/reset_global_properties_request.h" +#include "mobile/reset_global_properties_response.h" +#include "mobile/scrollable_message_request.h" +#include "mobile/scrollable_message_response.h" +#include "mobile/send_location_request.h" +#include "mobile/send_location_response.h" +#include "mobile/set_app_icon_request.h" +#include "mobile/set_app_icon_response.h" +#include "mobile/set_display_layout_request.h" +#include "mobile/set_display_layout_response.h" +#include "mobile/set_global_properties_request.h" +#include "mobile/set_global_properties_response.h" +#include "mobile/set_media_clock_timer_request.h" +#include "mobile/set_media_clock_timer_response.h" +#include "mobile/show_constant_tbt_request.h" +#include "mobile/show_constant_tbt_response.h" +#include "mobile/show_request.h" +#include "mobile/show_response.h" +#include "mobile/slider_request.h" +#include "mobile/slider_response.h" +#include "mobile/speak_request.h" +#include "mobile/speak_response.h" +#include "mobile/subscribe_button_request.h" +#include "mobile/subscribe_button_response.h" +#include "mobile/subscribe_way_points_request.h" +#include "mobile/subscribe_way_points_response.h" +#include "mobile/system_response.h" +#include "mobile/unregister_app_interface_request.h" +#include "mobile/unregister_app_interface_response.h" +#include "mobile/unsubscribe_button_request.h" +#include "mobile/unsubscribe_button_response.h" +#include "mobile/unsubscribe_way_points_request.h" +#include "mobile/unsubscribe_way_points_response.h" +#include "mobile/update_turn_list_request.h" +#include "mobile/update_turn_list_response.h" + +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "test/application_manager/mock_application_manager_settings.h" +#include "application_manager/mock_event_dispatcher.h" + +namespace am = application_manager; + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace dummy_mobile_commands_test { + +namespace commands = sdl_rpc_plugin::commands; +using ::testing::_; +using ::testing::NotNull; +using ::testing::Types; +using am::commands::MessageSharedPtr; +using ::test::components::event_engine_test::MockEventDispatcher; +using ::test::components::application_manager_test::MockApplicationManager; +using ::test::components::application_manager_test:: + MockApplicationManagerSettings; +using ::application_manager::ApplicationSharedPtr; +using ::test::components::application_manager_test::MockApplication; + +namespace { +const std::string kEmptyString_ = ""; +} // namespace + +template <class Command> +class MobileCommandsTest : public components::commands_test::CommandRequestTest< + CommandsTestMocks::kIsNice> { + public: + typedef Command CommandType; + + void InitCommand(const uint32_t& timeout) OVERRIDE { + EXPECT_CALL(app_mngr_settings_, default_timeout()) + .WillOnce(ReturnRef(timeout)); + ON_CALL(app_mngr_, event_dispatcher()) + .WillByDefault(ReturnRef(event_dispatcher_)); + ON_CALL(app_mngr_, get_settings()) + .WillByDefault(ReturnRef(app_mngr_settings_)); + ON_CALL(app_mngr_settings_, app_icons_folder()) + .WillByDefault(ReturnRef(kEmptyString_)); + } +}; + +template <class Command> +class MobileCommandsTestFirst : public MobileCommandsTest<Command> { + public: + using typename MobileCommandsTest<Command>::CommandType; +}; + +template <class Command> +class MobileCommandsTestSecond : public MobileCommandsTest<Command> { + public: + using typename MobileCommandsTest<Command>::CommandType; +}; + +template <class Command> +class MobileCommandsTestThird : public MobileCommandsTest<Command> { + public: + using typename MobileCommandsTest<Command>::CommandType; +}; + +/* macro TYPED_TEST_CASE takes max 50 args. That is why there are few + * TYPED_TEST_CASE for HMI and mobile commands + */ + +typedef Types<commands::AddCommandRequest, + commands::AddCommandResponse, + commands::AddSubMenuRequest, + commands::AddSubMenuResponse, + commands::AlertManeuverRequest, + commands::AlertManeuverResponse, + commands::AlertRequest, + commands::AlertResponse, + commands::ChangeRegistrationRequest, + commands::ChangeRegistrationResponse, + commands::CreateInteractionChoiceSetRequest, + commands::CreateInteractionChoiceSetResponse, + commands::DeleteCommandRequest, + commands::DeleteCommandResponse, + commands::DeleteFileRequest, + commands::DeleteFileResponse, + commands::DeleteInteractionChoiceSetRequest, + commands::DeleteInteractionChoiceSetResponse, + commands::DeleteSubMenuRequest, + commands::DeleteSubMenuResponse, + commands::DialNumberRequest, + commands::DialNumberResponse, + commands::EndAudioPassThruRequest, + commands::EndAudioPassThruResponse, + commands::GenericResponse, + commands::GetWayPointsRequest, + commands::GetWayPointsResponse, + commands::ListFilesRequest, + commands::ListFilesResponse, + commands::OnAppInterfaceUnregisteredNotification, + commands::OnAudioPassThruNotification, + commands::mobile::OnButtonEventNotification, + commands::mobile::OnButtonPressNotification, + commands::OnCommandNotification, + commands::mobile::OnDriverDistractionNotification, + commands::mobile::OnHashChangeNotification, + commands::OnHMIStatusNotification, + commands::OnHMIStatusNotificationFromMobile, + commands::mobile::OnKeyBoardInputNotification, + commands::OnLanguageChangeNotification, + commands::OnPermissionsChangeNotification, + commands::mobile::OnSystemRequestNotification, + commands::OnTBTClientStateNotification, + commands::mobile::OnTouchEventNotification> + MobileCommandsListFirst; + +typedef Types<commands::OnWayPointChangeNotification, + commands::PerformAudioPassThruRequest, + commands::PerformAudioPassThruResponse, + commands::PerformInteractionRequest, + commands::PerformInteractionResponse, + commands::PutFileRequest, + commands::PutFileResponse, + commands::RegisterAppInterfaceRequest, + commands::RegisterAppInterfaceResponse, + commands::ResetGlobalPropertiesRequest, + commands::ResetGlobalPropertiesResponse, + commands::ScrollableMessageRequest, + commands::ScrollableMessageResponse, + commands::SendLocationRequest, + commands::SendLocationResponse, + commands::SetAppIconRequest, + commands::SetAppIconResponse, + commands::SetDisplayLayoutRequest, + commands::SetDisplayLayoutResponse, + commands::SetGlobalPropertiesRequest, + commands::SetGlobalPropertiesResponse, + commands::SetMediaClockRequest, + commands::SetMediaClockTimerResponse, + commands::ShowConstantTBTRequest, + commands::ShowConstantTBTResponse, + commands::ShowRequest, + commands::ShowResponse, + commands::SliderRequest, + commands::SliderResponse, + commands::SpeakRequest, + commands::SpeakResponse, + commands::SubscribeButtonRequest, + commands::SubscribeButtonResponse, + commands::SubscribeWayPointsRequest, + commands::SubscribeWayPointsResponse, + commands::SystemResponse, + commands::UnregisterAppInterfaceRequest, + commands::UnregisterAppInterfaceResponse, + commands::UnsubscribeButtonRequest, + commands::UnsubscribeButtonResponse> MobileCommandsListSecond; + +typedef Types<commands::UnSubscribeWayPointsRequest, + commands::UnsubscribeWayPointsResponse, + commands::UpdateTurnListRequest, + commands::UpdateTurnListResponse> MobileCommandsListThird; + +TYPED_TEST_CASE(MobileCommandsTestFirst, MobileCommandsListFirst); +TYPED_TEST_CASE(MobileCommandsTestSecond, MobileCommandsListSecond); +TYPED_TEST_CASE(MobileCommandsTestThird, MobileCommandsListThird); + +TYPED_TEST(MobileCommandsTestFirst, CtorAndDtorCall) { + utils::SharedPtr<typename TestFixture::CommandType> command = + this->template CreateCommand<typename TestFixture::CommandType>(); + UNUSED(command); +} + +TYPED_TEST(MobileCommandsTestSecond, CtorAndDtorCall) { + utils::SharedPtr<typename TestFixture::CommandType> command = + this->template CreateCommand<typename TestFixture::CommandType>(); + UNUSED(command); +} +TYPED_TEST(MobileCommandsTestThird, CtorAndDtorCall) { + utils::SharedPtr<typename TestFixture::CommandType> command = + this->template CreateCommand<typename TestFixture::CommandType>(); + UNUSED(command); +} + +} // namespace dummy_mobile_commands_test +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/end_audio_pass_thru_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/end_audio_pass_thru_request_test.cc new file mode 100644 index 0000000000..567f46e4ea --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/end_audio_pass_thru_request_test.cc @@ -0,0 +1,120 @@ +/* + * 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 <stdint.h> +#include <string> +#include <vector> + +#include "mobile/end_audio_pass_thru_request.h" + +#include "gtest/gtest.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_hmi_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace end_audio_pass_thru_request { + +namespace am = ::application_manager; +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::EndAudioPassThruRequest; +using am::event_engine::Event; +using am::MockMessageHelper; + +typedef SharedPtr<EndAudioPassThruRequest> EndAudioPassThruRequestPtr; + +class EndAudioPassThruRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(EndAudioPassThruRequestTest, OnEvent_UI_UNSUPPORTED_RESOUCRE) { + const uint32_t kConnectionKey = 2u; + const uint32_t app_id = kConnectionKey; + + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + EndAudioPassThruRequestPtr command( + CreateCommand<EndAudioPassThruRequest>(command_msg)); + + MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map)); + (*event_msg)[am::strings::msg_params] = 0; + (*event_msg)[am::strings::params][am::hmi_response::code] = + mobile_apis::Result::UNSUPPORTED_RESOURCE; + + Event event(hmi_apis::FunctionID::UI_EndAudioPassThru); + event.set_smart_object(*event_msg); + + EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false)); + + MessageSharedPtr ui_command_result; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true))); + + MockAppPtr app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app)); + + command->on_event(event); + + EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success] + .asBool(), + true); + EXPECT_EQ( + (*ui_command_result)[am::strings::msg_params][am::strings::result_code] + .asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + if ((*ui_command_result)[am::strings::msg_params].keyExists( + am::strings::info)) { + EXPECT_FALSE( + (*ui_command_result)[am::strings::msg_params][am::strings::info] + .asString() + .empty()); + } +} + +} // namespace end_audio_pass_thru_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc new file mode 100644 index 0000000000..0239f3c7d7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc @@ -0,0 +1,282 @@ +/* + * 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 "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application.h" +#include "mobile/get_way_points_request.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/mock_message_helper.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace get_way_points_request { + +using namespace mobile_apis::Result; +using ::testing::Return; +using ::testing::_; +using sdl_rpc_plugin::commands::GetWayPointsRequest; +using application_manager::MockMessageHelper; +using application_manager::MockHmiInterfaces; + +typedef SharedPtr<GetWayPointsRequest> CommandPtr; +typedef mobile_apis::Result::eType MobileResult; +typedef hmi_apis::Common_Result::eType HmiResult; + +namespace { +const uint32_t kCorrelationId = 2u; +const uint32_t kAppId = 3u; +const uint32_t kConnectionKey = kAppId; +const std::string kMethodName = "Navigation.GetWayPoints"; +} + +class GetWayPointsRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + GetWayPointsRequestTest() : mock_app_(CreateMockApp()) {} + + void SetUp() OVERRIDE { + message_ = utils::MakeShared<SmartObject>(::smart_objects::SmartType_Map); + (*message_)[am::strings::msg_params] = + ::smart_objects::SmartObject(::smart_objects::SmartType_Map); + + command_sptr_ = CreateCommand<GetWayPointsRequest>(message_); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); + } + + MockAppPtr mock_app_; + MessageSharedPtr message_; + utils::SharedPtr<GetWayPointsRequest> command_sptr_; +}; + +class GetWayPointsRequestOnEventTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + GetWayPointsRequestOnEventTest() : app_(CreateMockApp()) {} + + void CheckOnEventResponse(const std::string& wayPointsParam, + const HmiResult ResultCode, + const bool success) { + Event event(Event::EventID::Navigation_GetWayPoints); + CommandPtr command(CreateCommand<GetWayPointsRequest>()); + MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map)); + (*event_msg)[am::strings::params][am::hmi_response::code] = ResultCode; + if ("0" == wayPointsParam) { + (*event_msg)[am::strings::msg_params] = 0; + } else { + (*event_msg)[am::strings::msg_params][am::strings::way_points][0]["123"] = + wayPointsParam; + } + + event.set_smart_object(*event_msg); + + const MobileResult mobile_result = static_cast<MobileResult>(ResultCode); + + MessageSharedPtr result_msg( + CatchMobileCommandResult(CallOnEvent(*command, event))); + EXPECT_EQ( + mobile_result, + static_cast<MobileResult>( + (*result_msg)[am::strings::msg_params][am::strings::result_code] + .asInt())); + EXPECT_EQ( + success, + (*result_msg)[am::strings::msg_params][am::strings::success].asBool()); + } + + protected: + MockAppPtr app_; + MockHmiInterfaces hmi_interfaces_; +}; + +TEST_F(GetWayPointsRequestTest, + Run_InvalidApp_ApplicationNotRegisteredResponce) { + (*message_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + utils::SharedPtr<am::Application> null_application_sptr; + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(null_application_sptr)); + + CallRun caller(*command_sptr_); + + MessageSharedPtr result_message = CatchMobileCommandResult(caller); + + const mobile_apis::Result::eType result = + static_cast<mobile_apis::Result::eType>( + (*result_message)[am::strings::msg_params][am::strings::result_code] + .asInt()); + + EXPECT_EQ(mobile_apis::Result::APPLICATION_NOT_REGISTERED, result); +} + +TEST_F(GetWayPointsRequestTest, Run_ApplicationRegistered_Success) { + (*message_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + MockAppPtr application_sptr = CreateMockApp(); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(application_sptr)); + EXPECT_CALL(*application_sptr, app_id()).WillOnce(Return(1)); + + EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillOnce(Return(kCorrelationId)); + + CallRun caller(*command_sptr_); + + MessageSharedPtr result_message = CatchHMICommandResult(caller); + + const hmi_apis::FunctionID::eType result_function_id = + static_cast<hmi_apis::FunctionID::eType>( + (*result_message)[am::strings::params][am::strings::function_id] + .asInt()); + + EXPECT_EQ(hmi_apis::FunctionID::Navigation_GetWayPoints, result_function_id); + EXPECT_EQ(kCorrelationId, + (*result_message)[am::strings::params][am::strings::correlation_id] + .asUInt()); +} + +TEST_F(GetWayPointsRequestTest, + OnEvent_NavigationGetWayPointsEvent_SendResponse) { + am::event_engine::Event event(hmi_apis::FunctionID::Navigation_GetWayPoints); + + (*message_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + + event.set_smart_object(*message_); + + CallOnEvent caller(*command_sptr_, event); + + MessageSharedPtr result_message = CatchMobileCommandResult(caller); + + const mobile_apis::Result::eType result = + static_cast<mobile_apis::Result::eType>( + (*result_message)[am::strings::msg_params][am::strings::result_code] + .asInt()); + + EXPECT_EQ(mobile_apis::Result::SUCCESS, result); +} + +TEST_F(GetWayPointsRequestTest, OnEvent_DefaultCase) { + am::event_engine::Event event(hmi_apis::FunctionID::INVALID_ENUM); + + event.set_smart_object(*message_); + + EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + + CallOnEvent caller(*command_sptr_, event); + caller(); +} + +TEST_F(GetWayPointsRequestOnEventTest, OnEvent_WrongEventId_UNSUCCESS) { + Event event(Event::EventID::INVALID_ENUM); + CommandPtr command(CreateCommand<GetWayPointsRequest>()); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + command->on_event(event); +} + +TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_SUCCESS_Case1) { + CheckOnEventResponse("0", HmiResult::SUCCESS, true); +} + +TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_SUCCESS_Case2) { + CheckOnEventResponse("", HmiResult::SUCCESS, true); +} + +TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_SUCCESS_Case3) { + CheckOnEventResponse("test", HmiResult::SUCCESS, true); +} + +TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case1) { + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + CheckOnEventResponse(" ", HmiResult::GENERIC_ERROR, false); +} + +TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case2) { + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + CheckOnEventResponse("test\t", HmiResult::GENERIC_ERROR, false); +} + +TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case3) { + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + CheckOnEventResponse("test\n", HmiResult::GENERIC_ERROR, false); +} + +TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case4) { + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + CheckOnEventResponse("test\t\n", HmiResult::GENERIC_ERROR, false); +} + +} // namespace get_way_points_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/list_files_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/list_files_request_test.cc new file mode 100644 index 0000000000..f9fd31f99a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/list_files_request_test.cc @@ -0,0 +1,145 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application.h" +#include "mobile/list_files_request.h" +#include "interfaces/MOBILE_API.h" +#include "application_manager/smart_object_keys.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace list_files_request { + +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::DoAll; +using ::testing::SaveArg; +namespace am = ::application_manager; +using sdl_rpc_plugin::commands::ListFilesRequest; +using am::commands::MessageSharedPtr; + +class ListFilesRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + ListFilesRequestTest() : kStoragePath_("storage"), kResponseSize_(1) {} + const std::string kStoragePath_; + const uint32_t kResponseSize_; +}; + +TEST_F(ListFilesRequestTest, Run_AppNotRegistered_UNSUCCESS) { + SharedPtr<ListFilesRequest> command(CreateCommand<ListFilesRequest>()); + + ON_CALL(app_mngr_, application(_)) + .WillByDefault(Return(SharedPtr<am::Application>())); + + MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command))); + EXPECT_EQ(mobile_apis::Result::APPLICATION_NOT_REGISTERED, + static_cast<mobile_apis::Result::eType>( + (*result_msg)[am::strings::msg_params][am::strings::result_code] + .asInt())); +} + +TEST_F(ListFilesRequestTest, Run_TooManyHmiNone_UNSUCCESS) { + MockAppPtr app(CreateMockApp()); + SharedPtr<ListFilesRequest> command(CreateCommand<ListFilesRequest>()); + + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, hmi_level()) + .WillByDefault(Return(mobile_apis::HMILevel::HMI_NONE)); + + const uint32_t kListFilesInNoneAllowed = 1u; + const uint32_t kListFilesInNoneCount = 2u; + + EXPECT_CALL(app_mngr_, get_settings()) + .WillOnce(ReturnRef(app_mngr_settings_)); + ON_CALL(app_mngr_settings_, list_files_in_none()) + .WillByDefault(ReturnRef(kListFilesInNoneAllowed)); + ON_CALL(*app, list_files_in_none_count()) + .WillByDefault(Return(kListFilesInNoneCount)); + + MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command))); + EXPECT_EQ(mobile_apis::Result::REJECTED, + static_cast<mobile_apis::Result::eType>( + (*result_msg)[am::strings::msg_params][am::strings::result_code] + .asInt())); +} + +TEST_F(ListFilesRequestTest, Run_SUCCESS) { + MockAppPtr app(CreateMockApp()); + SharedPtr<ListFilesRequest> command(CreateCommand<ListFilesRequest>()); + + EXPECT_CALL(app_mngr_, get_settings()) + .WillRepeatedly(ReturnRef(app_mngr_settings_)); + + ON_CALL(app_mngr_settings_, app_storage_folder()) + .WillByDefault(ReturnRef(kStoragePath_)); + + ON_CALL(app_mngr_settings_, list_files_response_size()) + .WillByDefault(ReturnRef(kResponseSize_)); + + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + + ON_CALL(*app, hmi_level()) + .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); + + ON_CALL(*app, increment_list_files_in_none_count()).WillByDefault(Return()); + + ON_CALL(*app, GetAvailableDiskSpace()).WillByDefault(Return(0)); + + am::AppFilesMap files_map; + ON_CALL(*app, getAppFiles()).WillByDefault(ReturnRef(files_map)); + + MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command))); + EXPECT_EQ(mobile_apis::Result::SUCCESS, + static_cast<mobile_apis::Result::eType>( + (*result_msg)[am::strings::msg_params][am::strings::result_code] + .asInt())); +} + +} // namespace list_files_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc new file mode 100644 index 0000000000..d2e86f0103 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc @@ -0,0 +1,340 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" + +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application.h" + +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "mobile/on_button_event_notification.h" +#include "mobile/on_button_press_notification.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace on_button_notification { + +namespace am = ::application_manager; +namespace commands = am::commands; +using sdl_rpc_plugin::commands::mobile::OnButtonEventNotification; +using sdl_rpc_plugin::commands::mobile::OnButtonPressNotification; +using ::testing::_; +using ::testing::Types; +using ::testing::Return; + +using ::utils::SharedPtr; +using am::commands::MessageSharedPtr; + +namespace { +const uint32_t kAppId = 5u; +const uint32_t kCustomButtonId = 3u; +const mobile_apis::ButtonName::eType kButtonName = mobile_apis::ButtonName::OK; +} // namespace + +template <class NotificationT, + mobile_apis::FunctionID::eType kExpectedFunctionId> +struct NotificationData { + typedef NotificationT Notification; + enum { kFunctionId = kExpectedFunctionId }; +}; + +template <class NotificationDataT> +class OnButtonNotificationCommandsTest + : public CommandsTest<CommandsTestMocks::kNotNice>, + public NotificationDataT {}; + +typedef Types<NotificationData<OnButtonEventNotification, + mobile_apis::FunctionID::OnButtonEventID>, + NotificationData<OnButtonPressNotification, + mobile_apis::FunctionID::OnButtonPressID> > + OnButtonNotificationCommandsList; + +MATCHER_P(CheckNotificationMessage, function_id, "") { + const bool kIsMobileProtocolTypeCorrect = + (*arg)[am::strings::params][am::strings::protocol_type].asInt() == + commands::CommandImpl::mobile_protocol_type_; + + const bool kIsProtocolVersionCorrect = + (*arg)[am::strings::params][am::strings::protocol_version].asInt() == + commands::CommandImpl::protocol_version_; + + const bool kIsNotificationCorrect = + (*arg)[am::strings::params][am::strings::message_type].asInt() == + am::MessageType::kNotification; + + const bool kIsFunctionIdCorrect = + (*arg)[am::strings::params][am::strings::function_id].asInt() == + function_id; + + bool is_custom_button_id_correct = true; + if ((*arg)[am::strings::msg_params].keyExists( + am::hmi_response::custom_button_id)) { + is_custom_button_id_correct = + (*arg)[am::strings::msg_params][am::strings::custom_button_id] == + kCustomButtonId; + } + + return kIsMobileProtocolTypeCorrect && kIsProtocolVersionCorrect && + kIsNotificationCorrect && kIsFunctionIdCorrect && + is_custom_button_id_correct; +} + +TYPED_TEST_CASE(OnButtonNotificationCommandsTest, + OnButtonNotificationCommandsList); + +TYPED_TEST(OnButtonNotificationCommandsTest, + Run_CustomButton_NoAppId_UNSUCCESS) { + typedef typename TestFixture::Notification Notification; + + MessageSharedPtr notification_msg( + this->CreateMessage(smart_objects::SmartType_Map)); + + (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] = + mobile_apis::ButtonName::CUSTOM_BUTTON; + + SharedPtr<Notification> command( + this->template CreateCommand<Notification>(notification_msg)); + + command->Run(); +} + +TYPED_TEST(OnButtonNotificationCommandsTest, + Run_CustomButton_NoCustomButtonId_UNSUCCESS) { + typedef typename TestFixture::Notification Notification; + + MessageSharedPtr notification_msg( + this->CreateMessage(smart_objects::SmartType_Map)); + + (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] = + mobile_apis::ButtonName::CUSTOM_BUTTON; + (*notification_msg)[am::strings::msg_params][am::strings::app_id] = kAppId; + + SharedPtr<Notification> command( + this->template CreateCommand<Notification>(notification_msg)); + + typename TestFixture::MockAppPtr mock_app = this->CreateMockApp(); + EXPECT_CALL(this->app_mngr_, application(kAppId)).WillOnce(Return(mock_app)); + + command->Run(); +} + +TYPED_TEST(OnButtonNotificationCommandsTest, + Run_CustomButton_AppNotRegistered_UNSUCCESS) { + typedef typename TestFixture::Notification Notification; + + MessageSharedPtr notification_msg( + this->CreateMessage(smart_objects::SmartType_Map)); + + (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] = + mobile_apis::ButtonName::CUSTOM_BUTTON; + (*notification_msg)[am::strings::msg_params][am::strings::app_id] = kAppId; + (*notification_msg)[am::strings::msg_params] + [am::hmi_response::custom_button_id] = kCustomButtonId; + + SharedPtr<Notification> command( + this->template CreateCommand<Notification>(notification_msg)); + + EXPECT_CALL(this->app_mngr_, application(kAppId)) + .WillOnce(Return(ApplicationSharedPtr())); + + command->Run(); +} + +TYPED_TEST(OnButtonNotificationCommandsTest, + Run_CustomButton_AppNotSubscribedToCustomButtonId_UNSUCCESS) { + typedef typename TestFixture::Notification Notification; + + MessageSharedPtr notification_msg( + this->CreateMessage(smart_objects::SmartType_Map)); + + (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] = + mobile_apis::ButtonName::CUSTOM_BUTTON; + (*notification_msg)[am::strings::msg_params][am::strings::app_id] = kAppId; + (*notification_msg)[am::strings::msg_params] + [am::hmi_response::custom_button_id] = kCustomButtonId; + + SharedPtr<Notification> command( + this->template CreateCommand<Notification>(notification_msg)); + + typename TestFixture::MockAppPtr mock_app = this->CreateMockApp(); + EXPECT_CALL(this->app_mngr_, application(kAppId)).WillOnce(Return(mock_app)); + + EXPECT_CALL(*mock_app, IsSubscribedToSoftButton(kCustomButtonId)) + .WillOnce(Return(false)); + + command->Run(); +} + +TYPED_TEST(OnButtonNotificationCommandsTest, Run_CustomButton_SUCCESS) { + typedef typename TestFixture::Notification Notification; + + MessageSharedPtr notification_msg( + this->CreateMessage(smart_objects::SmartType_Map)); + + (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] = + mobile_apis::ButtonName::CUSTOM_BUTTON; + (*notification_msg)[am::strings::msg_params][am::strings::app_id] = kAppId; + (*notification_msg)[am::strings::msg_params] + [am::hmi_response::custom_button_id] = kCustomButtonId; + + SharedPtr<Notification> command( + this->template CreateCommand<Notification>(notification_msg)); + + typename TestFixture::MockAppPtr mock_app = this->CreateMockApp(); + ON_CALL(*mock_app, hmi_level()) + .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); + EXPECT_CALL(this->app_mngr_, application(kAppId)).WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, IsSubscribedToSoftButton(kCustomButtonId)) + .WillOnce(Return(true)); + EXPECT_CALL(this->mock_rpc_service_, + SendMessageToMobile( + CheckNotificationMessage(TestFixture::kFunctionId), _)); + + command->Run(); +} + +TYPED_TEST(OnButtonNotificationCommandsTest, Run_NoSubscribedApps_UNSUCCESS) { + typedef typename TestFixture::Notification Notification; + + MessageSharedPtr notification_msg( + this->CreateMessage(smart_objects::SmartType_Map)); + + (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] = + kButtonName; + + SharedPtr<Notification> command( + this->template CreateCommand<Notification>(notification_msg)); + + const std::vector<ApplicationSharedPtr> empty_subscribed_apps_list; + EXPECT_CALL(this->app_mngr_, applications_by_button(kButtonName)) + .WillOnce(Return(empty_subscribed_apps_list)); + + command->Run(); +} + +TYPED_TEST(OnButtonNotificationCommandsTest, Run_InvalidHmiLevel_UNSUCCESS) { + typedef typename TestFixture::Notification Notification; + + MessageSharedPtr notification_msg( + this->CreateMessage(smart_objects::SmartType_Map)); + + (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] = + kButtonName; + + SharedPtr<Notification> command( + this->template CreateCommand<Notification>(notification_msg)); + + typename TestFixture::MockAppPtr mock_app = this->CreateMockApp(); + std::vector<ApplicationSharedPtr> subscribed_apps_list; + subscribed_apps_list.push_back(mock_app); + + EXPECT_CALL(*mock_app, hmi_level()) + .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_NONE)); + + EXPECT_CALL(this->app_mngr_, applications_by_button(kButtonName)) + .WillOnce(Return(subscribed_apps_list)); + + command->Run(); +} + +TYPED_TEST(OnButtonNotificationCommandsTest, + Run_ButtonOkOnlyForHmiLevelFull_UNSUCCESS) { + typedef typename TestFixture::Notification Notification; + + MessageSharedPtr notification_msg( + this->CreateMessage(smart_objects::SmartType_Map)); + + (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] = + kButtonName; + + SharedPtr<Notification> command( + this->template CreateCommand<Notification>(notification_msg)); + + typename TestFixture::MockAppPtr mock_app = this->CreateMockApp(); + std::vector<ApplicationSharedPtr> subscribed_apps_list; + subscribed_apps_list.push_back(mock_app); + + EXPECT_CALL(*mock_app, hmi_level()) + .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_LIMITED)); + + EXPECT_CALL(this->app_mngr_, applications_by_button(kButtonName)) + .WillOnce(Return(subscribed_apps_list)); + + command->Run(); +} + +TYPED_TEST(OnButtonNotificationCommandsTest, Run_SUCCESS) { + typedef typename TestFixture::Notification Notification; + + MessageSharedPtr notification_msg( + this->CreateMessage(smart_objects::SmartType_Map)); + + (*notification_msg)[am::strings::msg_params][am::strings::app_id] = kAppId; + (*notification_msg)[am::strings::msg_params][am::hmi_response::button_name] = + kButtonName; + + SharedPtr<Notification> command( + this->template CreateCommand<Notification>(notification_msg)); + + typename TestFixture::MockAppPtr mock_app = this->CreateMockApp(); + std::vector<ApplicationSharedPtr> subscribed_apps_list; + subscribed_apps_list.push_back(mock_app); + + EXPECT_CALL(*mock_app, hmi_level()) + .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); + + ON_CALL(*mock_app, IsFullscreen()).WillByDefault(Return(true)); + + EXPECT_CALL(this->app_mngr_, applications_by_button(kButtonName)) + .WillOnce(Return(subscribed_apps_list)); + EXPECT_CALL(this->mock_rpc_service_, + SendMessageToMobile( + CheckNotificationMessage(TestFixture::kFunctionId), _)); + + command->Run(); +} + +} // namespace on_button_notification +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_command_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_command_notification_test.cc new file mode 100644 index 0000000000..9e12303f23 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_command_notification_test.cc @@ -0,0 +1,137 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_impl.h" +#include "mobile/on_command_notification.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace on_command_notification { + +namespace am = ::application_manager; + +using ::testing::_; +using ::testing::Return; + +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::OnCommandNotification; + +typedef ::utils::SharedPtr<OnCommandNotification> CommandPtr; + +namespace { +const uint32_t kAppId = 1u; +const uint32_t kCommandId = 5u; +} // namespace + +class OnCommandNotificationTest + : public CommandsTest<CommandsTestMocks::kNotNice> {}; + +TEST_F(OnCommandNotificationTest, Run_AppNotRegistered_UNSUCCESS) { + CommandPtr command(CreateCommand<OnCommandNotification>()); + + EXPECT_CALL(app_mngr_, application(_)) + .WillOnce(Return(ApplicationSharedPtr())); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + + command->Run(); +} + +TEST_F(OnCommandNotificationTest, Run_NoAppsForTheCommand_UNSUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[am::strings::msg_params][am::strings::app_id] = kAppId; + (*command_msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId; + + CommandPtr command(CreateCommand<OnCommandNotification>(command_msg)); + + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kAppId)).WillOnce(Return(mock_app)); + + EXPECT_CALL(*mock_app, FindCommand(kCommandId)) + .WillOnce(Return(static_cast<SmartObject*>(NULL))); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + + command->Run(); +} + +MATCHER(CheckNotificationMessage, "") { + const bool kIsMobileProtocolTypeCorrect = + (*arg)[am::strings::params][am::strings::protocol_type].asInt() == + am::commands::CommandImpl::mobile_protocol_type_; + + const bool kIsProtocolVersionCorrect = + (*arg)[am::strings::params][am::strings::protocol_version].asInt() == + am::commands::CommandImpl::protocol_version_; + + const bool kIsNotificationCorrect = + (*arg)[am::strings::params][am::strings::message_type].asInt() == + am::MessageType::kNotification; + + return kIsMobileProtocolTypeCorrect && kIsProtocolVersionCorrect && + kIsNotificationCorrect; +} + +TEST_F(OnCommandNotificationTest, Run_SUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[am::strings::msg_params][am::strings::app_id] = kAppId; + (*command_msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId; + + CommandPtr command(CreateCommand<OnCommandNotification>(command_msg)); + + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kAppId)).WillOnce(Return(mock_app)); + + MessageSharedPtr dummy_msg(CreateMessage()); + EXPECT_CALL(*mock_app, FindCommand(kCommandId)) + .WillOnce(Return(dummy_msg.get())); + EXPECT_CALL(mock_rpc_service_, + SendMessageToMobile(CheckNotificationMessage(), _)); + + command->Run(); +} + +} // namespace on_command_notification +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hash_change_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hash_change_notification_test.cc new file mode 100644 index 0000000000..86df3cdab6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hash_change_notification_test.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 <string> + +#include "gtest/gtest.h" +#include "mobile/on_hash_change_notification.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/test/include/application_manager/commands/commands_test.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace on_hash_change_notification { + +namespace strings = application_manager::strings; + +using sdl_rpc_plugin::commands::mobile::OnHashChangeNotification; +using application_manager::MockMessageHelper; +using application_manager::commands::CommandImpl; +using testing::Mock; +using testing::Return; +using testing::ReturnRef; +using testing::_; + +class OnHashChangeNotificationTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(OnHashChangeNotificationTest, Run_ValidApp_SUCCESS) { + const uint32_t kConnectionKey = 1u; + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::connection_key] = kConnectionKey; + + SharedPtr<OnHashChangeNotification> command = + CreateCommand<OnHashChangeNotification>(msg); + + std::string return_string = "1234"; + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, curHash()).WillOnce(ReturnRef(return_string)); + EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)) + .WillOnce(Return(false)); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(msg, _)); + + command->Run(); + + ASSERT_EQ(application_manager::MessageType::kNotification, + (*msg)[strings::params][strings::message_type].asInt()); + ASSERT_EQ(CommandImpl::mobile_protocol_type_, + (*msg)[strings::params][strings::protocol_type].asInt()); + ASSERT_EQ(CommandImpl::protocol_version_, + (*msg)[strings::params][strings::protocol_version].asInt()); + ASSERT_EQ(return_string, + (*msg)[strings::msg_params][strings::hash_id].asString()); +} + +TEST_F(OnHashChangeNotificationTest, Run_InvalidApp_NoNotification) { + const uint32_t kConnectionKey = 1u; + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::connection_key] = kConnectionKey; + + SharedPtr<OnHashChangeNotification> command = + CreateCommand<OnHashChangeNotification>(msg); + + std::string return_string; + MockAppPtr mock_app = CreateMockApp(); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(MockAppPtr())); + EXPECT_CALL(*mock_app, curHash()).Times(0); + EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)).Times(0); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(msg, _)).Times(0); + + command->Run(); + + ASSERT_EQ(application_manager::MessageType::kNotification, + (*msg)[strings::params][strings::message_type].asInt()); +} + +} // namespace on_hash_change_notification +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc new file mode 100644 index 0000000000..43e01c5a3d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc @@ -0,0 +1,284 @@ +/* + * 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 "gtest/gtest.h" +#include "mobile/on_hmi_status_notification_from_mobile.h" +#include "application_manager/commands/commands_test.h" +#include <application_manager/smart_object_keys.h> +#include "application_manager/message.h" +#include "application_manager/application_manager.h" +#include "application_manager/mock_message_helper.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace on_hmi_status_notification_from_mobile { + +namespace { +const uint32_t kConnectionKey = 1u; +const connection_handler::DeviceHandle kHandle = 2u; +} // namespace + +namespace strings = application_manager::strings; + +using sdl_rpc_plugin::commands::OnHMIStatusNotificationFromMobile; +using protocol_handler::MajorProtocolVersion; +using application_manager::ApplicationSet; +using testing::Mock; +using testing::Return; +using testing::_; + +class OnHMIStatusNotificationFromMobileTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + OnHMIStatusNotificationFromMobileTest() + : lock_(std::make_shared<sync_primitives::Lock>()) {} + MessageSharedPtr CreateMsgParams( + const mobile_apis::HMILevel::eType kHMIState) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::connection_key] = kConnectionKey; + (*msg)[strings::msg_params][strings::hmi_level] = kHMIState; + return msg; + } + ApplicationSet app_set_; + std::shared_ptr<sync_primitives::Lock> lock_; +}; + +TEST_F(OnHMIStatusNotificationFromMobileTest, + Run_CurrentStateForeground_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL); + + SharedPtr<OnHMIStatusNotificationFromMobile> command = + CreateCommand<OnHMIStatusNotificationFromMobile>(msg); + + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, set_foreground(true)); + + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); + EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(true)); + + DataAccessor<ApplicationSet> accessor(app_set_, lock_); + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); + + EXPECT_CALL(*mock_app, protocol_version()) + .WillRepeatedly( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5)); + EXPECT_CALL(*mock_app, is_foreground()).WillRepeatedly(Return(true)); + + command->Run(); + + ASSERT_EQ(application_manager::MessageType::kNotification, + (*msg)[strings::params][strings::message_type].asInt()); +} + +TEST_F(OnHMIStatusNotificationFromMobileTest, Run_InvalidApp_NoNotification) { + MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL); + + SharedPtr<OnHMIStatusNotificationFromMobile> command = + CreateCommand<OnHMIStatusNotificationFromMobile>(msg); + + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(MockAppPtr())); + EXPECT_CALL(*mock_app, set_foreground(true)).Times(0); + + EXPECT_CALL(*mock_app, device()).Times(0); + EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).Times(0); + + EXPECT_CALL(app_mngr_, applications()).Times(0); + + EXPECT_CALL(*mock_app, protocol_version()).Times(0); + EXPECT_CALL(*mock_app, is_foreground()).Times(0); + + command->Run(); + + ASSERT_EQ(application_manager::MessageType::kNotification, + (*msg)[strings::params][strings::message_type].asInt()); +} + +TEST_F(OnHMIStatusNotificationFromMobileTest, + Run_CurrentStateNotForeground_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_BACKGROUND); + + SharedPtr<OnHMIStatusNotificationFromMobile> command = + CreateCommand<OnHMIStatusNotificationFromMobile>(msg); + + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, set_foreground(false)); + + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); + EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(true)); + + DataAccessor<ApplicationSet> accessor(app_set_, lock_); + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); + + EXPECT_CALL(*mock_app, protocol_version()) + .WillRepeatedly( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5)); + EXPECT_CALL(*mock_app, is_foreground()).WillRepeatedly(Return(true)); + + command->Run(); + + ASSERT_EQ(application_manager::MessageType::kNotification, + (*msg)[strings::params][strings::message_type].asInt()); +} + +TEST_F(OnHMIStatusNotificationFromMobileTest, + Run_ProtocolVersionKV3_NoNotification) { + MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_BACKGROUND); + + SharedPtr<OnHMIStatusNotificationFromMobile> command = + CreateCommand<OnHMIStatusNotificationFromMobile>(msg); + + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, set_foreground(false)); + + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); + EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(true)); + + DataAccessor<ApplicationSet> accessor(app_set_, lock_); + EXPECT_CALL(app_mngr_, applications()).Times(0); + + EXPECT_CALL(*mock_app, protocol_version()) + .WillOnce( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3)); + EXPECT_CALL(*mock_app, is_foreground()).Times(0); + + command->Run(); + + ASSERT_EQ(application_manager::MessageType::kNotification, + (*msg)[strings::params][strings::message_type].asInt()); +} + +TEST_F(OnHMIStatusNotificationFromMobileTest, + Run_AppNotRequestedBeforeAndKV3_NoNotification) { + MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL); + + SharedPtr<OnHMIStatusNotificationFromMobile> command = + CreateCommand<OnHMIStatusNotificationFromMobile>(msg); + + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, set_foreground(true)); + + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); + EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(false)); + + EXPECT_CALL(app_mngr_, applications()).Times(0); + + EXPECT_CALL(*mock_app, protocol_version()) + .WillOnce( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3)); + EXPECT_CALL(*mock_app, is_foreground()).Times(0); + + command->Run(); + + ASSERT_EQ(application_manager::MessageType::kNotification, + (*msg)[strings::params][strings::message_type].asInt()); +} + +TEST_F(OnHMIStatusNotificationFromMobileTest, + Run_AppNotRequestedBefore_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL); + + SharedPtr<OnHMIStatusNotificationFromMobile> command = + CreateCommand<OnHMIStatusNotificationFromMobile>(msg); + + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, set_foreground(true)); + + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); + EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(false)); + + EXPECT_CALL(*mock_app, protocol_version()) + .WillOnce( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5)); + + EXPECT_CALL(app_mngr_, applications()).Times(0); + + EXPECT_CALL(*mock_app, is_foreground()).WillOnce(Return(true)); + + EXPECT_CALL(mock_message_helper_, SendQueryApps(kConnectionKey, _)); + + command->Run(); + + ASSERT_EQ(application_manager::MessageType::kNotification, + (*msg)[strings::params][strings::message_type].asInt()); +} + +TEST_F(OnHMIStatusNotificationFromMobileTest, + Run_AnotherForegroundSDLApp_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL); + + SharedPtr<OnHMIStatusNotificationFromMobile> command = + CreateCommand<OnHMIStatusNotificationFromMobile>(msg); + + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, set_foreground(true)); + + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); + EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(true)); + + DataAccessor<ApplicationSet> accessor(app_set_, lock_); + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); + + EXPECT_CALL(*mock_app, protocol_version()) + .WillRepeatedly( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5)); + EXPECT_CALL(*mock_app, is_foreground()).WillRepeatedly(Return(false)); + + EXPECT_CALL(app_mngr_, MarkAppsGreyOut(kHandle, false)); + EXPECT_CALL(app_mngr_, SendUpdateAppList()); + + command->Run(); + + ASSERT_EQ(application_manager::MessageType::kNotification, + (*msg)[strings::params][strings::message_type].asInt()); +} + +} // namespace on_hmi_status_notification_from_mobile +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_test.cc new file mode 100644 index 0000000000..034fff73d7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_test.cc @@ -0,0 +1,205 @@ +/* + * 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 "gtest/gtest.h" +#include "mobile/on_hmi_status_notification.h" +#include "application_manager/test/include/application_manager/commands/commands_test.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/commands/command_impl.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace on_hmi_status_notification { + +namespace { +const uint32_t kConnectionKey = 1u; +} // namespace + +namespace strings = application_manager::strings; +using sdl_rpc_plugin::commands::OnHMIStatusNotification; +using protocol_handler::MajorProtocolVersion; +using application_manager::MockMessageHelper; +using application_manager::commands::CommandImpl; +using testing::Mock; +using testing::Return; +using testing::_; + +class OnHMIStatusNotificationTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + MessageSharedPtr CreateMsgParams( + const mobile_apis::HMILevel::eType kHMIState) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::connection_key] = kConnectionKey; + (*msg)[strings::msg_params][strings::hmi_level] = kHMIState; + return msg; + } + + void SetSendNotificationExpectations(MessageSharedPtr& msg) { + EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)) + .WillOnce(Return(false)); + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(msg, _)); + } + + void VerifySendNotificationData(MessageSharedPtr& msg) { + ASSERT_EQ(application_manager::MessageType::kNotification, + (*msg)[strings::params][strings::message_type].asInt()); + ASSERT_EQ(CommandImpl::mobile_protocol_type_, + (*msg)[strings::params][strings::protocol_type].asInt()); + ASSERT_EQ(CommandImpl::protocol_version_, + (*msg)[strings::params][strings::protocol_version].asInt()); + } +}; + +TEST_F(OnHMIStatusNotificationTest, Run_InvalidApp_NoNotification) { + MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL); + + SharedPtr<OnHMIStatusNotification> command = + CreateCommand<OnHMIStatusNotification>(msg); + + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(MockAppPtr())); + + EXPECT_CALL(*mock_app, tts_properties_in_full()).Times(0); + EXPECT_CALL(*mock_app, set_tts_properties_in_full(_)).Times(0); + EXPECT_CALL(*mock_app, app_id()).Times(0); + EXPECT_CALL(app_mngr_, AddAppToTTSGlobalPropertiesList(kConnectionKey)) + .Times(0); + + command->Run(); +} + +TEST_F(OnHMIStatusNotificationTest, Run_InvalidEnum_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::INVALID_ENUM); + + SharedPtr<OnHMIStatusNotification> command = + CreateCommand<OnHMIStatusNotification>(msg); + + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + + SetSendNotificationExpectations(msg); + + command->Run(); + + VerifySendNotificationData(msg); +} + +TEST_F(OnHMIStatusNotificationTest, Run_BackgroundAndFalseProperties_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_BACKGROUND); + SetSendNotificationExpectations(msg); + + SharedPtr<OnHMIStatusNotification> command = + CreateCommand<OnHMIStatusNotification>(msg); + + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + + EXPECT_CALL(*mock_app, tts_properties_in_none()).WillOnce(Return(false)); + EXPECT_CALL(*mock_app, set_tts_properties_in_none(true)); + EXPECT_CALL(mock_message_helper_, SendTTSGlobalProperties(_, false, _)); + + command->Run(); + + VerifySendNotificationData(msg); +} + +TEST_F(OnHMIStatusNotificationTest, Run_BackgroundAndTrueProperties_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_BACKGROUND); + + SharedPtr<OnHMIStatusNotification> command = + CreateCommand<OnHMIStatusNotification>(msg); + + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + + EXPECT_CALL(*mock_app, tts_properties_in_none()).WillOnce(Return(true)); + + SetSendNotificationExpectations(msg); + + command->Run(); + + VerifySendNotificationData(msg); +} + +TEST_F(OnHMIStatusNotificationTest, Run_FullAndFalseProperties_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL); + + SharedPtr<OnHMIStatusNotification> command = + CreateCommand<OnHMIStatusNotification>(msg); + + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + + EXPECT_CALL(*mock_app, tts_properties_in_full()).WillOnce(Return(false)); + EXPECT_CALL(*mock_app, set_tts_properties_in_full(true)); + EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kConnectionKey)); + EXPECT_CALL(app_mngr_, AddAppToTTSGlobalPropertiesList(kConnectionKey)); + + SetSendNotificationExpectations(msg); + + command->Run(); + + VerifySendNotificationData(msg); +} + +TEST_F(OnHMIStatusNotificationTest, Run_FullAndTrueProperties_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(mobile_apis::HMILevel::HMI_FULL); + + SharedPtr<OnHMIStatusNotification> command = + CreateCommand<OnHMIStatusNotification>(msg); + + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + + EXPECT_CALL(*mock_app, tts_properties_in_full()).WillOnce(Return(true)); + + SetSendNotificationExpectations(msg); + + command->Run(); + + VerifySendNotificationData(msg); +} + +} // namespace on_hmi_status_notification +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_keyboard_input_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_keyboard_input_notification_test.cc new file mode 100644 index 0000000000..ebfc2256ac --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_keyboard_input_notification_test.cc @@ -0,0 +1,167 @@ +/* + * 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 "gtest/gtest.h" +#include "mobile/on_keyboard_input_notification.h" +#include "application_manager/commands/commands_test.h" +#include <application_manager/smart_object_keys.h> +#include "application_manager/message.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/commands/command_impl.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace on_keyboard_input_notification { + +namespace strings = application_manager::strings; + +namespace { +const uint32_t kConnectionKey = 1u; +} // namespace + +using sdl_rpc_plugin::commands::mobile::OnKeyBoardInputNotification; +using application_manager::MockMessageHelper; +using application_manager::commands::CommandImpl; +using application_manager::ApplicationSet; +using testing::Mock; +using testing::Return; +using testing::_; + +class OnKeyBoardInputNotificationTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + OnKeyBoardInputNotificationTest() + : lock_(std::make_shared<sync_primitives::Lock>()) {} + void SetSendNotificationExpectations(MessageSharedPtr msg) { + EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)) + .WillOnce(Return(false)); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(msg, _)); + } + + void SetSendNotificationVariables(MessageSharedPtr msg) { + ASSERT_EQ(application_manager::MessageType::kNotification, + (*msg)[strings::params][strings::message_type].asInt()); + ASSERT_EQ(CommandImpl::mobile_protocol_type_, + (*msg)[strings::params][strings::protocol_type].asInt()); + ASSERT_EQ(CommandImpl::protocol_version_, + (*msg)[strings::params][strings::protocol_version].asInt()); + } + + MockAppPtr InitAppSetDataAccessor(SharedPtr<ApplicationSet>& app_set) { + app_set = (!app_set ? ::utils::MakeShared<ApplicationSet>() : app_set); + MockAppPtr app(CreateMockApp()); + app_set->insert(app); + EXPECT_CALL(app_mngr_, applications()) + .WillOnce(Return(DataAccessor<ApplicationSet>(*app_set, lock_))); + return app; + } + + SharedPtr<ApplicationSet> app_set_; + std::shared_ptr<sync_primitives::Lock> lock_; +}; + +TEST_F(OnKeyBoardInputNotificationTest, Run_ActionActive_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + + SharedPtr<OnKeyBoardInputNotification> command = + CreateCommand<OnKeyBoardInputNotification>(msg); + + MockAppPtr mock_app(InitAppSetDataAccessor(app_set_)); + EXPECT_CALL(*mock_app, is_perform_interaction_active()).WillOnce(Return(1)); + EXPECT_CALL(*mock_app, perform_interaction_layout()) + .WillOnce(Return(mobile_apis::LayoutMode::KEYBOARD)); + EXPECT_CALL(*mock_app, hmi_level()).Times(0); + + EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kConnectionKey)); + + SetSendNotificationExpectations(msg); + + command->Run(); + + SetSendNotificationVariables(msg); + + ASSERT_EQ(kConnectionKey, + (*msg)[strings::params][strings::connection_key].asInt()); +} + +TEST_F(OnKeyBoardInputNotificationTest, Run_ActionNotActive_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + + SharedPtr<OnKeyBoardInputNotification> command = + CreateCommand<OnKeyBoardInputNotification>(msg); + + MockAppPtr mock_app(InitAppSetDataAccessor(app_set_)); + EXPECT_CALL(*mock_app, is_perform_interaction_active()) + .WillRepeatedly(Return(0)); + + EXPECT_CALL(*mock_app, hmi_level()) + .WillOnce(Return(mobile_apis::HMILevel::eType::HMI_FULL)); + + EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kConnectionKey)); + + SetSendNotificationExpectations(msg); + + command->Run(); + + SetSendNotificationVariables(msg); + + ASSERT_EQ(kConnectionKey, + (*msg)[strings::params][strings::connection_key].asInt()); +} + +TEST_F(OnKeyBoardInputNotificationTest, Run_InvalidApp_NoNotification) { + MessageSharedPtr msg = CreateMessage(); + + SharedPtr<OnKeyBoardInputNotification> command = + CreateCommand<OnKeyBoardInputNotification>(msg); + + MockAppPtr mock_app(InitAppSetDataAccessor(app_set_)); + EXPECT_CALL(*mock_app, is_perform_interaction_active()) + .WillRepeatedly(Return(0)); + + EXPECT_CALL(*mock_app, hmi_level()) + .WillOnce(Return(mobile_apis::HMILevel::eType::HMI_BACKGROUND)); + EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)).Times(0); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(msg, _)).Times(0); + + command->Run(); +} + +} // namespace on_keyboard_input_notification +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_request_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_request_notification_test.cc new file mode 100644 index 0000000000..d6e1b2fe52 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_request_notification_test.cc @@ -0,0 +1,273 @@ +/* + * 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 <string> + +#include "gtest/gtest.h" +#include "mobile/on_system_request_notification.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace on_system_request_notification { + +namespace strings = application_manager::strings; + +using sdl_rpc_plugin::commands::mobile::OnSystemRequestNotification; +using application_manager::commands::CommandImpl; +using application_manager::MockMessageHelper; +using test::components::policy_test::MockPolicyHandlerInterface; +using namespace mobile_apis; +using testing::SaveArg; +using testing::Mock; +using testing::Return; +using testing::ReturnRef; +using testing::_; + +namespace { +const uint32_t kConnectionKey = 1u; +const std::string kPolicyAppId = "fake-app-id"; +} // namespace + +class OnSystemRequestNotificationTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + OnSystemRequestNotificationTest() : mock_app_(CreateMockApp()) {} + + void PreConditions() { + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); + } + + protected: + MockAppPtr mock_app_; +}; + +TEST_F(OnSystemRequestNotificationTest, Run_ProprietaryType_SUCCESS) { + const mobile_apis::RequestType::eType request_type = + mobile_apis::RequestType::PROPRIETARY; + + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::connection_key] = kConnectionKey; + (*msg)[strings::msg_params][strings::request_type] = request_type; + + SharedPtr<OnSystemRequestNotification> command = + CreateCommand<OnSystemRequestNotification>(msg); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillRepeatedly(Return(mock_app_)); + + EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId)); + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kPolicyAppId, request_type)) + .WillRepeatedly(Return(true)); + +#ifdef PROPRIETARY_MODE + EXPECT_CALL(mock_policy_handler_, TimeoutExchangeSec()).WillOnce(Return(5u)); +#endif // PROPRIETARY_MODE + + EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)) + .WillOnce(Return(false)); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(msg, _)); + + command->Run(); + + ASSERT_EQ(FileType::JSON, + (*msg)[strings::msg_params][strings::file_type].asInt()); + ASSERT_EQ(application_manager::MessageType::kNotification, + (*msg)[strings::params][strings::message_type].asInt()); + ASSERT_EQ(CommandImpl::mobile_protocol_type_, + (*msg)[strings::params][strings::protocol_type].asInt()); + ASSERT_EQ(CommandImpl::protocol_version_, + (*msg)[strings::params][strings::protocol_version].asInt()); +} + +TEST_F(OnSystemRequestNotificationTest, Run_HTTPType_SUCCESS) { + const mobile_apis::RequestType::eType request_type = + mobile_apis::RequestType::HTTP; + + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::connection_key] = kConnectionKey; + (*msg)[strings::msg_params][strings::request_type] = request_type; + + SharedPtr<OnSystemRequestNotification> command = + CreateCommand<OnSystemRequestNotification>(msg); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId)); + EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _)) + .WillOnce(Return(true)); + + EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)) + .WillOnce(Return(false)); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(msg, _)); + + command->Run(); + + ASSERT_EQ(FileType::BINARY, + (*msg)[strings::msg_params][strings::file_type].asInt()); + ASSERT_EQ(application_manager::MessageType::kNotification, + (*msg)[strings::params][strings::message_type].asInt()); + ASSERT_EQ(CommandImpl::mobile_protocol_type_, + (*msg)[strings::params][strings::protocol_type].asInt()); + ASSERT_EQ(CommandImpl::protocol_version_, + (*msg)[strings::params][strings::protocol_version].asInt()); +} + +TEST_F(OnSystemRequestNotificationTest, Run_InvalidApp_NoNotification) { + const mobile_apis::RequestType::eType request_type = + mobile_apis::RequestType::HTTP; + + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::connection_key] = kConnectionKey; + (*msg)[strings::msg_params][strings::request_type] = request_type; + + SharedPtr<OnSystemRequestNotification> command = + CreateCommand<OnSystemRequestNotification>(msg); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(MockAppPtr())); + EXPECT_CALL(*mock_app_, policy_app_id()).Times(0); + EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _)).Times(0); + + EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)).Times(0); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(msg, _)).Times(0); + + command->Run(); +} + +TEST_F(OnSystemRequestNotificationTest, Run_RequestNotAllowed_NoNotification) { + const mobile_apis::RequestType::eType request_type = + mobile_apis::RequestType::HTTP; + + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::connection_key] = kConnectionKey; + (*msg)[strings::msg_params][strings::request_type] = request_type; + + SharedPtr<OnSystemRequestNotification> command = + CreateCommand<OnSystemRequestNotification>(msg); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId)); + EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _)) + .WillOnce(Return(false)); + + EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)).Times(0); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(msg, _)).Times(0); + + command->Run(); +} + +TEST_F( + OnSystemRequestNotificationTest, + Run_RequestTypeAllowedAndRequestSubTypeDisallowed_MessageNotSentToMobile) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::connection_key] = kConnectionKey; + const auto request_type = mobile_apis::RequestType::HTTP; + (*msg)[strings::msg_params][strings::request_type] = request_type; + const std::string request_subtype = "fakeSubType"; + (*msg)[am::strings::msg_params][am::strings::request_subtype] = + request_subtype; + + PreConditions(); + + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kPolicyAppId, request_type)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_policy_handler_, + IsRequestSubTypeAllowed(kPolicyAppId, request_subtype)) + .WillOnce(Return(false)); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)).Times(0); + + auto command = CreateCommand<OnSystemRequestNotification>(msg); + + ASSERT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(OnSystemRequestNotificationTest, + Run_RequestTypeAllowedAndRequestSubTypeAllowed_SendMessageToMobile) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::connection_key] = kConnectionKey; + const auto request_type = mobile_apis::RequestType::OEM_SPECIFIC; + (*msg)[strings::msg_params][strings::request_type] = request_type; + const std::string request_subtype = "fakeSubType"; + (*msg)[am::strings::msg_params][am::strings::request_subtype] = + request_subtype; + + PreConditions(); + + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kPolicyAppId, request_type)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_policy_handler_, + IsRequestSubTypeAllowed(kPolicyAppId, request_subtype)) + .WillOnce(Return(true)); + + smart_objects::SmartObjectSPtr result; + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)) + .WillOnce((SaveArg<0>(&result))); + + auto command = CreateCommand<OnSystemRequestNotification>(msg); + + ASSERT_TRUE(command->Init()); + command->Run(); + + EXPECT_EQ(application_manager::MessageType::kNotification, + (*result)[strings::params][strings::message_type].asInt()); + EXPECT_EQ(request_type, + (*result)[strings::msg_params][strings::request_type].asInt()); + EXPECT_EQ( + request_subtype, + (*result)[strings::msg_params][strings::request_subtype].asString()); +} + +} // namespace on_system_request_notification +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_tbt_client_state_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_tbt_client_state_notification_test.cc new file mode 100644 index 0000000000..14939a433d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_tbt_client_state_notification_test.cc @@ -0,0 +1,138 @@ +/* + * 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 <stdint.h> +#include <vector> + +#include "gtest/gtest.h" +#include "mobile/on_tbt_client_state_notification.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_impl.h" +#include "utils/helpers.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace on_tbt_client_state_notification { + +namespace am = ::application_manager; + +using ::testing::_; +using ::testing::Return; + +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::OnTBTClientStateNotification; + +typedef ::utils::SharedPtr<OnTBTClientStateNotification> NotificationPtr; + +namespace { +const uint32_t kAppId = 1u; +} // namespace + +class OnTBTClientStateNotificationTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + OnTBTClientStateNotificationTest() + : command_(CreateCommand<OnTBTClientStateNotification>()) {} + + NotificationPtr command_; +}; + +TEST_F(OnTBTClientStateNotificationTest, Run_HmiLevelNone_UNSUCCESS) { + MockAppPtr mock_app(CreateMockApp()); + std::vector<ApplicationSharedPtr> applications_with_navi; + applications_with_navi.push_back(mock_app); + + EXPECT_CALL(app_mngr_, applications_with_navi()) + .WillOnce(Return(applications_with_navi)); + + EXPECT_CALL(*mock_app, hmi_level()) + .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE)); + + EXPECT_CALL(*mock_app, app_id()).Times(0); + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)).Times(0); + + command_->Run(); +} + +MATCHER(CheckMessageData, "") { + const bool kIsMobileProtocolTypeCorrect = + (*arg)[am::strings::params][am::strings::protocol_type].asInt() == + am::commands::CommandImpl::mobile_protocol_type_; + + const bool kIsProtocolVersionCorrect = + (*arg)[am::strings::params][am::strings::protocol_version].asInt() == + am::commands::CommandImpl::protocol_version_; + + const bool kIsNotificationCorrect = + (*arg)[am::strings::params][am::strings::message_type].asInt() == + am::MessageType::kNotification; + + const bool kIsConnectionKeyCorrect = + (*arg)[am::strings::params][am::strings::connection_key].asUInt() == + kAppId; + + using namespace helpers; + return Compare<bool, EQ, ALL>(true, + kIsMobileProtocolTypeCorrect, + kIsProtocolVersionCorrect, + kIsNotificationCorrect, + kIsConnectionKeyCorrect); +} + +TEST_F(OnTBTClientStateNotificationTest, + Run_NotEmptyListOfAppsWithNavi_SUCCESS) { + MockAppPtr mock_app(CreateMockApp()); + std::vector<ApplicationSharedPtr> applications_with_navi; + applications_with_navi.push_back(mock_app); + + EXPECT_CALL(app_mngr_, applications_with_navi()) + .WillOnce(Return(applications_with_navi)); + + EXPECT_CALL(*mock_app, hmi_level()) + .WillOnce(Return(mobile_apis::HMILevel::HMI_FULL)); + + EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppId)); + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(CheckMessageData(), _)); + + command_->Run(); +} + +} // namespace on_tbt_client_state_notification +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_touch_event_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_touch_event_notification_test.cc new file mode 100644 index 0000000000..4576637d8d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_touch_event_notification_test.cc @@ -0,0 +1,148 @@ +/* + * 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 <stdint.h> +#include <vector> + +#include "gtest/gtest.h" +#include "mobile/on_touch_event_notification.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_impl.h" +#include "utils/helpers.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace on_touch_event_notification { + +namespace am = ::application_manager; + +using ::testing::_; +using ::testing::Return; + +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::mobile::OnTouchEventNotification; + +typedef ::utils::SharedPtr<OnTouchEventNotification> NotificationPtr; + +namespace { +const uint32_t kAppId = 1u; +} // namespace + +class OnTouchEventNotificationTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + OnTouchEventNotificationTest() + : command_(CreateCommand<OnTouchEventNotification>()) {} + + NotificationPtr command_; +}; + +TEST_F(OnTouchEventNotificationTest, Run_AppIsNotFullscreen_UNSUCCESS) { + MockAppPtr mock_app(CreateMockApp()); + std::vector<ApplicationSharedPtr> applications_with_navi; + applications_with_navi.push_back(mock_app); + + std::vector<ApplicationSharedPtr> applications_with_mobile_projection; + applications_with_mobile_projection.push_back(mock_app); + + EXPECT_CALL(app_mngr_, applications_with_navi()) + .WillOnce(Return(applications_with_navi)); + + EXPECT_CALL(app_mngr_, applications_with_mobile_projection()) + .WillOnce(Return(applications_with_mobile_projection)); + + EXPECT_CALL(*mock_app, IsFullscreen()).WillRepeatedly(Return(false)); + + EXPECT_CALL(*mock_app, app_id()).Times(0); + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)).Times(0); + + command_->Run(); +} + +MATCHER(CheckMessageData, "") { + const bool kIsMobileProtocolTypeCorrect = + (*arg)[am::strings::params][am::strings::protocol_type].asInt() == + am::commands::CommandImpl::mobile_protocol_type_; + + const bool kIsProtocolVersionCorrect = + (*arg)[am::strings::params][am::strings::protocol_version].asInt() == + am::commands::CommandImpl::protocol_version_; + + const bool kIsNotificationCorrect = + (*arg)[am::strings::params][am::strings::message_type].asInt() == + am::MessageType::kNotification; + + const bool kIsConnectionKeyCorrect = + (*arg)[am::strings::params][am::strings::connection_key].asUInt() == + kAppId; + + using namespace helpers; + return Compare<bool, EQ, ALL>(true, + kIsMobileProtocolTypeCorrect, + kIsProtocolVersionCorrect, + kIsNotificationCorrect, + kIsConnectionKeyCorrect); +} + +TEST_F(OnTouchEventNotificationTest, Run_NotEmptyListOfAppsWithNavi_SUCCESS) { + MockAppPtr mock_app(CreateMockApp()); + std::vector<ApplicationSharedPtr> applications_with_navi; + applications_with_navi.push_back(mock_app); + + std::vector<ApplicationSharedPtr> applications_with_mobile_projection; + applications_with_mobile_projection.push_back(mock_app); + + EXPECT_CALL(app_mngr_, applications_with_navi()) + .WillOnce(Return(applications_with_navi)); + + EXPECT_CALL(app_mngr_, applications_with_mobile_projection()) + .WillOnce(Return(applications_with_mobile_projection)); + + EXPECT_CALL(*mock_app, IsFullscreen()).WillRepeatedly(Return(true)); + + EXPECT_CALL(*mock_app, app_id()).WillRepeatedly(Return(kAppId)); + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(CheckMessageData(), _)) + .Times(2); + + command_->Run(); +} + +} // namespace on_touch_event_notification +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc new file mode 100644 index 0000000000..e0b7ab3b38 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc @@ -0,0 +1,115 @@ +/* + * 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 <stdint.h> +#include <set> + +#include "gtest/gtest.h" +#include "mobile/on_way_point_change_notification.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_impl.h" +#include "utils/helpers.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace on_way_point_change_notification { + +namespace am = ::application_manager; + +using ::testing::_; +using ::testing::Return; + +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::OnWayPointChangeNotification; + +typedef ::utils::SharedPtr<OnWayPointChangeNotification> NotificationPtr; + +namespace { +const uint32_t kAppId = 1u; +} // namespace + +class OnWayPointChangeNotificationTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + OnWayPointChangeNotificationTest() + : command_(CreateCommand<OnWayPointChangeNotification>()) {} + + NotificationPtr command_; +}; + +MATCHER(CheckMessageData, "") { + const bool kIsMobileProtocolTypeCorrect = + (*arg)[am::strings::params][am::strings::protocol_type].asInt() == + am::commands::CommandImpl::mobile_protocol_type_; + + const bool kIsProtocolVersionCorrect = + (*arg)[am::strings::params][am::strings::protocol_version].asInt() == + am::commands::CommandImpl::protocol_version_; + + const bool kIsNotificationCorrect = + (*arg)[am::strings::params][am::strings::message_type].asInt() == + am::MessageType::kNotification; + + const bool kIsConnectionKeyCorrect = + (*arg)[am::strings::params][am::strings::connection_key].asUInt() == + kAppId; + + using namespace helpers; + return Compare<bool, EQ, ALL>(true, + kIsMobileProtocolTypeCorrect, + kIsProtocolVersionCorrect, + kIsNotificationCorrect, + kIsConnectionKeyCorrect); +} + +TEST_F(OnWayPointChangeNotificationTest, + Run_NotEmptyListOfAppsSubscribedForWayPoints_SUCCESS) { + std::set<int32_t> apps_subscribed_for_way_points; + apps_subscribed_for_way_points.insert(kAppId); + + EXPECT_CALL(app_mngr_, GetAppsSubscribedForWayPoints()) + .WillOnce(Return(apps_subscribed_for_way_points)); + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(CheckMessageData(), _)); + + command_->Run(); +} + +} // namespace on_way_point_change_notification +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc new file mode 100644 index 0000000000..f06a642e3b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc @@ -0,0 +1,835 @@ +/* + * 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 <stdint.h> +#include <string> +#include <set> + +#include "mobile/perform_audio_pass_thru_request.h" + +#include "gtest/gtest.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace perform_audio_pass_thru_request { + +namespace am = application_manager; +using sdl_rpc_plugin::commands::PerformAudioPassThruRequest; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using am::MockMessageHelper; +using ::utils::SharedPtr; +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::InSequence; + +namespace { +const int32_t kCommandId = 1; +const uint32_t kAppId = 1u; +const uint32_t kCmdId = 1u; +const uint32_t kConnectionKey = 2u; +const uint32_t kCorrelationId = 2u; +const std::string kCorrectPrompt = "CorrectPrompt"; +const std::string kCorrectType = "CorrectType"; +const std::string kCorrectDisplayText1 = "CorrectDisplayText1"; +const std::string kCorrectDisplayText2 = "CorrectDisplayText2"; +const std::string kFunctionId = "FunctionId"; +const uint32_t kTimeoutForTTSSpeak = 1u; +} // namespace + +class PerformAudioPassThruRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + PerformAudioPassThruRequestTest() + : mock_app_(CreateMockApp()) + , message_(utils::MakeShared<SmartObject>(::smart_objects::SmartType_Map)) + , msg_params_((*message_)[am::strings::msg_params]) {} + + MessageSharedPtr CreateFullParamsUISO() { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + smart_objects::SmartObject menu_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + menu_params[am::strings::position] = 10; + menu_params[am::strings::menu_name] = "LG"; + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[am::strings::cmd_id] = kCmdId; + msg_params[am::strings::menu_params] = menu_params; + msg_params[am::strings::app_id] = kAppId; + msg_params[am::strings::cmd_icon] = 1; + msg_params[am::strings::cmd_icon][am::strings::value] = "10"; + (*msg)[am::strings::msg_params] = msg_params; + + return msg; + } + + void TestWrongSyntaxInField(const std::string& field) { + if (field == am::strings::initial_prompt) { + msg_params_[field][0][am::strings::text] = "prompt\\n"; + } else { + msg_params_[field] = "prompt\\n"; + } + + EXPECT_CALL(*application_sptr_, hmi_level()) + .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); + + CallRun caller(*command_sptr_); + MessageSharedPtr result_message = CatchMobileCommandResult(caller); + + const am::mobile_api::Result::eType result = + static_cast<am::mobile_api::Result::eType>( + (*result_message)[am::strings::msg_params][am::strings::result_code] + .asInt()); + + EXPECT_EQ(am::mobile_api::Result::INVALID_DATA, result); + } + + void SetUp() OVERRIDE { + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + (*message_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + command_sptr_ = CreateCommand<PerformAudioPassThruRequest>(message_); + + application_sptr_ = CreateMockApp(); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(application_sptr_)); + } + + void ResultCommandExpectations(MessageSharedPtr msg, + const std::string& info) { + EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(), + true); + EXPECT_EQ( + (*msg)[am::strings::msg_params][am::strings::result_code].asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(), + info); + } + + sync_primitives::Lock lock_; + MockAppPtr mock_app_; + MessageSharedPtr message_; + ::smart_objects::SmartObject& msg_params_; + utils::SharedPtr<PerformAudioPassThruRequest> command_sptr_; + MockAppPtr application_sptr_; +}; + +TEST_F(PerformAudioPassThruRequestTest, OnTimeout_GENERIC_ERROR) { + MessageSharedPtr msg_ui = CreateMessage(smart_objects::SmartType_Map); + (*msg_ui)[am::strings::msg_params][am::strings::result_code] = + am::mobile_api::Result::GENERIC_ERROR; + (*msg_ui)[am::strings::msg_params][am::strings::success] = false; + + MessageSharedPtr message = + utils::MakeShared<SmartObject>(::smart_objects::SmartType_Map); + (*message)[am::strings::params][am::strings::connection_key] = kConnectionKey; + + utils::SharedPtr<PerformAudioPassThruRequest> command = + CreateCommand<PerformAudioPassThruRequest>(message); + + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, StopAudioPassThru(_)); + + EXPECT_CALL( + mock_message_helper_, + CreateNegativeResponse(_, _, _, am::mobile_api::Result::GENERIC_ERROR)) + .WillOnce(Return(msg_ui)); + + MessageSharedPtr vr_command_result; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true))); + + command->onTimeOut(); + EXPECT_EQ((*vr_command_result)[am::strings::msg_params][am::strings::success] + .asBool(), + false); + EXPECT_EQ( + (*vr_command_result)[am::strings::msg_params][am::strings::result_code] + .asInt(), + static_cast<int32_t>(am::mobile_api::Result::GENERIC_ERROR)); +} + +TEST_F(PerformAudioPassThruRequestTest, + OnEvent_UIHmiSendUnsupportedResource_UNSUPPORTED_RESOURCE) { + MessageSharedPtr mobile_request = CreateFullParamsUISO(); + (*mobile_request)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + smart_objects::SmartObject initial_prompt = + smart_objects::SmartObject(smart_objects::SmartType_Array); + initial_prompt[0] = smart_objects::SmartObject(smart_objects::SmartType_Map); + initial_prompt[0][am::strings::text] = "tts chunk text"; + initial_prompt[0][am::strings::type] = 0; + (*mobile_request)[am::strings::msg_params][am::strings::initial_prompt] = + initial_prompt; + + EXPECT_CALL(*application_sptr_, hmi_level()) + .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); + utils::SharedPtr<PerformAudioPassThruRequest> command = + CreateCommand<PerformAudioPassThruRequest>(mobile_request); + + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + MessageSharedPtr response_msg_tts = + CreateMessage(smart_objects::SmartType_Map); + (*response_msg_tts)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*response_msg_tts)[am::strings::msg_params][am::strings::cmd_id] = kCmdId; + am::event_engine::Event event_tts(hmi_apis::FunctionID::TTS_Speak); + event_tts.set_smart_object(*response_msg_tts); + + MessageSharedPtr response_ui = CreateMessage(smart_objects::SmartType_Map); + (*response_ui)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*response_ui)[am::strings::msg_params][am::strings::cmd_id] = kCommandId; + (*response_ui)[am::strings::msg_params][am::strings::info] = + "UI is not supported by system"; + am::event_engine::Event event_ui( + hmi_apis::FunctionID::UI_PerformAudioPassThru); + event_ui.set_smart_object(*response_ui); + + MessageSharedPtr response_to_mobile; + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillRepeatedly(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + EXPECT_CALL(mock_message_helper_, + VerifyTtsFiles((*mobile_request)[am::strings::msg_params] + [am::strings::initial_prompt], + _, + _)).WillOnce(Return(mobile_apis::Result::SUCCESS)); + + command->Run(); + command->on_event(event_tts); + command->on_event(event_ui); + + EXPECT_EQ((*response_to_mobile)[am::strings::msg_params][am::strings::success] + .asBool(), + false); + EXPECT_EQ( + (*response_to_mobile)[am::strings::msg_params][am::strings::result_code] + .asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + EXPECT_EQ((*response_to_mobile)[am::strings::msg_params][am::strings::info] + .asString(), + "UI is not supported by system"); +} + +TEST_F(PerformAudioPassThruRequestTest, + Run_InvalidApp_ApplicationNotRegisteredResponce) { + utils::SharedPtr<am::Application> null_application_sptr; + EXPECT_CALL(app_mngr_, application(_)) + .WillOnce(Return(null_application_sptr)); + + CallRun caller(*command_sptr_); + MessageSharedPtr result_message = CatchMobileCommandResult(caller); + + const am::mobile_api::Result::eType result = + static_cast<am::mobile_api::Result::eType>( + (*result_message)[am::strings::msg_params][am::strings::result_code] + .asInt()); + EXPECT_EQ(am::mobile_api::Result::APPLICATION_NOT_REGISTERED, result); +} + +TEST_F(PerformAudioPassThruRequestTest, Run_HmiLevelNone_Rejected) { + EXPECT_CALL(*application_sptr_, hmi_level()) + .WillOnce(Return(am::mobile_api::HMILevel::HMI_NONE)); + + CallRun caller(*command_sptr_); + MessageSharedPtr result_message = CatchMobileCommandResult(caller); + + const am::mobile_api::Result::eType result = + static_cast<am::mobile_api::Result::eType>( + (*result_message)[am::strings::msg_params][am::strings::result_code] + .asInt()); + EXPECT_EQ(am::mobile_api::Result::REJECTED, result); +} + +TEST_F(PerformAudioPassThruRequestTest, + Run_WhitespaceInInitialPrompt_InvalidData) { + TestWrongSyntaxInField(am::strings::initial_prompt); +} + +TEST_F(PerformAudioPassThruRequestTest, + Run_WhitespaceInAudioPassDisplayText1_InvalidData) { + TestWrongSyntaxInField(am::strings::audio_pass_display_text1); +} + +TEST_F(PerformAudioPassThruRequestTest, + Run_WhitespaceInAudioPassDisplayText2_InvalidData) { + TestWrongSyntaxInField(am::strings::audio_pass_display_text2); +} + +TEST_F(PerformAudioPassThruRequestTest, + Run_InitPromptCorrect_TTSSpeakIsAbsent) { + // First we need to call SendSpeakRequest() + // to enable the "is_active_tts_speak" key + + EXPECT_CALL(*application_sptr_, hmi_level()) + .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); + + msg_params_[am::strings::initial_prompt][0][am::strings::text] = + kCorrectPrompt; + msg_params_[am::strings::initial_prompt][0][am::strings::type] = kCorrectType; + + EXPECT_CALL(mock_message_helper_, + VerifyTtsFiles(msg_params_[am::strings::initial_prompt], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + + MessageSharedPtr speak_reqeust_result_msg; + MessageSharedPtr perform_result_msg; + { + InSequence dummy; + // Send speak request sending + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_Speak)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&speak_reqeust_result_msg), Return(true))); + + // Perform audio path thru request sending + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + ON_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_PerformAudioPassThru)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true))); + } + CallRun run_caller(*command_sptr_); + run_caller(); + + const ::smart_objects::SmartObject& speak_msg_params = + (*speak_reqeust_result_msg)[am::strings::msg_params]; + + const std::string result_initial_prompt = + speak_msg_params[am::hmi_request::tts_chunks][0][am::strings::text] + .asString(); + const std::string result_prompt_type = + speak_msg_params[am::hmi_request::tts_chunks][0][am::strings::type] + .asString(); + + EXPECT_EQ(kCorrectPrompt, result_initial_prompt); + EXPECT_EQ(kCorrectType, result_prompt_type); + + // Now we recieve on_event() + + am::event_engine::Event event(hmi_apis::FunctionID::UI_PerformAudioPassThru); + (*message_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::GENERIC_ERROR; + event.set_smart_object(*message_); + + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false)); + + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_StopSpeaking)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + + CallOnEvent on_event_caller(*command_sptr_, event); + MessageSharedPtr command_result = CatchHMICommandResult(on_event_caller); + + const hmi_apis::FunctionID::eType result_function_id = + static_cast<hmi_apis::FunctionID::eType>( + (*command_result)[am::strings::params][am::strings::function_id] + .asInt()); + + EXPECT_EQ(hmi_apis::FunctionID::TTS_StopSpeaking, result_function_id); +} + +TEST_F(PerformAudioPassThruRequestTest, + Run_InitPromptCorrect_SpeakAndPerformAPTRequestsSendMuteTrue) { + EXPECT_CALL(*application_sptr_, hmi_level()) + .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); + + msg_params_[am::strings::initial_prompt][0][am::strings::text] = + kCorrectPrompt; + msg_params_[am::strings::initial_prompt][0][am::strings::type] = kCorrectType; + msg_params_[am::strings::audio_pass_display_text1] = kCorrectDisplayText1; + msg_params_[am::strings::audio_pass_display_text2] = kCorrectDisplayText2; + + EXPECT_CALL(mock_message_helper_, + VerifyTtsFiles(msg_params_[am::strings::initial_prompt], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + + MessageSharedPtr speak_reqeust_result_msg; + MessageSharedPtr perform_result_msg; + { + InSequence dummy; + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_Speak)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&speak_reqeust_result_msg), Return(true))); + + // Perform audio path thru request sending + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + ON_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_PerformAudioPassThru)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true))); + } + CallRun caller(*command_sptr_); + caller(); + + const ::smart_objects::SmartObject& speak_msg_params = + (*speak_reqeust_result_msg)[am::strings::msg_params]; + const ::smart_objects::SmartObject& perform_msg_params = + (*perform_result_msg)[am::strings::msg_params]; + + const std::string result_initial_prompt = + speak_msg_params[am::hmi_request::tts_chunks][0][am::strings::text] + .asString(); + const std::string result_prompt_type = + speak_msg_params[am::hmi_request::tts_chunks][0][am::strings::type] + .asString(); + const std::string result_display_text_1 = + perform_msg_params[am::hmi_request::audio_pass_display_texts][0] + [am::hmi_request::field_text].asString(); + const std::string result_display_text_2 = + perform_msg_params[am::hmi_request::audio_pass_display_texts][1] + [am::hmi_request::field_text].asString(); + + EXPECT_EQ(kCorrectPrompt, result_initial_prompt); + EXPECT_EQ(kCorrectType, result_prompt_type); + EXPECT_EQ(kCorrectDisplayText1, result_display_text_1); + EXPECT_EQ(kCorrectDisplayText2, result_display_text_2); + + EXPECT_EQ(true, perform_msg_params[am::strings::mute_audio].asBool()); +} + +TEST_F(PerformAudioPassThruRequestTest, + Run_InitPromptCorrect_SpeakAndPerformAPTRequestsSendMuteFalse) { + EXPECT_CALL(*application_sptr_, hmi_level()) + .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); + + msg_params_[am::strings::initial_prompt][0][am::strings::text] = + kCorrectPrompt; + msg_params_[am::strings::initial_prompt][0][am::strings::type] = kCorrectType; + + EXPECT_CALL(mock_message_helper_, + VerifyTtsFiles(msg_params_[am::strings::initial_prompt], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + + const bool muted = false; + + msg_params_[am::strings::mute_audio] = muted; + + MessageSharedPtr speak_reqeust_result_msg; + MessageSharedPtr perform_result_msg; + { + InSequence dummy; + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_Speak)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&speak_reqeust_result_msg), Return(true))); + + // Perform audio path thru request sending + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + ON_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_PerformAudioPassThru)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true))); + } + CallRun caller(*command_sptr_); + caller(); + + EXPECT_EQ( + muted, + (*perform_result_msg)[am::strings::msg_params][am::strings::mute_audio] + .asBool()); +} + +TEST_F( + PerformAudioPassThruRequestTest, + Run_InitPromptEmpty_PerformAndRecordStartNotificationsAndStartRecording) { + EXPECT_CALL(*application_sptr_, hmi_level()) + .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); + + MessageSharedPtr start_record_result_msg; + MessageSharedPtr perform_result_msg; + { + InSequence dummy; + + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + ON_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_PerformAudioPassThru)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + // Perform audio path thru request sending + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true))); + + // Perform audio path thru request sending + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_OnRecordStart)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + // Start recording notification sending + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&start_record_result_msg), Return(true))); + } + + // Start microphone recording cals + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id)); + EXPECT_CALL(app_mngr_, StartAudioPassThruThread(_, _, _, _, _, _)); + + CallRun caller(*command_sptr_); + caller(); + + const hmi_apis::FunctionID::eType start_record_result_function_id = + static_cast<hmi_apis::FunctionID::eType>( + (*start_record_result_msg)[am::strings::params] + [am::strings::function_id].asInt()); + EXPECT_EQ(hmi_apis::FunctionID::UI_OnRecordStart, + start_record_result_function_id); +} + +TEST_F(PerformAudioPassThruRequestTest, OnEvent_UIPAPT_Rejected) { + am::event_engine::Event event(hmi_apis::FunctionID::UI_PerformAudioPassThru); + + (*message_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::REJECTED; + event.set_smart_object(*message_); + + CallOnEvent caller(*command_sptr_, event); + + MessageSharedPtr result_message = CatchMobileCommandResult(caller); + + const am::mobile_api::Result::eType result_code = + static_cast<am::mobile_api::Result::eType>( + (*result_message)[am::strings::msg_params][am::strings::result_code] + .asInt()); + + EXPECT_EQ(am::mobile_api::Result::REJECTED, result_code); +} + +TEST_F(PerformAudioPassThruRequestTest, + OnEvent_TTSSpeakSuccess_UpdateRequestTimeout) { + am::event_engine::Event event(hmi_apis::FunctionID::TTS_Speak); + + (*message_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + event.set_smart_object(*message_); + + // Start recording notification sending + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); + + // Start microphone recording cals + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id)); + EXPECT_CALL(app_mngr_, StartAudioPassThruThread(_, _, _, _, _, _)); + + EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); + + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + CallOnEvent caller(*command_sptr_, event); + caller(); +} + +TEST_F(PerformAudioPassThruRequestTest, + DISABLED_OnEvent_PAPTunsupportedResource_CorrectInfo) { + const std::string return_info = "Unsupported phoneme type sent in a prompt"; + + am::event_engine::Event event_speak(hmi_apis::FunctionID::TTS_Speak); + am::event_engine::Event event_perform( + hmi_apis::FunctionID::UI_PerformAudioPassThru); + + (*message_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + event_speak.set_smart_object(*message_); + + (*message_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + event_perform.set_smart_object(*message_); + + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + // First call on_event for setting result_tts_speak_ to UNSUPPORTED_RESOURCE + EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); + CallOnEvent caller_speak(*command_sptr_, event_speak); + caller_speak(); + + // Second call for test correct behavior of UI_PerformAudioPassThru event + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false)); + EXPECT_CALL(app_mngr_, StopAudioPassThru(_)).Times(0); + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + CallOnEvent caller_perform(*command_sptr_, event_perform); + + MessageSharedPtr perform_event_result = + CatchMobileCommandResult(caller_perform); + + EXPECT_EQ(return_info, + (*perform_event_result)[am::strings::msg_params][am::strings::info] + .asString()); +} + +TEST_F(PerformAudioPassThruRequestTest, + DISABLED_OnEvent_TTSSpeak_UpdateTimeout) { + am::event_engine::Event event(hmi_apis::FunctionID::TTS_Speak); + + msg_params_[am::strings::connection_key] = kConnectionKey; + msg_params_[am::strings::function_id] = kFunctionId; + msg_params_[am::strings::correlation_id] = kCorrelationId; + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); + + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id)).WillOnce(Return(true)); + + EXPECT_CALL( + app_mngr_, + StartAudioPassThruThread(kConnectionKey, kCorrelationId, _, _, _, _)); + + EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + CallOnEvent caller(*command_sptr_, event); + caller(); + + EXPECT_EQ(kConnectionKey, msg_params_[am::strings::connection_key].asUInt()); + EXPECT_EQ(kFunctionId, msg_params_[am::strings::function_id].asString()); +} + +TEST_F(PerformAudioPassThruRequestTest, + DISABLED_OnEvent_TTSOnResetTimeout_UpdateTimeout) { + am::event_engine::Event event(hmi_apis::FunctionID::TTS_OnResetTimeout); + + msg_params_[am::strings::connection_key] = kConnectionKey; + msg_params_[am::strings::function_id] = kFunctionId; + + uint32_t app_id = kConnectionKey; + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id)).WillOnce(Return(true)); + + EXPECT_CALL( + app_mngr_, + StartAudioPassThruThread(kConnectionKey, kCorrelationId, _, _, _, _)); + EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + CallOnEvent caller(*command_sptr_, event); + caller(); + + EXPECT_EQ(kConnectionKey, msg_params_[am::strings::connection_key].asUInt()); + EXPECT_EQ(kFunctionId, msg_params_[am::strings::function_id].asString()); +} + +TEST_F(PerformAudioPassThruRequestTest, OnEvent_DefaultCase) { + am::event_engine::Event event(hmi_apis::FunctionID::INVALID_ENUM); + + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).Times(0); + + CallOnEvent caller(*command_sptr_, event); + caller(); +} + +TEST_F(PerformAudioPassThruRequestTest, Init_CorrectTimeout) { + const uint32_t kDefaultTimeout = command_sptr_->default_timeout(); + const uint32_t kMaxDuration = 10000u; + + msg_params_[am::strings::max_duration] = kMaxDuration; + + command_sptr_->Init(); + + EXPECT_EQ(kDefaultTimeout + kMaxDuration, command_sptr_->default_timeout()); +} + +TEST_F(PerformAudioPassThruRequestTest, + onTimeOut_ttsSpeakNotActive_DontSendHMIReqeust) { + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, StopAudioPassThru(_)); + + // For setting current_state_ -> kCompleted + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); + command_sptr_->SendResponse(true, am::mobile_api::Result::SUCCESS); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + + command_sptr_->onTimeOut(); +} + +TEST_F(PerformAudioPassThruRequestTest, + DISABLED_onTimeOut_ttsSpeakActive_SendHMIReqeust) { + uint32_t app_id = kConnectionKey; + EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, StopAudioPassThru(_)); + + EXPECT_CALL(*application_sptr_, hmi_level()) + .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); + + msg_params_[am::strings::initial_prompt][0][am::strings::text] = + kCorrectPrompt; + msg_params_[am::strings::initial_prompt][0][am::strings::type] = kCorrectType; + + EXPECT_CALL(mock_message_helper_, + VerifyTtsFiles(msg_params_[am::strings::initial_prompt], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + + MessageSharedPtr speak_reqeust_result_msg; + MessageSharedPtr perform_result_msg; + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_Speak)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&speak_reqeust_result_msg), Return(true))); + + // Perform audio path thru request sending + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + ON_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_PerformAudioPassThru)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true))); + + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + EXPECT_CALL( + mock_message_helper_, + CreateNegativeResponse(_, _, _, am::mobile_api::Result::GENERIC_ERROR)) + .WillOnce(Return(msg)); + + // For setting is_active_tts_speak -> true + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .Times(2) + .WillRepeatedly(Return(false)); + CallRun caller(*command_sptr_); + caller(); + + // For setting current_state_ -> kCompleted + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)); + command_sptr_->SendResponse(true, am::mobile_api::Result::SUCCESS); + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking))) + .WillOnce(Return(false)); + + command_sptr_->onTimeOut(); +} + +} // namespace perform_audio_pass_thru_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace tests diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_interaction_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_interaction_test.cc new file mode 100644 index 0000000000..2ffe9195b6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_interaction_test.cc @@ -0,0 +1,264 @@ +/* + * 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 <stdint.h> +#include <string> +#include <set> + +#include "mobile/perform_interaction_request.h" + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "utils/helpers.h" +#include "utils/make_shared.h" +#include "smart_objects/smart_object.h" +#include "utils/custom_string.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace perform_interaction_request { + +namespace am = application_manager; +using am::commands::CommandImpl; +using am::ApplicationManager; +using am::commands::MessageSharedPtr; +using am::ApplicationSharedPtr; +using am::MockMessageHelper; +using ::testing::_; +using ::utils::SharedPtr; +using ::testing::Return; +using ::testing::ReturnRef; +using sdl_rpc_plugin::commands::PerformInteractionRequest; +using ::test::components::application_manager_test::MockApplication; + +namespace strings = ::application_manager::strings; +namespace hmi_response = ::application_manager::hmi_response; + +namespace { +const int32_t kCommandId = 1; +const uint32_t kCmdId = 1u; +const uint32_t kConnectionKey = 2u; +} // namespace + +class PerformInteractionRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + PerformInteractionRequestTest() : mock_app_(CreateMockApp()) {} + + void SetUp() OVERRIDE { + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + } + + void ResultCommandExpectations(MessageSharedPtr msg, + const std::string& info) { + EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(), + true); + EXPECT_EQ( + (*msg)[am::strings::msg_params][am::strings::result_code].asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(), + info); + } + + sync_primitives::Lock lock_; + MockAppPtr mock_app_; +}; + +TEST_F(PerformInteractionRequestTest, OnTimeout_VR_GENERIC_ERROR) { + MessageSharedPtr response_msg_vr = + CreateMessage(smart_objects::SmartType_Map); + (*response_msg_vr)[strings::params][hmi_response::code] = + static_cast<uint64_t>(hmi_apis::Common_Result::SUCCESS); + (*response_msg_vr)[strings::msg_params][strings::info] = "info"; + MessageSharedPtr request_msg = CreateMessage(smart_objects::SmartType_Map); + (*request_msg)[strings::msg_params][strings::interaction_mode] = + mobile_apis::InteractionMode::BOTH; + utils::SharedPtr<PerformInteractionRequest> command = + CreateCommand<PerformInteractionRequest>(request_msg); + MockAppPtr mock_app; + + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); + + Event event(hmi_apis::FunctionID::VR_PerformInteraction); + event.set_smart_object(*response_msg_vr); + + command->Init(); + command->on_event(event); + MessageSharedPtr response_to_mobile = + CreateMessage(smart_objects::SmartType_Map); + (*response_to_mobile)[strings::msg_params][strings::result_code] = + static_cast<uint64_t>(am::mobile_api::Result::GENERIC_ERROR); + EXPECT_CALL( + mock_message_helper_, + CreateNegativeResponse(_, _, _, am::mobile_api::Result::GENERIC_ERROR)) + .WillOnce(Return(response_to_mobile)); + + MessageSharedPtr vr_command_result; + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true))); + command->onTimeOut(); + + EXPECT_EQ( + (*vr_command_result)[strings::msg_params][strings::success].asBool(), + false); + EXPECT_EQ( + (*vr_command_result)[strings::msg_params][strings::result_code].asInt(), + static_cast<int32_t>(am::mobile_api::Result::GENERIC_ERROR)); +} + +TEST_F(PerformInteractionRequestTest, + OnEvent_VRHmiSendSuccess_UNSUPPORTED_RESOURCE) { + MessageSharedPtr msg_from_mobile = + CreateMessage(smart_objects::SmartType_Map); + (*msg_from_mobile)[strings::params][strings::connection_key] = kConnectionKey; + (*msg_from_mobile)[strings::msg_params][strings::interaction_mode] = + mobile_apis::InteractionMode::VR_ONLY; + utils::SharedPtr<PerformInteractionRequest> command = + CreateCommand<PerformInteractionRequest>(msg_from_mobile); + command->Init(); + + MockAppPtr mock_app; + EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app)); + + MessageSharedPtr response_msg_vr = + CreateMessage(smart_objects::SmartType_Map); + (*response_msg_vr)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*response_msg_vr)[strings::msg_params][strings::cmd_id] = kCommandId; + (*response_msg_vr)[am::strings::msg_params][am::strings::info] = + "VR is not supported by system"; + + am::event_engine::Event event_vr(hmi_apis::FunctionID::VR_PerformInteraction); + event_vr.set_smart_object(*response_msg_vr); + + MessageSharedPtr response_msg_ui = + CreateMessage(smart_objects::SmartType_Map); + (*response_msg_ui)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + + am::event_engine::Event event_ui(hmi_apis::FunctionID::UI_PerformInteraction); + event_ui.set_smart_object(*response_msg_ui); + + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + MessageSharedPtr response_to_mobile; + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command->on_event(event_vr); + command->on_event(event_ui); + + ResultCommandExpectations(response_to_mobile, + "VR is not supported by system"); +} + +TEST_F(PerformInteractionRequestTest, + OnEvent_UIHmiSendSuccess_UNSUPPORTED_RESOURCE) { + MessageSharedPtr msg_from_mobile = + CreateMessage(smart_objects::SmartType_Map); + (*msg_from_mobile)[strings::params][strings::connection_key] = kConnectionKey; + (*msg_from_mobile)[strings::msg_params][strings::interaction_mode] = + mobile_apis::InteractionMode::VR_ONLY; + utils::SharedPtr<PerformInteractionRequest> command = + CreateCommand<PerformInteractionRequest>(msg_from_mobile); + + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + MessageSharedPtr response_msg_vr = + CreateMessage(smart_objects::SmartType_Map); + (*response_msg_vr)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + am::event_engine::Event event_vr(hmi_apis::FunctionID::VR_PerformInteraction); + event_vr.set_smart_object(*response_msg_vr); + + MessageSharedPtr response_msg_ui = + CreateMessage(smart_objects::SmartType_Map); + (*response_msg_ui)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*response_msg_ui)[strings::msg_params][strings::cmd_id] = kCommandId; + (*response_msg_ui)[am::strings::msg_params][am::strings::info] = + "UI is not supported by system"; + + am::event_engine::Event event_ui(hmi_apis::FunctionID::UI_PerformInteraction); + event_ui.set_smart_object(*response_msg_ui); + + MessageSharedPtr response_to_mobile; + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command->on_event(event_vr); + + EXPECT_CALL(*mock_app_, is_perform_interaction_active()) + .WillOnce(Return(false)); + EXPECT_CALL(*mock_app_, DeletePerformInteractionChoiceSet(_)); + + command->on_event(event_ui); + + ResultCommandExpectations(response_to_mobile, + "UI is not supported by system"); +} + +} // namespace perform_interaction_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace tests diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/put_file_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/put_file_test.cc new file mode 100644 index 0000000000..c5feeeba25 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/put_file_test.cc @@ -0,0 +1,407 @@ +/* + * 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 <stdint.h> +#include <string> +#include <vector> + +#include "gtest/gtest.h" + +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" + +#include "mobile/put_file_response.h" +#include "mobile/put_file_request.h" + +#include "utils/make_shared.h" +#include "utils/file_system.h" +#include "smart_objects/smart_object.h" +#include "interfaces/MOBILE_API.h" +#include "application_manager/application.h" +#include "application_manager/mock_application.h" +#include "application_manager/policies/mock_policy_handler_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace put_file { + +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::AtLeast; + +namespace am = ::application_manager; + +using sdl_rpc_plugin::commands::PutFileRequest; +using sdl_rpc_plugin::commands::PutFileResponse; +using am::commands::MessageSharedPtr; +using policy_test::MockPolicyHandlerInterface; + +typedef SharedPtr<PutFileRequest> PutFileRequestPtr; +typedef SharedPtr<PutFileResponse> PutFileResponsePtr; + +namespace { +const uint32_t kConnectionKey = 1u; +const std::string kFileName = "sync_file_name.txt"; +const int64_t kOffset = 10u; +const int64_t kZeroOffset = 0u; +const std::string kStorageFolder = "./storage"; +const std::string kFolder = "folder"; +const std::string kAppFolder = "app_folder"; +} + +class PutFileRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + PutFileRequestTest() + : msg_(CreateMessage(::smart_objects::SmartType_Map)) + , mock_app_(CreateMockApp()) {} + + void SetUp() OVERRIDE { + binary_data_.push_back(1u); + + (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg_)[am::strings::msg_params][am::strings::sync_file_name] = kFileName; + (*msg_)[am::strings::msg_params][am::strings::persistent_file] = true; + (*msg_)[am::strings::msg_params][am::strings::file_type] = + mobile_apis::FileType::JSON; + (*msg_)[am::strings::params][am::strings::binary_data] = binary_data_; + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, hmi_level()) + .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); + } + + void ExpectReceiveMessageFromSDK() { + EXPECT_CALL(mock_policy_handler_, + ReceiveMessageFromSDK(kFileName, binary_data_)) + .WillOnce(Return(false)); + } + void ExpectManageMobileCommandWithResultCode( + const mobile_apis::Result::eType code) { + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(code), + am::commands::Command::CommandSource::SOURCE_SDL)); + } + + MessageSharedPtr msg_; + MockAppPtr mock_app_; + std::vector<uint8_t> binary_data_; +}; + +class PutFileResponceTest : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + PutFileResponceTest() : message_(CreateMessage()) {} + + void SetUp() OVERRIDE { + command_sptr_ = CreateCommand<PutFileResponse>(message_); + } + + MessageSharedPtr message_; + SharedPtr<PutFileResponse> command_sptr_; +}; + +TEST_F(PutFileResponceTest, Run_InvalidApp_ApplicationNotRegisteredResponce) { + ::smart_objects::SmartObject& message_ref = *message_; + + message_ref[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + utils::SharedPtr<am::Application> null_application_sptr; + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(null_application_sptr)); + EXPECT_CALL( + mock_rpc_service_, + SendMessageToMobile( + MobileResultCodeIs(mobile_apis::Result::APPLICATION_NOT_REGISTERED), + _)); + command_sptr_->Run(); +} + +TEST_F(PutFileResponceTest, Run_ApplicationRegistered_Success) { + ::smart_objects::SmartObject& message_ref = *message_; + + message_ref[am::strings::params][am::strings::connection_key] = + kConnectionKey; + message_ref[am::strings::msg_params][am::strings::success] = true; + + utils::SharedPtr<am::Application> application_sptr = + utils::MakeShared<MockApplication>(); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(application_sptr)); + EXPECT_CALL( + mock_rpc_service_, + SendMessageToMobile(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)); + command_sptr_->Run(); +} + +TEST_F(PutFileRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(ApplicationSharedPtr())); + ExpectManageMobileCommandWithResultCode( + mobile_apis::Result::APPLICATION_NOT_REGISTERED); + + PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_)); + command->Run(); +} + +TEST_F(PutFileRequestTest, Run_HmiLevelNone_UNSUCCESS) { + EXPECT_CALL(*mock_app_, hmi_level()) + .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE)); + + const uint32_t settings_put_file_in_none = 1u; + const uint32_t app_put_file_in_none_count = 2u; + EXPECT_CALL(app_mngr_settings_, put_file_in_none()) + .WillOnce(ReturnRef(settings_put_file_in_none)); + EXPECT_CALL(*mock_app_, put_file_in_none_count()) + .WillOnce(Return(app_put_file_in_none_count)); + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::REJECTED); + + PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_)); + command->Run(); +} + +TEST_F(PutFileRequestTest, Run_BinaryDataDoesNotExists_UNSUCCESS) { + (*msg_)[am::strings::params].erase(am::strings::binary_data); + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA); + + PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_)); + command->Run(); +} + +TEST_F(PutFileRequestTest, Run_SyncFileNameDoesNotExists_UNSUCCESS) { + (*msg_)[am::strings::msg_params].erase(am::strings::sync_file_name); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA); + + PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_)); + command->Run(); +} + +TEST_F(PutFileRequestTest, Run_FileTypeDoesNotExists_UNSUCCESS) { + (*msg_)[am::strings::msg_params].erase(am::strings::file_type); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA); + + PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_)); + command->Run(); +} + +TEST_F(PutFileRequestTest, Run_BinaryDataGreaterThanAvaliableSpace_UNSUCCESS) { + (*msg_)[am::strings::msg_params][am::strings::offset] = kOffset; + (*msg_)[am::strings::msg_params][am::strings::system_file] = false; + + ExpectReceiveMessageFromSDK(); + EXPECT_CALL(app_mngr_settings_, app_storage_folder()) + .WillOnce(ReturnRef(kStorageFolder)); + EXPECT_CALL(*mock_app_, folder_name()).WillOnce(Return(kAppFolder)); + + const uint32_t avaliable_space = 0u; + EXPECT_CALL(*mock_app_, GetAvailableDiskSpace()) + .WillOnce(Return(avaliable_space)); + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::OUT_OF_MEMORY); + + PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_)); + command->Run(); +} + +TEST_F(PutFileRequestTest, Run_IvalidCreationDirectory_UNSUCCESS) { + (*msg_)[am::strings::msg_params][am::strings::offset] = kOffset; + (*msg_)[am::strings::msg_params][am::strings::system_file] = true; + + ExpectReceiveMessageFromSDK(); + + const std::string storage_folder = "/storage"; + EXPECT_CALL(app_mngr_settings_, system_files_path()) + .WillOnce(ReturnRef(storage_folder)); + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::GENERIC_ERROR); + + PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_)); + command->Run(); +} + +TEST_F(PutFileRequestTest, Run_IvalidUpdateFile_UNSUCCESS) { + (*msg_)[am::strings::msg_params][am::strings::offset] = kZeroOffset; + (*msg_)[am::strings::msg_params][am::strings::system_file] = false; + + ExpectReceiveMessageFromSDK(); + EXPECT_CALL(app_mngr_settings_, app_storage_folder()) + .WillOnce(ReturnRef(kStorageFolder)); + EXPECT_CALL(*mock_app_, folder_name()).WillOnce(Return(kAppFolder)); + + const uint32_t avaliable_space = 2u; + EXPECT_CALL(*mock_app_, GetAvailableDiskSpace()) + .WillOnce(Return(avaliable_space)) + .WillOnce(Return(avaliable_space)); + + const std::string file_path = kStorageFolder + "/" + kAppFolder; + EXPECT_CALL(app_mngr_, + SaveBinary(binary_data_, file_path, kFileName, kZeroOffset)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(*mock_app_, AddFile(_)).WillOnce(Return(false)); + EXPECT_CALL(*mock_app_, UpdateFile(_)).WillOnce(Return(false)); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA); + + PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_)); + command->Run(); +} + +TEST_F(PutFileRequestTest, Run_AddFile_SUCCESS) { + (*msg_)[am::strings::msg_params][am::strings::offset] = kZeroOffset; + (*msg_)[am::strings::msg_params][am::strings::system_file] = false; + + ExpectReceiveMessageFromSDK(); + EXPECT_CALL(app_mngr_settings_, app_storage_folder()) + .WillOnce(ReturnRef(kStorageFolder)); + EXPECT_CALL(*mock_app_, folder_name()).WillOnce(Return(kAppFolder)); + + const uint32_t avaliable_space = 2u; + EXPECT_CALL(*mock_app_, GetAvailableDiskSpace()) + .WillOnce(Return(avaliable_space)) + .WillOnce(Return(avaliable_space)); + + const std::string file_path = kStorageFolder + "/" + kAppFolder; + EXPECT_CALL(app_mngr_, + SaveBinary(binary_data_, file_path, kFileName, kZeroOffset)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(*mock_app_, AddFile(_)).WillOnce(Return(true)); + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::SUCCESS); + + PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_)); + command->Run(); +} + +TEST_F(PutFileRequestTest, Run_SendOnPutFileNotification_SUCCESS) { + (*msg_)[am::strings::msg_params][am::strings::offset] = kZeroOffset; + (*msg_)[am::strings::msg_params][am::strings::system_file] = true; + + ExpectReceiveMessageFromSDK(); + EXPECT_CALL(app_mngr_settings_, system_files_path()) + .WillOnce(ReturnRef(kStorageFolder)); + EXPECT_CALL(app_mngr_, + SaveBinary(binary_data_, kStorageFolder, kFileName, kZeroOffset)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::BasicCommunication_OnPutFile))) + .WillOnce(Return(true)); + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::SUCCESS); + + PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_)); + command->Run(); +} + +TEST_F(PutFileRequestTest, Run_InvalidPutFile_UNSUCCESS) { + (*msg_)[am::strings::msg_params][am::strings::offset] = kZeroOffset; + (*msg_)[am::strings::msg_params][am::strings::system_file] = true; + + ExpectReceiveMessageFromSDK(); + EXPECT_CALL(app_mngr_settings_, system_files_path()) + .WillOnce(ReturnRef(kStorageFolder)); + EXPECT_CALL(app_mngr_, + SaveBinary(binary_data_, kStorageFolder, kFileName, kZeroOffset)) + .WillOnce(Return(mobile_apis::Result::INVALID_DATA)); + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA); + + PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_)); + command->Run(); +} + +TEST_F(PutFileRequestTest, Run_CrcSumEqual_SendSuccessResponse) { + binary_data_ = {1u}; + (*msg_)[am::strings::params][am::strings::binary_data] = binary_data_; + const uint32_t correct_crc_sum = + 2768625435u; // calculated using the GetCrc32CheckSum method + (*msg_)[am::strings::msg_params][am::strings::crc32_check_sum] = + correct_crc_sum; + + ExpectReceiveMessageFromSDK(); + ON_CALL(app_mngr_, get_settings()) + .WillByDefault(ReturnRef(app_mngr_settings_)); + ON_CALL(app_mngr_settings_, app_storage_folder()) + .WillByDefault(ReturnRef(kStorageFolder)); + ON_CALL(*mock_app_, folder_name()).WillByDefault(Return(kFolder)); + const size_t available_space = binary_data_.size() + 1; + ON_CALL(*mock_app_, GetAvailableDiskSpace()) + .WillByDefault(Return(available_space)); + ON_CALL(*mock_app_, AddFile(_)).WillByDefault(Return(true)); + + const std::string file_path = kStorageFolder + "/" + kFolder; + EXPECT_CALL(app_mngr_, SaveBinary(binary_data_, file_path, kFileName, 0u)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(*mock_app_, increment_put_file_in_none_count()); + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::SUCCESS); + PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_)); + ASSERT_TRUE(command->Init()); + command->Run(); + // The folder was created in the "Run" method + EXPECT_TRUE(file_system::RemoveDirectory(kStorageFolder, true)); +} + +TEST_F(PutFileRequestTest, Run_CrcSumUnequal_SendCorruptedDataResponse) { + binary_data_ = {1u}; + (*msg_)[am::strings::params][am::strings::binary_data] = binary_data_; + const uint32_t incorrect_crc_sum = 0u; + (*msg_)[am::strings::msg_params][am::strings::crc32_check_sum] = + incorrect_crc_sum; + + ExpectReceiveMessageFromSDK(); + ON_CALL(app_mngr_, get_settings()) + .WillByDefault(ReturnRef(app_mngr_settings_)); + ON_CALL(app_mngr_settings_, app_storage_folder()) + .WillByDefault(ReturnRef(kStorageFolder)); + ON_CALL(*mock_app_, folder_name()).WillByDefault(Return(kFolder)); + const size_t available_space = binary_data_.size() + 1; + ON_CALL(*mock_app_, GetAvailableDiskSpace()) + .WillByDefault(Return(available_space)); + ON_CALL(*mock_app_, AddFile(_)).WillByDefault(Return(true)); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::CORRUPTED_DATA); + EXPECT_CALL(app_mngr_, SaveBinary(_, _, _, _)).Times(0); + PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_)); + ASSERT_TRUE(command->Init()); + command->Run(); + // The folder was created in the "Run" method + EXPECT_TRUE(file_system::RemoveDirectory(kStorageFolder, true)); +} + +} // namespace put_file +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc new file mode 100644 index 0000000000..8b21ceff17 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc @@ -0,0 +1,526 @@ +/* + * 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 <stdint.h> +#include <string> +#include <vector> + +#include "gtest/gtest.h" +#include "mobile/register_app_interface_request.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_helper.h" +#include "interfaces/MOBILE_API.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "protocol_handler/mock_session_observer.h" +#include "connection_handler/mock_connection_handler.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_resume_ctrl.h" +#include "application_manager/mock_hmi_interface.h" +#include "utils/data_accessor.h" +#include "utils/custom_string.h" +#include "utils/lock.h" +#include "utils/macro.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace register_app_interface_request { + +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::DoAll; + +namespace am = ::application_manager; + +using ::utils::SharedPtr; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::RegisterAppInterfaceRequest; + +namespace { +const uint32_t kConnectionKey = 1u; +const hmi_apis::Common_Language::eType kHmiLanguage = + hmi_apis::Common_Language::EN_US; +const mobile_apis::Language::eType kMobileLanguage = + mobile_apis::Language::EN_US; +const std::string kMacAddress = "test_mac_address"; +const std::string kAppId = "test_app_id"; +const std::string kDummyString = "test_string"; +const std::vector<uint32_t> kDummyDiagModes; +} // namespace + +class RegisterAppInterfaceRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + RegisterAppInterfaceRequestTest() + : msg_(CreateMessage()) + , command_(CreateCommand<RegisterAppInterfaceRequest>(msg_)) + , app_name_("test_app_name_") + , lock_ptr_(std::make_shared<sync_primitives::Lock>()) + , mock_application_helper_( + application_manager_test::MockApplicationHelper:: + application_helper_mock()) { + InitGetters(); + InitLanguage(); + } + + void SetUp() OVERRIDE { + testing::Mock::VerifyAndClearExpectations(&mock_application_helper_); + } + + void TearDown() OVERRIDE { + testing::Mock::VerifyAndClearExpectations(&mock_application_helper_); + } + + void InitBasicMessage() { + (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg_)[am::strings::msg_params][am::strings::app_id] = kAppId; + (*msg_)[am::strings::msg_params][am::strings::app_name] = app_name_; + (*msg_)[am::strings::msg_params][am::strings::language_desired] = + kHmiLanguage; + (*msg_)[am::strings::msg_params] + [am::strings::hmi_display_language_desired] = kHmiLanguage; + } + + MockAppPtr CreateBasicMockedApp() { + MockAppPtr mock_app = CreateMockApp(); + ON_CALL(*mock_app, name()).WillByDefault(ReturnRef(app_name_)); + ON_CALL(*mock_app, mac_address()).WillByDefault(ReturnRef(kMacAddress)); + ON_CALL(*mock_app, app_icon_path()).WillByDefault(ReturnRef(kDummyString)); + ON_CALL(*mock_app, language()).WillByDefault(ReturnRef(kMobileLanguage)); + ON_CALL(*mock_app, ui_language()).WillByDefault(ReturnRef(kMobileLanguage)); + ON_CALL(*mock_app, policy_app_id()).WillByDefault(Return(kAppId)); + return mock_app; + } + + void InitLanguage( + hmi_apis::Common_Language::eType ui_language = kHmiLanguage, + hmi_apis::Common_Language::eType vr_language = kHmiLanguage, + hmi_apis::Common_Language::eType tts_language = kHmiLanguage) { + ON_CALL(mock_hmi_capabilities_, active_vr_language()) + .WillByDefault(Return(vr_language)); + ON_CALL(mock_hmi_capabilities_, active_ui_language()) + .WillByDefault(Return(ui_language)); + ON_CALL(mock_hmi_capabilities_, active_tts_language()) + .WillByDefault(Return(tts_language)); + } + + void InitGetters() { + ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(true)); + ON_CALL(app_mngr_, resume_controller()) + .WillByDefault(ReturnRef(mock_resume_crt_)); + ON_CALL(app_mngr_, connection_handler()) + .WillByDefault(ReturnRef(mock_connection_handler_)); + ON_CALL(mock_connection_handler_, get_session_observer()) + .WillByDefault(ReturnRef(mock_session_observer_)); + ON_CALL(app_mngr_settings_, sdl_version()) + .WillByDefault(ReturnRef(kDummyString)); + ON_CALL(mock_hmi_capabilities_, ccpu_version()) + .WillByDefault(ReturnRef(kDummyString)); + ON_CALL(app_mngr_settings_, supported_diag_modes()) + .WillByDefault(ReturnRef(kDummyDiagModes)); + ON_CALL(mock_policy_handler_, GetAppRequestTypes(_)) + .WillByDefault(Return(std::vector<std::string>())); + ON_CALL(mock_policy_handler_, GetAppRequestTypeState(_)) + .WillByDefault(Return(policy::RequestType::State::EMPTY)); + ON_CALL(mock_policy_handler_, GetAppRequestSubTypes(_)) + .WillByDefault(Return(std::vector<std::string>())); + ON_CALL(mock_policy_handler_, GetAppRequestSubTypeState(_)) + .WillByDefault(Return(policy::RequestSubType::State::EMPTY)); + ON_CALL(mock_policy_handler_, GetUserConsentForDevice(_)) + .WillByDefault(Return(policy::DeviceConsent::kDeviceAllowed)); + ON_CALL(app_mngr_, GetDeviceTransportType(_)) + .WillByDefault(Return(hmi_apis::Common_TransportType::WIFI)); + ON_CALL(app_mngr_, IsAppInReconnectMode(_)).WillByDefault(Return(false)); + ON_CALL(app_mngr_, application_by_policy_id(_)) + .WillByDefault(Return(ApplicationSharedPtr())); + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + ON_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR)); + ON_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_ChangeRegistration)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); + ON_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_ChangeRegistration)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + } + + void SetCommonExpectionsOnSwitchedApplication( + MockAppPtr mock_app, mobile_apis::Result::eType response_result_code) { + EXPECT_CALL(mock_policy_handler_, AddApplication(_, _)).Times(0); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(response_result_code), _)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::BasicCommunication_OnAppRegistered))) + .Times(0); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::Buttons_OnButtonSubscription))) + .Times(0); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::UI_ChangeRegistration))).Times(0); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::TTS_ChangeRegistration))).Times(0); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::VR_ChangeRegistration))).Times(0); + + EXPECT_CALL( + app_mngr_, + OnApplicationSwitched( + MockAppPtr::static_pointer_cast<application_manager::Application>( + mock_app))); + } + + MessageSharedPtr msg_; + SharedPtr<RegisterAppInterfaceRequest> command_; + + const utils::custom_string::CustomString app_name_; + std::shared_ptr<sync_primitives::Lock> lock_ptr_; + am::ApplicationSet app_set_; + + typedef IsNiceMock<policy_test::MockPolicyHandlerInterface, + kMocksAreNice>::Result MockPolicyHandlerInterface; + + typedef IsNiceMock<resumprion_test::MockResumeCtrl, kMocksAreNice>::Result + MockResumeCtrl; + + typedef IsNiceMock<connection_handler_test::MockConnectionHandler, + kMocksAreNice>::Result MockConnectionHandler; + + typedef IsNiceMock<protocol_handler_test::MockSessionObserver, + kMocksAreNice>::Result MockSessionObserver; + + typedef IsNiceMock<application_manager_test::MockHMICapabilities, + kMocksAreNice>::Result MockHMICapabilities; + + MockResumeCtrl mock_resume_crt_; + MockConnectionHandler mock_connection_handler_; + MockSessionObserver mock_session_observer_; + application_manager_test::MockApplicationHelper& mock_application_helper_; +}; + +TEST_F(RegisterAppInterfaceRequestTest, Init_SUCCESS) { + EXPECT_TRUE(command_->Init()); +} + +TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) { + InitBasicMessage(); + (*msg_)[am::strings::msg_params][am::strings::hash_id] = kAppId; + EXPECT_CALL(app_mngr_, IsStopping()) + .WillOnce(Return(false)) + .WillOnce(Return(true)) + .WillOnce(Return(false)); + ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(false)); + EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); + EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false)); + + MockAppPtr mock_app = CreateBasicMockedApp(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(ApplicationSharedPtr())) + .WillRepeatedly(Return(mock_app)); + + ON_CALL(app_mngr_, applications()) + .WillByDefault( + Return(DataAccessor<am::ApplicationSet>(app_set_, lock_ptr_))); + ON_CALL(mock_policy_handler_, PolicyEnabled()).WillByDefault(Return(true)); + ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId, _, _)) + .WillByDefault(Return(true)); + policy::StatusNotifier notify_upd_manager = + utils::MakeShared<utils::CallNothing>(); + ON_CALL(mock_policy_handler_, AddApplication(_, _)) + .WillByDefault(Return(notify_upd_manager)); + + EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).WillOnce(Return(mock_app)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::BasicCommunication_OnAppRegistered))) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::Buttons_OnButtonSubscription))) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) + .Times(2); + command_->Run(); +} + +MATCHER_P(CheckHMIInterfacesRealtedData, expected_data, "") { + const bool is_result_id_correct = + mobile_apis::Result::SUCCESS == + static_cast<mobile_apis::Result::eType>( + (*arg)[am::strings::msg_params][am::strings::result_code].asInt()); + + const bool are_ui_related_data_exist = + (*arg)[am::strings::msg_params].keyExists( + am::hmi_response::display_capabilities); + + const bool are_vi_related_data_exist = + (*arg)[am::strings::msg_params][am::hmi_response::vehicle_type] == + (*expected_data)[am::hmi_response::vehicle_type]; + + const bool are_vr_related_data_exist = + (*arg)[am::strings::msg_params][am::strings::vr_capabilities] == + (*expected_data)[am::strings::vr_capabilities]; + + return is_result_id_correct && are_ui_related_data_exist && + are_vi_related_data_exist && are_vr_related_data_exist; +} + +TEST_F(RegisterAppInterfaceRequestTest, + Run_HmiInterfacesStateAvailable_SUCCESS) { + InitBasicMessage(); + + EXPECT_CALL(app_mngr_, IsStopping()) + .WillOnce(Return(false)) + .WillOnce(Return(true)) + .WillOnce(Return(false)); + ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(false)); + EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); + EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false)); + + MockAppPtr mock_app = CreateBasicMockedApp(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(ApplicationSharedPtr())) + .WillRepeatedly(Return(mock_app)); + + MessageSharedPtr expected_message = + CreateMessage(smart_objects::SmartType_Map); + + (*expected_message)[am::hmi_response::vehicle_type] = "test_vehicle_type"; + (*expected_message)[am::strings::vr_capabilities] = "test_vr_capabilities"; + (*expected_message)[am::hmi_response::display_capabilities] = 0; + SmartObject& display_capabilities = + (*expected_message)[am::hmi_response::display_capabilities]; + display_capabilities[am::hmi_response::display_type] = "test_display_type"; + display_capabilities[am::hmi_response::display_name] = "GENERIC_DISPLAY"; + display_capabilities[am::hmi_response::text_fields] = "test_text_fields"; + display_capabilities[am::hmi_response::image_fields] = "test_image_fields"; + display_capabilities[am::hmi_response::media_clock_formats] = + "test_media_clock_ptr_formats"; + display_capabilities[am::hmi_response::num_custom_presets_available] = + "test_num_custom_presets_available"; + display_capabilities[am::hmi_response::graphic_supported] = + "test_graphic_supported"; + display_capabilities[am::hmi_response::templates_available] = + "test_templates_available"; + display_capabilities[am::hmi_response::screen_params] = "test_screen_params"; + + ON_CALL(mock_hmi_capabilities_, vehicle_type()) + .WillByDefault( + Return(&(*expected_message)[am::hmi_response::vehicle_type])); + ON_CALL(mock_hmi_capabilities_, vr_capabilities()) + .WillByDefault( + Return(&(*expected_message)[am::strings::vr_capabilities])); + ON_CALL(mock_hmi_capabilities_, display_capabilities()) + .WillByDefault( + Return(&(*expected_message)[am::hmi_response::display_capabilities])); + + ON_CALL(app_mngr_, applications()) + .WillByDefault( + Return(DataAccessor<am::ApplicationSet>(app_set_, lock_ptr_))); + ON_CALL(mock_policy_handler_, PolicyEnabled()).WillByDefault(Return(true)); + ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId, _, _)) + .WillByDefault(Return(true)); + policy::StatusNotifier notify_upd_manager = + utils::MakeShared<utils::CallNothing>(); + ON_CALL(mock_policy_handler_, AddApplication(_, _)) + .WillByDefault(Return(notify_upd_manager)); + + EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).WillOnce(Return(mock_app)); + + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::BasicCommunication_OnAppRegistered))) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::Buttons_OnButtonSubscription))) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_ChangeRegistration))) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::TTS_ChangeRegistration))) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_ChangeRegistration))) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) + .Times(2); + + command_->Run(); +} + +TEST_F(RegisterAppInterfaceRequestTest, + SwitchApplication_CorrectHash_ExpectNoCleanupSuccess) { + InitBasicMessage(); + + const std::string request_hash_id = "abc123"; + (*msg_)[am::strings::msg_params][am::strings::hash_id] = request_hash_id; + + MockAppPtr mock_app = CreateBasicMockedApp(); + EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId)) + .WillRepeatedly(Return(mock_app)); + + EXPECT_CALL(app_mngr_, IsAppInReconnectMode(kAppId)).WillOnce(Return(true)); + + EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey)); + + EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).Times(0); + + EXPECT_CALL( + mock_resume_crt_, + CheckApplicationHash( + MockAppPtr::static_pointer_cast<application_manager::Application>( + mock_app), + request_hash_id)).WillOnce(Return(true)); + + EXPECT_CALL(mock_resume_crt_, RemoveApplicationFromSaved(_)).Times(0); + + EXPECT_CALL(mock_application_helper_, RecallApplicationData(_, _)).Times(0); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillRepeatedly(Return(mock_app)); + + SetCommonExpectionsOnSwitchedApplication(mock_app, + mobile_apis::Result::SUCCESS); + + command_->Run(); +} + +TEST_F(RegisterAppInterfaceRequestTest, + SwitchApplication_WrongHash_ExpectCleanupResumeFailed) { + InitBasicMessage(); + + const std::string request_hash_id = "abc123"; + (*msg_)[am::strings::msg_params][am::strings::hash_id] = request_hash_id; + + MockAppPtr mock_app = CreateBasicMockedApp(); + EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId)) + .WillRepeatedly(Return(mock_app)); + + EXPECT_CALL(app_mngr_, IsAppInReconnectMode(kAppId)).WillOnce(Return(true)); + + EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey)); + + EXPECT_CALL( + mock_resume_crt_, + CheckApplicationHash( + MockAppPtr::static_pointer_cast<application_manager::Application>( + mock_app), + request_hash_id)).WillOnce(Return(false)); + + EXPECT_CALL( + mock_application_helper_, + RecallApplicationData( + MockAppPtr::static_pointer_cast<application_manager::Application>( + mock_app), + _)); + + EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).Times(0); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillRepeatedly(Return(mock_app)); + + SetCommonExpectionsOnSwitchedApplication(mock_app, + mobile_apis::Result::RESUME_FAILED); + + command_->Run(); +} + +TEST_F(RegisterAppInterfaceRequestTest, + SwitchApplication_NoHash_ExpectCleanupResumeFailed) { + InitBasicMessage(); + + MockAppPtr mock_app = CreateBasicMockedApp(); + EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId)) + .WillRepeatedly(Return(mock_app)); + + EXPECT_CALL(app_mngr_, IsAppInReconnectMode(kAppId)).WillOnce(Return(true)); + + EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey)); + + EXPECT_CALL( + mock_application_helper_, + RecallApplicationData( + MockAppPtr::static_pointer_cast<application_manager::Application>( + mock_app), + _)); + + EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).Times(0); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillRepeatedly(Return(mock_app)); + + SetCommonExpectionsOnSwitchedApplication(mock_app, + mobile_apis::Result::RESUME_FAILED); + + command_->Run(); +} + +} // namespace register_app_interface_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc new file mode 100644 index 0000000000..4cdf4f8858 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc @@ -0,0 +1,576 @@ +/* + * 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 <stdint.h> +#include <string> +#include <vector> + +#include "mobile/reset_global_properties_request.h" +#include "mobile/reset_global_properties_response.h" + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "utils/make_shared.h" +#include "smart_objects/smart_object.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace reset_global_properties { + +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +namespace am = ::application_manager; + +using sdl_rpc_plugin::commands::ResetGlobalPropertiesRequest; +using sdl_rpc_plugin::commands::ResetGlobalPropertiesResponse; +using am::commands::MessageSharedPtr; +using am::event_engine::Event; +using am::MockMessageHelper; + +typedef SharedPtr<ResetGlobalPropertiesRequest> ResetGlobalPropertiesRequestPtr; +typedef SharedPtr<ResetGlobalPropertiesResponse> + ResetGlobalPropertiesResponsePtr; + +namespace { +const uint32_t kConnectionKey = 2u; +const uint32_t kCorrelationId = 10u; +} // namespace + +class ResetGlobalPropertiesRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + protected: + ResetGlobalPropertiesRequestTest() + : msg_(CreateMessage()), mock_app_(CreateMockApp()) {} + + void SetUp() OVERRIDE { + (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg_)[am::strings::params][am::strings::correlation_id] = kCorrelationId; + + command_ = CreateCommand<ResetGlobalPropertiesRequest>(msg_); + + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kCorrelationId)); + } + + MessageSharedPtr msg_; + MockAppPtr mock_app_; + ResetGlobalPropertiesRequestPtr command_; +}; + +class ResetGlobalPropertiesResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(ResetGlobalPropertiesRequestTest, Run_InvalidApp_UNSUCCESS) { + MockAppPtr invalid_app; + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app)); + + MessageSharedPtr command_result; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&command_result), Return(true))); + + command_->Run(); + EXPECT_EQ( + (*command_result)[am::strings::msg_params][am::strings::success].asBool(), + false); + EXPECT_EQ( + (*command_result)[am::strings::msg_params][am::strings::result_code] + .asInt(), + static_cast<int32_t>(mobile_apis::Result::APPLICATION_NOT_REGISTERED)); +} + +TEST_F(ResetGlobalPropertiesRequestTest, Run_InvalidVrHelp_UNSUCCESS) { + (*msg_)[am::strings::msg_params][am::strings::properties][0] = + mobile_apis::GlobalProperty::HELPPROMPT; + (*msg_)[am::strings::msg_params][am::strings::properties][1] = + mobile_apis::GlobalProperty::TIMEOUTPROMPT; + (*msg_)[am::strings::msg_params][am::strings::properties][2] = + mobile_apis::GlobalProperty::VRHELPTITLE; + (*msg_)[am::strings::msg_params][am::strings::properties][3] = + mobile_apis::GlobalProperty::MENUNAME; + (*msg_)[am::strings::msg_params][am::strings::properties][4] = + mobile_apis::GlobalProperty::MENUICON; + (*msg_)[am::strings::msg_params][am::strings::properties][5] = + mobile_apis::GlobalProperty::KEYBOARDPROPERTIES; + + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + smart_objects::SmartObject so_prompt = + smart_objects::SmartObject(smart_objects::SmartType_Array); + EXPECT_CALL(*mock_app_, set_help_prompt(so_prompt)); + + std::vector<std::string> time_out_prompt; + time_out_prompt.push_back("time_out"); + EXPECT_CALL(app_mngr_settings_, time_out_promt()) + .WillOnce(ReturnRef(time_out_prompt)); + + smart_objects::SmartObject timeout_prompt = + smart_objects::SmartObject(smart_objects::SmartType_Map); + timeout_prompt[am::strings::text] = time_out_prompt[0]; + timeout_prompt[am::strings::type] = + hmi_apis::Common_SpeechCapabilities::SC_TEXT; + + smart_objects::SmartObject so_time_out_prompt = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + so_time_out_prompt[0] = timeout_prompt; + + EXPECT_CALL(*mock_app_, set_timeout_prompt(so_time_out_prompt)); + + EXPECT_CALL(*mock_app_, reset_vr_help_title()); + EXPECT_CALL(*mock_app_, reset_vr_help()); + + EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); + + smart_objects::SmartObjectSPtr vr_help; // = NULL; + EXPECT_CALL(mock_message_helper_, CreateAppVrHelp(_)) + .WillOnce(Return(vr_help)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + + command_->Run(); +} + +TEST_F(ResetGlobalPropertiesRequestTest, Run_SUCCESS) { + (*msg_)[am::strings::msg_params][am::strings::properties][0] = + mobile_apis::GlobalProperty::HELPPROMPT; + (*msg_)[am::strings::msg_params][am::strings::properties][1] = + mobile_apis::GlobalProperty::TIMEOUTPROMPT; + (*msg_)[am::strings::msg_params][am::strings::properties][2] = + mobile_apis::GlobalProperty::VRHELPTITLE; + (*msg_)[am::strings::msg_params][am::strings::properties][3] = + mobile_apis::GlobalProperty::MENUNAME; + (*msg_)[am::strings::msg_params][am::strings::properties][4] = + mobile_apis::GlobalProperty::MENUICON; + (*msg_)[am::strings::msg_params][am::strings::properties][5] = + mobile_apis::GlobalProperty::KEYBOARDPROPERTIES; + + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + smart_objects::SmartObject so_prompt = + smart_objects::SmartObject(smart_objects::SmartType_Array); + EXPECT_CALL(*mock_app_, set_help_prompt(so_prompt)); + + std::vector<std::string> time_out_prompt; + time_out_prompt.push_back("time_out"); + EXPECT_CALL(app_mngr_settings_, time_out_promt()) + .WillOnce(ReturnRef(time_out_prompt)); + + smart_objects::SmartObject timeout_prompt = + smart_objects::SmartObject(smart_objects::SmartType_Map); + timeout_prompt[am::strings::text] = time_out_prompt[0]; + timeout_prompt[am::strings::type] = + hmi_apis::Common_SpeechCapabilities::SC_TEXT; + + smart_objects::SmartObject so_time_out_prompt = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + so_time_out_prompt[0] = timeout_prompt; + + EXPECT_CALL(*mock_app_, set_timeout_prompt(so_time_out_prompt)); + + EXPECT_CALL(*mock_app_, reset_vr_help_title()); + EXPECT_CALL(*mock_app_, reset_vr_help()); + + EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); + + smart_objects::SmartObjectSPtr vr_help = + ::utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); + EXPECT_CALL(mock_message_helper_, CreateAppVrHelp(_)) + .WillOnce(Return(vr_help)); + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[am::hmi_request::menu_title] = ""; + + EXPECT_CALL(*mock_app_, + set_menu_title(msg_params[am::hmi_request::menu_title])); + + const smart_objects::SmartObjectSPtr so_help_prompt = + ::utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); + EXPECT_CALL(*mock_app_, help_prompt()).WillOnce(Return(so_help_prompt.get())); + EXPECT_CALL(*mock_app_, timeout_prompt()) + .WillOnce(Return(so_help_prompt.get())); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::UI_SetGlobalProperties))) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::TTS_SetGlobalProperties))) + .WillOnce(Return(true)); + + command_->Run(); +} + +TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_InvalidEventId_UNSUCCESS) { + Event event(hmi_apis::FunctionID::INVALID_ENUM); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + command_->on_event(event); +} + +TEST_F(ResetGlobalPropertiesRequestTest, + OnEvent_UI_SetGlobalProperties_SUCCESS) { + Event event(hmi_apis::FunctionID::UI_SetGlobalProperties); + const hmi_apis::Common_Result::eType result_code = + hmi_apis::Common_Result::SUCCESS; + (*msg_)[am::strings::params][am::hmi_response::code] = result_code; + + (*msg_)[am::strings::msg_params][am::strings::properties][0] = + mobile_apis::GlobalProperty::VRHELPTITLE; + + EXPECT_CALL(*mock_app_, reset_vr_help_title()); + EXPECT_CALL(*mock_app_, reset_vr_help()); + EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); + + smart_objects::SmartObjectSPtr vr_help = + ::utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); + EXPECT_CALL(mock_message_helper_, CreateAppVrHelp(_)) + .WillOnce(Return(vr_help)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::UI_SetGlobalProperties))) + .WillOnce(Return(true)); + + command_->Run(); + + event.set_smart_object(*msg_); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::eType::SUCCESS), + am::commands::Command::SOURCE_SDL)); + + command_->on_event(event); +} + +TEST_F(ResetGlobalPropertiesRequestTest, + OnEvent_TTS_SetGlobalProperties_SUCCESS) { + Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties); + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::UNSUPPORTED_RESOURCE; + + (*msg_)[am::strings::msg_params][am::strings::properties][0] = + mobile_apis::GlobalProperty::TIMEOUTPROMPT; + (*msg_)[am::strings::msg_params][am::strings::properties][1] = + mobile_apis::GlobalProperty::MENUICON; + + std::vector<std::string> time_out_prompt; + time_out_prompt.push_back("time_out"); + EXPECT_CALL(app_mngr_settings_, time_out_promt()) + .WillOnce(ReturnRef(time_out_prompt)); + + EXPECT_CALL(*mock_app_, set_timeout_prompt(_)); + + smart_objects::SmartObjectSPtr prompt = + utils::MakeShared<smart_objects::SmartObject>(); + *prompt = "prompt"; + + EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(prompt.get())); + + EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); + + MessageSharedPtr ui_msg = CreateMessage(); + (*ui_msg)[am::strings::params][am::strings::correlation_id] = kCorrelationId; + (*ui_msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::SUCCESS; + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::UI_SetGlobalProperties))) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::TTS_SetGlobalProperties))) + .WillOnce(Return(true)); + Event ui_event(hmi_apis::FunctionID::UI_SetGlobalProperties); + ui_event.set_smart_object(*ui_msg); + + command_->Run(); + command_->on_event(ui_event); + event.set_smart_object(*msg_); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::WARNINGS), + am::commands::Command::SOURCE_SDL)); + + command_->on_event(event); +} + +TEST_F(ResetGlobalPropertiesResponseTest, Run_Sendmsg_SUCCESS) { + MessageSharedPtr message(CreateMessage()); + ResetGlobalPropertiesResponsePtr command( + CreateCommand<ResetGlobalPropertiesResponse>(message)); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(message, _)); + command->Run(); +} + +TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_InvalidApp_NoHashUpdate) { + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::SUCCESS; + + (*msg_)[am::strings::msg_params][am::strings::properties][0] = + mobile_apis::GlobalProperty::VRHELPTITLE; + + EXPECT_CALL(*mock_app_, reset_vr_help_title()); + EXPECT_CALL(*mock_app_, reset_vr_help()); + + EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::UI_SetGlobalProperties))) + .WillOnce(Return(true)); + smart_objects::SmartObjectSPtr vr_help = + ::utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); + EXPECT_CALL(mock_message_helper_, CreateAppVrHelp(_)) + .WillOnce(Return(vr_help)); + + EXPECT_CALL(*mock_app_, UpdateHash()).Times(0); + + ResetGlobalPropertiesRequestPtr command = + CreateCommand<ResetGlobalPropertiesRequest>(msg_); + command->Run(); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::eType::SUCCESS), + am::commands::Command::SOURCE_SDL)); + + Event event(hmi_apis::FunctionID::UI_SetGlobalProperties); + event.set_smart_object(*msg_); + command->on_event(event); +} + +TEST_F(ResetGlobalPropertiesRequestTest, + Run_WaitTTS_Timeout_GENERIC_ERROR_TTSNotRespond) { + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::UNSUPPORTED_RESOURCE; + + (*msg_)[am::strings::msg_params][am::strings::properties][0] = + mobile_apis::GlobalProperty::TIMEOUTPROMPT; + (*msg_)[am::strings::msg_params][am::strings::properties][1] = + mobile_apis::GlobalProperty::MENUICON; + + std::vector<std::string> time_out_prompt; + time_out_prompt.push_back("time_out"); + EXPECT_CALL(app_mngr_settings_, time_out_promt()) + .WillOnce(ReturnRef(time_out_prompt)); + + EXPECT_CALL(*mock_app_, set_timeout_prompt(_)); + + smart_objects::SmartObjectSPtr prompt = + utils::MakeShared<smart_objects::SmartObject>(); + *prompt = "prompt"; + + EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(prompt.get())); + + EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::UI_SetGlobalProperties))) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::TTS_SetGlobalProperties))) + .WillOnce(Return(true)); + + ResetGlobalPropertiesRequestPtr command = + CreateCommand<ResetGlobalPropertiesRequest>(msg_); + command->Run(); + + // Received response only from UI + MessageSharedPtr ui_msg = CreateMessage(); + (*ui_msg)[am::strings::params][am::strings::correlation_id] = kCorrelationId; + (*ui_msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::SUCCESS; + (*ui_msg)[am::strings::msg_params] = + SmartObject(smart_objects::SmartType_Map); + Event ui_event(hmi_apis::FunctionID::UI_SetGlobalProperties); + ui_event.set_smart_object(*ui_msg); + command->on_event(ui_event); + + // TTS doesn't respond, so timeout should send generic error + smart_objects::SmartObjectSPtr response = + utils::MakeShared<smart_objects::SmartObject>(); + (*response)[am::strings::msg_params][am::strings::result_code] = + mobile_apis::Result::GENERIC_ERROR; + EXPECT_CALL(mock_message_helper_, CreateNegativeResponse(_, _, _, _)) + .WillOnce(Return(response)); + const std::string info = "TTS component does not respond"; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + MobileResponseIs(mobile_apis::Result::GENERIC_ERROR, info, false), + am::commands::Command::SOURCE_SDL)); + command->onTimeOut(); +} + +TEST_F(ResetGlobalPropertiesRequestTest, + Run_WaitUI_Timeout_GENERIC_ERROR_UINotRespond) { + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::UNSUPPORTED_RESOURCE; + + (*msg_)[am::strings::msg_params][am::strings::properties][0] = + mobile_apis::GlobalProperty::TIMEOUTPROMPT; + (*msg_)[am::strings::msg_params][am::strings::properties][1] = + mobile_apis::GlobalProperty::MENUICON; + + std::vector<std::string> time_out_prompt; + time_out_prompt.push_back("time_out"); + EXPECT_CALL(app_mngr_settings_, time_out_promt()) + .WillOnce(ReturnRef(time_out_prompt)); + + EXPECT_CALL(*mock_app_, set_timeout_prompt(_)); + + smart_objects::SmartObjectSPtr prompt = + utils::MakeShared<smart_objects::SmartObject>(); + *prompt = "prompt"; + + EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(prompt.get())); + + EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::UI_SetGlobalProperties))) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::TTS_SetGlobalProperties))) + .WillOnce(Return(true)); + + command_->Run(); + + // Received response only from TTS + MessageSharedPtr tts_msg = CreateMessage(); + (*tts_msg)[am::strings::params][am::strings::correlation_id] = kCorrelationId; + (*tts_msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::SUCCESS; + + Event tts_event(hmi_apis::FunctionID::TTS_SetGlobalProperties); + tts_event.set_smart_object(*tts_msg); + command_->on_event(tts_event); + + // UI doesn't respond, so timeout should send generic error + smart_objects::SmartObjectSPtr response = + utils::MakeShared<smart_objects::SmartObject>(); + (*response)[am::strings::msg_params][am::strings::result_code] = + mobile_apis::Result::GENERIC_ERROR; + EXPECT_CALL(mock_message_helper_, CreateNegativeResponse(_, _, _, _)) + .WillOnce(Return(response)); + + const std::string info = "UI component does not respond"; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + MobileResponseIs(mobile_apis::Result::GENERIC_ERROR, info, false), + am::commands::Command::SOURCE_SDL)); + command_->onTimeOut(); +} + +TEST_F(ResetGlobalPropertiesRequestTest, + Run_WaitUIAndTTS_Timeout_GENERIC_ERROR_TTSAndUINotRespond) { + Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties); + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::UNSUPPORTED_RESOURCE; + + (*msg_)[am::strings::msg_params][am::strings::properties][0] = + mobile_apis::GlobalProperty::TIMEOUTPROMPT; + (*msg_)[am::strings::msg_params][am::strings::properties][1] = + mobile_apis::GlobalProperty::MENUICON; + + std::vector<std::string> time_out_prompt; + time_out_prompt.push_back("time_out"); + EXPECT_CALL(app_mngr_settings_, time_out_promt()) + .WillOnce(ReturnRef(time_out_prompt)); + + EXPECT_CALL(*mock_app_, set_timeout_prompt(_)); + + smart_objects::SmartObjectSPtr prompt = + utils::MakeShared<smart_objects::SmartObject>(); + *prompt = "prompt"; + + EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(prompt.get())); + + EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::UI_SetGlobalProperties))) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::TTS_SetGlobalProperties))) + .WillOnce(Return(true)); + + command_->Run(); + // TTS and UI don't respond, so timeout should send generic error + std::string info = "TTS, UI component does not respond"; + smart_objects::SmartObjectSPtr response = + utils::MakeShared<smart_objects::SmartObject>(); + (*response)[am::strings::msg_params][am::strings::result_code] = + mobile_apis::Result::GENERIC_ERROR; + EXPECT_CALL(mock_message_helper_, CreateNegativeResponse(_, _, _, _)) + .WillOnce(Return(response)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + MobileResponseIs(mobile_apis::Result::GENERIC_ERROR, info, false), + am::commands::Command::SOURCE_SDL)); + command_->onTimeOut(); +} + +} // namespace reset_global_properties +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/scrollable_message_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/scrollable_message_test.cc new file mode 100644 index 0000000000..f550043414 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/scrollable_message_test.cc @@ -0,0 +1,286 @@ +/* + * 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 <stdint.h> +#include <string> +#include <set> + +#include "mobile/scrollable_message_request.h" + +#include "gtest/gtest.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/policies/mock_policy_handler_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace scrollable_message_request { + +namespace am = application_manager; +namespace hmi_response = am::hmi_response; +namespace mobile_result = mobile_apis::Result; +namespace am = ::application_manager; + +using sdl_rpc_plugin::commands::ScrollableMessageRequest; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using am::MockMessageHelper; +using ::utils::SharedPtr; +using ::testing::_; +using ::testing::Eq; +using ::testing::Ref; +using ::testing::Return; +using ::testing::ReturnRef; + +using namespace am::strings; +using test::components::policy_test::MockPolicyHandlerInterface; + +namespace { +const uint32_t kAppId = 1u; +const uint32_t kCmdId = 1u; +const uint32_t kConnectionKey = 2u; +const uint32_t kTimeOut = 30000u; +const uint32_t kCorrelationId = 10u; +const uint32_t kFunctionID = 3u; +} // namespace + +class ScrollableMessageRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + typedef TypeIf<kMocksAreNice, + NiceMock<application_manager_test::MockHMICapabilities>, + application_manager_test::MockHMICapabilities>::Result + MockHMICapabilities; + sync_primitives::Lock lock_; + + MessageSharedPtr CreateFullParamsUISO() { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + smart_objects::SmartObject menu_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + menu_params[am::strings::position] = 10; + menu_params[am::strings::menu_name] = "LG"; + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[am::strings::cmd_id] = kCmdId; + msg_params[am::strings::menu_params] = menu_params; + msg_params[am::strings::app_id] = kAppId; + msg_params[am::strings::cmd_icon] = 1; + msg_params[am::strings::cmd_icon][am::strings::value] = "10"; + (*msg)[am::strings::msg_params] = msg_params; + + return msg; + } + + void SetUp() OVERRIDE { + mock_app_ = CreateMockApp(); + command_ = CreateCommand<ScrollableMessageRequest>(msg_); + } + + MockAppPtr mock_app_; + MessageSharedPtr msg_; + SharedPtr<ScrollableMessageRequest> command_; +}; + +typedef ScrollableMessageRequestTest::MockHMICapabilities MockHMICapabilities; + +TEST_F(ScrollableMessageRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) { + MessageSharedPtr msg_ui = CreateFullParamsUISO(); + (*msg_ui)[am::strings::params][am::strings::connection_key] = kConnectionKey; + + utils::SharedPtr<ScrollableMessageRequest> command = + CreateCommand<ScrollableMessageRequest>(msg_ui); + + MockAppPtr mock_app = CreateMockApp(); + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app)); + + ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey)); + + ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) + .WillByDefault(Return(true)); + + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*msg)[am::strings::msg_params][am::strings::info] = "info1"; + + Event event(hmi_apis::FunctionID::UI_ScrollableMessage); + event.set_smart_object(*msg); + + MessageSharedPtr ui_command_result; + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true))); + + command->on_event(event); + + EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success] + .asBool(), + true); + EXPECT_EQ( + (*ui_command_result)[am::strings::msg_params][am::strings::result_code] + .asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + if ((*ui_command_result)[am::strings::msg_params].keyExists( + am::strings::info)) { + EXPECT_FALSE( + (*ui_command_result)[am::strings::msg_params][am::strings::info] + .asString() + .empty()); + } +} + +TEST_F(ScrollableMessageRequestTest, Init_CorrectTimeout_SUCCESS) { + (*msg_)[msg_params][timeout] = kTimeOut; + (*msg_)[msg_params][interaction_mode] = + mobile_apis::InteractionMode::MANUAL_ONLY; + EXPECT_EQ(kDefaultTimeout_, command_->default_timeout()); + command_->Init(); + EXPECT_EQ(kTimeOut, command_->default_timeout()); +} + +TEST_F(ScrollableMessageRequestTest, Init_CorrectTimeout_UNSUCCESS) { + (*msg_)[msg_params][interaction_mode] = + mobile_apis::InteractionMode::MANUAL_ONLY; + EXPECT_EQ(kDefaultTimeout_, command_->default_timeout()); + command_->Init(); + EXPECT_EQ(kTimeOut, command_->default_timeout()); +} + +TEST_F(ScrollableMessageRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { + EXPECT_CALL(app_mngr_, application(_)) + .WillOnce(Return(ApplicationSharedPtr())); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _)); + command_->Run(); +} + +TEST_F(ScrollableMessageRequestTest, + Run_SoftButtonProcessingResultWrogParameters_UNSUCCESS) { + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_)); + const mobile_apis::Result::eType processing_result = + mobile_apis::Result::ABORTED; + smart_objects::SmartObject& msg_params = (*msg_)[am::strings::msg_params]; + EXPECT_CALL( + mock_message_helper_, + ProcessSoftButtons( + msg_params, Eq(mock_app_), Ref(mock_policy_handler_), Ref(app_mngr_))) + .WillOnce(Return(processing_result)); + MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command_))); + EXPECT_EQ(processing_result, + static_cast<mobile_apis::Result::eType>( + (*result_msg)[am::strings::msg_params][result_code].asInt())); +} + +TEST_F(ScrollableMessageRequestTest, Run_SoftButtonProcessingResult_SUCCESS) { + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); + smart_objects::SmartObject& msg_params = (*msg_)[am::strings::msg_params]; + (*msg_)[am::strings::params][am::strings::function_id] = kFunctionID; + (*msg_)[am::strings::msg_params][am::strings::soft_buttons][0] + [am::strings::soft_button_id] = 0; + EXPECT_CALL( + mock_message_helper_, + ProcessSoftButtons( + msg_params, Eq(mock_app_), Ref(mock_policy_handler_), Ref(app_mngr_))) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + EXPECT_CALL(mock_message_helper_, SubscribeApplicationToSoftButton(_, _, _)); + + MessageSharedPtr result_msg(CatchHMICommandResult(CallRun(*command_))); + EXPECT_EQ(hmi_apis::FunctionID::UI_ScrollableMessage, + static_cast<hmi_apis::FunctionID::eType>( + (*result_msg)[params][function_id].asInt())); +} + +TEST_F(ScrollableMessageRequestTest, OnEvent_ReceivedUnknownEvent_UNSUCCESS) { + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + Event event(hmi_apis::FunctionID::INVALID_ENUM); + command_->on_event(event); +} + +TEST_F(ScrollableMessageRequestTest, + OnEvent_ReceivedUIOnResetTimeoutEvent_SUCCESS) { + (*msg_)[params][connection_key] = kConnectionKey; + (*msg_)[params][correlation_id] = kCorrelationId; + EXPECT_CALL( + app_mngr_, + updateRequestTimeout(kConnectionKey, kCorrelationId, kDefaultTimeout_)); + Event event(hmi_apis::FunctionID::UI_OnResetTimeout); + event.set_smart_object(*msg_); + command_->on_event(event); +} + +TEST_F(ScrollableMessageRequestTest, + DISABLED_OnEvent_ReceivedUIScrollableMessage_SUCCESS) { + (*msg_)[params][hmi_response::code] = hmi_apis::Common_Result::SUCCESS; + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)); + Event event(hmi_apis::FunctionID::UI_ScrollableMessage); + event.set_smart_object(*msg_); + command_->on_event(event); +} + +TEST_F(ScrollableMessageRequestTest, + DISABLED_OnEvent_UnsupportedRCAndUICoop_SUCCESS) { + (*msg_)[params][hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), _)); + Event event(hmi_apis::FunctionID::UI_ScrollableMessage); + event.set_smart_object(*msg_); + command_->on_event(event); +} + +} // namespace scrollable_message_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace tests diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_haptic_data_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_haptic_data_test.cc new file mode 100644 index 0000000000..c0c44922e3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_haptic_data_test.cc @@ -0,0 +1,164 @@ +/* + * 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 "gtest/gtest.h" + +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" + +#include "mobile/send_haptic_data_request.h" +#include "mobile/send_haptic_data_response.h" + +#include "interfaces/MOBILE_API.h" +#include "application_manager/application.h" +#include "application_manager/mock_application.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace send_haptic_data { + +using ::testing::_; +using ::testing::Return; + +namespace am = ::application_manager; + +using sdl_rpc_plugin::commands::SendHapticDataRequest; +using sdl_rpc_plugin::commands::SendHapticDataResponse; +using am::commands::MessageSharedPtr; + +typedef SharedPtr<SendHapticDataRequest> SendHapticDataRequestPtr; +typedef SharedPtr<SendHapticDataResponse> SendHapticDataResponsePtr; + +namespace { +const uint32_t kConnectionKey = 1u; +} + +class SendHapticDataRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + SendHapticDataRequestTest() + : msg_(CreateMessage(::smart_objects::SmartType_Map)) + , mock_app_(CreateMockApp()) {} + + void SetUp() OVERRIDE { + (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey; + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + } + + MessageSharedPtr msg_; + MockAppPtr mock_app_; +}; + +class SendHapticDataResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + SendHapticDataResponseTest() : message_(CreateMessage()) {} + + void SetUp() OVERRIDE { + command_sptr_ = CreateCommand<SendHapticDataResponse>(message_); + } + + MessageSharedPtr message_; + SharedPtr<SendHapticDataResponse> command_sptr_; +}; + +TEST_F(SendHapticDataRequestTest, Run_SUCCESS) { + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + + EXPECT_CALL(*mock_app_, is_navi()).WillOnce(Return(true)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SendHapticData))) + .WillOnce(Return(true)); + + SendHapticDataRequestPtr command(CreateCommand<SendHapticDataRequest>(msg_)); + + command->Init(); + command->Run(); +} + +TEST_F(SendHapticDataRequestTest, Run_DISALLOWED) { + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + + EXPECT_CALL(*mock_app_, is_navi()).WillOnce(Return(false)); + + EXPECT_CALL(*mock_app_, mobile_projection_enabled()).WillOnce(Return(false)); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(Return(true)); + + SendHapticDataRequestPtr command(CreateCommand<SendHapticDataRequest>(msg_)); + + command->Init(); + command->Run(); +} + +TEST_F(SendHapticDataRequestTest, OnEvent_SUCCESS) { + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), + am::commands::Command::SOURCE_SDL)); + + (*msg_)[am::strings::msg_params] = 0; + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::SUCCESS; + Event event(hmi_apis::FunctionID::UI_SendHapticData); + event.set_smart_object(*msg_); + SendHapticDataRequestPtr command(CreateCommand<SendHapticDataRequest>(msg_)); + + command->Init(); + command->on_event(event); +} + +TEST_F(SendHapticDataResponseTest, Run_Success) { + ::smart_objects::SmartObject& message_ref = *message_; + message_ref[am::strings::msg_params][am::strings::result_code] = + mobile_apis::Result::SUCCESS; + + EXPECT_CALL( + mock_rpc_service_, + SendMessageToMobile(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)); + command_sptr_->Init(); + command_sptr_->Run(); +} + +} // namespace send_haptic_data +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc new file mode 100644 index 0000000000..d0072f6288 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc @@ -0,0 +1,406 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "mobile/send_location_request.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_message_helper.h" +#include "utils/shared_ptr.h" +#include "application_manager/commands/command_request_test.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace send_location_request { + +using application_manager::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::SendLocationRequest; +using application_manager::MockMessageHelper; +using test::components::application_manager_test::MockHMICapabilities; +using smart_objects::SmartObject; +using utils::SharedPtr; +using testing::_; +using testing::Return; +using testing::ReturnRef; + +namespace strings = application_manager::strings; +namespace hmi_response = application_manager::hmi_response; +namespace Common_TextFieldName = hmi_apis::Common_TextFieldName; + +namespace { +const uint32_t kConnectionKey = 1u; +const uint32_t kFunctionID = 2u; +const uint32_t kAppID = 3u; +const double kLongitudeDegrees = 13.4; +const std::string kLocationDescription = "Location_Description"; +const std::string kNewLine = "\\n"; +const std::string kAddressLine = "Address_Line"; +const std::string kPhoneNumber = "Phone_number"; +const std::string kCorrectAddress = "Correct address"; +const std::string kEmptyAddress = ""; +const std::string kAddressWithWrongSyntax = "Wrong Syntax\\n"; +} // namespace + +class SendLocationRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + class UnwrappedSendLocationRequest : public SendLocationRequest { + public: + UnwrappedSendLocationRequest( + const MessageSharedPtr& message, + application_manager::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : SendLocationRequest(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + ::application_manager::CommandParametersPermissions& + get_parameters_permissions() { + return parameters_permissions_; + } + }; + + typedef SharedPtr<UnwrappedSendLocationRequest> CommandSPrt; + + SendLocationRequestTest() { + mock_app_ = CreateMockApp(); + disp_cap_ = utils::MakeShared<SmartObject>(smart_objects::SmartType_Map); + message_ = CreateMessage(); + command_ = CreateCommand<UnwrappedSendLocationRequest>(message_); + } + + void InitialSetup(MessageSharedPtr message_) { + (*message_)[strings::params][strings::connection_key] = kConnectionKey; + (*message_)[strings::params][strings::function_id] = kFunctionID; + (*message_)[strings::msg_params] = + SmartObject(smart_objects::SmartType_Map); + (*message_)[strings::msg_params][strings::address] = kCorrectAddress; + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + + AllowMandatoryFields(); + } + + void HMICapabilitiesSetupHelper() { + EXPECT_CALL(mock_hmi_capabilities_, is_ui_cooperating()) + .WillOnce(Return(true)); + } + + void HMICapabilitiesSetupWithArguments( + Common_TextFieldName::eType field_name) { + HMICapabilitiesSetupHelper(); + (*disp_cap_)[hmi_response::text_fields] = + SmartObject(smart_objects::SmartType_Array); + (*disp_cap_)[hmi_response::text_fields][0] = + SmartObject(smart_objects::SmartType_Map); + (*disp_cap_)[hmi_response::text_fields][0][strings::name] = field_name; + EXPECT_CALL(mock_hmi_capabilities_, display_capabilities()) + .Times(2) + .WillRepeatedly(Return(disp_cap_.get())); + } + + void FinishSetup() { + EXPECT_CALL(*mock_app_, hmi_app_id()).WillOnce(Return(kAppID)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::Navigation_SendLocation))); + } + + void FinishSetupCancelled(mobile_apis::Result::eType result) { + EXPECT_CALL(*mock_app_, hmi_app_id()).Times(0); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(result), _)); + } + + void AllowMandatoryFields() { + application_manager::CommandParametersPermissions& permissions = + command_->get_parameters_permissions(); + permissions.allowed_params.insert(strings::longitude_degrees); + permissions.allowed_params.insert(strings::latitude_degrees); + } + + MockAppPtr mock_app_; + SharedPtr<SmartObject> disp_cap_; + MessageSharedPtr message_; + CommandSPrt command_; +}; + +TEST_F(SendLocationRequestTest, Run_InvalidApp_Success) { + (*message_)[strings::params][strings::connection_key] = kConnectionKey; + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(MockAppPtr())); + FinishSetupCancelled(mobile_apis::Result::APPLICATION_NOT_REGISTERED); + command_->Run(); +} + +TEST_F(SendLocationRequestTest, Run_DeliveryMode_Success) { + InitialSetup(message_); + SmartObject msg_params = (*message_)[strings::msg_params]; + msg_params[strings::delivery_mode] = SmartObject(); + (*message_)[strings::msg_params] = msg_params; + msg_params.erase(strings::delivery_mode); + FinishSetup(); + command_->Run(); +} + +TEST_F(SendLocationRequestTest, Run_LocationNameIsAllowed_Success) { + InitialSetup(message_); + (*message_)[strings::msg_params][strings::location_name] = "Location_Name"; + HMICapabilitiesSetupWithArguments(Common_TextFieldName::locationName); + FinishSetup(); + command_->Run(); +} + +TEST_F(SendLocationRequestTest, Run_LocationNameIsNotAllowed_Cancelled) { + InitialSetup(message_); + (*message_)[strings::msg_params][strings::location_name] = "Location_Name"; + HMICapabilitiesSetupWithArguments(Common_TextFieldName::INVALID_ENUM); + FinishSetupCancelled(mobile_apis::Result::UNSUPPORTED_RESOURCE); + command_->Run(); +} + +TEST_F(SendLocationRequestTest, Run_LocationNameWrongSyntax_Cancelled) { + InitialSetup(message_); + (*message_)[strings::msg_params][strings::location_name] = "Location_Name\\n"; + HMICapabilitiesSetupWithArguments(Common_TextFieldName::locationName); + FinishSetupCancelled(mobile_apis::Result::INVALID_DATA); + command_->Run(); +} + +TEST_F(SendLocationRequestTest, Run_LocationDescriptionIsAllowed_Success) { + InitialSetup(message_); + (*message_)[strings::msg_params][strings::location_description] = + kLocationDescription; + HMICapabilitiesSetupWithArguments(Common_TextFieldName::locationDescription); + FinishSetup(); + command_->Run(); +} + +TEST_F(SendLocationRequestTest, Run_LocationDescriptionIsNotAllowed_Cancelled) { + InitialSetup(message_); + (*message_)[strings::msg_params][strings::location_description] = + kLocationDescription; + HMICapabilitiesSetupWithArguments(Common_TextFieldName::INVALID_ENUM); + FinishSetupCancelled(mobile_apis::Result::UNSUPPORTED_RESOURCE); + command_->Run(); +} + +TEST_F(SendLocationRequestTest, Run_LocationDescriptionWrongSyntax_Cancelled) { + InitialSetup(message_); + (*message_)[strings::msg_params][strings::location_description] = + kLocationDescription + kNewLine; + HMICapabilitiesSetupWithArguments(Common_TextFieldName::locationDescription); + FinishSetupCancelled(mobile_apis::Result::INVALID_DATA); + command_->Run(); +} + +TEST_F(SendLocationRequestTest, Run_AddressLinesAreAllowed_Success) { + InitialSetup(message_); + (*message_)[strings::msg_params][strings::address_lines] = + SmartObject(smart_objects::SmartType_Array); + (*message_)[strings::msg_params][strings::address_lines][0] = kAddressLine; + HMICapabilitiesSetupWithArguments(Common_TextFieldName::addressLines); + FinishSetup(); + command_->Run(); +} + +TEST_F(SendLocationRequestTest, Run_AddressLinesAreNotAllowed_Cancelled) { + InitialSetup(message_); + (*message_)[strings::msg_params][strings::address_lines] = + SmartObject(smart_objects::SmartType_Array); + (*message_)[strings::msg_params][strings::address_lines][0] = kAddressLine; + HMICapabilitiesSetupWithArguments(Common_TextFieldName::INVALID_ENUM); + FinishSetupCancelled(mobile_apis::Result::UNSUPPORTED_RESOURCE); + command_->Run(); +} + +TEST_F(SendLocationRequestTest, Run_AddressLinesWrongSyntax_Cancelled) { + InitialSetup(message_); + (*message_)[strings::msg_params][strings::address_lines] = + SmartObject(smart_objects::SmartType_Array); + (*message_)[strings::msg_params][strings::address_lines][0] = + kAddressLine + kNewLine; + HMICapabilitiesSetupWithArguments(Common_TextFieldName::addressLines); + FinishSetupCancelled(mobile_apis::Result::INVALID_DATA); + command_->Run(); +} + +TEST_F(SendLocationRequestTest, Run_PhoneNumberIsAllowed_Success) { + InitialSetup(message_); + (*message_)[strings::msg_params][strings::phone_number] = kPhoneNumber; + HMICapabilitiesSetupWithArguments(Common_TextFieldName::phoneNumber); + FinishSetup(); + command_->Run(); +} + +TEST_F(SendLocationRequestTest, Run_PhoneNumberIsNotAllowed_Cancelled) { + InitialSetup(message_); + (*message_)[strings::msg_params][strings::phone_number] = kPhoneNumber; + HMICapabilitiesSetupWithArguments(Common_TextFieldName::INVALID_ENUM); + FinishSetupCancelled(mobile_apis::Result::UNSUPPORTED_RESOURCE); + command_->Run(); +} + +TEST_F(SendLocationRequestTest, Run_PhoneNumberWrongSyntax_Cancelled) { + InitialSetup(message_); + (*message_)[strings::msg_params][strings::phone_number] = + kPhoneNumber + kNewLine; + HMICapabilitiesSetupWithArguments(Common_TextFieldName::phoneNumber); + FinishSetupCancelled(mobile_apis::Result::INVALID_DATA); + command_->Run(); +} + +TEST_F(SendLocationRequestTest, Run_AddressesContainWrongSyntax_Cancelled) { + InitialSetup(message_); + (*message_)[strings::msg_params][strings::address] = + SmartObject(smart_objects::SmartType_Array); + (*message_)[strings::msg_params][strings::address]["Address 1"] = + kCorrectAddress; + (*message_)[strings::msg_params][strings::address]["Address 2"] = + kAddressWithWrongSyntax; + FinishSetupCancelled(mobile_apis::Result::INVALID_DATA); + command_->Run(); +} + +TEST_F(SendLocationRequestTest, Run_LocationImageValid_Success) { + InitialSetup(message_); + (*message_)[strings::msg_params][strings::location_image] = + SmartObject(smart_objects::SmartType_Map); + (*message_)[strings::msg_params][strings::location_image][strings::value] = + "1"; + EXPECT_CALL( + mock_message_helper_, + VerifyImage( + (*message_)[strings::msg_params][strings::location_image], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + FinishSetup(); + command_->Run(); +} + +TEST_F(SendLocationRequestTest, Run_LocationImageInvalid_Cancelled) { + InitialSetup(message_); + (*message_)[strings::msg_params][strings::location_image] = + SmartObject(smart_objects::SmartType_Map); + (*message_)[strings::msg_params][strings::location_image][strings::value] = + "1"; + EXPECT_CALL( + mock_message_helper_, + VerifyImage( + (*message_)[strings::msg_params][strings::location_image], _, _)) + .WillOnce(Return(mobile_apis::Result::ABORTED)); + FinishSetupCancelled(mobile_apis::Result::ABORTED); + command_->Run(); +} + +TEST_F(SendLocationRequestTest, Run_HMIUINotCoop_Cancelled) { + InitialSetup(message_); + (*message_)[strings::msg_params][strings::phone_number] = kPhoneNumber; + (*disp_cap_)[hmi_response::text_fields] = + SmartObject(smart_objects::SmartType_Array); + (*disp_cap_)[hmi_response::text_fields][0] = + SmartObject(smart_objects::SmartType_Map); + (*disp_cap_)[hmi_response::text_fields][0][strings::name] = + Common_TextFieldName::phoneNumber; + EXPECT_CALL(mock_hmi_capabilities_, is_ui_cooperating()) + .WillOnce(Return(false)); + FinishSetupCancelled(mobile_apis::Result::UNSUPPORTED_RESOURCE); + command_->Run(); +} + +TEST_F(SendLocationRequestTest, OnEvent_Success) { + mobile_apis::Result::eType response_code = mobile_apis::Result::SUCCESS; + (*message_)[strings::params][hmi_response::code] = response_code; + (*message_)[strings::params][strings::connection_key] = kConnectionKey; + + Event event(hmi_apis::FunctionID::Navigation_SendLocation); + event.set_smart_object(*message_); + + MockAppPtr app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillRepeatedly(Return(app)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)) + .WillOnce(Return(false)); + command_->on_event(event); +} + +TEST_F(SendLocationRequestTest, OnEvent_Cancelled) { + (*message_)[strings::params][hmi_response::code] = + mobile_apis::Result::SUCCESS; + Event event(hmi_apis::FunctionID::Navigation_OnWayPointChange); + event.set_smart_object(*message_); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)) + .Times(0); + command_->on_event(event); +} + +TEST_F(SendLocationRequestTest, Run_MandatoryParamsDisallowed_InvalidData) { + (*message_)[strings::params][strings::connection_key] = kConnectionKey; + (*message_)[strings::params][strings::function_id] = kFunctionID; + (*message_)[strings::msg_params] = SmartObject(smart_objects::SmartType_Map); + (*message_)[strings::msg_params][strings::address] = kCorrectAddress; + (*message_)[strings::msg_params][strings::longitude_degrees] = + kLongitudeDegrees; + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + application_manager::CommandParametersPermissions& permissions = + command_->get_parameters_permissions(); + // 1st one allowed + permissions.allowed_params.insert(strings::longitude_degrees); + // 2nd one disallowed + permissions.disallowed_params.insert(strings::latitude_degrees); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::INVALID_DATA), _)); + command_->Run(); +} + +} // namespace send_location_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_app_icon_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_app_icon_test.cc new file mode 100644 index 0000000000..e1612dbacb --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_app_icon_test.cc @@ -0,0 +1,174 @@ +/* + * 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 <stdint.h> +#include <string> +#include <set> + +#include "mobile/set_app_icon_request.h" + +#include "gtest/gtest.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "protocol_handler/mock_protocol_handler.h" +#include "protocol_handler/mock_protocol_handler_settings.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace set_app_icon_request { + +namespace am = application_manager; +using sdl_rpc_plugin::commands::SetAppIconRequest; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using am::MockMessageHelper; +using am::MockHmiInterfaces; +using test::components::protocol_handler_test::MockProtocolHandler; +using test::components::protocol_handler_test::MockProtocolHandlerSettings; +using ::utils::SharedPtr; +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +namespace { +const uint32_t kAppId = 1u; +const uint32_t kCmdId = 1u; +const uint32_t kConnectionKey = 2u; +} // namespace + +class SetAppIconRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + MessageSharedPtr CreateFullParamsUISO() { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + smart_objects::SmartObject menu_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + menu_params[am::strings::position] = 10; + menu_params[am::strings::menu_name] = "LG"; + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[am::strings::cmd_id] = kCmdId; + msg_params[am::strings::menu_params] = menu_params; + msg_params[am::strings::app_id] = kAppId; + msg_params[am::strings::cmd_icon] = 1; + msg_params[am::strings::cmd_icon][am::strings::value] = "10"; + (*msg)[am::strings::msg_params] = msg_params; + + return msg; + } + NiceMock<MockHmiInterfaces> hmi_interfaces_; + protocol_handler_test::MockProtocolHandler mock_protocol_handler_; + protocol_handler_test::MockProtocolHandlerSettings + mock_protocol_handler_settings_; +}; + +TEST_F(SetAppIconRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) { + const std::string file_path = "file_path"; + MessageSharedPtr msg_vr = CreateFullParamsUISO(); + (*msg_vr)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg_vr)[am::strings::msg_params][am::strings::sync_file_name] + [am::strings::value] = file_path; + + const std::string dir_path = "./"; + ON_CALL(app_mngr_settings_, app_icons_folder()) + .WillByDefault(ReturnRef(dir_path)); + + utils::SharedPtr<SetAppIconRequest> req_vr = + CreateCommand<SetAppIconRequest>(msg_vr); + + MockAppPtr mock_app = CreateMockApp(); + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app)); + ON_CALL(app_mngr_, hmi_interfaces()) + .WillByDefault(ReturnRef(hmi_interfaces_)); + ON_CALL(hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + ON_CALL(app_mngr_, protocol_handler()) + .WillByDefault(ReturnRef(mock_protocol_handler_)); + ON_CALL(mock_protocol_handler_, get_settings()) + .WillByDefault(ReturnRef(mock_protocol_handler_settings_)); + + ON_CALL(mock_protocol_handler_settings_, max_supported_protocol_version()) + .WillByDefault( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4)); + + ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(*mock_app, set_app_icon_path(_)).WillByDefault(Return(true)); + ON_CALL(*mock_app, app_icon_path()).WillByDefault(ReturnRef(file_path)); + + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*msg)[am::strings::msg_params][am::strings::info] = "info1"; + + Event event(hmi_apis::FunctionID::UI_SetAppIcon); + event.set_smart_object(*msg); + + MessageSharedPtr ui_command_result; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true))); + + req_vr->on_event(event); + + EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success] + .asBool(), + true); + EXPECT_EQ( + (*ui_command_result)[am::strings::msg_params][am::strings::result_code] + .asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + if ((*ui_command_result)[am::strings::msg_params].keyExists( + am::strings::info)) { + EXPECT_FALSE( + (*ui_command_result)[am::strings::msg_params][am::strings::info] + .asString() + .empty()); + } +} + +} // namespace set_app_icon_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace tests diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_display_layout_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_display_layout_test.cc new file mode 100644 index 0000000000..0758fb32f4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_display_layout_test.cc @@ -0,0 +1,250 @@ +/* + * 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 <stdint.h> +#include <string> +#include <set> + +#include "mobile/set_display_layout_request.h" + +#include "gtest/gtest.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_hmi_capabilities.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace set_display_layout_request { + +namespace am = application_manager; +namespace mobile_result = mobile_apis::Result; +using sdl_rpc_plugin::commands::SetDisplayLayoutRequest; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using am::MockMessageHelper; +using ::utils::SharedPtr; +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +typedef ::utils::SharedPtr<SetDisplayLayoutRequest> CommandPtr; + +namespace { +const uint32_t kAppId = 1u; +const uint32_t kCmdId = 1u; +const uint32_t kConnectionKey = 2u; +const uint32_t kCorrelationKey = 2u; +const std::string kLayout = "media"; +} // namespace + +MATCHER_P(CheckMshCorrId, corr_id, "") { + return (*arg)[am::strings::params][am::strings::correlation_id].asUInt() == + corr_id; +} + +class SetDisplayLayoutRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + SetDisplayLayoutRequestTest() : mock_app_(CreateMockApp()) { + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + } + + MessageSharedPtr CreateFullParamsUISO() { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + smart_objects::SmartObject menu_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + menu_params[am::strings::position] = 10; + menu_params[am::strings::menu_name] = "LG"; + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[am::strings::cmd_id] = kCmdId; + msg_params[am::strings::menu_params] = menu_params; + msg_params[am::strings::app_id] = kAppId; + msg_params[am::strings::cmd_icon] = 1; + msg_params[am::strings::cmd_icon][am::strings::value] = "10"; + (*msg)[am::strings::msg_params] = msg_params; + + return msg; + } + typedef TypeIf<kMocksAreNice, + NiceMock<application_manager_test::MockHMICapabilities>, + application_manager_test::MockHMICapabilities>::Result + MockHMICapabilities; + + void ResultCommandExpectations(MessageSharedPtr msg, + const std::string& info) { + EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(), + false); + EXPECT_EQ( + (*msg)[am::strings::msg_params][am::strings::result_code].asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(), + info); + } + + sync_primitives::Lock lock_; + MockAppPtr mock_app_; +}; + +typedef SetDisplayLayoutRequestTest::MockHMICapabilities MockHMICapabilities; + +TEST_F(SetDisplayLayoutRequestTest, + OnEvent_UIHmiUnsupportedResource_UNSUPPORTED_RESOURCE) { + MessageSharedPtr msg_ui = CreateFullParamsUISO(); + (*msg_ui)[am::strings::params][am::strings::connection_key] = kConnectionKey; + + utils::SharedPtr<SetDisplayLayoutRequest> command = + CreateCommand<SetDisplayLayoutRequest>(msg_ui); + + MockAppPtr mock_app = CreateMockApp(); + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app)); + + ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey)); + + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*msg)[am::strings::msg_params][am::strings::app_id] = kConnectionKey; + (*msg)[am::strings::msg_params][am::strings::info] = + "UI is not supported by system"; + + Event event(hmi_apis::FunctionID::UI_SetDisplayLayout); + event.set_smart_object(*msg); + + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + MessageSharedPtr ui_command_result; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true))); + + command->on_event(event); + + ResultCommandExpectations(ui_command_result, "UI is not supported by system"); +} + +TEST_F(SetDisplayLayoutRequestTest, Run_InvalidApp_UNSUCCESS) { + MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map)); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + CommandPtr command(CreateCommand<SetDisplayLayoutRequest>(msg)); + + MockAppPtr invalid_mock_app; + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(invalid_mock_app)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), + am::commands::Command::CommandSource::SOURCE_SDL)); + + command->Run(); +} + +TEST_F(SetDisplayLayoutRequestTest, Run_SUCCESS) { + MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map)); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + CommandPtr command(CreateCommand<SetDisplayLayoutRequest>(msg)); + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, display_layout()).WillOnce(ReturnRef(kLayout)); + EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppId)); + + EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillOnce(Return(kCorrelationKey)); + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetDisplayLayout)) + .WillRepeatedly(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(CheckMshCorrId(kCorrelationKey))) + .WillOnce(Return(true)); + + command->Run(); +} + +TEST_F(SetDisplayLayoutRequestTest, OnEvent_InvalidEventId_UNSUCCESS) { + CommandPtr command(CreateCommand<SetDisplayLayoutRequest>()); + am::event_engine::Event event(hmi_apis::FunctionID::INVALID_ENUM); + SmartObject msg(smart_objects::SmartType_Map); + + event.set_smart_object(msg); + + command->on_event(event); +} + +TEST_F(SetDisplayLayoutRequestTest, OnEvent_SUCCESS) { + am::event_engine::Event event(hmi_apis::FunctionID::UI_SetDisplayLayout); + MessageSharedPtr msg = CreateMessage(); + + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*msg)[am::strings::msg_params][am::hmi_response::display_capabilities] = 0; + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + event.set_smart_object(*msg); + + MessageSharedPtr dispaly_capabilities_msg = CreateMessage(); + (*dispaly_capabilities_msg)[am::hmi_response::templates_available] = + "templates_available"; + + EXPECT_CALL(mock_hmi_capabilities_, display_capabilities()) + .WillOnce(Return(dispaly_capabilities_msg.get())); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), + am::commands::Command::CommandSource::SOURCE_SDL)); + + CommandPtr command(CreateCommand<SetDisplayLayoutRequest>(msg)); + command->on_event(event); +} + +} // namespace set_display_layout_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace tests diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc new file mode 100644 index 0000000000..5d31f48970 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc @@ -0,0 +1,1251 @@ +/* + * 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 <stdint.h> +#include <string> +#include <set> + +#include "mobile/set_global_properties_request.h" + +#include "gtest/gtest.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace set_global_properties_request { + +namespace am = application_manager; +using sdl_rpc_plugin::commands::SetGlobalPropertiesRequest; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using am::MockMessageHelper; +using am::CommandsMap; +using utils::custom_string::CustomString; +using ::utils::SharedPtr; +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +namespace { +const int32_t kCommandId = 1; +const uint32_t kAppId = 1u; +const uint32_t kCmdId = 1u; +const uint32_t kConnectionKey = 1u; +const std::string kText = "one"; +const uint32_t kPosition = 1u; +} // namespace + +class SetGlobalPropertiesRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + SetGlobalPropertiesRequestTest() + : lock_ptr_(std::make_shared<sync_primitives::Lock>()) + , mock_app_(CreateMockApp()) {} + + MessageSharedPtr CreateFullParamsUISO() { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + smart_objects::SmartObject menu_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + menu_params[am::strings::position] = 10; + menu_params[am::strings::menu_name] = "LG"; + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[am::strings::cmd_id] = kCmdId; + msg_params[am::strings::menu_params] = menu_params; + msg_params[am::strings::app_id] = kAppId; + msg_params[am::strings::cmd_icon] = 1; + msg_params[am::strings::cmd_icon][am::strings::value] = "10"; + msg_params[am::strings::vr_help_title] = "vr_help_title"; + msg_params[am::strings::vr_help][0][am::strings::text] = "vr_help"; + msg_params[am::strings::vr_help][0][am::strings::position] = 1u; + msg_params[am::strings::help_prompt][0][am::strings::text] = "help_promt"; + (*msg)[am::strings::msg_params] = msg_params; + + return msg; + } + + MessageSharedPtr CreateMsgParams() { + MessageSharedPtr msg = CreateMessage(); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg)[am::strings::msg_params][am::strings::app_id] = kAppId; + return msg; + } + + void VRArraySetupHelper(MessageSharedPtr msg, + SmartObject& vr_help_title, + SmartObject& vr_help_array) { + (*msg)[am::strings::msg_params][am::strings::vr_help_title] = vr_help_title; + vr_help_array[0] = SmartObject(smart_objects::SmartType_Map); + vr_help_array[0][am::strings::text] = kText; + vr_help_array[0][am::strings::position] = kPosition; + (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array; + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + } + + void OnEventUISetupHelper(MessageSharedPtr msg, + SharedPtr<SetGlobalPropertiesRequest> command) { + SmartObject vr_help_title("yes"); + SmartObject vr_help_array(smart_objects::SmartType_Array); + VRArraySetupHelper(msg, vr_help_title, vr_help_array); + EXPECT_CALL(mock_message_helper_, + VerifyImageVrHelpItems(vr_help_array, _, _)) + .WillOnce((Return(mobile_apis::Result::SUCCESS))); + EXPECT_CALL(app_mngr_, + RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + EXPECT_CALL(*mock_app_, set_vr_help_title(vr_help_title)); + EXPECT_CALL(*mock_app_, set_vr_help(vr_help_array)); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); + EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(&vr_help_array)); + EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0); + EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0); + EXPECT_CALL(*mock_app_, set_keyboard_props(_)).Times(0); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + command->Run(); + } + + void OnEventTTSSetupHelper(MessageSharedPtr msg, + SharedPtr<SetGlobalPropertiesRequest> command) { + SmartObject help_prompt(smart_objects::SmartType_Array); + help_prompt[0][am::strings::text] = "Help_Prompt_One"; + (*msg)[am::strings::msg_params][am::strings::help_prompt] = help_prompt; + SmartObject timeout_prompt(smart_objects::SmartType_Array); + timeout_prompt[0][am::strings::text] = "Timeout_Prompt_One"; + (*msg)[am::strings::msg_params][am::strings::timeout_prompt] = + timeout_prompt; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(help_prompt, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(timeout_prompt, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(app_mngr_, + RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + SmartObject vr_help_title("title"); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); + EXPECT_CALL(*mock_app_, set_help_prompt(help_prompt)); + EXPECT_CALL(*mock_app_, help_prompt()).WillOnce(Return(&help_prompt)); + EXPECT_CALL(*mock_app_, set_timeout_prompt(timeout_prompt)); + EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(&timeout_prompt)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + command->Run(); + } + + void EmptyExpectationsSetupHelper() { + EXPECT_CALL(*mock_app_, set_vr_help_title(_)).Times(0); + EXPECT_CALL(*mock_app_, set_vr_help(_)).Times(0); + EXPECT_CALL(*mock_app_, vr_help_title()).Times(0); + EXPECT_CALL(*mock_app_, vr_help()).Times(0); + EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0); + EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0); + EXPECT_CALL(*mock_app_, set_keyboard_props(_)).Times(0); + EXPECT_CALL(*mock_app_, app_id()).Times(0); + } + + void ExpectInvalidData() { + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::INVALID_DATA), + am::commands::Command::SOURCE_SDL)); + } + + void ExpectVerifyImageVrHelpSuccess(SmartObject& smart_obj) { + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(smart_obj, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(_)).Times(0); + } + + void ExpectVerifyImageVrHelpUnsuccess() { + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(_)).Times(0); + } + + void ExpectVerifyImageSuccess(SmartObject& smart_obj) { + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(smart_obj, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(_)).Times(0); + } + + void SetUp() OVERRIDE { + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + } + + void ResultCommandExpectations(MessageSharedPtr msg, + const std::string& info) { + EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(), + true); + EXPECT_EQ( + (*msg)[am::strings::msg_params][am::strings::result_code].asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(), + info); + } + + void ExpectationsHmiInterface_Run() { + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties)) + .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties)) + .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + } + std::shared_ptr<sync_primitives::Lock> lock_ptr_; + MockAppPtr mock_app_; +}; + +TEST_F(SetGlobalPropertiesRequestTest, + OnEvent_UIHmiSendSuccess_UNSUPPORTED_RESOURCE) { + MessageSharedPtr msg_vr = CreateFullParamsUISO(); + (*msg_vr)[am::strings::msg_params][am::strings::vr_commands][0] = + "vr_command"; + + utils::SharedPtr<SetGlobalPropertiesRequest> command = + CreateCommand<SetGlobalPropertiesRequest>(msg_vr); + + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + const smart_objects::SmartObject* vr_help_title = + &((*msg_vr)[am::strings::msg_params][am::strings::vr_help_title]); + const smart_objects::SmartObject* vr_help = + &((*msg_vr)[am::strings::msg_params][am::strings::vr_help]); + const smart_objects::SmartObject* vr_help_prompt = + &((*msg_vr)[am::strings::msg_params][am::strings::help_prompt]); + ON_CALL(*mock_app_, vr_help_title()).WillByDefault(Return(vr_help_title)); + ON_CALL(*mock_app_, vr_help()).WillByDefault(Return(vr_help)); + ON_CALL(*mock_app_, help_prompt()).WillByDefault(Return(vr_help_prompt)); + + ExpectationsHmiInterface_Run(); + + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId; + (*msg)[am::strings::msg_params][am::strings::info] = + "UI is not supported by system"; + + Event event(hmi_apis::FunctionID::UI_SetGlobalProperties); + event.set_smart_object(*msg); + + ON_CALL(mock_message_helper_, + VerifyImageVrHelpItems( + (*msg_vr)[am::strings::msg_params][am::strings::vr_help], _, _)) + .WillByDefault(Return(mobile_apis::Result::SUCCESS)); + + ON_CALL(mock_message_helper_, VerifyImage(_, _, _)) + .WillByDefault(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*msg_vr)[am::strings::msg_params][am::strings::help_prompt], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::UI_SetGlobalProperties))) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::TTS_SetGlobalProperties))) + .WillOnce(Return(true)); + (*msg_vr)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + Event event_vr(hmi_apis::FunctionID::TTS_SetGlobalProperties); + event_vr.set_smart_object(*msg_vr); + + command->Run(); + command->on_event(event_vr); + + MessageSharedPtr ui_command_result; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true))); + + command->on_event(event); + + ResultCommandExpectations(ui_command_result, "UI is not supported by system"); +} + +TEST_F(SetGlobalPropertiesRequestTest, OnEvent_SUCCESS_Expect_MessageNotSend) { + MessageSharedPtr response = CreateMessage(smart_objects::SmartType_Map); + (*response)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*response)[am::strings::msg_params][am::strings::info] = "test"; + + am::event_engine::Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties); + event.set_smart_object(*response); + + utils::SharedPtr<SetGlobalPropertiesRequest> command = + CreateCommand<SetGlobalPropertiesRequest>(response); + + MockAppPtr mock_app(CreateMockApp()); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .Times(0); + command->on_event(event); +} + +TEST_F(SetGlobalPropertiesRequestTest, + OnEvent_UNSUPPORTED_RESOURCE_Expect_false) { + MessageSharedPtr response = CreateMessage(smart_objects::SmartType_Map); + (*response)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*response)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*response)[am::strings::msg_params][am::strings::info] = "qwe"; + + am::event_engine::Event event_tts( + hmi_apis::FunctionID::TTS_SetGlobalProperties); + event_tts.set_smart_object(*response); + am::event_engine::Event event_ui( + hmi_apis::FunctionID::UI_SetGlobalProperties); + event_tts.set_smart_object(*response); + utils::SharedPtr<SetGlobalPropertiesRequest> command = + CreateCommand<SetGlobalPropertiesRequest>(response); + + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + MessageSharedPtr response_to_mobile; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command->Run(); + command->on_event(event_ui); + command->on_event(event_tts); + + EXPECT_EQ((*response_to_mobile)[am::strings::msg_params][am::strings::success] + .asBool(), + false); + EXPECT_EQ( + (*response_to_mobile)[am::strings::msg_params][am::strings::result_code] + .asInt(), + static_cast<int32_t>(mobile_apis::Result::INVALID_DATA)); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_VRNoMenuAndKeyboard_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties)) + .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + OnEventUISetupHelper(msg, command); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_VRWithMenuAndKeyboard_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject vr_help_title("yes"); + SmartObject vr_help_array(smart_objects::SmartType_Array); + VRArraySetupHelper(msg, vr_help_title, vr_help_array); + (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array; + SmartObject menu_title("Menu_Title"); + (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title; + SmartObject menu_icon(smart_objects::SmartType_Map); + menu_icon[am::strings::value] = "1"; + (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; + SmartObject keyboard_properties(smart_objects::SmartType_Map); + (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = + keyboard_properties; + + EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _)) + .WillOnce((Return(mobile_apis::Result::SUCCESS))); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _)) + .WillOnce((Return(mobile_apis::Result::SUCCESS))); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + EXPECT_CALL(*mock_app_, set_vr_help_title(vr_help_title)); + EXPECT_CALL(*mock_app_, set_vr_help(vr_help_array)); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); + EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(&vr_help_array)); + EXPECT_CALL(*mock_app_, set_menu_title(menu_title)); + EXPECT_CALL(*mock_app_, set_menu_icon(menu_icon)); + EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties)) + .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_VRBrokenMenuIcon_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject vr_help_title("yes"); + (*msg)[am::strings::msg_params][am::strings::vr_help_title] = vr_help_title; + SmartObject menu_icon(smart_objects::SmartType_Map); + menu_icon[am::strings::value] = "1"; + (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _)) + .WillOnce((Return(mobile_apis::Result::ABORTED))); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(_)).Times(0); + EmptyExpectationsSetupHelper(); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_VRBrokenVRHelp_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject vr_help_title("yes"); + SmartObject menu_icon(smart_objects::SmartType_Map); + menu_icon[am::strings::value] = "1"; + (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; + SmartObject vr_help_array(smart_objects::SmartType_Array); + VRArraySetupHelper(msg, vr_help_title, vr_help_array); + + EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _)) + .WillOnce((Return(mobile_apis::Result::SUCCESS))); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _)) + .WillOnce((Return(mobile_apis::Result::ABORTED))); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(_)).Times(0); + EmptyExpectationsSetupHelper(); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_VRIncorrectSyntax_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg)[am::strings::msg_params][am::strings::app_id] = kAppId; + SmartObject vr_help_title("wrong syntax string\\n"); + SmartObject menu_icon(smart_objects::SmartType_Map); + menu_icon[am::strings::value] = "1"; + (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; + SmartObject vr_help_array(smart_objects::SmartType_Array); + VRArraySetupHelper(msg, vr_help_title, vr_help_array); + + EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _)) + .WillOnce((Return(mobile_apis::Result::SUCCESS))); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _)) + .WillOnce((Return(mobile_apis::Result::SUCCESS))); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(_)).Times(0); + EmptyExpectationsSetupHelper(); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_VRMissingTitle_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject vr_help_array(smart_objects::SmartType_Array); + vr_help_array[0] = SmartObject(smart_objects::SmartType_Map); + vr_help_array[0][am::strings::text] = kText; + vr_help_array[0][am::strings::position] = kPosition; + (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _)) + .WillOnce((Return(mobile_apis::Result::SUCCESS))); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + EmptyExpectationsSetupHelper(); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_VRMissingArray_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject vr_help_title("yes"); + (*msg)[am::strings::msg_params][am::strings::vr_help_title] = vr_help_title; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + EmptyExpectationsSetupHelper(); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_VRWrongOrder_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject vr_help_title("yes"); + SmartObject vr_help_array(smart_objects::SmartType_Array); + VRArraySetupHelper(msg, vr_help_title, vr_help_array); + vr_help_array[1] = SmartObject(smart_objects::SmartType_Map); + vr_help_array[1][am::strings::text] = "two"; + vr_help_array[1][am::strings::position] = 3u; + (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array; + + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _)) + .WillOnce((Return(mobile_apis::Result::SUCCESS))); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + EmptyExpectationsSetupHelper(); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_NoVR_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject keyboard_properties(smart_objects::SmartType_Map); + (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = + keyboard_properties; + SmartObject menu_title("Menu_Title"); + (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + SmartObject vr_help_title("Menu_Title"); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); + EXPECT_CALL(*mock_app_, set_menu_title(menu_title)); + EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0); + EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties)) + .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_VRCouldNotGenerate_INVALID_DATA) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject keyboard_properties(smart_objects::SmartType_Map); + (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = + keyboard_properties; + SmartObject menu_title("Menu_Title"); + (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + SmartObject* vr_help_title = NULL; + CommandsMap commands_map; + SmartObject empty_msg(smart_objects::SmartType_Map); + commands_map.insert(std::pair<uint32_t, SmartObject*>(1u, &empty_msg)); + DataAccessor<CommandsMap> accessor(commands_map, lock_ptr_); + EXPECT_CALL(*mock_app_, commands_map()).WillOnce(Return(accessor)); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(vr_help_title)); + EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::INVALID_DATA), + am::commands::Command::SOURCE_SDL)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataNoDefault_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject keyboard_properties(smart_objects::SmartType_Map); + (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = + keyboard_properties; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + SmartObject vr_help_title(smart_objects::SmartType_Null); + EXPECT_CALL(*mock_app_, vr_help_title()) + .WillOnce(Return(&vr_help_title)) + .WillOnce(Return(&vr_help_title)); + + CommandsMap commands_map; + DataAccessor<CommandsMap> accessor(commands_map, lock_ptr_); + EXPECT_CALL(*mock_app_, commands_map()).WillOnce(Return(accessor)); + const CustomString name("name"); + EXPECT_CALL(*mock_app_, name()).WillOnce(ReturnRef(name)); + EXPECT_CALL(*mock_app_, set_vr_help_title(SmartObject(name))); + EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0); + EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0); + EXPECT_CALL(*mock_app_, set_keyboard_props(_)); + EXPECT_CALL(*mock_app_, app_id()); + + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties)) + .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataDefaultCreated_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject keyboard_properties(smart_objects::SmartType_Map); + (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = + keyboard_properties; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + SmartObject vr_help_title(smart_objects::SmartType_Null); + EXPECT_CALL(*mock_app_, vr_help_title()) + .Times(2) + .WillRepeatedly(Return(&vr_help_title)); + + CommandsMap commands_map; + SmartObject command_text(smart_objects::SmartType_Map); + commands_map[0] = &command_text; + (*commands_map[0])[am::strings::vr_commands] = SmartObject("one"); + DataAccessor<CommandsMap> accessor(commands_map, lock_ptr_); + EXPECT_CALL(*mock_app_, commands_map()).WillOnce(Return(accessor)); + EXPECT_CALL(*mock_app_, set_vr_help(_)); + const CustomString name("name"); + EXPECT_CALL(*mock_app_, name()).WillOnce(ReturnRef(name)); + EXPECT_CALL(*mock_app_, set_vr_help_title(SmartObject(name))); + SmartObject vr_help_array(smart_objects::SmartType_Array); + EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(&vr_help_array)); + EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0); + EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0); + EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties)) + .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataFromSynonyms_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject keyboard_properties(smart_objects::SmartType_Map); + (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = + keyboard_properties; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + SmartObject vr_help_title(smart_objects::SmartType_Null); + EXPECT_CALL(*mock_app_, vr_help_title()) + .Times(2) + .WillRepeatedly(Return(&vr_help_title)); + + CommandsMap commands_map; + DataAccessor<CommandsMap> accessor(commands_map, lock_ptr_); + EXPECT_CALL(*mock_app_, commands_map()).WillOnce(Return(accessor)); + SmartObject vr_help_array(smart_objects::SmartType_Array); + vr_help_array[0] = SmartObject(smart_objects::SmartType_Map); + vr_help_array[0][am::strings::text] = kText; + vr_help_array[0][am::strings::position] = kPosition; + SmartObject vr_synonyms(smart_objects::SmartType_Array); + vr_synonyms[0] = vr_help_array; + const CustomString name("name"); + EXPECT_CALL(*mock_app_, name()).WillOnce(ReturnRef(name)); + EXPECT_CALL(*mock_app_, set_vr_help_title(SmartObject(name))); + EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0); + EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0); + EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties)) + .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_TTSHelpAndTimeout_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject help_prompt(smart_objects::SmartType_Array); + help_prompt[0][am::strings::text] = "Help_Prompt_One"; + (*msg)[am::strings::msg_params][am::strings::help_prompt] = help_prompt; + SmartObject timeout_prompt(smart_objects::SmartType_Array); + timeout_prompt[0][am::strings::text] = "Timeout_Prompt_One"; + (*msg)[am::strings::msg_params][am::strings::timeout_prompt] = timeout_prompt; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(help_prompt, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(timeout_prompt, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + SmartObject vr_help_title("title"); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); + EXPECT_CALL(*mock_app_, set_help_prompt(help_prompt)); + EXPECT_CALL(*mock_app_, help_prompt()).WillOnce(Return(&help_prompt)); + EXPECT_CALL(*mock_app_, set_timeout_prompt(timeout_prompt)); + EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(&timeout_prompt)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties)) + .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_TTSOnlyHelp_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject help_prompt(smart_objects::SmartType_Array); + help_prompt[0][am::strings::text] = "Help_Prompt_One"; + (*msg)[am::strings::msg_params][am::strings::help_prompt] = help_prompt; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(help_prompt, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + SmartObject vr_help_title("title"); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); + EXPECT_CALL(*mock_app_, set_help_prompt(help_prompt)); + EXPECT_CALL(*mock_app_, help_prompt()).WillOnce(Return(&help_prompt)); + EXPECT_CALL(*mock_app_, set_timeout_prompt(_)).Times(0); + EXPECT_CALL(*mock_app_, timeout_prompt()).Times(0); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties)) + .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_TTSOnlyTimeout_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject timeout_prompt(smart_objects::SmartType_Array); + timeout_prompt[0][am::strings::text] = "Timeout_Prompt_One"; + (*msg)[am::strings::msg_params][am::strings::timeout_prompt] = timeout_prompt; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(timeout_prompt, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + SmartObject vr_help_title("title"); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); + EXPECT_CALL(*mock_app_, set_help_prompt(_)).Times(0); + EXPECT_CALL(*mock_app_, help_prompt()).Times(0); + EXPECT_CALL(*mock_app_, set_timeout_prompt(timeout_prompt)); + EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(&timeout_prompt)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties)) + .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_TTSIncorrectSyntax_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject timeout_prompt(smart_objects::SmartType_Array); + timeout_prompt[0][am::strings::text] = "Timeout_Prompt_One\\n"; + (*msg)[am::strings::msg_params][am::strings::timeout_prompt] = timeout_prompt; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); + EmptyExpectationsSetupHelper(); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_InvalidHelpPromptText_INVALID_DATA) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject help_prompt(smart_objects::SmartType_Array); + help_prompt[0][am::strings::text] = + "invalid help prompt text with empty line in the end\\n"; + (*msg)[am::strings::msg_params][am::strings::help_prompt] = help_prompt; + + ExpectVerifyImageVrHelpUnsuccess(); + EmptyExpectationsSetupHelper(); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + ExpectInvalidData(); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_InvalidVrHelpText_INVALID_DATA) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject vr_help(smart_objects::SmartType_Array); + vr_help[0][am::strings::text] = + "invalid vr_help text with empty line in the end\\n"; + (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help; + + ExpectVerifyImageVrHelpSuccess(vr_help); + EmptyExpectationsSetupHelper(); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + ExpectInvalidData(); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_InvalidImageValue_INVALID_DATA) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject vr_help(smart_objects::SmartType_Array); + vr_help[0][am::strings::text] = "vr_help"; + vr_help[0][am::strings::image][am::strings::value] = + "invalid value text with empty line in the end\\n"; + (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help; + + ExpectVerifyImageVrHelpSuccess(vr_help); + EmptyExpectationsSetupHelper(); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + ExpectInvalidData(); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_InvalidMenuIcon_INVALID_DATA) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject menu_icon(smart_objects::SmartType_Array); + menu_icon[am::strings::value] = + "invalid menu icon text with empty line in the end\\n"; + (*msg)[am::strings::msg_params][am::strings::menu_icon] = menu_icon; + + ExpectVerifyImageSuccess(menu_icon); + EmptyExpectationsSetupHelper(); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + ExpectInvalidData(); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_InvalidMenuTitle_INVALID_DATA) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject menu_title(smart_objects::SmartType_Array); + menu_title = "invalid menu title text with empty line in the end\\n"; + (*msg)[am::strings::msg_params][am::strings::menu_title] = menu_title; + + ExpectVerifyImageVrHelpUnsuccess(); + EmptyExpectationsSetupHelper(); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + ExpectInvalidData(); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, + Run_InvalidLimitedCharacterList_INVALID_DATA) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject limited_character_list(smart_objects::SmartType_Array); + limited_character_list[0] = + "invalid limited character list text with empty line in the end\\n"; + (*msg)[am::strings::msg_params][am::strings::keyboard_properties] + [am::strings::limited_character_list] = limited_character_list; + + ExpectVerifyImageVrHelpUnsuccess(); + EmptyExpectationsSetupHelper(); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + ExpectInvalidData(); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, + Run_InvalidAutoCompleteText_INVALID_DATA) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject auto_complete_text(smart_objects::SmartType_Array); + auto_complete_text = + "invalid auto completetext with empty line in the end\\n"; + (*msg)[am::strings::msg_params][am::strings::keyboard_properties] + [am::strings::auto_complete_text] = auto_complete_text; + + ExpectVerifyImageVrHelpUnsuccess(); + EmptyExpectationsSetupHelper(); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + ExpectInvalidData(); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_NoData_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + + ExpectVerifyImageVrHelpUnsuccess(); + EmptyExpectationsSetupHelper(); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_InvalidApp_Canceled) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + + ExpectVerifyImageVrHelpUnsuccess(); + + EmptyExpectationsSetupHelper(); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, OnEvent_PendingRequest_UNSUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + hmi_apis::Common_Result::eType response_code = + hmi_apis::Common_Result::SUCCESS; + (*msg)[am::strings::params][am::hmi_response::code] = response_code; + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + Event event(hmi_apis::FunctionID::UI_SetGlobalProperties); + event.set_smart_object(*msg); + + command->on_event(event); +} + +TEST_F(SetGlobalPropertiesRequestTest, OnEvent_UIAndSuccessResultCode_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + hmi_apis::Common_Result::eType response_code = + hmi_apis::Common_Result::SUCCESS; + (*msg)[am::strings::params][am::hmi_response::code] = response_code; + + ON_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + OnEventUISetupHelper(msg, command); + + Event event(hmi_apis::FunctionID::UI_SetGlobalProperties); + event.set_smart_object(*msg); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) + .WillOnce(Return(true)); + + command->on_event(event); +} + +TEST_F(SetGlobalPropertiesRequestTest, OnEvent_UIAndWarningResultCode_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + hmi_apis::Common_Result::eType response_code = + hmi_apis::Common_Result::WARNINGS; + (*msg)[am::strings::params][am::hmi_response::code] = response_code; + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + ON_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + OnEventUISetupHelper(msg, command); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + + Event event(hmi_apis::FunctionID::UI_SetGlobalProperties); + event.set_smart_object(*msg); + + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) + .WillOnce(Return(true)); + + command->on_event(event); +} + +TEST_F(SetGlobalPropertiesRequestTest, OnEvent_InvalidApp_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + hmi_apis::Common_Result::eType response_code = + hmi_apis::Common_Result::WARNINGS; + (*msg)[am::strings::params][am::hmi_response::code] = response_code; + ON_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + OnEventUISetupHelper(msg, command); + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillRepeatedly(Return(MockAppPtr())); + + EXPECT_CALL(*mock_app_, UpdateHash()).Times(0); + + Event event(hmi_apis::FunctionID::UI_SetGlobalProperties); + event.set_smart_object(*msg); + + command->on_event(event); +} + +TEST_F(SetGlobalPropertiesRequestTest, OnEvent_InvalidEventID_Canceled) { + MessageSharedPtr msg = CreateMessage(); + + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)).Times(0); + EXPECT_CALL(*mock_app_, UpdateHash()).Times(0); + + Event event(hmi_apis::FunctionID::TTS_Stopped); + event.set_smart_object(*msg); + + command->on_event(event); +} + +TEST_F(SetGlobalPropertiesRequestTest, + OnEvent_TTSAndSuccessResultCode_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + hmi_apis::Common_Result::eType response_code = + hmi_apis::Common_Result::SUCCESS; + (*msg)[am::strings::params][am::hmi_response::code] = response_code; + ON_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + OnEventTTSSetupHelper(msg, command); + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) + .WillOnce(Return(true)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + + Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties); + event.set_smart_object(*msg); + + command->on_event(event); +} + +TEST_F(SetGlobalPropertiesRequestTest, + OnEvent_TTSAndWarningsResultCode_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + const hmi_apis::Common_Result::eType response_code = + hmi_apis::Common_Result::WARNINGS; + (*msg)[am::strings::params][am::hmi_response::code] = response_code; + ON_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + SharedPtr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + OnEventTTSSetupHelper(msg, command); + + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + MessageSharedPtr ui_command_result; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true))); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + + Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties); + event.set_smart_object(*msg); + + command->on_event(event); + + EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success] + .asBool(), + true); + EXPECT_EQ( + (*ui_command_result)[am::strings::msg_params][am::strings::result_code] + .asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::WARNINGS)); +} + +} // namespace set_global_properties_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_media_clock_timer_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_media_clock_timer_test.cc new file mode 100644 index 0000000000..9d2dd996bc --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_media_clock_timer_test.cc @@ -0,0 +1,356 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "mobile/set_media_clock_timer_request.h" + +#include "gtest/gtest.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace set_media_clock_timer_request { + +namespace am = ::application_manager; +using sdl_rpc_plugin::commands::SetMediaClockRequest; +using am::commands::MessageSharedPtr; +using am::event_engine::Event; +using am::MockMessageHelper; +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +namespace UpdateMode = mobile_apis::UpdateMode; + +typedef SharedPtr<SetMediaClockRequest> SetMediaClockRequestPtr; + +namespace { +const uint32_t kConnectionKey = 2u; +const uint32_t kCorrelationId = 2u; +const uint32_t kAppID = 2u; +const uint32_t kHours = 2u; +const uint32_t kMinutes = 26u; +const uint32_t kSeconds = 1u; +} // namespace + +class SetMediaClockRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + SetMediaClockRequestTest() : mock_app_(CreateMockApp()) {} + + void SetUp() OVERRIDE { + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + } + + void ResultCommandExpectations(MessageSharedPtr msg, + const std::string& info) { + EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(), + true); + EXPECT_EQ( + (*msg)[am::strings::msg_params][am::strings::result_code].asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(), + info); + } + + MessageSharedPtr CreateMsgParams() { + MessageSharedPtr msg = CreateMessage(); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + return msg; + } + + void ExpectationsSetupHelper(bool is_media) { + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(*mock_app_, is_media_application()).WillOnce(Return(is_media)); + EXPECT_CALL(*mock_app_, app_id()).Times(0); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); + } + + MockAppPtr mock_app_; +}; + +TEST_F(SetMediaClockRequestTest, + OnEvent_UIHmiSendUnsupportedResource_UNSUPPORTED_RESOURCE) { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + + utils::SharedPtr<SetMediaClockRequest> command = + CreateCommand<SetMediaClockRequest>(msg); + + MessageSharedPtr ev_msg = CreateMessage(smart_objects::SmartType_Map); + (*ev_msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*ev_msg)[am::strings::msg_params][am::strings::app_id] = kConnectionKey; + (*ev_msg)[am::strings::msg_params][am::strings::info] = + "UI is not supported by system"; + + Event event(hmi_apis::FunctionID::UI_SetMediaClockTimer); + event.set_smart_object(*ev_msg); + + EXPECT_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_RESPONSE)); + + MessageSharedPtr ui_command_result; + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true))); + + command->on_event(event); + + ResultCommandExpectations(ui_command_result, "UI is not supported by system"); +} + +TEST_F(SetMediaClockRequestTest, Run_UpdateCountUp_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::update_mode] = + UpdateMode::COUNTUP; + (*msg)[am::strings::msg_params][am::strings::start_time][am::strings::hours] = + kHours; + (*msg)[am::strings::msg_params][am::strings::start_time] + [am::strings::minutes] = kMinutes; + (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::hours] = + kHours; + (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::minutes] = + kMinutes; + (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::seconds] = + kSeconds; + + SharedPtr<SetMediaClockRequest> command( + CreateCommand<SetMediaClockRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(*mock_app_, is_media_application()).WillOnce(Return(true)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppID)); + EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillOnce(Return(kCorrelationId)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetMediaClockTimer)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); + + command->Run(); +} + +TEST_F(SetMediaClockRequestTest, Run_UpdateCountDown_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::update_mode] = + UpdateMode::COUNTDOWN; + (*msg)[am::strings::msg_params][am::strings::start_time][am::strings::hours] = + kHours; + (*msg)[am::strings::msg_params][am::strings::start_time] + [am::strings::minutes] = kMinutes; + (*msg)[am::strings::msg_params][am::strings::start_time] + [am::strings::seconds] = kSeconds; + (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::hours] = + kHours; + (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::minutes] = + kMinutes; + + SharedPtr<SetMediaClockRequest> command( + CreateCommand<SetMediaClockRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(*mock_app_, is_media_application()).WillOnce(Return(true)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppID)); + EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillOnce(Return(kCorrelationId)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetMediaClockTimer)) + .WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); + + command->Run(); +} + +TEST_F(SetMediaClockRequestTest, Run_UpdateCountUpWrongTime_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::update_mode] = + UpdateMode::COUNTUP; + (*msg)[am::strings::msg_params][am::strings::start_time][am::strings::hours] = + kHours; + (*msg)[am::strings::msg_params][am::strings::start_time] + [am::strings::minutes] = kMinutes; + (*msg)[am::strings::msg_params][am::strings::start_time] + [am::strings::seconds] = kSeconds; + (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::hours] = + kHours; + (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::minutes] = + kMinutes; + + SharedPtr<SetMediaClockRequest> command( + CreateCommand<SetMediaClockRequest>(msg)); + + ExpectationsSetupHelper(true); + + command->Run(); +} + +TEST_F(SetMediaClockRequestTest, Run_UpdateCountDownWrongTime_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::update_mode] = + UpdateMode::COUNTDOWN; + (*msg)[am::strings::msg_params][am::strings::start_time][am::strings::hours] = + kHours; + (*msg)[am::strings::msg_params][am::strings::start_time] + [am::strings::minutes] = kMinutes; + (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::hours] = + kHours; + (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::minutes] = + kMinutes; + (*msg)[am::strings::msg_params][am::strings::end_time][am::strings::seconds] = + kSeconds; + + SharedPtr<SetMediaClockRequest> command( + CreateCommand<SetMediaClockRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(*mock_app_, is_media_application()).WillOnce(Return(true)); + EXPECT_CALL(*mock_app_, app_id()).Times(0); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); + + command->Run(); +} + +TEST_F(SetMediaClockRequestTest, Run_NoStartTime_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::update_mode] = + UpdateMode::COUNTDOWN; + + SharedPtr<SetMediaClockRequest> command( + CreateCommand<SetMediaClockRequest>(msg)); + + ExpectationsSetupHelper(true); + + command->Run(); +} + +TEST_F(SetMediaClockRequestTest, Run_NoUpdateMode_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<SetMediaClockRequest> command( + CreateCommand<SetMediaClockRequest>(msg)); + + ExpectationsSetupHelper(true); + + command->Run(); +} + +TEST_F(SetMediaClockRequestTest, Run_NotMediaApp_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<SetMediaClockRequest> command( + CreateCommand<SetMediaClockRequest>(msg)); + + ExpectationsSetupHelper(false); + + command->Run(); +} + +TEST_F(SetMediaClockRequestTest, Run_InvalidApp_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<SetMediaClockRequest> command( + CreateCommand<SetMediaClockRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(MockAppPtr())); + EXPECT_CALL(*mock_app_, is_media_application()).Times(0); + EXPECT_CALL(*mock_app_, app_id()).Times(0); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); + + command->Run(); +} + +TEST_F(SetMediaClockRequestTest, OnEvent_Success) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Null); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); + + MockAppPtr app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app)); + + Event event(hmi_apis::FunctionID::UI_SetMediaClockTimer); + event.set_smart_object(*msg); + SharedPtr<SetMediaClockRequest> command( + CreateCommand<SetMediaClockRequest>(msg)); + command->on_event(event); +} + +TEST_F(SetMediaClockRequestTest, OnEvent_Canceled) { + MessageSharedPtr msg = CreateMessage(); + + SharedPtr<SetMediaClockRequest> command( + CreateCommand<SetMediaClockRequest>(msg)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + Event event(hmi_apis::FunctionID::UI_Slider); + event.set_smart_object(*msg); + + command->on_event(event); +} + +} // namespace set_media_clock_timer_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc new file mode 100644 index 0000000000..9d5497d4a7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc @@ -0,0 +1,921 @@ +/* + * 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 <stdint.h> +#include <string> +#include <set> + +#include "mobile/show_request.h" + +#include "gtest/gtest.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/policies/mock_policy_handler_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace show_request { + +namespace am = application_manager; +using sdl_rpc_plugin::commands::ShowRequest; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using am::MockMessageHelper; +using test::components::policy_test::MockPolicyHandlerInterface; +using ::utils::SharedPtr; +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +namespace { +const int32_t kCommandId = 1; +const uint32_t kAppId = 1u; +const uint32_t kCmdId = 1u; +const uint32_t kConnectionKey = 2u; +const uint32_t kFunctionID = 3u; +} // namespace + +class ShowRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + ShowRequestTest() { + mock_app_ = CreateMockApp(); + } + sync_primitives::Lock lock_; + + MessageSharedPtr CreateFullParamsUISO() { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + smart_objects::SmartObject menu_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + menu_params[am::strings::position] = 10; + menu_params[am::strings::menu_name] = "LG"; + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[am::strings::cmd_id] = kCmdId; + msg_params[am::strings::menu_params] = menu_params; + msg_params[am::strings::app_id] = kAppId; + msg_params[am::strings::cmd_icon] = 1; + msg_params[am::strings::cmd_icon][am::strings::value] = "10"; + (*msg)[am::strings::msg_params] = msg_params; + + return msg; + } + + MessageSharedPtr CreateMsgParams() { + MessageSharedPtr msg = CreateMessage(); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg)[am::strings::params][am::strings::function_id] = kFunctionID; + return msg; + } + + void TestSetupHelper(MessageSharedPtr msg, + hmi_apis::Common_TextFieldName::eType field_name, + const char* field) { + SmartObject msg_params(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg)[am::strings::params][am::strings::function_id] = kFunctionID; + msg_params[field] = text_field_; + (*msg)[am::strings::msg_params] = msg_params; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + msg_params[am::strings::app_id] = kAppId; + msg_params[am::hmi_request::show_strings] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + msg_params.erase(field); + msg_params[am::hmi_request::show_strings][0][am::hmi_request::field_name] = + static_cast<int32_t>(field_name); + msg_params[am::hmi_request::show_strings][0][am::hmi_request::field_text] = + text_field_; + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)); + } + + void TestSetupHelperWrongSyntax( + MessageSharedPtr msg, + hmi_apis::Common_TextFieldName::eType field_name, + const char* field) { + SmartObject msg_params(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + msg_params[field] = text_field_; + (*msg)[am::strings::msg_params] = msg_params; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); + EXPECT_CALL(*mock_app_, app_id()).Times(0); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0); + } + + void TestSetupHelperWithMetadata( + MessageSharedPtr msg, + hmi_apis::Common_TextFieldName::eType field_name, + const char* field, + size_t num_tags, + int32_t* field_tags, + bool set_field_text = true) { + SmartObject msg_params(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg)[am::strings::params][am::strings::function_id] = kFunctionID; + if (set_field_text) { + msg_params[field] = text_field_; + } + msg_params[am::strings::metadata_tags][field] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + for (size_t i = 0; i < num_tags; ++i) { + const int32_t current_tag = field_tags[i]; + msg_params[am::strings::metadata_tags][field][i] = current_tag; + } + (*msg)[am::strings::msg_params] = msg_params; + + EXPECT_EQ((*msg)[am::strings::msg_params], msg_params); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + msg_params.erase(field); + msg_params.erase(am::strings::metadata_tags); + + msg_params[am::strings::app_id] = kAppId; + msg_params[am::hmi_request::show_strings] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + if (set_field_text) { + msg_params[am::hmi_request::show_strings][0] + [am::hmi_request::field_name] = + static_cast<int32_t>(field_name); + msg_params[am::hmi_request::show_strings][0] + [am::hmi_request::field_text] = text_field_; + msg_params[am::hmi_request::show_strings][0] + [am::hmi_request::field_types] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + for (size_t i = 0; i < num_tags; ++i) { + const int32_t current_tag = field_tags[i]; + msg_params[am::hmi_request::show_strings][0] + [am::hmi_request::field_types][i] = current_tag; + } + } + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)); + } + + MockAppPtr mock_app_; + std::string text_field_; +}; + +TEST_F(ShowRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) { + MessageSharedPtr msg_vr = CreateFullParamsUISO(); + (*msg_vr)[am::strings::msg_params][am::strings::menu_params] + [am::hmi_request::parent_id] = 10u; + (*msg_vr)[am::strings::msg_params][am::strings::menu_params] + [am::strings::menu_name] = "menu_name"; + + utils::SharedPtr<ShowRequest> command = CreateCommand<ShowRequest>(msg_vr); + + MockAppPtr mock_app = CreateMockApp(); + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app)); + ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey)); + + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*msg)[am::strings::msg_params][am::strings::cmd_id] = kCommandId; + + Event event(hmi_apis::FunctionID::UI_Show); + event.set_smart_object(*msg); + + MessageSharedPtr vr_command_result; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&vr_command_result), Return(true))); + + command->on_event(event); + + EXPECT_EQ((*vr_command_result)[am::strings::msg_params][am::strings::success] + .asBool(), + true); + EXPECT_EQ( + (*vr_command_result)[am::strings::msg_params][am::strings::result_code] + .asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + if ((*vr_command_result)[am::strings::msg_params].keyExists( + am::strings::info)) { + EXPECT_FALSE( + (*vr_command_result)[am::strings::msg_params][am::strings::info] + .asString() + .empty()); + } +} + +TEST_F(ShowRequestTest, Run_SoftButtonExists_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + + SmartObject msg_params(smart_objects::SmartType_Map); + msg_params[am::strings::soft_buttons] = "Soft_Buttons"; + (*msg)[am::strings::msg_params] = msg_params; + SmartObject creation_msg_params(msg_params); + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, ProcessSoftButtons(msg_params, _, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + msg_params[am::strings::app_id] = kAppId; + msg_params[am::hmi_request::show_strings] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + EXPECT_CALL( + mock_message_helper_, + SubscribeApplicationToSoftButton(creation_msg_params, _, kFunctionID)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)); + + command->Run(); +} + +TEST_F(ShowRequestTest, Run_SoftButtonNotExists_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + + SmartObject msg_params(smart_objects::SmartType_Map); + msg_params[am::strings::soft_buttons] = ""; + (*msg)[am::strings::msg_params] = msg_params; + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, ProcessSoftButtons(_, _, _, _)).Times(0); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + msg_params[am::strings::app_id] = kAppId; + msg_params[am::hmi_request::show_strings] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + EXPECT_CALL(*mock_app_, UnsubscribeFromSoftButtons(kFunctionID)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)); + + command->Run(); +} + +TEST_F(ShowRequestTest, Run_SoftButtonExists_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + + SmartObject msg_params(smart_objects::SmartType_Map); + msg_params[am::strings::soft_buttons] = "Soft_Buttons"; + (*msg)[am::strings::msg_params] = msg_params; + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, ProcessSoftButtons(msg_params, _, _, _)) + .WillOnce(Return(mobile_apis::Result::ABORTED)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); + + EXPECT_CALL(*mock_app_, app_id()).Times(0); + + EXPECT_CALL(mock_message_helper_, SubscribeApplicationToSoftButton(_, _, _)) + .Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0); + + command->Run(); +} + +TEST_F(ShowRequestTest, Run_Graphic_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + + SmartObject msg_params(smart_objects::SmartType_Map); + SmartObject graphic(smart_objects::SmartType_Map); + graphic[am::strings::value] = "1"; + msg_params[am::strings::graphic] = graphic; + (*msg)[am::strings::msg_params] = msg_params; + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + msg_params[am::strings::app_id] = kAppId; + msg_params[am::hmi_request::show_strings] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)); + + command->Run(); +} + +TEST_F(ShowRequestTest, Run_Graphic_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + + SmartObject msg_params(smart_objects::SmartType_Map); + SmartObject graphic(smart_objects::SmartType_Map); + graphic[am::strings::value] = "1"; + msg_params[am::strings::graphic] = graphic; + (*msg)[am::strings::msg_params] = msg_params; + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) + .WillOnce(Return(mobile_apis::Result::ABORTED)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); + EXPECT_CALL(*mock_app_, app_id()).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)).Times(0); + + command->Run(); +} + +TEST_F(ShowRequestTest, Run_Graphic_WrongSyntax) { + MessageSharedPtr msg = CreateMsgParams(); + + SmartObject msg_params(smart_objects::SmartType_Map); + SmartObject graphic(smart_objects::SmartType_Map); + graphic[am::strings::value] = "\\n"; + msg_params[am::strings::graphic] = graphic; + (*msg)[am::strings::msg_params] = msg_params; + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); + EXPECT_CALL(*mock_app_, app_id()).Times(0); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)).Times(0); + + command->Run(); +} + +TEST_F(ShowRequestTest, Run_SecondaryGraphic_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + + SmartObject msg_params(smart_objects::SmartType_Map); + SmartObject graphic(smart_objects::SmartType_Map); + graphic[am::strings::value] = "1"; + msg_params[am::strings::secondary_graphic] = graphic; + (*msg)[am::strings::msg_params] = msg_params; + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + msg_params[am::strings::app_id] = kAppId; + msg_params[am::hmi_request::show_strings] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)); + + command->Run(); +} + +TEST_F(ShowRequestTest, Run_SecondaryGraphic_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + + SmartObject msg_params(smart_objects::SmartType_Map); + SmartObject graphic(smart_objects::SmartType_Map); + graphic[am::strings::value] = "1"; + msg_params[am::strings::secondary_graphic] = graphic; + (*msg)[am::strings::msg_params] = msg_params; + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) + .WillOnce(Return(mobile_apis::Result::ABORTED)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); + EXPECT_CALL(*mock_app_, app_id()).Times(0); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)).Times(0); + + command->Run(); +} + +TEST_F(ShowRequestTest, Run_SecondaryGraphic_WrongSyntax) { + MessageSharedPtr msg = CreateMsgParams(); + + SmartObject msg_params(smart_objects::SmartType_Map); + SmartObject graphic(smart_objects::SmartType_Map); + graphic[am::strings::value] = ""; + msg_params[am::strings::secondary_graphic] = graphic; + (*msg)[am::strings::msg_params] = msg_params; + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); + EXPECT_CALL(*mock_app_, app_id()).Times(0); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)).Times(0); + + command->Run(); +} + +TEST_F(ShowRequestTest, Run_MainField1_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Main_Field_1"; + TestSetupHelper(msg, + hmi_apis::Common_TextFieldName::mainField1, + am::strings::main_field_1); + + command->Run(); +} + +TEST_F(ShowRequestTest, Run_MainField1_WrongSyntax) { + MessageSharedPtr msg = CreateMessage(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Main_Field_1\\n"; + TestSetupHelperWrongSyntax(msg, + hmi_apis::Common_TextFieldName::mainField1, + am::strings::main_field_1); + + command->Run(); +} + +TEST_F(ShowRequestTest, Run_MainField2_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Main_Field_2"; + TestSetupHelper(msg, + hmi_apis::Common_TextFieldName::mainField2, + am::strings::main_field_2); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_MainField2_WrongSyntax) { + MessageSharedPtr msg = CreateMessage(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Main_Field_2\\n"; + TestSetupHelperWrongSyntax(msg, + hmi_apis::Common_TextFieldName::mainField2, + am::strings::main_field_2); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_MainField3_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Main_Field_3"; + TestSetupHelper(msg, + hmi_apis::Common_TextFieldName::mainField3, + am::strings::main_field_3); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_MainField3_WrongSyntax) { + MessageSharedPtr msg = CreateMessage(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Main_Field_3\\n"; + TestSetupHelperWrongSyntax(msg, + hmi_apis::Common_TextFieldName::mainField3, + am::strings::main_field_3); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_MainField4_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Main_Field_4"; + TestSetupHelper(msg, + hmi_apis::Common_TextFieldName::mainField4, + am::strings::main_field_4); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_MainField4_WrongSyntax) { + MessageSharedPtr msg = CreateMessage(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Main_Field_4\\n"; + TestSetupHelperWrongSyntax(msg, + hmi_apis::Common_TextFieldName::mainField4, + am::strings::main_field_4); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_MainField1_MetadataTag) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Main_Field_1"; + const size_t num_tags = 1; + int32_t tags[num_tags] = {hmi_apis::Common_MetadataType::mediaArtist}; + TestSetupHelperWithMetadata(msg, + hmi_apis::Common_TextFieldName::mainField1, + am::strings::main_field_1, + num_tags, + tags); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_MainField1_MultipleMetadataTags) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Main_Field_1"; + const size_t num_tags = 5; + int32_t tags[num_tags] = {hmi_apis::Common_MetadataType::mediaTitle, + hmi_apis::Common_MetadataType::mediaArtist, + hmi_apis::Common_MetadataType::rating, + hmi_apis::Common_MetadataType::humidity, + hmi_apis::Common_MetadataType::currentTemperature}; + TestSetupHelperWithMetadata(msg, + hmi_apis::Common_TextFieldName::mainField1, + am::strings::main_field_1, + num_tags, + tags); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_MainField2_MetadataTag) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Main_Field_2"; + const size_t num_tags = 1; + int32_t tags[num_tags] = {hmi_apis::Common_MetadataType::mediaArtist}; + TestSetupHelperWithMetadata(msg, + hmi_apis::Common_TextFieldName::mainField2, + am::strings::main_field_2, + num_tags, + tags); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_MainField3_MetadataTag) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Main_Field_3"; + const size_t num_tags = 1; + int32_t tags[num_tags] = {hmi_apis::Common_MetadataType::mediaArtist}; + TestSetupHelperWithMetadata(msg, + hmi_apis::Common_TextFieldName::mainField3, + am::strings::main_field_3, + num_tags, + tags); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_MainField4_MetadataTag) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Main_Field_4"; + const size_t num_tags = 1; + int32_t tags[num_tags] = {hmi_apis::Common_MetadataType::mediaArtist}; + TestSetupHelperWithMetadata(msg, + hmi_apis::Common_TextFieldName::mainField4, + am::strings::main_field_4, + num_tags, + tags); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_MainField1_MetadataTagWithNoFieldData) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Main_Field_1"; + const size_t num_tags = 1; + int32_t tags[num_tags] = {hmi_apis::Common_MetadataType::mediaArtist}; + TestSetupHelperWithMetadata(msg, + hmi_apis::Common_TextFieldName::mainField1, + am::strings::main_field_1, + num_tags, + tags, + false); + command->Run(); + + MessageSharedPtr ev_msg = CreateMessage(smart_objects::SmartType_Map); + (*ev_msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*ev_msg)[am::strings::msg_params][am::strings::app_id] = kConnectionKey; + (*ev_msg)[am::strings::msg_params][am::strings::info] = ""; + + Event event(hmi_apis::FunctionID::UI_Show); + event.set_smart_object(*ev_msg); + + MessageSharedPtr ui_command_result; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true))); + + command->on_event(event); + + EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success] + .asBool(), + true); + EXPECT_EQ( + (*ui_command_result)[am::strings::msg_params][am::strings::result_code] + .asInt(), + static_cast<int32_t>(mobile_apis::Result::WARNINGS)); +} + +TEST_F(ShowRequestTest, Run_MediaClock_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Media_Clock"; + TestSetupHelper(msg, + hmi_apis::Common_TextFieldName::mediaClock, + am::strings::media_clock); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_MediaClock_WrongSyntax) { + MessageSharedPtr msg = CreateMessage(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Media_Clock\\n"; + TestSetupHelperWrongSyntax(msg, + hmi_apis::Common_TextFieldName::mediaClock, + am::strings::media_clock); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_MediaTrack_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Media_Track"; + TestSetupHelper(msg, + hmi_apis::Common_TextFieldName::mediaTrack, + am::strings::media_track); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_MediaTrack_WrongSyntax) { + MessageSharedPtr msg = CreateMessage(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Media_Track\\n"; + TestSetupHelperWrongSyntax(msg, + hmi_apis::Common_TextFieldName::mediaTrack, + am::strings::media_track); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_StatusBar_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Status_Bar"; + TestSetupHelper( + msg, hmi_apis::Common_TextFieldName::statusBar, am::strings::status_bar); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_StatusBar_WrongSyntax) { + MessageSharedPtr msg = CreateMessage(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + text_field_ = "Status_Bar\\n"; + TestSetupHelperWrongSyntax( + msg, hmi_apis::Common_TextFieldName::statusBar, am::strings::status_bar); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_Alignment_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject msg_params(smart_objects::SmartType_Map); + msg_params[am::strings::alignment] = "Alignment"; + (*msg)[am::strings::msg_params] = msg_params; + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + msg_params[am::strings::app_id] = kAppId; + msg_params[am::hmi_request::show_strings] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)); + + command->Run(); +} + +TEST_F(ShowRequestTest, Run_CustomPresets_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject msg_params(smart_objects::SmartType_Map); + SmartObject custom_presets(smart_objects::SmartType_Array); + custom_presets[0] = "Custom_Presets"; + msg_params[am::strings::custom_presets] = custom_presets; + (*msg)[am::strings::msg_params] = msg_params; + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + msg_params[am::strings::app_id] = kAppId; + msg_params[am::hmi_request::show_strings] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)); + + command->Run(); +} + +TEST_F(ShowRequestTest, Run_CustomPresets_WrongSyntax) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject msg_params(smart_objects::SmartType_Map); + SmartObject custom_presets(smart_objects::SmartType_Array); + custom_presets[0] = "Custom_Presets\\t"; + msg_params[am::strings::custom_presets] = custom_presets; + (*msg)[am::strings::msg_params] = msg_params; + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); + EXPECT_CALL(*mock_app_, app_id()).Times(0); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0); + + command->Run(); +} + +TEST_F(ShowRequestTest, Run_InvalidApp_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(MockAppPtr())); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); + EXPECT_CALL(*mock_app_, app_id()).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0); + + command->Run(); +} + +TEST_F(ShowRequestTest, Run_EmptyParams_Canceled) { + MessageSharedPtr msg = CreateMsgParams(); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); + EXPECT_CALL(*mock_app_, app_id()).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0); + + command->Run(); +} + +TEST_F(ShowRequestTest, OnEvent_SuccessResultCode_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::SUCCESS; + (*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Map); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::eType::SUCCESS), _)); + + Event event(hmi_apis::FunctionID::UI_Show); + event.set_smart_object(*msg); + + EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app_)); + + command->on_event(event); +} + +TEST_F(ShowRequestTest, OnEvent_WarningsResultCode_SUCCESS) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[am::strings::params][am::hmi_response::code] = + mobile_apis::Result::WARNINGS; + (*msg)[am::strings::params][am::hmi_response::message] = "Response Info"; + (*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Map); + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); + + Event event(hmi_apis::FunctionID::UI_Show); + event.set_smart_object(*msg); + + EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app_)); + + command->on_event(event); +} + +TEST_F(ShowRequestTest, OnEvent_WrongFunctionID_Canceled) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[am::strings::params][am::hmi_response::code] = + mobile_apis::Result::SUCCESS; + + SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + + Event event(hmi_apis::FunctionID::UI_Alert); + event.set_smart_object(*msg); + + command->on_event(event); +} + +} // namespace show_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace tests diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_notification_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_notification_commands_test.cc new file mode 100644 index 0000000000..dcdda55b1c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_notification_commands_test.cc @@ -0,0 +1,99 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" +#include "mobile/on_app_interface_unregistered_notification.h" +#include "mobile/on_audio_pass_thru_notification.h" +#include "mobile/on_driver_distraction_notification.h" +#include "mobile/on_language_change_notification.h" +#include "mobile/on_permissions_change_notification.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace simple_notification_commands_test { + +namespace am = ::application_manager; +namespace commands = sdl_rpc_plugin::commands; + +using ::testing::_; +using ::testing::Types; +using ::testing::Return; + +template <class Command> +class MobileNotificationCommandsTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + typedef Command CommandType; +}; + +typedef Types<commands::OnAppInterfaceUnregisteredNotification, + commands::OnAudioPassThruNotification, + commands::OnLanguageChangeNotification, + commands::OnPermissionsChangeNotification, + commands::mobile::OnDriverDistractionNotification> + NotificationCommandsList; + +MATCHER(CheckNotificationMessage, "") { + return (*arg)[am::strings::params][am::strings::protocol_type].asInt() == + am::commands::CommandImpl::mobile_protocol_type_ && + (*arg)[am::strings::params][am::strings::protocol_version].asInt() == + am::commands::CommandImpl::protocol_version_ && + (*arg)[am::strings::params][am::strings::message_type].asInt() == + application_manager::MessageType::kNotification; +} + +TYPED_TEST_CASE(MobileNotificationCommandsTest, NotificationCommandsList); + +TYPED_TEST(MobileNotificationCommandsTest, Run_SendMessageToMobile_SUCCESS) { + ::utils::SharedPtr<typename TestFixture::CommandType> command = + this->template CreateCommand<typename TestFixture::CommandType>(); + EXPECT_CALL(this->mock_rpc_service_, + SendMessageToMobile(CheckNotificationMessage(), _)); + command->Run(); +} + +} // namespace simple_notification_commands_test +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_response_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_response_commands_test.cc new file mode 100644 index 0000000000..cf1f7c6711 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_response_commands_test.cc @@ -0,0 +1,189 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/helpers.h" +#include "utils/shared_ptr.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_application_manager.h" +#include "mobile/delete_command_response.h" +#include "mobile/alert_maneuver_response.h" +#include "mobile/alert_response.h" +#include "mobile/list_files_response.h" +#include "mobile/subscribe_button_response.h" +#include "mobile/add_sub_menu_response.h" +#include "mobile/dial_number_response.h" +#include "mobile/end_audio_pass_thru_response.h" +#include "mobile/unregister_app_interface_response.h" +#include "mobile/unsubscribe_button_response.h" +#include "mobile/unsubscribe_way_points_response.h" +#include "mobile/update_turn_list_response.h" +#include "mobile/slider_response.h" +#include "mobile/speak_response.h" +#include "mobile/subscribe_way_points_response.h" +#include "mobile/system_response.h" +#include "mobile/get_way_points_response.h" +#include "mobile/perform_interaction_response.h" +#include "mobile/perform_audio_pass_thru_response.h" +#include "mobile/set_global_properties_response.h" +#include "mobile/set_media_clock_timer_response.h" +#include "mobile/show_constant_tbt_response.h" +#include "mobile/show_response.h" +#include "mobile/add_command_response.h" +#include "mobile/send_location_response.h" +#include "mobile/set_app_icon_response.h" +#include "mobile/set_display_layout_response.h" +#include "mobile/generic_response.h" +#include "mobile/set_app_icon_response.h" +#include "mobile/scrollable_message_response.h" +#include "mobile/change_registration_response.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace simple_response_commands_test { + +namespace commands = sdl_rpc_plugin::commands; +namespace am = ::application_manager; + +using ::testing::_; +using ::testing::NotNull; +using ::testing::Types; + +using am::commands::MessageSharedPtr; + +template <class Command> +class MobileResponseCommandsTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + typedef Command CommandType; +}; + +typedef Types<commands::ListFilesResponse, + commands::DeleteCommandResponse, + commands::AlertManeuverResponse, + commands::AlertResponse, + commands::SubscribeButtonResponse, + commands::AddSubMenuResponse, + commands::DialNumberResponse, + commands::EndAudioPassThruResponse, + commands::UnregisterAppInterfaceResponse, + commands::UnsubscribeWayPointsResponse, + commands::UpdateTurnListResponse, + commands::UnsubscribeButtonResponse, + commands::SliderResponse, + commands::SpeakResponse, + commands::SubscribeWayPointsResponse, + commands::SystemResponse, + commands::GetWayPointsResponse, + commands::PerformInteractionResponse, + commands::PerformAudioPassThruResponse, + commands::SetGlobalPropertiesResponse, + commands::SetMediaClockTimerResponse, + commands::ShowConstantTBTResponse, + commands::ShowResponse, + commands::SystemResponse, + commands::AddCommandResponse, + commands::SendLocationResponse, + commands::SetAppIconResponse, + commands::SetDisplayLayoutResponse, + commands::ChangeRegistrationResponse> ResponseCommandsList; + +TYPED_TEST_CASE(MobileResponseCommandsTest, ResponseCommandsList); + +TYPED_TEST(MobileResponseCommandsTest, Run_SendResponseToMobile_SUCCESS) { + ::utils::SharedPtr<typename TestFixture::CommandType> command = + this->template CreateCommand<typename TestFixture::CommandType>(); + EXPECT_CALL(this->mock_rpc_service_, SendMessageToMobile(NotNull(), _)); + command->Run(); +} + +class GenericResponseFromHMICommandsTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +MATCHER_P2(CheckMessageParams, success, result, "") { + const bool is_msg_type_correct = + (am::MessageType::kResponse) == + static_cast<int32_t>( + (*arg)[am::strings::params][am::strings::message_type].asInt()); + const bool is_success_correct = + success == (*arg)[am::strings::msg_params][am::strings::success].asBool(); + const bool is_result_code_correct = + result == + static_cast<int32_t>( + (*arg)[am::strings::msg_params][am::strings::result_code].asInt()); + + using namespace helpers; + return Compare<bool, EQ, ALL>( + true, is_msg_type_correct, is_success_correct, is_result_code_correct); +} + +TEST_F(GenericResponseFromHMICommandsTest, Run_SUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + + SharedPtr<commands::GenericResponse> command( + CreateCommand<commands::GenericResponse>(command_msg)); + + EXPECT_CALL( + this->mock_rpc_service_, + SendMessageToMobile( + CheckMessageParams(false, mobile_apis::Result::INVALID_DATA), false)); + + command->Run(); +} + +class ScrollableMessageResponseTest + : public CommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(ScrollableMessageResponseTest, Run_SUCCESS) { + MessageSharedPtr message = CreateMessage(); + (*message)[am::strings::msg_params][am::strings::result_code] = + mobile_apis::Result::SUCCESS; + + MockAppPtr app(CreateMockApp()); + + SharedPtr<commands::ScrollableMessageResponse> command( + CreateCommand<commands::ScrollableMessageResponse>(message)); + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app)); + EXPECT_CALL(*app, UnsubscribeFromSoftButtons(_)); + command->Run(); +} + +} // namespace simple_response_commands_test +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc new file mode 100644 index 0000000000..a039581284 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc @@ -0,0 +1,342 @@ +/* + * 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 <stdint.h> +#include <string> +#include <set> + +#include "mobile/slider_request.h" + +#include "gtest/gtest.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/policies/mock_policy_handler_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace slider_request { + +namespace am = application_manager; +using sdl_rpc_plugin::commands::SliderRequest; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using am::MockMessageHelper; +using policy_test::MockPolicyHandlerInterface; +using ::utils::SharedPtr; +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +typedef SharedPtr<SliderRequest> CommandPtr; + +namespace { +const int32_t kCommandId = 1; +const uint32_t kAppId = 1u; +const uint32_t kCmdId = 1u; +const uint32_t kConnectionKey = 2u; +const uint32_t kDefaultTimeout = 1000u; +const uint32_t kCorrelationId = 2u; +const uint32_t kFunctionId = 3u; +const uint32_t kNumTicks = 2u; +const uint32_t kPositionGreaterTicks = 3u; +const uint32_t kPositionLessTicks = 1u; +} // namespace + +class SliderRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + SliderRequestTest() + : mock_app_(CreateMockApp()) + , msg_(CreateMessage(smart_objects::SmartType_Map)) {} + + MessageSharedPtr CreateFullParamsUISO() { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + smart_objects::SmartObject menu_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + menu_params[am::strings::position] = 10; + menu_params[am::strings::menu_name] = "LG"; + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[am::strings::cmd_id] = kCmdId; + msg_params[am::strings::menu_params] = menu_params; + msg_params[am::strings::app_id] = kAppId; + msg_params[am::strings::cmd_icon] = 1; + msg_params[am::strings::cmd_icon][am::strings::value] = "10"; + (*msg)[am::strings::msg_params] = msg_params; + + return msg; + } + + void PreConditions() { + (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg_)[am::strings::msg_params][am::strings::num_ticks] = kNumTicks; + (*msg_)[am::strings::msg_params][am::strings::position] = + kPositionLessTicks; + (*msg_)[am::strings::msg_params][am::strings::slider_footer][0] = + "slider_footer1"; + (*msg_)[am::strings::msg_params][am::strings::slider_footer][1] = + "slider_footer2"; + (*msg_)[am::strings::msg_params][am::strings::slider_header] = + "slider_header"; + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + } + + void ExpectManageMobileCommandWithResultCode( + const mobile_apis::Result::eType code) { + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(code), + am::commands::Command::CommandSource::SOURCE_SDL)); + } + + sync_primitives::Lock lock_; + + MockAppPtr mock_app_; + MessageSharedPtr msg_; + MockPolicyHandlerInterface mock_policy_handler_; +}; + +TEST_F(SliderRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) { + MessageSharedPtr msg_ui = CreateFullParamsUISO(); + (*msg_ui)[am::strings::params][am::strings::connection_key] = kConnectionKey; + + utils::SharedPtr<SliderRequest> command = + CreateCommand<SliderRequest>(msg_ui); + + MockAppPtr mock_app = CreateMockApp(); + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app)); + + ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey)); + + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + (*msg)[am::strings::msg_params][am::strings::info] = "info"; + + Event event(hmi_apis::FunctionID::UI_Slider); + event.set_smart_object(*msg); + + MessageSharedPtr ui_command_result; + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true))); + + command->on_event(event); + + EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success] + .asBool(), + true); + EXPECT_EQ( + (*ui_command_result)[am::strings::msg_params][am::strings::result_code] + .asInt(), + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + if ((*ui_command_result)[am::strings::msg_params].keyExists( + am::strings::info)) { + EXPECT_FALSE( + (*ui_command_result)[am::strings::msg_params][am::strings::info] + .asString() + .empty()); + } +} + +class CallOnTimeOut { + public: + CallOnTimeOut(CommandRequestImpl& command) : command_(command) {} + + void operator()() { + command_.onTimeOut(); + } + + CommandRequestImpl& command_; +}; + +TEST_F(SliderRequestTest, Init_SUCCESS) { + PreConditions(); + (*msg_)[am::strings::msg_params][am::strings::timeout] = kDefaultTimeout; + + CommandPtr command(CreateCommand<SliderRequest>(msg_)); + EXPECT_TRUE(command->Init()); +} + +TEST_F(SliderRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { + PreConditions(); + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(ApplicationSharedPtr())); + ExpectManageMobileCommandWithResultCode( + mobile_apis::Result::APPLICATION_NOT_REGISTERED); + + CommandPtr command(CreateCommand<SliderRequest>(msg_)); + command->Run(); +} + +TEST_F(SliderRequestTest, Run_PositionGreaterTicks_UNSUCCESS) { + PreConditions(); + (*msg_)[am::strings::msg_params][am::strings::position] = + kPositionGreaterTicks; + + CommandPtr command(CreateCommand<SliderRequest>(msg_)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA); + command->Run(); +} + +TEST_F(SliderRequestTest, Run_SliderFooterNotEqToNumticks_UNSUCCESS) { + PreConditions(); + (*msg_)[am::strings::msg_params][am::strings::slider_footer][2] = + "slider_footer3"; + CommandPtr command(CreateCommand<SliderRequest>(msg_)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA); + command->Run(); +} + +TEST_F(SliderRequestTest, Run_InvalidSliderHeader_UNSUCCESS) { + PreConditions(); + (*msg_)[am::strings::msg_params][am::strings::slider_header] = + "invalid_test_with_empty_str\\n"; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA); + + CommandPtr command(CreateCommand<SliderRequest>(msg_)); + command->Run(); +} + +TEST_F(SliderRequestTest, Run_InvalidSliderFooter_UNSUCCESS) { + PreConditions(); + (*msg_)[am::strings::msg_params][am::strings::slider_footer][0] = + "invalid_test_with_empty_str\\n"; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_DATA); + + CommandPtr command(CreateCommand<SliderRequest>(msg_)); + command->Run(); +} + +TEST_F(SliderRequestTest, Run_SUCCESS) { + PreConditions(); + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_Slider))); + + CommandPtr command(CreateCommand<SliderRequest>(msg_)); + command->Run(); +} + +TEST_F(SliderRequestTest, OnEvent_UI_OnResetTimeout_UNSUCCESS) { + PreConditions(); + (*msg_)[am::strings::msg_params][am::strings::timeout] = kDefaultTimeout; + (*msg_)[am::strings::params][am::strings::correlation_id] = kCorrelationId; + + CommandPtr command(CreateCommand<SliderRequest>(msg_)); + EXPECT_TRUE(command->Init()); + + EXPECT_CALL(app_mngr_, + updateRequestTimeout(kConnectionKey, kCorrelationId, _)); + + Event event(hmi_apis::FunctionID::UI_OnResetTimeout); + event.set_smart_object(*msg_); + command->on_event(event); +} + +TEST_F(SliderRequestTest, OnEvent_UI_UnknownEventId_UNSUCCESS) { + PreConditions(); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + + Event event(hmi_apis::FunctionID::INVALID_ENUM); + event.set_smart_object(*msg_); + + CommandPtr command(CreateCommand<SliderRequest>(msg_)); + command->on_event(event); +} + +TEST_F(SliderRequestTest, OnEvent_UISliderPositionExists_SUCCESS) { + PreConditions(); + (*msg_)[am::strings::msg_params][am::strings::timeout] = kDefaultTimeout; + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::TIMED_OUT; + (*msg_)[am::strings::params][am::strings::data] + [am::strings::slider_position] = "position"; + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::TIMED_OUT); + + Event event(hmi_apis::FunctionID::UI_Slider); + event.set_smart_object(*msg_); + + CommandPtr command(CreateCommand<SliderRequest>(msg_)); + command->on_event(event); +} + +TEST_F(SliderRequestTest, OnEvent_UISliderAborted_SUCCESS) { + PreConditions(); + (*msg_)[am::strings::msg_params][am::strings::timeout] = kDefaultTimeout; + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::ABORTED; + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::ABORTED); + + Event event(hmi_apis::FunctionID::UI_Slider); + event.set_smart_object(*msg_); + + CommandPtr command(CreateCommand<SliderRequest>(msg_)); + command->on_event(event); +} + +} // namespace slider_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace tests diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc new file mode 100644 index 0000000000..ab086de0e6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc @@ -0,0 +1,407 @@ +/* + + 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 <string> +#include "gtest/gtest.h" +#include "mobile/speak_request.h" +#include "utils/shared_ptr.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" +#include "utils/shared_ptr.h" +#include "utils/helpers.h" +#include "utils/make_shared.h" +#include "smart_objects/smart_object.h" +#include "utils/custom_string.h" +#include "application_manager/application.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace speak_request { + +namespace am = application_manager; +namespace mobile_result = mobile_apis::Result; +namespace hmi_response = ::application_manager::hmi_response; +namespace strings = ::application_manager::strings; +using am::commands::CommandImpl; +using am::ApplicationManager; +using am::commands::MessageSharedPtr; +using am::ApplicationSharedPtr; +using am::MockMessageHelper; +using ::testing::_; +using ::utils::SharedPtr; +using ::testing::Return; +using ::testing::ReturnRef; +using sdl_rpc_plugin::commands::SpeakRequest; +using ::test::components::application_manager_test::MockApplication; + +typedef SharedPtr<SpeakRequest> CommandPtr; + +namespace { +const uint32_t kAppId = 10u; +const uint32_t kConnectionKey = 5u; +} + +class SpeakRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + SpeakRequestTest() + : request_(CreateMessage(smart_objects::SmartType_Map)) + , response_(CreateMessage(smart_objects::SmartType_Map)) + , app_(CreateMockApp()) {} + + void CheckExpectations(const hmi_apis::Common_Result::eType hmi_response, + const mobile_apis::Result::eType mobile_response, + const am::HmiInterfaces::InterfaceState state, + const bool success) { + utils::SharedPtr<SpeakRequest> command = + CreateCommand<SpeakRequest>(request_); + + (*response_)[strings::params][hmi_response::code] = hmi_response; + (*response_)[strings::msg_params] = 0; + + am::event_engine::Event event_tts(hmi_apis::FunctionID::TTS_Speak); + event_tts.set_smart_object(*response_); + + MockAppPtr mock_app(CreateMockApp()); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); + + MessageSharedPtr response_to_mobile; + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(state)); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + _, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command->on_event(event_tts); + + EXPECT_EQ( + (*response_to_mobile)[strings::msg_params][strings::success].asBool(), + success); + EXPECT_EQ((*response_to_mobile)[strings::msg_params][strings::result_code] + .asInt(), + static_cast<int32_t>(mobile_response)); + } + + MessageSharedPtr request_; + MessageSharedPtr response_; + MockAppPtr app_; +}; + +TEST_F(SpeakRequestTest, OnEvent_SUCCESS_Expect_true) { + utils::SharedPtr<SpeakRequest> command = + CreateCommand<SpeakRequest>(request_); + + (*response_)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*response_)[strings::msg_params] = 0; + + am::event_engine::Event event_tts(hmi_apis::FunctionID::TTS_Speak); + event_tts.set_smart_object(*response_); + + MockAppPtr mock_app(CreateMockApp()); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); + + MessageSharedPtr response_to_mobile; + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command->on_event(event_tts); + + EXPECT_EQ( + (*response_to_mobile)[strings::msg_params][strings::success].asBool(), + true); + EXPECT_EQ( + (*response_to_mobile)[strings::msg_params][strings::result_code].asInt(), + static_cast<int32_t>(mobile_apis::Result::SUCCESS)); +} + +TEST_F(SpeakRequestTest, + OnEvent_UNSUPPORTED_RESOURCE_STATE_AVAILABLE_Expect_true) { + CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + am::HmiInterfaces::STATE_AVAILABLE, + true); +} + +TEST_F(SpeakRequestTest, + OnEvent_UNSUPPORTED_RESOURCE_STATE_NOT_AVAILABLE_Expect_false) { + CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + am::HmiInterfaces::STATE_NOT_AVAILABLE, + false); +} + +TEST_F(SpeakRequestTest, + OnEvent_UNSUPPORTED_RESOURCE_STATE_NOT_RESPONSE_Expect_true) { + CheckExpectations(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + am::HmiInterfaces::STATE_NOT_RESPONSE, + true); +} + +TEST_F(SpeakRequestTest, Run_ApplicationIsNotRegistered) { + CommandPtr command(CreateCommand<SpeakRequest>(request_)); + + ON_CALL(app_mngr_, application(_)) + .WillByDefault(Return(ApplicationSharedPtr())); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _)); + + command->Run(); +} + +TEST_F(SpeakRequestTest, Run_MsgWithWhiteSpace_InvalidData) { + (*request_)[am::strings::msg_params][am::strings::tts_chunks][0] + [am::strings::text] = " "; + CommandPtr command(CreateCommand<SpeakRequest>(request_)); + + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _)); + + command->Run(); +} + +TEST_F(SpeakRequestTest, Run_MsgWithIncorrectChar1_InvalidData) { + (*request_)[am::strings::msg_params][am::strings::tts_chunks][0] + [am::strings::text] = "sd\\t"; + CommandPtr command(CreateCommand<SpeakRequest>(request_)); + + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _)); + + command->Run(); +} + +TEST_F(SpeakRequestTest, Run_MsgWithIncorrectChar2_InvalidData) { + (*request_)[am::strings::msg_params][am::strings::tts_chunks][0] + [am::strings::text] = "sd\\n"; + CommandPtr command(CreateCommand<SpeakRequest>(request_)); + + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _)); + + command->Run(); +} + +TEST_F(SpeakRequestTest, Run_MsgWithIncorrectChar3_InvalidData) { + (*request_)[am::strings::msg_params][am::strings::tts_chunks][0] + [am::strings::text] = "sd\tdf"; + CommandPtr command(CreateCommand<SpeakRequest>(request_)); + + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _)); + + command->Run(); +} + +TEST_F(SpeakRequestTest, Run_MsgWithIncorrectChar4_InvalidData) { + (*request_)[am::strings::msg_params][am::strings::tts_chunks][0] + [am::strings::text] = "sd\n rer"; + CommandPtr command(CreateCommand<SpeakRequest>(request_)); + + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _)); + + command->Run(); +} + +TEST_F(SpeakRequestTest, Run_MsgWithIncorrectCharInfirstPlace_InvalidData) { + (*request_)[am::strings::msg_params][am::strings::tts_chunks][0] + [am::strings::text] = "\n"; + CommandPtr command(CreateCommand<SpeakRequest>(request_)); + + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _)); + + command->Run(); +} + +TEST_F(SpeakRequestTest, Run_MsgWithEmptyString_Success) { + (*request_)[am::strings::msg_params][am::strings::tts_chunks][0] + [am::strings::text] = ""; + CommandPtr command(CreateCommand<SpeakRequest>(request_)); + + EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*request_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_)); + ON_CALL(*app_, app_id()).WillByDefault(Return(kAppId)); + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak))); + + command->Run(); +} + +TEST_F(SpeakRequestTest, Run_MsgCorrect_Success) { + (*request_)[am::strings::msg_params][am::strings::tts_chunks][0] + [am::strings::text] = "asda"; + CommandPtr command(CreateCommand<SpeakRequest>(request_)); + + EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*request_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_)); + ON_CALL(*app_, app_id()).WillByDefault(Return(kAppId)); + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak))); + + command->Run(); +} + +TEST_F(SpeakRequestTest, OnEvent_WrongEventId_UNSUCCESS) { + Event event(Event::EventID::INVALID_ENUM); + CommandPtr command(CreateCommand<SpeakRequest>()); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + command->on_event(event); +} + +TEST_F(SpeakRequestTest, OnEvent_TTS_Speak_SUCCESS) { + Event event(Event::EventID::TTS_Speak); + MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map)); + hmi_apis::Common_Result::eType hmi_result = hmi_apis::Common_Result::SUCCESS; + (*event_msg)[am::strings::msg_params][am::strings::tts_chunks][0] + [am::strings::text] = "1234"; + (*event_msg)[am::strings::params][am::hmi_response::code] = hmi_result; + (*event_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + event.set_smart_object(*event_msg); + CommandPtr command(CreateCommand<SpeakRequest>(request_)); + + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); + command->on_event(event); +} + +TEST_F(SpeakRequestTest, OnEvent_TTS_SpeakWithWarning_WarningWithSuccess) { + Event event(Event::EventID::TTS_Speak); + MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map)); + hmi_apis::Common_Result::eType hmi_result = hmi_apis::Common_Result::WARNINGS; + (*event_msg)[am::strings::params][am::hmi_response::code] = hmi_result; + (*event_msg)[am::strings::msg_params][am::strings::tts_chunks][0] + [am::strings::text] = "asda"; + event.set_smart_object(*event_msg); + CommandPtr command(CreateCommand<SpeakRequest>()); + + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::WARNINGS), _)); + command->on_event(event); +} + +TEST_F(SpeakRequestTest, OnEvent_TTS_OnResetTimeout_UpdateTimeout) { + Event event(Event::EventID::TTS_OnResetTimeout); + (*request_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*request_)[am::strings::params][am::strings::correlation_id] = kAppId; + CommandPtr command(CreateCommand<SpeakRequest>(request_)); + + EXPECT_CALL(app_mngr_, updateRequestTimeout(kConnectionKey, kAppId, _)); + + command->on_event(event); +} + +TEST_F(SpeakRequestTest, OnEvent_ApplicationIsNotRegistered_UNSUCCESS) { + const hmi_apis::Common_Result::eType hmi_result = + hmi_apis::Common_Result::SUCCESS; + + Event event(Event::EventID::TTS_Speak); + MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map)); + (*event_msg)[am::strings::msg_params][am::strings::tts_chunks][0] + [am::strings::text] = "text"; + (*event_msg)[am::strings::params][am::hmi_response::code] = hmi_result; + (*event_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + event.set_smart_object(*event_msg); + CommandPtr command(CreateCommand<SpeakRequest>(request_)); + + EXPECT_CALL(app_mngr_, application(_)) + .WillOnce(Return(ApplicationSharedPtr())); + + command->on_event(event); +} + +} // namespace speak_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace component +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc new file mode 100644 index 0000000000..17c4db36bc --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc @@ -0,0 +1,202 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "mobile/subscribe_button_request.h" +#include "interfaces/MOBILE_API.h" +#include "application_manager/smart_object_keys.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace subscribe_button_request { + +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::DoAll; +using ::testing::SaveArg; +namespace am = ::application_manager; +using sdl_rpc_plugin::commands::SubscribeButtonRequest; +using am::commands::MessageSharedPtr; + +typedef SharedPtr<SubscribeButtonRequest> CommandPtr; + +class SubscribeButtonRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + typedef TypeIf<kMocksAreNice, + NiceMock<application_manager_test::MockHMICapabilities>, + application_manager_test::MockHMICapabilities>::Result + MockHMICapabilities; +}; + +typedef SubscribeButtonRequestTest::MockHMICapabilities MockHMICapabilities; + +TEST_F(SubscribeButtonRequestTest, Run_AppNotRegistered_UNSUCCESS) { + CommandPtr command(CreateCommand<SubscribeButtonRequest>()); + + ON_CALL(app_mngr_, application(_)) + .WillByDefault(Return(SharedPtr<am::Application>())); + + MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command))); + EXPECT_EQ(mobile_apis::Result::APPLICATION_NOT_REGISTERED, + static_cast<mobile_apis::Result::eType>( + (*result_msg)[am::strings::msg_params][am::strings::result_code] + .asInt())); +} + +TEST_F(SubscribeButtonRequestTest, Run_SubscriptionNotAllowed_UNSUCCESS) { + MessageSharedPtr msg(CreateMessage()); + (*msg)[am::strings::msg_params][am::strings::button_name] = + mobile_apis::ButtonName::SEEKLEFT; + CommandPtr command(CreateCommand<SubscribeButtonRequest>(msg)); + + MockAppPtr app(CreateMockApp()); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, is_media_application()).WillByDefault(Return(false)); + + MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command))); + EXPECT_EQ(mobile_apis::Result::REJECTED, + static_cast<mobile_apis::Result::eType>( + (*result_msg)[am::strings::msg_params][am::strings::result_code] + .asInt())); +} + +TEST_F(SubscribeButtonRequestTest, Run_UiIsNotSupported_UNSUCCESS) { + CommandPtr command(CreateCommand<SubscribeButtonRequest>()); + + MockAppPtr app(CreateMockApp()); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + + ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) + .WillByDefault(Return(false)); + + MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command))); + EXPECT_EQ(mobile_apis::Result::UNSUPPORTED_RESOURCE, + static_cast<mobile_apis::Result::eType>( + (*result_msg)[am::strings::msg_params][am::strings::result_code] + .asInt())); +} + +TEST_F(SubscribeButtonRequestTest, Run_IsSubscribedToButton_UNSUCCESS) { + const mobile_apis::ButtonName::eType kButtonName = + mobile_apis::ButtonName::SEEKLEFT; + + MessageSharedPtr msg(CreateMessage()); + (*msg)[am::strings::msg_params][am::strings::button_name] = kButtonName; + CommandPtr command(CreateCommand<SubscribeButtonRequest>(msg)); + + MockAppPtr app(CreateMockApp()); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, is_media_application()).WillByDefault(Return(true)); + + ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) + .WillByDefault(Return(true)); + + MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map)); + (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonName; + + ON_CALL(mock_hmi_capabilities_, button_capabilities()) + .WillByDefault(Return(button_caps_ptr.get())); + + ON_CALL(*app, IsSubscribedToButton(_)).WillByDefault(Return(true)); + + MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command))); + EXPECT_EQ(mobile_apis::Result::IGNORED, + static_cast<mobile_apis::Result::eType>( + (*result_msg)[am::strings::msg_params][am::strings::result_code] + .asInt())); +} + +TEST_F(SubscribeButtonRequestTest, Run_SUCCESS) { + const mobile_apis::ButtonName::eType kButtonName = + mobile_apis::ButtonName::SEEKLEFT; + + MessageSharedPtr msg(CreateMessage()); + (*msg)[am::strings::msg_params][am::strings::button_name] = kButtonName; + CommandPtr command(CreateCommand<SubscribeButtonRequest>(msg)); + + MockAppPtr app(CreateMockApp()); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, is_media_application()).WillByDefault(Return(true)); + + ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) + .WillByDefault(Return(true)); + + MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map)); + (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonName; + + ON_CALL(mock_hmi_capabilities_, button_capabilities()) + .WillByDefault(Return(button_caps_ptr.get())); + + ON_CALL(*app, IsSubscribedToButton(_)).WillByDefault(Return(false)); + + MessageSharedPtr hmi_result_msg; + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&hmi_result_msg), Return(true))); + + MessageSharedPtr mobile_result_msg; + EXPECT_CALL(this->mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&mobile_result_msg), Return(true))); + ASSERT_TRUE(command->Init()); + command->Run(); + + EXPECT_EQ(hmi_apis::FunctionID::Buttons_OnButtonSubscription, + static_cast<hmi_apis::FunctionID::eType>( + (*hmi_result_msg)[am::strings::params][am::strings::function_id] + .asInt())); + + EXPECT_EQ(mobile_apis::Result::SUCCESS, + static_cast<mobile_apis::Result::eType>( + (*mobile_result_msg)[am::strings::msg_params] + [am::strings::result_code].asInt())); +} + +} // namespace subscribe_button_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_way_points_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_way_points_request_test.cc new file mode 100644 index 0000000000..e944c3eb39 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_way_points_request_test.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 "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_message_helper.h" +#include "mobile/subscribe_way_points_request.h" +#include "interfaces/MOBILE_API.h" +#include "application_manager/smart_object_keys.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace subscribe_way_points_request { + +using ::testing::_; +using ::testing::A; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::DoAll; +using ::testing::SaveArg; +using ::testing::InSequence; +namespace am = ::application_manager; +using sdl_rpc_plugin::commands::SubscribeWayPointsRequest; +using am::commands::MessageSharedPtr; + +typedef SharedPtr<SubscribeWayPointsRequest> CommandPtr; + +class SubscribeWayPointsRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(SubscribeWayPointsRequestTest, Run_SUCCESS) { + CommandPtr command(CreateCommand<SubscribeWayPointsRequest>()); + MockAppPtr app(CreateMockApp()); + + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(app_mngr_, IsAppSubscribedForWayPoints(A<am::ApplicationSharedPtr>())) + .WillByDefault(Return(false)); + ON_CALL(app_mngr_, IsAnyAppSubscribedForWayPoints()) + .WillByDefault(Return(true)); + + { + InSequence dummy; + EXPECT_CALL(app_mngr_, + SubscribeAppForWayPoints(A<am::ApplicationSharedPtr>())); + EXPECT_CALL(*app, UpdateHash()); + } + + command->Init(); + MessageSharedPtr mobile_result_msg( + CatchMobileCommandResult(CallRun(*command))); + + EXPECT_EQ(mobile_apis::Result::SUCCESS, + static_cast<mobile_apis::Result::eType>( + (*mobile_result_msg)[am::strings::msg_params] + [am::strings::result_code].asInt())); +} + +TEST_F(SubscribeWayPointsRequestTest, OnEvent_SUCCESS) { + CommandPtr command(CreateCommand<SubscribeWayPointsRequest>()); + MockAppPtr app(CreateMockApp()); + Event event(hmi_apis::FunctionID::Navigation_SubscribeWayPoints); + + MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map)); + const hmi_apis::Common_Result::eType result_code = + hmi_apis::Common_Result::SUCCESS; + (*event_msg)[am::strings::params][am::hmi_response::code] = result_code; + (*event_msg)[am::strings::msg_params] = 0; + + event.set_smart_object(*event_msg); + + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + + { + InSequence dummy; + EXPECT_CALL(app_mngr_, + SubscribeAppForWayPoints(A<am::ApplicationSharedPtr>())); + EXPECT_CALL(mock_message_helper_, HMIToMobileResult(result_code)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); + EXPECT_CALL(*app, UpdateHash()); + } + + command->Init(); + command->on_event(event); +} + +} // namespace subscribe_way_points_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc new file mode 100644 index 0000000000..7214e0eea4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc @@ -0,0 +1,236 @@ +/* + * 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 <stdint.h> +#include <string> +#include <set> + +#include "gtest/gtest.h" + +#include "mobile/system_request.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/policies/mock_policy_handler_interface.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace system_request { + +namespace am = application_manager; +using sdl_rpc_plugin::commands::SystemRequest; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using am::MockHmiInterfaces; +using am::event_engine::Event; +using am::MessageType; +using policy_test::MockPolicyHandlerInterface; +using ::utils::SharedPtr; +using ::testing::_; +using ::testing::DoAll; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::SaveArg; + +namespace { +const uint32_t kConnectionKey = 2u; +const std::string kAppPolicyId = "fake-app-id"; +const uint32_t kDefaultTimeout = 1000u; +const std::string kAppFolderName = "fake-app-name"; +const std::string kAppStorageFolder = "fake-storage"; +const std::string kSystemFilesPath = "/fake/system/files"; +const std::string kFileName = "Filename"; +const uint32_t kHmiAppId = 3u; +} // namespace + +class SystemRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + SystemRequestTest() : mock_app_(CreateMockApp()) {} + + protected: + MessageSharedPtr CreateIVSUMessage() { + MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg)[am::strings::msg_params][am::strings::request_type] = + mobile_apis::RequestType::HTTP; + (*msg)[am::strings::msg_params][am::strings::file_name] = kFileName; + return msg; + } + + void PreConditions() { + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kAppPolicyId)); + ON_CALL(*mock_app_, folder_name()).WillByDefault(Return(kAppFolderName)); + ON_CALL(*mock_app_, hmi_app_id()).WillByDefault(Return(kHmiAppId)); + + ON_CALL(app_mngr_settings_, system_files_path()) + .WillByDefault(ReturnRef(kSystemFilesPath)); + ON_CALL(app_mngr_settings_, app_storage_folder()) + .WillByDefault(ReturnRef(kAppStorageFolder)); + + ON_CALL(mock_policy_handler_, IsRequestTypeAllowed(kAppPolicyId, _)) + .WillByDefault(Return(true)); + } + + void ExpectManageMobileCommandWithResultCode( + const mobile_apis::Result::eType code) { + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(code), + am::commands::Command::CommandSource::SOURCE_SDL)); + } + + MockAppPtr mock_app_; +}; + +TEST_F(SystemRequestTest, Run_HTTP_FileName_no_binary_data_REJECTED) { + PreConditions(); + MessageSharedPtr msg = CreateIVSUMessage(); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::REJECTED); + + SharedPtr<SystemRequest> command(CreateCommand<SystemRequest>(msg)); + command->Run(); +} + +TEST_F(SystemRequestTest, + Run_RequestTypeAllowedAndRequestSubTypeAllowed_SendHMIRequest) { + MessageSharedPtr msg = CreateIVSUMessage(); + + (*msg)[am::strings::msg_params][am::strings::request_type] = + mobile_apis::RequestType::OEM_SPECIFIC; + + const std::string request_subtype = "fakeSubType"; + (*msg)[am::strings::msg_params][am::strings::request_subtype] = + request_subtype; + + const std::vector<uint8_t> binary_data = {1u, 2u}; + (*msg)[am::strings::params][am::strings::binary_data] = binary_data; + + PreConditions(); + + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kAppPolicyId, + mobile_apis::RequestType::OEM_SPECIFIC)) + .WillOnce(Return(true)); + + EXPECT_CALL(mock_policy_handler_, + IsRequestSubTypeAllowed(kAppPolicyId, request_subtype)) + .WillOnce(Return(true)); + + EXPECT_CALL(app_mngr_, + SaveBinary(binary_data, kSystemFilesPath, kFileName, 0u)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + + smart_objects::SmartObjectSPtr result; + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&result), Return(true))); + + SharedPtr<SystemRequest> command(CreateCommand<SystemRequest>(msg)); + ASSERT_TRUE(command->Init()); + command->Run(); + + EXPECT_EQ(MessageType::kRequest, + (*result)[am::strings::params][am::strings::message_type].asInt()); + EXPECT_EQ( + mobile_apis::RequestType::OEM_SPECIFIC, + (*result)[am::strings::msg_params][am::strings::request_type].asInt()); + EXPECT_EQ( + request_subtype, + (*msg)[am::strings::msg_params][am::strings::request_subtype].asString()); +} + +TEST_F( + SystemRequestTest, + Run_RequestTypeAllowedAndRequestSubTypeDisallowed_SendDisallowedResponse) { + MessageSharedPtr msg = CreateIVSUMessage(); + + (*msg)[am::strings::msg_params][am::strings::request_type] = + mobile_apis::RequestType::OEM_SPECIFIC; + + const std::string request_subtype = "fakeSubType2"; + (*msg)[am::strings::msg_params][am::strings::request_subtype] = + request_subtype; + + PreConditions(); + + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kAppPolicyId, + mobile_apis::RequestType::OEM_SPECIFIC)) + .WillOnce(Return(true)); + + EXPECT_CALL(mock_policy_handler_, + IsRequestSubTypeAllowed(kAppPolicyId, request_subtype)) + .WillOnce(Return(false)); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::DISALLOWED); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + + SharedPtr<SystemRequest> command(CreateCommand<SystemRequest>(msg)); + ASSERT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(SystemRequestTest, Run_RequestTypeDisallowed_SendDisallowedResponse) { + MessageSharedPtr msg = CreateIVSUMessage(); + + (*msg)[am::strings::msg_params][am::strings::request_type] = + mobile_apis::RequestType::OEM_SPECIFIC; + + PreConditions(); + + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kAppPolicyId, + mobile_apis::RequestType::OEM_SPECIFIC)) + .WillOnce(Return(false)); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::DISALLOWED); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + + SharedPtr<SystemRequest> command(CreateCommand<SystemRequest>(msg)); + ASSERT_TRUE(command->Init()); + command->Run(); +} + +} // namespace system_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unregister_app_interface_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unregister_app_interface_request_test.cc new file mode 100644 index 0000000000..1c4df3a463 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unregister_app_interface_request_test.cc @@ -0,0 +1,118 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_message_helper.h" +#include "mobile/unregister_app_interface_request.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace unregister_app_interface_request { + +namespace am = ::application_manager; +namespace mobile_result = mobile_apis::Result; + +using ::testing::_; + +using sdl_rpc_plugin::commands::UnregisterAppInterfaceRequest; +using am::commands::MessageSharedPtr; + +typedef ::utils::SharedPtr<UnregisterAppInterfaceRequest> CommandPtr; + +class UnregisterAppInterfaceRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(UnregisterAppInterfaceRequestTest, Run_AppNotRegistered_UNSUCCESS) { + CommandPtr command(CreateCommand<UnregisterAppInterfaceRequest>()); + + EXPECT_CALL(app_mngr_, application(_)) + .WillOnce(Return(ApplicationSharedPtr())); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _)); + + command->Run(); +} + +TEST_F(UnregisterAppInterfaceRequestTest, Run_SUCCESS) { + const uint32_t kConnectionKey = 1u; + + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + CommandPtr command(CreateCommand<UnregisterAppInterfaceRequest>(command_msg)); + + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillRepeatedly(Return(mock_app)); + + const mobile_apis::AppInterfaceUnregisteredReason::eType kUnregisterReason = + mobile_apis::AppInterfaceUnregisteredReason::INVALID_ENUM; + + MessageSharedPtr dummy_msg(CreateMessage()); + EXPECT_CALL(mock_message_helper_, + GetOnAppInterfaceUnregisteredNotificationToMobile( + kConnectionKey, kUnregisterReason)) + .WillOnce(Return(dummy_msg)); + { + ::testing::InSequence sequence; + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(dummy_msg, _)); + + EXPECT_CALL(app_mngr_, + UnregisterApplication( + kConnectionKey, mobile_apis::Result::SUCCESS, _, _)); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)); + } + + command->Run(); +} + +} // namespace unregister_app_interface_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc new file mode 100644 index 0000000000..439e94b94f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc @@ -0,0 +1,150 @@ +#include <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "utils/shared_ptr.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "mobile/unsubscribe_button_request.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace unsubscribe_button_request { + +namespace am = ::application_manager; +namespace mobile_result = mobile_apis::Result; + +using ::testing::_; + +using sdl_rpc_plugin::commands::UnsubscribeButtonRequest; +using am::commands::MessageSharedPtr; + +typedef ::utils::SharedPtr<UnsubscribeButtonRequest> CommandPtr; + +namespace { +const uint32_t kConnectionKey = 1u; +const mobile_apis::ButtonName::eType kButtonId = mobile_apis::ButtonName::OK; +} // namespace + +class UnsubscribeButtonRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + typedef TypeIf<kMocksAreNice, + NiceMock<application_manager_test::MockHMICapabilities>, + application_manager_test::MockHMICapabilities>::Result + MockHMICapabilities; +}; + +TEST_F(UnsubscribeButtonRequestTest, Run_AppNotRegistered_UNSUCCESS) { + CommandPtr command(CreateCommand<UnsubscribeButtonRequest>()); + + EXPECT_CALL(app_mngr_, application(_)) + .WillOnce(Return(ApplicationSharedPtr())); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _)); + + command->Run(); +} + +TEST_F(UnsubscribeButtonRequestTest, + Run_UnsubscribeNotSubscribedButton_UNSUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*command_msg)[am::strings::msg_params][am::strings::button_name] = kButtonId; + + CommandPtr command(CreateCommand<UnsubscribeButtonRequest>(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, is_ui_cooperating()) + .WillOnce(Return(true)); + + MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map)); + (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonId; + EXPECT_CALL(mock_hmi_capabilities_, button_capabilities()) + .WillOnce(Return(button_caps_ptr.get())); + + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId)) + .WillOnce(Return(false)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::IGNORED), _)); + + command->Run(); +} + +TEST_F(UnsubscribeButtonRequestTest, + Run_UnsubscribeNotAllowedByHmiCapabilities_UNSUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*command_msg)[am::strings::msg_params][am::strings::button_name] = kButtonId; + CommandPtr command(CreateCommand<UnsubscribeButtonRequest>(command_msg)); + + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + + EXPECT_CALL(mock_hmi_capabilities_, is_ui_cooperating()) + .WillOnce(Return(true)); + + MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map)); + EXPECT_CALL(mock_hmi_capabilities_, button_capabilities()) + .WillOnce(Return(button_caps_ptr.get())); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_result::UNSUPPORTED_RESOURCE), _)); + + command->Run(); +} + +TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*command_msg)[am::strings::msg_params][am::strings::button_name] = kButtonId; + + CommandPtr command(CreateCommand<UnsubscribeButtonRequest>(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, is_ui_cooperating()) + .WillOnce(Return(true)); + + MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map)); + (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonId; + EXPECT_CALL(mock_hmi_capabilities_, button_capabilities()) + .WillOnce(Return(button_caps_ptr.get())); + + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillRepeatedly(Return(mock_app)); + + EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::Buttons_OnButtonSubscription))); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); + + EXPECT_CALL(*mock_app, UpdateHash()); + command->Init(); + command->Run(); +} + +} // namespace unsubscribe_button_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc new file mode 100644 index 0000000000..a6e1eb0518 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc @@ -0,0 +1,171 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "mobile/unsubscribe_way_points_request.h" +#include "interfaces/MOBILE_API.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/event_engine/event.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace unsubscribe_way_points_request { + +namespace am = ::application_manager; +namespace mobile_result = mobile_apis::Result; + +using ::testing::_; +using ::testing::Return; + +using sdl_rpc_plugin::commands::UnSubscribeWayPointsRequest; +using am::commands::MessageSharedPtr; + +namespace { +const uint32_t kConnectionKey = 3u; +const uint32_t kAppId = 5u; +} // namespace + +class UnSubscribeWayPointsRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + UnSubscribeWayPointsRequestTest() + : command_msg_(CreateMessage(smart_objects::SmartType_Map)) + , command_(CreateCommand<UnSubscribeWayPointsRequest>(command_msg_)) { + (*command_msg_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + } + + MessageSharedPtr command_msg_; + ::utils::SharedPtr<UnSubscribeWayPointsRequest> command_; +}; + +TEST_F(UnSubscribeWayPointsRequestTest, + Run_ApplicationIsNotRegistered_UNSUCCESS) { + EXPECT_CALL(app_mngr_, application(_)) + .WillOnce(Return(ApplicationSharedPtr())); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _)); + + command_->Run(); +} + +TEST_F(UnSubscribeWayPointsRequestTest, + Run_AppIsNotSubscribedForWayPoints_UNSUCCESS) { + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + + EXPECT_CALL(app_mngr_, + IsAppSubscribedForWayPoints( + ::testing::Matcher<am::ApplicationSharedPtr>(mock_app))) + .WillOnce(Return(false)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::IGNORED), _)); + + command_->Run(); +} + +TEST_F(UnSubscribeWayPointsRequestTest, Run_AppSubscribedForWayPoints_SUCCESS) { + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + + EXPECT_CALL(app_mngr_, + IsAppSubscribedForWayPoints( + ::testing::Matcher<am::ApplicationSharedPtr>(mock_app))) + .WillOnce(Return(true)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints))); + + command_->Run(); +} + +TEST_F(UnSubscribeWayPointsRequestTest, OnEvent_UnknownEvent_UNSUCCESS) { + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + + Event event(hmi_apis::FunctionID::INVALID_ENUM); + + command_->on_event(event); +} + +TEST_F(UnSubscribeWayPointsRequestTest, + OnEvent_ReceivedNavigationUnSubscribeWayPointsEvent_SUCCESS) { + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillRepeatedly(Return(mock_app)); + + MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map)); + (*event_msg)[am::strings::msg_params] = 0; + (*event_msg)[am::strings::params][am::hmi_response::code] = + mobile_result::SUCCESS; + Event event(hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints); + event.set_smart_object(*event_msg); + + EXPECT_CALL(app_mngr_, + UnsubscribeAppFromWayPoints( + ::testing::Matcher<am::ApplicationSharedPtr>(mock_app))); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); + + command_->on_event(event); +} + +} // namespace unsubscribe_way_points_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc new file mode 100644 index 0000000000..d1f59bb3a4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc @@ -0,0 +1,292 @@ +/* + * 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 <stdint.h> +#include <string> + +#include "gtest/gtest.h" +#include "mobile/update_turn_list_request.h" +#include "interfaces/MOBILE_API.h" +#include "utils/shared_ptr.h" +#include "smart_objects/smart_object.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/event_engine/event.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace update_turn_list_request { + +namespace am = ::application_manager; +namespace mobile_result = mobile_apis::Result; + +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::Ref; +using ::testing::Eq; + +using sdl_rpc_plugin::commands::UpdateTurnListRequest; +using am::commands::MessageSharedPtr; +using application_manager_test::MockHMICapabilities; + +namespace { +const uint32_t kConnectionKey = 3u; +const hmi_apis::FunctionID::eType kFunctionId = + hmi_apis::FunctionID::Buttons_OnButtonEvent; +const uint32_t kAppId = 5u; +} // namespace + +class UpdateTurnListRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + UpdateTurnListRequestTest() + : command_msg_(CreateMessage(smart_objects::SmartType_Map)) + , command_(CreateCommand<UpdateTurnListRequest>(command_msg_)) { + (*command_msg_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*command_msg_)[am::strings::params][am::strings::function_id] = + kFunctionId; + } + + MessageSharedPtr command_msg_; + ::utils::SharedPtr<UpdateTurnListRequest> command_; +}; + +TEST_F(UpdateTurnListRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(ApplicationSharedPtr())); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), _)); + + command_->Run(); +} + +TEST_F(UpdateTurnListRequestTest, Run_InvalidNavigationText_UNSUCCESS) { + (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] + [am::strings::navigation_text] = "invalid_navigation_text\t\n"; + + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _)); + + command_->Run(); +} + +TEST_F(UpdateTurnListRequestTest, Run_InvalidTurnIcon_UNSUCCESS) { + (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] + [am::strings::navigation_text] = "valid_navigation_text"; + (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] + [am::strings::turn_icon][am::strings::value] = + "invalid_turn_icon\t\n"; + + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _)); + + command_->Run(); +} + +TEST_F(UpdateTurnListRequestTest, + Run_ProcessSoftButtonsNotSucceeded_UNSUCCESS) { + (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] + [am::strings::navigation_text] = "valid_navigation_text"; + (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] + [am::strings::turn_icon][am::strings::value] = + "valid_turn_icon"; + + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + + const mobile_result::eType kExpectedResult = mobile_result::INVALID_ENUM; + EXPECT_CALL(mock_message_helper_, + ProcessSoftButtons((*command_msg_)[am::strings::msg_params], + Eq(mock_app), + Ref(mock_policy_handler_), + Ref(app_mngr_))) + .WillOnce(Return(kExpectedResult)); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(kExpectedResult), _)); + + command_->Run(); +} + +TEST_F(UpdateTurnListRequestTest, Run_NoTurnList_UNSUCCESS) { + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + + EXPECT_CALL(mock_message_helper_, + ProcessSoftButtons((*command_msg_)[am::strings::msg_params], + Eq(mock_app), + Ref(mock_policy_handler_), + Ref(app_mngr_))) + .WillOnce(Return(mobile_result::SUCCESS)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::INVALID_DATA), _)); + + command_->Run(); +} + +TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_SUCCESS) { + const std::string kNavigationText = "valid_navigation_text"; + + (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] + [am::strings::navigation_text] = kNavigationText; + (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] + [am::strings::turn_icon][am::strings::value] = + "valid_turn_icon"; + (*command_msg_)[am::strings::msg_params][am::strings::soft_buttons] = 0; + + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + + EXPECT_CALL(mock_message_helper_, + ProcessSoftButtons((*command_msg_)[am::strings::msg_params], + Eq(mock_app), + Ref(mock_policy_handler_), + Ref(app_mngr_))) + .WillOnce(Return(mobile_result::SUCCESS)); + + EXPECT_CALL( + mock_message_helper_, + VerifyImage( + (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] + [am::strings::turn_icon], + Eq(mock_app), + Ref(app_mngr_))).WillOnce(Return(mobile_result::SUCCESS)); + + EXPECT_CALL(mock_message_helper_, + SubscribeApplicationToSoftButton(_, _, kFunctionId)); + + MessageSharedPtr result_msg(CatchHMICommandResult(CallRun(*command_))); + ASSERT_TRUE(result_msg); + EXPECT_EQ( + hmi_apis::FunctionID::Navigation_UpdateTurnList, + (*result_msg)[am::strings::params][am::strings::function_id].asInt()); + + ASSERT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0] + .keyExists(am::hmi_request::navi_text)); + + EXPECT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0] + [am::hmi_request::navi_text].keyExists( + am::hmi_request::field_name)); + EXPECT_EQ( + hmi_apis::Common_TextFieldName::turnText, + (*result_msg)[am::strings::msg_params][am::strings::turn_list][0] + [am::hmi_request::navi_text][am::hmi_request::field_name] + .asInt()); + + EXPECT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0] + [am::hmi_request::navi_text].keyExists( + am::hmi_request::field_text)); + EXPECT_EQ( + kNavigationText, + (*result_msg)[am::strings::msg_params][am::strings::turn_list][0] + [am::hmi_request::navi_text][am::hmi_request::field_text] + .asString()); +} + +TEST_F(UpdateTurnListRequestTest, OnEvent_UnknownEvent_UNSUCCESS) { + Event event(hmi_apis::FunctionID::INVALID_ENUM); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + + command_->on_event(event); +} + +TEST_F(UpdateTurnListRequestTest, OnEvent_UnsupportedResource_SUCCESS) { + MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map)); + const hmi_apis::Common_Result::eType hmi_response_code = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; + const mobile_result::eType mobile_response_code = + mobile_result::UNSUPPORTED_RESOURCE; + (*event_msg)[am::strings::params][am::hmi_response::code] = hmi_response_code; + (*event_msg)[am::strings::msg_params] = 0; + + Event event(hmi_apis::FunctionID::Navigation_UpdateTurnList); + event.set_smart_object(*event_msg); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_response_code), _)); + + command_->on_event(event); +} + +TEST_F(UpdateTurnListRequestTest, + OnEvent_ReceivedNavigationUpdateTurnListEvent_SUCCESS) { + const hmi_apis::Common_Result::eType hmi_response_code = + hmi_apis::Common_Result::SUCCESS; + const mobile_result::eType mobile_response_code = mobile_result::SUCCESS; + + MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map)); + (*event_msg)[am::strings::params][am::hmi_response::code] = hmi_response_code; + (*event_msg)[am::strings::msg_params] = 0; + + Event event(hmi_apis::FunctionID::Navigation_UpdateTurnList); + event.set_smart_object(*event_msg); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_response_code), _)); + + command_->on_event(event); +} + +} // namespace update_turn_list_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test |