diff options
25 files changed, 2143 insertions, 0 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_create_window_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_create_window_request.h new file mode 100644 index 0000000000..6fe8e182c4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_create_window_request.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 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_CREATE_WINDOW_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CREATE_WINDOW_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UI.CreateWindow request command class + **/ +class UICreateWindowRequest : public app_mngr::commands::RequestToHMI { + public: + UICreateWindowRequest(const app_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); + + ~UICreateWindowRequest() FINAL; + + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(UICreateWindowRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CREATE_WINDOW_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_create_window_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_create_window_response.h new file mode 100644 index 0000000000..b9452fce1f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_create_window_response.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 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_CREATE_WINDOW_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CREATE_WINDOW_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UI.CreateWindow response command class + **/ +class UICreateWindowResponse : public app_mngr::commands::ResponseFromHMI { + public: + UICreateWindowResponse(const app_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); + + ~UICreateWindowResponse() FINAL; + + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(UICreateWindowResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CREATE_WINDOW_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_window_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_window_request.h new file mode 100644 index 0000000000..58b2c3989f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_window_request.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 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_WINDOW_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_WINDOW_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UI.DeleteWindow request command class + **/ +class UIDeleteWindowRequest : public app_mngr::commands::RequestToHMI { + public: + UIDeleteWindowRequest(const app_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); + + ~UIDeleteWindowRequest() FINAL; + + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(UIDeleteWindowRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_WINDOW_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_window_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_window_response.h new file mode 100644 index 0000000000..1500a3f9b2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_window_response.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 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_WINDOW_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_WINDOW_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UI.DeleteWindow response command class + **/ +class UIDeleteWindowResponse : public app_mngr::commands::ResponseFromHMI { + public: + UIDeleteWindowResponse(const app_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); + + ~UIDeleteWindowResponse() FINAL; + + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(UIDeleteWindowResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_WINDOW_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_window_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_window_request.h new file mode 100644 index 0000000000..7a851b4d84 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_window_request.h @@ -0,0 +1,95 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 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_WINDOW_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_WINDOW_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/hmi_state.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief CreateWindow request command class + **/ +class CreateWindowRequest : public app_mngr::commands::CommandRequestImpl { + public: + CreateWindowRequest(const app_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); + + ~CreateWindowRequest() FINAL; + + app_mngr::WindowID window_id() const FINAL; + + void Run() FINAL; + + void on_event(const app_mngr::event_engine::Event& event) FINAL; + + /** + * @brief Init sets hash update mode for request + */ + bool Init() FINAL; + + private: + /** + * @brief CheckWindowName checks if provided window_name exists and allowed to + * be created + * @param app pointer to application owns affected window + * @param window_name window name to check + * @return true if window_name is valid, otherwise returns false + */ + bool CheckWindowName(app_mngr::ApplicationSharedPtr app, + const app_mngr::WindowID window_id, + const std::string& window_name) const; + + /** + * @brief ApplyWindowInitialState apply changes related to window HMI state + * initialization + * @param app pointer to application owns affected window + */ + void ApplyWindowInitialState(app_mngr::ApplicationSharedPtr app) const; + + DISALLOW_COPY_AND_ASSIGN(CreateWindowRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_WINDOW_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_window_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_window_response.h new file mode 100644 index 0000000000..5163293a7c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_window_response.h @@ -0,0 +1,67 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 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_WINDOW_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_WINDOW_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 CreateWindow response command class + **/ +class CreateWindowResponse : public app_mngr::commands::CommandResponseImpl { + public: + CreateWindowResponse(const app_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); + + ~CreateWindowResponse() FINAL; + + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(CreateWindowResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_WINDOW_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_window_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_window_request.h new file mode 100644 index 0000000000..b837724d7b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_window_request.h @@ -0,0 +1,91 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 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_WINDOW_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_WINDOW_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/hmi_state.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief CreateWindow request command class + **/ +class DeleteWindowRequest : public app_mngr::commands::CommandRequestImpl { + public: + DeleteWindowRequest(const app_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); + + ~DeleteWindowRequest() FINAL; + + void Run() FINAL; + + void on_event(const app_mngr::event_engine::Event& event) FINAL; + + app_mngr::WindowID window_id() const FINAL; + + /** + * @brief Init sets hash update mode for request + */ + bool Init() FINAL; + + private: + /** + * @brief CheckWindowId checks if provided window_id exists and allowed to be + * deleted + * @param app pointer to application owns affected window + * @return true if window_id is valid, otherwise returns false + */ + bool CheckWindowId(app_mngr::ApplicationSharedPtr app) const; + + /** + * @brief DeleteWindow deletes data related to a request window id + * @param app pointer to applications owns affected window + */ + void DeleteWindow(app_mngr::ApplicationSharedPtr app) const; + + DISALLOW_COPY_AND_ASSIGN(DeleteWindowRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_WINDOW_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_window_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_window_response.h new file mode 100644 index 0000000000..279541724a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_window_response.h @@ -0,0 +1,67 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 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_WINDOW_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_WINDOW_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 DeleteWindow response command class + **/ +class DeleteWindowResponse : public app_mngr::commands::CommandResponseImpl { + public: + DeleteWindowResponse(const app_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); + + ~DeleteWindowResponse() FINAL; + + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(DeleteWindowResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_WINDOW_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_create_window_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_create_window_request.cc new file mode 100644 index 0000000000..b354009e3f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_create_window_request.cc @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING 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_create_window_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UICreateWindowRequest::UICreateWindowRequest( + 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) {} + +UICreateWindowRequest::~UICreateWindowRequest() {} + +void UICreateWindowRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_create_window_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_create_window_response.cc new file mode 100644 index 0000000000..c3a323818d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_create_window_response.cc @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING 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_create_window_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UICreateWindowResponse::UICreateWindowResponse( + 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) {} + +UICreateWindowResponse::~UICreateWindowResponse() {} + +void UICreateWindowResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_CreateWindow); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_window_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_window_request.cc new file mode 100644 index 0000000000..7933574d92 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_window_request.cc @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING 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_window_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIDeleteWindowRequest::UIDeleteWindowRequest( + 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) {} + +UIDeleteWindowRequest::~UIDeleteWindowRequest() {} + +void UIDeleteWindowRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_window_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_window_response.cc new file mode 100644 index 0000000000..ba703e18ae --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_window_response.cc @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING 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_window_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIDeleteWindowResponse::UIDeleteWindowResponse( + 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) {} + +UIDeleteWindowResponse::~UIDeleteWindowResponse() {} + +void UIDeleteWindowResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_DeleteWindow); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_window_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_window_request.cc new file mode 100644 index 0000000000..227ab79b70 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_window_request.cc @@ -0,0 +1,246 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING 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_window_request.h" + +#include <algorithm> + +#include "application_manager/application_impl.h" +#include "application_manager/application_state.h" +#include "application_manager/message_helper.h" +#include "utils/helpers.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +using app_mngr::ApplicationSharedPtr; + +namespace commands { + +CreateWindowRequest::CreateWindowRequest( + 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) {} + +CreateWindowRequest::~CreateWindowRequest() {} + +bool CreateWindowRequest::CheckWindowName( + app_mngr::ApplicationSharedPtr app, + const app_mngr::WindowID window_id, + const std::string& window_name) const { + if (mobile_apis::PredefinedWindows::PRIMARY_WIDGET == window_id) { + LOG4CXX_DEBUG(logger_, + "Window name check is ignored for the primary widgets"); + return true; + } + + const bool names_are_equal = window_name == app->name().c_str(); + if (names_are_equal && + mobile_apis::PredefinedWindows::DEFAULT_WINDOW != window_id) { + LOG4CXX_ERROR(logger_, + "Regular widget can't have the same name as application: " + << window_name); + return false; + } + + const WindowNames window_names = app->GetWindowNames(); + return !helpers::in_range(window_names, window_name); +} + +void CreateWindowRequest::ApplyWindowInitialState( + ApplicationSharedPtr app) const { + const mobile_apis::WindowType::eType window_type = + static_cast<mobile_apis::WindowType::eType>( + (*message_)[strings::msg_params][strings::window_type].asInt()); + + // State should be initialized with INVALID_ENUM value to let state controller + // trigger OnHmiStatus notifiation sending + HmiStatePtr initial_state = application_manager_.CreateRegularState( + app, + window_type, + mobile_apis::HMILevel::INVALID_ENUM, + mobile_apis::AudioStreamingState::INVALID_ENUM, + mobile_apis::VideoStreamingState::INVALID_ENUM, + mobile_api::SystemContext::INVALID_ENUM); + + const WindowID window_id = + (*message_)[strings::msg_params][strings::window_id].asUInt(); + const std::string window_name = + (*message_)[strings::msg_params][strings::window_name].asString(); + + smart_objects::SmartObject window_info(smart_objects::SmartType_Map); + if ((*message_)[strings::msg_params].keyExists( + strings::associated_service_type)) { + window_info[strings::associated_service_type] = + (*message_)[strings::msg_params][strings::associated_service_type]; + } + if ((*message_)[strings::msg_params].keyExists( + strings::duplicate_updates_from_window_id)) { + window_info[strings::duplicate_updates_from_window_id] = + (*message_)[strings::msg_params] + [strings::duplicate_updates_from_window_id]; + } + + window_info[strings::window_name] = window_name; + + app->AddWindowInfo(window_id, window_info); + + app->SetInitialState(window_id, window_name, initial_state); + + // Default HMI level for all windows except the main one is always NONE + application_manager_.state_controller().OnAppWindowAdded( + app, window_id, window_type, mobile_apis::HMILevel::HMI_NONE); +} + +app_mngr::WindowID CreateWindowRequest::window_id() const { + return mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +} + +void CreateWindowRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + const auto 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 auto window_id = + (*message_)[strings::msg_params][strings::window_id].asUInt(); + if (application->WindowIdExists(window_id)) { + LOG4CXX_ERROR(logger_, + "Window with id #" << window_id << " does already exist"); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + + const auto window_type = + (*message_)[strings::msg_params][strings::window_type].asInt(); + + if (mobile_apis::WindowType::eType::MAIN == window_type) { + LOG4CXX_ERROR(logger_, "MAIN application window already exists"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if ((*message_)[strings::msg_params].keyExists( + strings::duplicate_updates_from_window_id)) { + const auto duplicate_updates_from_window_id = + (*message_)[strings::msg_params] + [strings::duplicate_updates_from_window_id] + .asInt(); + if (!application->WindowIdExists(duplicate_updates_from_window_id)) { + LOG4CXX_ERROR(logger_, + "Window with id #" << duplicate_updates_from_window_id + << " does not exist"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } + + const std::string window_name = + (*message_)[strings::msg_params][strings::window_name].asString(); + if (!CheckWindowName(application, window_id, window_name)) { + LOG4CXX_ERROR(logger_, + "Window name \"" << window_name + << "\" is disallowed for window #" + << window_id); + SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); + return; + } + + smart_objects::SmartObject msg_params = (*message_)[strings::msg_params]; + msg_params[strings::app_id] = application->hmi_app_id(); + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_CreateWindow, &msg_params, true); +} + +void CreateWindowRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + + if (hmi_apis::FunctionID::UI_CreateWindow != event.id()) { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + + auto application = application_manager_.application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + LOG4CXX_INFO(logger_, "Received CreateWindow event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + + const smart_objects::SmartObject& response_message = event.smart_object(); + const auto result_code = CommandRequestImpl::GetMobileResultCode( + static_cast<hmi_apis::Common_Result::eType>( + response_message[strings::params][hmi_response::code].asInt())); + + const bool is_success = IsMobileResultSuccess(result_code); + std::string response_info; + GetInfo(response_message, response_info); + + if (!is_success) { + LOG4CXX_ERROR(logger_, "CreateWindow request has failed on HMI side"); + SendResponse(is_success, + result_code, + response_info.empty() ? nullptr : response_info.c_str()); + return; + } + + ApplyWindowInitialState(application); + + SendResponse(is_success, + result_code, + response_info.empty() ? nullptr : response_info.c_str()); +} + +bool CreateWindowRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_window_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_window_response.cc new file mode 100644 index 0000000000..0d9bbc2815 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_window_response.cc @@ -0,0 +1,64 @@ +/* + + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING 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_window_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +CreateWindowResponse::CreateWindowResponse( + 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) {} + +CreateWindowResponse::~CreateWindowResponse() {} + +void CreateWindowResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_window_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_window_request.cc new file mode 100644 index 0000000000..2bfe0465f0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_window_request.cc @@ -0,0 +1,161 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING 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_window_request.h" + +#include <algorithm> + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +DeleteWindowRequest::DeleteWindowRequest( + 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) {} + +DeleteWindowRequest::~DeleteWindowRequest() {} + +bool DeleteWindowRequest::CheckWindowId( + app_mngr::ApplicationSharedPtr app) const { + const WindowID window_id = + (*message_)[strings::msg_params][strings::window_id].asUInt(); + if (mobile_apis::PredefinedWindows::DEFAULT_WINDOW == window_id) { + LOG4CXX_ERROR(logger_, "Main application window can't be deleted"); + return false; + } + + if (!app->WindowIdExists(window_id)) { + LOG4CXX_ERROR(logger_, + "Window with id #" << window_id << " does not exist"); + return false; + } + + return true; +} + +app_mngr::WindowID DeleteWindowRequest::window_id() const { + return mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +} + +void DeleteWindowRequest::DeleteWindow( + app_mngr::ApplicationSharedPtr app) const { + const WindowID window_id = + (*message_)[strings::msg_params][strings::window_id].asUInt(); + app->RemoveWindowInfo(window_id); + app->RemoveHMIState(window_id, HmiState::StateID::STATE_ID_REGULAR); +} + +void DeleteWindowRequest::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; + } + + if (!CheckWindowId(application)) { + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + + smart_objects::SmartObject msg_params = (*message_)[strings::msg_params]; + msg_params[strings::app_id] = application->hmi_app_id(); + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_DeleteWindow, &msg_params, true); +} + +void DeleteWindowRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + + if (hmi_apis::FunctionID::UI_DeleteWindow != event.id()) { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + + 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; + } + + LOG4CXX_INFO(logger_, "Received DeleteWindow event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + + const smart_objects::SmartObject& response_message = event.smart_object(); + const auto result_code = CommandRequestImpl::GetMobileResultCode( + static_cast<hmi_apis::Common_Result::eType>( + response_message[strings::params][hmi_response::code].asInt())); + + const bool is_success = IsMobileResultSuccess(result_code); + std::string response_info; + GetInfo(response_message, response_info); + + if (!is_success) { + LOG4CXX_ERROR(logger_, "DeleteWindow request has failed on HMI side"); + SendResponse(is_success, + result_code, + response_info.empty() ? nullptr : response_info.c_str()); + return; + } + + DeleteWindow(application); + + SendResponse(is_success, + result_code, + response_info.empty() ? nullptr : response_info.c_str()); +} + +bool DeleteWindowRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_window_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_window_response.cc new file mode 100644 index 0000000000..f9ac9a46d6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_window_response.cc @@ -0,0 +1,64 @@ +/* + + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING 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_window_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +DeleteWindowResponse::DeleteWindowResponse( + 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) {} + +DeleteWindowResponse::~DeleteWindowResponse() {} + +void DeleteWindowResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin 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 index d76a053808..d99a65a37f 100644 --- 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 @@ -99,10 +99,14 @@ #include "sdl_rpc_plugin/commands/hmi/ui_alert_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_create_window_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_create_window_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_delete_submenu_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_delete_submenu_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_delete_window_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_delete_window_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_end_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_get_capabilities_request.h" @@ -423,6 +427,11 @@ CommandCreator& HMICommandFactory::get_creator_factory( ? factory.GetCreator<commands::UIShowAppMenuRequest>() : factory.GetCreator<commands::UIShowAppMenuResponse>(); } + case hmi_apis::FunctionID::UI_DeleteWindow: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UIDeleteWindowRequest>() + : factory.GetCreator<commands::UIDeleteWindowResponse>(); + } case hmi_apis::FunctionID::UI_SetMediaClockTimer: { return hmi_apis::messageType::request == message_type ? factory.GetCreator<commands::UISetMediaClockTimerRequest>() @@ -471,6 +480,11 @@ CommandCreator& HMICommandFactory::get_creator_factory( ? factory.GetCreator<commands::UIChangeRegistrationRequest>() : factory.GetCreator<commands::UIChangeRegistratioResponse>(); } + case hmi_apis::FunctionID::UI_CreateWindow: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UICreateWindowRequest>() + : factory.GetCreator<commands::UICreateWindowResponse>(); + } case hmi_apis::FunctionID::UI_PerformAudioPassThru: { return hmi_apis::messageType::request == message_type ? factory.GetCreator<commands::UIPerformAudioPassThruRequest>() 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 index 7f5318751e..c6f4b64636 100644 --- 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 @@ -48,6 +48,8 @@ #include "sdl_rpc_plugin/commands/mobile/close_application_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/create_window_request.h" +#include "sdl_rpc_plugin/commands/mobile/create_window_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/delete_file_request.h" @@ -56,6 +58,8 @@ #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/delete_window_request.h" +#include "sdl_rpc_plugin/commands/mobile/delete_window_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/end_audio_pass_thru_request.h" @@ -176,6 +180,11 @@ CommandCreator& MobileCommandFactory::get_command_creator( ? factory.GetCreator<commands::AddCommandRequest>() : factory.GetCreator<commands::AddCommandResponse>(); } + case mobile_apis::FunctionID::CreateWindowID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::CreateWindowRequest>() + : factory.GetCreator<commands::CreateWindowResponse>(); + } case mobile_apis::FunctionID::DeleteCommandID: { return mobile_api::messageType::request == message_type ? factory.GetCreator<commands::DeleteCommandRequest>() @@ -196,6 +205,11 @@ CommandCreator& MobileCommandFactory::get_command_creator( ? factory.GetCreator<commands::ShowAppMenuRequest>() : factory.GetCreator<commands::ShowAppMenuResponse>(); } + case mobile_apis::FunctionID::DeleteWindowID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::DeleteWindowRequest>() + : factory.GetCreator<commands::DeleteWindowResponse>(); + } case mobile_apis::FunctionID::DeleteInteractionChoiceSetID: { return mobile_api::messageType::request == message_type ? factory.GetCreator< diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_window_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_window_request_test.cc new file mode 100644 index 0000000000..9c74196f06 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_window_request_test.cc @@ -0,0 +1,418 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 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 <memory> +#include <set> +#include <string> + +#include "mobile/create_window_request.h" + +#include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/hmi_state.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_state_controller.h" +#include "gtest/gtest.h" +#include "interfaces/MOBILE_API.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace create_window_request { + +namespace am = application_manager; +using am::MockMessageHelper; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::CreateWindowRequest; +using namespace mobile_apis::PredefinedWindows; +using am::commands::Command; +using application_manager::WindowID; +using test::components::application_manager_test::MockStateController; +using test::components::policy_test::MockPolicyHandlerInterface; +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +namespace { +const uint32_t kAppId = 1u; +const uint32_t kConnectionKey = 2u; +const int32_t kFunctionID = mobile_apis::FunctionID::CreateWindowID; +const WindowID kTestWindowId = 12; +const WindowID kDuplicateWindowID = 13; +const char* const kWindowName = "WindowName"; +const utils::custom_string::CustomString kAppName("TestApp"); +} // namespace + +MATCHER_P2(CheckMessageToMobile, result_code, success, "") { + const bool is_success = + (*arg)[am::strings::msg_params][am::strings::success].asBool() == success; + + const bool is_result_code_correct = + (*arg)[am::strings::msg_params][am::strings::result_code].asInt() == + static_cast<int32_t>(result_code); + return is_success && is_result_code_correct; +} + +class CreateWindowRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + CreateWindowRequestTest() { + mock_app_ = CreateMockApp(); + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + } + + protected: + MessageSharedPtr CreateMsgParams() { + auto msg = CreateMessage(); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg)[am::strings::params][am::strings::function_id] = kFunctionID; + return msg; + } + + void SetupHelperApplyWindowInitialState(const MockAppPtr& app, + const MessageSharedPtr& msg) { + am::HmiStatePtr state(new am::HmiState(app, app_mngr_)); + const auto window_type = static_cast<mobile_apis::WindowType::eType>( + (*msg)[am::strings::msg_params][am::strings::window_type].asInt()); + const auto window_id = static_cast<mobile_apis::WindowType::eType>( + (*msg)[am::strings::msg_params][am::strings::window_id].asInt()); + const auto window_name = + (*msg)[am::strings::msg_params][am::strings::window_name].asString(); + + state->set_window_type(window_type); + state->set_hmi_level(mobile_apis::HMILevel::INVALID_ENUM); + state->set_audio_streaming_state( + mobile_apis::AudioStreamingState::INVALID_ENUM); + state->set_video_streaming_state( + mobile_apis::VideoStreamingState::INVALID_ENUM); + state->set_system_context(mobile_apis::SystemContext::INVALID_ENUM); + ApplicationSharedPtr AppPtr = app; + ON_CALL(app_mngr_, + CreateRegularState(AppPtr, + window_type, + mobile_apis::HMILevel::INVALID_ENUM, + mobile_apis::AudioStreamingState::INVALID_ENUM, + mobile_apis::VideoStreamingState::INVALID_ENUM, + mobile_apis::SystemContext::INVALID_ENUM)) + .WillByDefault(Return(state)); + ON_CALL(*mock_app_, SetInitialState(kTestWindowId, window_name, state)) + .WillByDefault(Return()); + ON_CALL(app_mngr_, state_controller()) + .WillByDefault(ReturnRef(mock_state_controller)); + ON_CALL( + mock_state_controller, + OnAppWindowAdded( + AppPtr, window_id, window_type, mobile_apis::HMILevel::HMI_NONE)) + .WillByDefault(Return()); + } + + MockAppPtr mock_app_; + NiceMock<MockStateController> mock_state_controller; +}; + +TEST_F(CreateWindowRequestTest, WindowID_ExpectDefaultWindowID) { + auto msg = CreateMsgParams(); + const auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_EQ(mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + command->window_id()); +} + +TEST_F(CreateWindowRequestTest, + Run_AppDoesNotExist_ExpectAppNotRegisteredResponseToMobile) { + const auto result_code = mobile_apis::Result::APPLICATION_NOT_REGISTERED; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(nullptr)); + + auto msg = CreateMsgParams(); + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(CreateWindowRequestTest, + Run_WindowIDAlreadyExist_ExpectInvalidIDResponseToMobile) { + const auto result_code = mobile_apis::Result::INVALID_ID; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(true)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(CreateWindowRequestTest, + Run_CreateWindowForMAINWindowType_ExpectInvalidDataResponseToMobile) { + const auto result_code = mobile_apis::Result::INVALID_DATA; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(false)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params][am::strings::window_type] = + mobile_apis::WindowType::eType::MAIN; + + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F( + CreateWindowRequestTest, + Run_DuplicateUpdatesFromNotExistingWindowId_ExpectInvalidDataResponseToMobile) { + const auto result_code = mobile_apis::Result::INVALID_DATA; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(false)); + ON_CALL(*mock_app_, WindowIdExists(kDuplicateWindowID)) + .WillByDefault(Return(false)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params] + [am::strings::duplicate_updates_from_window_id] = kDuplicateWindowID; + + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F( + CreateWindowRequestTest, + Run_DuplicateUpdatesFromExistingWindowId_ExpectUICreateWindowIsSentToHMI) { + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_CreateWindow), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(false)); + ON_CALL(*mock_app_, WindowIdExists(kDuplicateWindowID)) + .WillByDefault(Return(true)); + ON_CALL(*mock_app_, name()).WillByDefault(ReturnRef(kAppName)); + ON_CALL(*mock_app_, GetWindowNames()) + .WillByDefault(Return(std::vector<std::string>())); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params] + [am::strings::duplicate_updates_from_window_id] = kDuplicateWindowID; + + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(CreateWindowRequestTest, + Run_WindowNameAppNameAreEqual_ExpectDuplicateNameResponseToMobile) { + const auto result_code = mobile_apis::Result::DUPLICATE_NAME; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(false)); + ON_CALL(*mock_app_, name()).WillByDefault(ReturnRef(kAppName)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params][am::strings::window_name] = kAppName; + + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(CreateWindowRequestTest, + Run_AllParametersCorrect_ExpectUICreateWindowIsSentToHMI) { + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_CreateWindow), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(false)); + ON_CALL(*mock_app_, WindowIdExists(kDuplicateWindowID)) + .WillByDefault(Return(true)); + ON_CALL(*mock_app_, name()).WillByDefault(ReturnRef(kAppName)); + + const std::vector<std::string> windowNames = { + "WindowName_1", "WindowName_2", "WindowName_3"}; + ON_CALL(*mock_app_, GetWindowNames()).WillByDefault(Return(windowNames)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params][am::strings::window_name] = kWindowName; + (*msg)[am::strings::msg_params] + [am::strings::duplicate_updates_from_window_id] = kDuplicateWindowID; + (*msg)[am::strings::msg_params][am::strings::associated_service_type] = + "MEDIA"; + + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F( + CreateWindowRequestTest, + CheckWindowName_AllParametersCorrectCreateWindowForPrimaryWidget_SendMessageToHMI) { + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_CreateWindow), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(false)); + ON_CALL(*mock_app_, WindowIdExists(kDuplicateWindowID)) + .WillByDefault(Return(true)); + ON_CALL(*mock_app_, name()).WillByDefault(ReturnRef(kAppName)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = + mobile_apis::PredefinedWindows::PRIMARY_WIDGET; + (*msg)[am::strings::msg_params][am::strings::window_name] = kWindowName; + (*msg)[am::strings::msg_params] + [am::strings::duplicate_updates_from_window_id] = kDuplicateWindowID; + (*msg)[am::strings::msg_params][am::strings::associated_service_type] = + "MEDIA"; + + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(CreateWindowRequestTest, + OnEvent_InvalidFunctionId_MessageNotSendToMobile) { + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + auto msg = CreateMsgParams(); + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + Event event(hmi_apis::FunctionID::INVALID_ENUM); + command->on_event(event); +} + +TEST_F(CreateWindowRequestTest, + OnEvent_AppDoesNotExist_ExpectAppNotRegisteredResponseToMobile) { + const auto result_code = mobile_apis::Result::APPLICATION_NOT_REGISTERED; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(nullptr)); + + auto msg = CreateMsgParams(); + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + Event event(hmi_apis::FunctionID::UI_CreateWindow); + command->on_event(event); +} + +TEST_F(CreateWindowRequestTest, + OnEvent_RequestFailedOnHMISide_SendGenericErrorResponseToMobile) { + const auto result_code = mobile_apis::Result::GENERIC_ERROR; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::GENERIC_ERROR; + (*msg)[am::strings::msg_params][am::strings::window_name] = kWindowName; + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params][am::strings::window_type] = + mobile_apis::WindowType::eType::WIDGET; + + SetupHelperApplyWindowInitialState(mock_app_, msg); + + Event event(hmi_apis::FunctionID::UI_CreateWindow); + event.set_smart_object(*msg); + + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->on_event(event); +} + +TEST_F(CreateWindowRequestTest, + OnEvent_AllParametersCorrect_SendSuccessResponseToMobile) { + const auto result_code = mobile_apis::Result::SUCCESS; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, true), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(*mock_app_, UpdateHash()).Times(1); + auto msg = CreateMsgParams(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*msg)[am::strings::msg_params][am::strings::window_name] = kWindowName; + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params][am::strings::window_type] = + mobile_apis::WindowType::eType::WIDGET; + + SetupHelperApplyWindowInitialState(mock_app_, msg); + + Event event(hmi_apis::FunctionID::UI_CreateWindow); + event.set_smart_object(*msg); + + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->on_event(event); +} + +} // namespace create_window_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_window_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_window_request_test.cc new file mode 100644 index 0000000000..f951d5c2a7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_window_request_test.cc @@ -0,0 +1,278 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 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 <memory> +#include <set> +#include <string> + +#include "mobile/delete_window_request.h" + +#include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/hmi_state.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_state_controller.h" +#include "gtest/gtest.h" +#include "interfaces/MOBILE_API.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace delete_window_request { + +namespace am = application_manager; +using am::MockMessageHelper; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::DeleteWindowRequest; +using namespace mobile_apis::PredefinedWindows; +using am::commands::Command; +using application_manager::WindowID; +using test::components::application_manager_test::MockStateController; +using test::components::policy_test::MockPolicyHandlerInterface; +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +namespace { +const uint32_t kConnectionKey = 2u; +const int32_t kFunctionID = mobile_apis::FunctionID::DeleteWindowID; +const WindowID kTestWindowId = 12; +} // namespace + +MATCHER_P2(CheckMessageToMobile, result_code, success, "") { + const bool is_success = + (*arg)[am::strings::msg_params][am::strings::success].asBool() == success; + + const bool is_result_code_correct = + (*arg)[am::strings::msg_params][am::strings::result_code].asInt() == + static_cast<int32_t>(result_code); + return is_success && is_result_code_correct; +} + +class DeleteWindowRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + DeleteWindowRequestTest() { + mock_app_ = CreateMockApp(); + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + } + + protected: + MessageSharedPtr CreateMsgParams() { + auto msg = CreateMessage(); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg)[am::strings::params][am::strings::function_id] = kFunctionID; + return msg; + } + + MockAppPtr mock_app_; + NiceMock<MockStateController> mock_state_controller; +}; + +TEST_F(DeleteWindowRequestTest, WindowID_ExpectDefaultWindowID) { + auto msg = CreateMsgParams(); + const auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_EQ(mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + command->window_id()); +} + +TEST_F(DeleteWindowRequestTest, + Run_AppDoesNotExist_ExpectAppNotRegisteredResponseToMobile) { + const auto result_code = mobile_apis::Result::APPLICATION_NOT_REGISTERED; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(nullptr)); + + auto msg = CreateMsgParams(); + auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(DeleteWindowRequestTest, + Run_WindowIDForMainApplicationWindow_ExpectInvalidIDResponseToMobile) { + const auto result_code = mobile_apis::Result::INVALID_ID; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; + + auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(DeleteWindowRequestTest, + Run_WindowIDNotExist_ExpectInvalidIDResponseToMobile) { + const auto result_code = mobile_apis::Result::INVALID_ID; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, GetWindowIds()).WillByDefault(Return(am::WindowIds())); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + + auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(DeleteWindowRequestTest, + Run_AllParametersCorrect_ExpectUIDeleteWindowIsSentToHMI) { + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteWindow), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + + ON_CALL(*mock_app_, GetWindowIds()) + .WillByDefault(Return(am::WindowIds(1, kTestWindowId))); + EXPECT_CALL(*mock_app_, WindowIdExists(kTestWindowId)).WillOnce(Return(true)); + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + + auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(DeleteWindowRequestTest, + Run_AllParametersCorrectDeleteWindowForPrimaryWidget_SendMessageToHMI) { + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteWindow), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + const auto primary_widget_window_id = + mobile_apis::PredefinedWindows::PRIMARY_WIDGET; + ON_CALL(*mock_app_, GetWindowIds()) + .WillByDefault(Return(am::WindowIds(1, primary_widget_window_id))); + EXPECT_CALL(*mock_app_, WindowIdExists(primary_widget_window_id)) + .WillOnce(Return(true)); + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = + primary_widget_window_id; + + auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(DeleteWindowRequestTest, + OnEvent_InvalidFunctionId_MessageNotSendToMobile) { + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + auto msg = CreateMsgParams(); + auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + Event event(hmi_apis::FunctionID::INVALID_ENUM); + command->on_event(event); +} + +TEST_F(DeleteWindowRequestTest, + OnEvent_AppDoesNotExist_ExpectAppNotRegisteredResponseToMobile) { + const auto result_code = mobile_apis::Result::APPLICATION_NOT_REGISTERED; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(nullptr)); + + auto msg = CreateMsgParams(); + auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + Event event(hmi_apis::FunctionID::UI_DeleteWindow); + command->on_event(event); +} + +TEST_F(DeleteWindowRequestTest, + OnEvent_RequestFailedOnHMISide_SendGenericErrorResponseToMobile) { + const auto result_code = mobile_apis::Result::GENERIC_ERROR; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::GENERIC_ERROR; + + Event event(hmi_apis::FunctionID::UI_DeleteWindow); + event.set_smart_object(*msg); + + auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->on_event(event); +} + +TEST_F(DeleteWindowRequestTest, + OnEvent_AllParametersCorrect_SendSuccessResponseToMobile) { + const auto result_code = mobile_apis::Result::SUCCESS; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, true), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(*mock_app_, UpdateHash()).Times(1); + EXPECT_CALL(*mock_app_, RemoveHMIState(kTestWindowId, _)).Times(1); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + + Event event(hmi_apis::FunctionID::UI_DeleteWindow); + event.set_smart_object(*msg); + + auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->on_event(event); +} + +} // namespace delete_window_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/src/hmi_interfaces_impl.cc b/src/components/application_manager/src/hmi_interfaces_impl.cc index 1400ead8cf..f1f8660217 100644 --- a/src/components/application_manager/src/hmi_interfaces_impl.cc +++ b/src/components/application_manager/src/hmi_interfaces_impl.cc @@ -138,6 +138,8 @@ generate_function_to_interface_convert_map() { convert_map[UI_AddSubMenu] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_DeleteSubMenu] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_ShowAppMenu] = HmiInterfaces::HMI_INTERFACE_UI; + convert_map[UI_CreateWindow] = HmiInterfaces::HMI_INTERFACE_UI; + convert_map[UI_DeleteWindow] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_PerformInteraction] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_SetMediaClockTimer] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_SetGlobalProperties] = HmiInterfaces::HMI_INTERFACE_UI; diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index 2cff10d8be..d3aee9dcf8 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -492,6 +492,16 @@ enum FunctionID { ShowAppMenuID = 59, /** + * @brief CreateWindowID. + */ + CreateWindowID = 60, + + /** + * @brief DeleteWindowID. + */ + DeleteWindowID = 61, + + /** * @brief OnHMIStatusID. */ OnHMIStatusID = 32768, diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index 5628dd5729..6f60b43af9 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -1169,6 +1169,16 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { return true; } + if ("CreateWindow" == literal) { + *result = CreateWindowID; + return true; + } + + if ("DeleteWindow" == literal) { + *result = DeleteWindowID; + return true; + } + if ("CloseApplication" == literal) { *result = CloseApplicationID; return true; diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index 840f429bf7..899e40993e 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -477,6 +477,16 @@ enum FunctionID { ShowAppMenuID = 59, /** + * @brief CreateWindowID. + */ + CreateWindowID = 60, + + /** + * @brief DeleteWindowID. + */ + DeleteWindowID = 61, + + /** * @brief OnHMIStatusID. */ OnHMIStatusID = 32768, diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index d753c22b49..56bbd53762 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -863,6 +863,10 @@ bool IsValidEnum(FunctionID val) { return true; case CancelInteractionID: return true; + case CreateWindowID: + return true; + case DeleteWindowID: + return true; case CloseApplicationID: return true; case ShowAppMenuID: @@ -1034,6 +1038,10 @@ const char* EnumToJsonString(FunctionID val) { return "UnpublishAppService"; case CancelInteractionID: return "CancelInteraction"; + case CreateWindowID: + return "CreateWindow"; + case DeleteWindowID: + return "DeleteWindow"; case CloseApplicationID: return "CloseApplication"; case ShowAppMenuID: @@ -1372,6 +1380,16 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { return true; } + if ("CreateWindow" == literal) { + *result = CreateWindowID; + return true; + } + + if ("DeleteWindow" == literal) { + *result = DeleteWindowID; + return true; + } + if ("CloseApplication" == literal) { *result = CloseApplicationID; return true; |