diff options
author | Ira Lytvynenko <ILytvynenko@luxoft.com> | 2018-02-09 15:26:05 +0200 |
---|---|---|
committer | Ira Lytvynenko (GitHub) <ILytvynenko@luxoft.com> | 2018-06-26 12:01:45 +0300 |
commit | 87abaf17c2f8a7e5b5153b0db3f7c1d03c6d5b5a (patch) | |
tree | 26019df5d99063c20e6cad43c367a636343f0c77 /src/components/application_manager/rpc_plugins/rc_rpc_plugin | |
parent | c8e706b2b9613dbe5b8250635d7418596007f75e (diff) | |
download | sdl_core-87abaf17c2f8a7e5b5153b0db3f7c1d03c6d5b5a.tar.gz |
Add initial impl for rc command factory and fix some rc commands
Add app extension
Add reaction on App registraion
fix notofying plugins about app registrtion
Diffstat (limited to 'src/components/application_manager/rpc_plugins/rc_rpc_plugin')
27 files changed, 400 insertions, 45 deletions
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/CMakeLists.txt index 6844a5013f..d727785dfc 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/CMakeLists.txt @@ -58,7 +58,7 @@ if(ENABLE_LOG) list(APPEND LIBRARIES log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) endif() -add_library("rc_rpc_plugin" SHARED ${MOBILE_COMMANDS} ${HMI_COMMANDS} ${RPC_PLUGIN_SOURCES}) +add_library("rc_rpc_plugin" SHARED ${PLUGIN_SOURCES} ${MOBILE_COMMANDS} ${HMI_COMMANDS}) target_link_libraries("rc_rpc_plugin" ${LIBRARIES}) set(INSTALL_DESTINATION bin) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h index 78f552aa50..7c88cea5a7 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h @@ -5,10 +5,13 @@ #include "utils/macro.h" namespace rc_rpc_plugin { +namespace app_mngr = application_manager; + namespace commands { -class ButtonPressRequest - : public application_manager::commands::CommandRequestImpl { +class ButtonPressRequest : public app_mngr::commands::CommandRequestImpl { public: + ButtonPressRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager); bool Init() OVERRIDE; void Run() OVERRIDE; void on_event(const application_manager::event_engine::Event& event) OVERRIDE; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h index 27c32e9e59..165124cdfe 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h @@ -5,10 +5,14 @@ #include "utils/macro.h" namespace rc_rpc_plugin { +namespace app_mngr = application_manager; + namespace commands { class ButtonPressResponse : public application_manager::commands::CommandResponseImpl { public: + ButtonPressResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager); bool Init() OVERRIDE; void Run() OVERRIDE; void on_event(const application_manager::event_engine::Event& event); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h index 8130611ce2..7b1128b103 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h @@ -5,10 +5,15 @@ #include "utils/macro.h" namespace rc_rpc_plugin { +namespace app_mngr = application_manager; + namespace commands { class GetInteriorVehicleDataRequest : public application_manager::commands::CommandRequestImpl { public: + GetInteriorVehicleDataRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager); bool Init() OVERRIDE; void Run() OVERRIDE; void on_event(const application_manager::event_engine::Event& event) OVERRIDE; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h index 246e7eb27f..07df368e85 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h @@ -5,10 +5,15 @@ #include "utils/macro.h" namespace rc_rpc_plugin { +namespace app_mngr = application_manager; + namespace commands { class GetInteriorVehicleDataResponse : public application_manager::commands::CommandResponseImpl { public: + GetInteriorVehicleDataResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager); bool Init() OVERRIDE; void Run() OVERRIDE; void on_event(const application_manager::event_engine::Event& event); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h new file mode 100644 index 0000000000..f3f8535486 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2017, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_APP_EXTENSION_H_ +#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_APP_EXTENSION_H_ + +#include <string> +#include <set> +#include "application_manager/app_extension.h" +#include "json/json.h" + +namespace rc_rpc_plugin { +class RCAppExtension : public application_manager::AppExtension { + public: + explicit RCAppExtension(application_manager::AppExtensionUID uid); + ~RCAppExtension(); + + /** + * @brief Subscribe to OnInteriorVehicleDataNotification + * @param module interior data specification(zone, data type) + */ + void SubscribeToInteriorVehicleData(const Json::Value& module_type); + + /** + * @brief Unsubscribe from OnInteriorVehicleDataNotification + * @param module interior data specification(zone, data type) + */ + void UnsubscribeFromInteriorVehicleData(const Json::Value& module_type); + + /** + * @brief UnsubscribeFromInteriorVehicleData removes all subscriptions for + * interior data + */ + void UnsubscribeFromInteriorVehicleData(); + + /** + * @brief Check if application subscribed to OnInteriorVehicleDataNotification + * @param module interior data specification(zone, data type) + */ + bool IsSubscibedToInteriorVehicleData(const Json::Value& module_type); + + private: + std::set<Json::Value> subscribed_interior_vehicle_data_; +}; + +typedef utils::SharedPtr<RCAppExtension> RCAppExtensionPtr; + +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_APP_EXTENSION_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h index e54d3bd5a3..fc4ba13b85 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h @@ -1,37 +1,40 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H -#include "application_manager/command_factory.h" #include <memory> +#include "application_manager/command_factory.h" #include "application_manager/application_manager.h" #include "application_manager/command_factory.h" -#include "sdl_rpc_plugin/hmi_command_factory.h" -#include "sdl_rpc_plugin/mobile_command_factory.h" #include "application_manager/rpc_service.h" #include "application_manager/hmi_capabilities.h" #include "application_manager/policies/policy_handler_interface.h" +#include "utils/macro.h" namespace rc_rpc_plugin { +namespace app_mngr = application_manager; class RCCommandFactory : public application_manager::CommandFactory { - namespace commands = application_manager::commands; - namespace app_mngr = application_manager; - public: RCCommandFactory(app_mngr::ApplicationManager& app_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, policy::PolicyHandlerInterface& policy_handler); application_manager::CommandSharedPtr CreateCommand( - const commands::MessageSharedPtr& message, - commands::Command::CommandSource source) OVERRIDE; + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::commands::Command::CommandSource source) OVERRIDE; private: + application_manager::CommandSharedPtr CreateMobileCommand( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::commands::Command::CommandSource source); + + application_manager::CommandSharedPtr CreateHMICommand( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::commands::Command::CommandSource source); + app_mngr::ApplicationManager& app_manager_; app_mngr::rpc_service::RPCService& rpc_service_; app_mngr::HMICapabilities& hmi_capabilities_; policy::PolicyHandlerInterface& policy_handler_; - std::unique_ptr<HMICommandFactory> hmi_command_factory_; - std::unique_ptr<MobileCommandFactory> mobile_command_factory_; }; } // namespace rc_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h index 8afea2f75c..faa82ebae3 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h @@ -52,6 +52,11 @@ class RCRPCPlugin : public plugins::RPCPlugin { void OnPolicyEvent(app_mngr::plugin_manager::PolicyEvent event) OVERRIDE; void OnApplicationEvent(plugins::ApplicationEvent event, app_mngr::ApplicationSharedPtr application) OVERRIDE; + + static const uint32_t kRCPluginID = 153; + + private: + std::unique_ptr<application_manager::CommandFactory> command_factory_; }; } // namespace rc_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_PLUGIN_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_request.cc index bc164c61ca..d59f12a6df 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_request.cc @@ -5,10 +5,11 @@ namespace rc_rpc_plugin { namespace commands { bool RCButtonPressRequest::Init() { - return true; + return true; } void RCButtonPressRequest::Run() {} -void RCButtonPressRequest::on_event(const application_manager::event_engine::Event& event) {} +void RCButtonPressRequest::on_event( + const application_manager::event_engine::Event& event) {} } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_response.cc index 1a7eca3408..7765de7534 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_response.cc @@ -5,10 +5,11 @@ namespace rc_rpc_plugin { namespace commands { bool RCButtonPressResponse::Init() { - return true; + return true; } void RCButtonPressResponse::Run() {} -void RCButtonPressResponse::on_event(const application_manager::event_engine::Event& event) {} +void RCButtonPressResponse::on_event( + const application_manager::event_engine::Event& event) {} } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_request.cc index c3cc73fd5f..11c3569a1e 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_request.cc @@ -5,10 +5,11 @@ namespace rc_rpc_plugin { namespace commands { bool RCGetInteriorVehicleDataRequest::Init() { - return true; + return true; } void RCGetInteriorVehicleDataRequest::Run() {} -void RCGetInteriorVehicleDataRequest::on_event(const application_manager::event_engine::Event& event) {} +void RCGetInteriorVehicleDataRequest::on_event( + const application_manager::event_engine::Event& event) {} } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc index 7099e31885..53c19dcad7 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc @@ -5,10 +5,11 @@ namespace rc_rpc_plugin { namespace commands { bool RCGetInteriorVehicleDataResponse::Init() { - return true; + return true; } void RCGetInteriorVehicleDataResponse::Run() {} -void RCGetInteriorVehicleDataResponse::on_event(const application_manager::event_engine::Event& event) {} +void RCGetInteriorVehicleDataResponse::on_event( + const application_manager::event_engine::Event& event) {} } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc index c933e7799d..8109a4cdb3 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc @@ -5,10 +5,11 @@ namespace rc_rpc_plugin { namespace commands { bool RCOnInteriorVehicleDataNotification::Init() { - return true; + return true; } void RCOnInteriorVehicleDataNotification::Run() {} -void RCOnInteriorVehicleDataNotification::on_event(const application_manager::event_engine::Event& event) {} +void RCOnInteriorVehicleDataNotification::on_event( + const application_manager::event_engine::Event& event) {} } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc index 9b2945a52a..cb1d066e0f 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc @@ -5,10 +5,11 @@ namespace rc_rpc_plugin { namespace commands { bool RCOnRemoteControlSettingsNotification::Init() { - return true; + return true; } void RCOnRemoteControlSettingsNotification::Run() {} -void RCOnRemoteControlSettingsNotification::on_event(const application_manager::event_engine::Event& event) {} +void RCOnRemoteControlSettingsNotification::on_event( + const application_manager::event_engine::Event& event) {} } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc index 23a1983abd..25645308d2 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc @@ -5,10 +5,11 @@ namespace rc_rpc_plugin { namespace commands { bool RCSetInteriorVehicleDataRequest::Init() { - return true; + return true; } void RCSetInteriorVehicleDataRequest::Run() {} -void RCSetInteriorVehicleDataRequest::on_event(const application_manager::event_engine::Event& event) {} +void RCSetInteriorVehicleDataRequest::on_event( + const application_manager::event_engine::Event& event) {} } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc index e4185cc357..0f54cc2c81 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc @@ -5,10 +5,11 @@ namespace rc_rpc_plugin { namespace commands { bool RCSetInteriorVehicleDataResponse::Init() { - return true; + return true; } void RCSetInteriorVehicleDataResponse::Run() {} -void RCSetInteriorVehicleDataResponse::on_event(const application_manager::event_engine::Event& event) {} +void RCSetInteriorVehicleDataResponse::on_event( + const application_manager::event_engine::Event& event) {} } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc index 70456631a0..d3c328b43a 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc @@ -4,11 +4,17 @@ namespace rc_rpc_plugin { namespace commands { +ButtonPressRequest::ButtonPressRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager) + : app_mngr::commands::CommandRequestImpl(message, application_manager) {} + bool ButtonPressRequest::Init() { - return true; + return true; } void ButtonPressRequest::Run() {} -void ButtonPressRequest::on_event(const application_manager::event_engine::Event& event) {} +void ButtonPressRequest::on_event( + const application_manager::event_engine::Event& event) {} } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_response.cc index f42f1d3ed2..37e7029e9d 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_response.cc @@ -4,11 +4,17 @@ namespace rc_rpc_plugin { namespace commands { +ButtonPressResponse::ButtonPressResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager) + : app_mngr::commands::CommandResponseImpl(message, application_manager) {} + bool ButtonPressResponse::Init() { - return true; + return true; } void ButtonPressResponse::Run() {} -void ButtonPressResponse::on_event(const application_manager::event_engine::Event& event) {} +void ButtonPressResponse::on_event( + const application_manager::event_engine::Event& event) {} } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc index 4f6cbd311e..3c8e4d2f4b 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc @@ -4,11 +4,17 @@ namespace rc_rpc_plugin { namespace commands { +GetInteriorVehicleDataRequest::GetInteriorVehicleDataRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager) + : app_mngr::commands::CommandRequestImpl(message, application_manager) {} + bool GetInteriorVehicleDataRequest::Init() { - return true; + return true; } void GetInteriorVehicleDataRequest::Run() {} -void GetInteriorVehicleDataRequest::on_event(const application_manager::event_engine::Event& event) {} +void GetInteriorVehicleDataRequest::on_event( + const application_manager::event_engine::Event& event) {} } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc index bf425276cc..c8c8a56675 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc @@ -4,11 +4,17 @@ namespace rc_rpc_plugin { namespace commands { +GetInteriorVehicleDataResponse::GetInteriorVehicleDataResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager) + : app_mngr::commands::CommandResponseImpl(message, application_manager) {} + bool GetInteriorVehicleDataResponse::Init() { - return true; + return true; } void GetInteriorVehicleDataResponse::Run() {} -void GetInteriorVehicleDataResponse::on_event(const application_manager::event_engine::Event& event) {} +void GetInteriorVehicleDataResponse::on_event( + const application_manager::event_engine::Event& event) {} } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc index ae8e587923..88e73fa83d 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc @@ -5,10 +5,11 @@ namespace rc_rpc_plugin { namespace commands { bool OnInteriorVehicleDataNotification::Init() { - return true; + return true; } void OnInteriorVehicleDataNotification::Run() {} -void OnInteriorVehicleDataNotification::on_event(const application_manager::event_engine::Event& event) {} +void OnInteriorVehicleDataNotification::on_event( + const application_manager::event_engine::Event& event) {} } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_remote_control_settings_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_remote_control_settings_notification.cc index 3b8b91639f..5229e9e172 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_remote_control_settings_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_remote_control_settings_notification.cc @@ -5,10 +5,11 @@ namespace rc_rpc_plugin { namespace commands { bool OnRemoveControlSettingsNotification::Init() { - return true; + return true; } void OnRemoveControlSettingsNotification::Run() {} -void OnRemoveControlSettingsNotification::on_event(const application_manager::event_engine::Event& event) {} +void OnRemoveControlSettingsNotification::on_event( + const application_manager::event_engine::Event& event) {} } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index 7fd4b4dfdf..10bfcbd104 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -5,10 +5,11 @@ namespace rc_rpc_plugin { namespace commands { bool SetInteriorVehicleDataRequest::Init() { - return true; + return true; } void SetInteriorVehicleDataRequest::Run() {} -void SetInteriorVehicleDataRequest::on_event(const application_manager::event_engine::Event& event) {} +void SetInteriorVehicleDataRequest::on_event( + const application_manager::event_engine::Event& event) {} } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_response.cc index df8725c485..802866e334 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_response.cc @@ -5,10 +5,11 @@ namespace rc_rpc_plugin { namespace commands { bool SetInteriorVehicleDataResponse::Init() { - return true; + return true; } void SetInteriorVehicleDataResponse::Run() {} -void SetInteriorVehicleDataResponse::on_event(const application_manager::event_engine::Event& event) {} +void SetInteriorVehicleDataResponse::on_event( + const application_manager::event_engine::Event& event) {} } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc new file mode 100644 index 0000000000..8a4ad3c331 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc @@ -0,0 +1,62 @@ +/* + Copyright (c) 2017, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "rc_rpc_plugin/rc_app_extension.h" + +namespace rc_rpc_plugin { +RCAppExtension::RCAppExtension(application_manager::AppExtensionUID uid) + : AppExtension(uid) {} + +void RCAppExtension::SubscribeToInteriorVehicleData( + const Json::Value& module_type) { + subscribed_interior_vehicle_data_.insert(module_type); +} + +void RCAppExtension::UnsubscribeFromInteriorVehicleData( + const Json::Value& module_type) { + subscribed_interior_vehicle_data_.erase(module_type); +} + +void RCAppExtension::UnsubscribeFromInteriorVehicleData() { + subscribed_interior_vehicle_data_.clear(); +} + +bool RCAppExtension::IsSubscibedToInteriorVehicleData( + const Json::Value& module_type) { + std::set<Json::Value>::iterator it = + subscribed_interior_vehicle_data_.find(module_type); + + return (it != subscribed_interior_vehicle_data_.end()); +} + +RCAppExtension::~RCAppExtension() {} +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc index e69de29bb2..4e9e81bf45 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc @@ -0,0 +1,106 @@ +/* + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Copyright (c) 2017 Xevo Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the copyright holders nor the names of their contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "rc_rpc_plugin/rc_command_factory.h" +#include "rc_rpc_plugin/commands/mobile/button_press_request.h" +#include "rc_rpc_plugin/commands/mobile/button_press_response.h" +#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h" +#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h" +#include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h" +#include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h" +#include "rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h" +#include "rc_rpc_plugin/commands/mobile/on_remote_control_settings_notification.h" + +#include "interfaces/MOBILE_API.h" + +CREATE_LOGGERPTR_GLOBAL(logger_, "RCCommandFactory") + +namespace rc_rpc_plugin { +using namespace application_manager; + +RCCommandFactory::RCCommandFactory( + app_mngr::ApplicationManager& app_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : app_manager_(app_manager) + , rpc_service_(rpc_service) + , hmi_capabilities_(hmi_capabilities) + , policy_handler_(policy_handler) {} + +CommandSharedPtr RCCommandFactory::CreateCommand( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::commands::Command::CommandSource source) { + if (app_mngr::commands::Command::SOURCE_HMI == source) { + return CreateHMICommand(message, source); + } else { + return CreateMobileCommand(message, source); + } +} + +CommandSharedPtr RCCommandFactory::CreateMobileCommand( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::commands::Command::CommandSource source) { + CommandSharedPtr command; + const int function_id = + (*message)[strings::params][strings::function_id].asInt(); + LOG4CXX_DEBUG( + logger_, + "MobileCommandFactory::CreateCommand function_id: " << function_id); + switch (function_id) { + case mobile_apis::FunctionID::ButtonPressID: { + if ((*message)[strings::params][strings::message_type] == + static_cast<int>(application_manager::MessageType::kRequest)) { + command.reset(new commands::ButtonPressRequest(message, app_manager_)); + } else { + command.reset(new commands::ButtonPressRequest(message, app_manager_)); + } + } + + break; + default: + break; + } + return command; +} + +CommandSharedPtr RCCommandFactory::CreateHMICommand( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::commands::Command::CommandSource source) { + CommandSharedPtr command; + return command; +} + +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc index e69de29bb2..2d5baba139 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc @@ -0,0 +1,47 @@ +#include "rc_rpc_plugin/rc_rpc_plugin.h" +#include "rc_rpc_plugin/rc_command_factory.h" +#include "rc_rpc_plugin/rc_app_extension.h" + +namespace rc_rpc_plugin { +namespace plugins = application_manager::plugin_manager; + +bool RCRPCPlugin::Init( + application_manager::ApplicationManager& app_manager, + application_manager::rpc_service::RPCService& rpc_service, + application_manager::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) { + return true; +} + +bool RCRPCPlugin::IsAbleToProcess( + const int32_t function_id, + const application_manager::commands::Command::CommandSource + message_source) { + return true; +} + +std::string RCRPCPlugin::PluginName() { + return "RC RPC Plugin"; +} + +application_manager::CommandFactory& RCRPCPlugin::GetCommandFactory() { + return *command_factory_; +} + +void RCRPCPlugin::OnPolicyEvent( + application_manager::plugin_manager::PolicyEvent event) {} + +void RCRPCPlugin::OnApplicationEvent( + application_manager::plugin_manager::ApplicationEvent event, + application_manager::ApplicationSharedPtr application) { + switch (event) { + case plugins::kApplicationRegistered: { + application->AddExtension(new RCAppExtension(kRCPluginID)); + break; + } + default: + break; + } +} + +} // namespace rc_rpc_plugin |