diff options
author | BSolonenko <BSolonenko@luxoft.com> | 2018-02-16 16:43:15 +0200 |
---|---|---|
committer | Ira Lytvynenko (GitHub) <ILytvynenko@luxoft.com> | 2018-06-26 12:01:45 +0300 |
commit | 9fc8889ca79de0b7b8a1bc0d4e6dd6a10a0d22f2 (patch) | |
tree | 17b234f05e691e84a129abe7f50f94561beeaf1d /src/components/application_manager/rpc_plugins/rc_rpc_plugin/src | |
parent | cee8da7793f62a45d4d5555e05fcbbc9072dee84 (diff) | |
download | sdl_core-9fc8889ca79de0b7b8a1bc0d4e6dd6a10a0d22f2.tar.gz |
Refactoring rc rpc plugin's factory
Diffstat (limited to 'src/components/application_manager/rpc_plugins/rc_rpc_plugin/src')
17 files changed, 423 insertions, 276 deletions
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 c90f2aedb2..ad873cd331 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 @@ -9,12 +9,15 @@ RCButtonPressRequest::RCButtonPressRequest( app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + policy::PolicyHandlerInterface& policy_handle, + ResourceAllocationManager& resource_allocation_manager) : application_manager::commands::RequestToHMI(message, application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle) { + UNUSED(resource_allocation_manager); +} RCButtonPressRequest::~RCButtonPressRequest() {} 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 f3ebaece1e..fec7110bb0 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 @@ -9,12 +9,15 @@ RCButtonPressResponse::RCButtonPressResponse( app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + policy::PolicyHandlerInterface& policy_handle, + ResourceAllocationManager& resource_allocation_manager) : application_manager::commands::ResponseFromHMI(message, application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle) { + UNUSED(resource_allocation_manager); +} void RCButtonPressResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); 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 9468191142..5335187ec1 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 @@ -9,12 +9,15 @@ RCGetInteriorVehicleDataRequest::RCGetInteriorVehicleDataRequest( app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + policy::PolicyHandlerInterface& policy_handle, + ResourceAllocationManager& resource_allocation_manager) : application_manager::commands::RequestToHMI(message, application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle) { + UNUSED(resource_allocation_manager); +} RCGetInteriorVehicleDataRequest::~RCGetInteriorVehicleDataRequest() {} 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 77607a791f..8f0cea03a2 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 @@ -9,19 +9,22 @@ RCGetInteriorVehicleDataResponse::RCGetInteriorVehicleDataResponse( app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + policy::PolicyHandlerInterface& policy_handle, + ResourceAllocationManager& resource_allocation_manager) : application_manager::commands::ResponseFromHMI(message, application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle) { + UNUSED(resource_allocation_manager); +} void RCGetInteriorVehicleDataResponse::Run() { - LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_AUTO_TRACE(logger_); - app_mngr::event_engine::Event event( - hmi_apis::FunctionID::RC_GetInteriorVehicleData); - event.set_smart_object(*message_); - event.raise(application_manager_.event_dispatcher()); + app_mngr::event_engine::Event event( + hmi_apis::FunctionID::RC_GetInteriorVehicleData); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); } RCGetInteriorVehicleDataResponse::~RCGetInteriorVehicleDataResponse() {} 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 e45a875aa5..a7318a1ac1 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 @@ -9,12 +9,18 @@ RCOnInteriorVehicleDataNotification::RCOnInteriorVehicleDataNotification( app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + policy::PolicyHandlerInterface& policy_handle, + ResourceAllocationManager& resource_allocation_manager) : application_manager::commands::NotificationFromHMI(message, application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle) { + UNUSED(resource_allocation_manager); +} + +RCOnInteriorVehicleDataNotification::~RCOnInteriorVehicleDataNotification() {} + bool RCOnInteriorVehicleDataNotification::Init() { return true; } 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 1ed872f273..9626f8b364 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 @@ -15,18 +15,19 @@ std::map<std::string, hmi_apis::Common_RCAccessMode::eType> access_modes{ CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") -RCOnRemoteControlSettingsNotification::RCOnRemoteControlSettingsNotification(const app_mngr::commands::MessageSharedPtr& message, +RCOnRemoteControlSettingsNotification::RCOnRemoteControlSettingsNotification( + const app_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, - ResourceAllocationManager &resource_allocation_manager) + ResourceAllocationManager& resource_allocation_manager) : application_manager::commands::NotificationFromHMI(message, application_manager, rpc_service, hmi_capabilities, policy_handle) - , resource_allocation_manager_(resource_allocation_manager){} + , resource_allocation_manager_(resource_allocation_manager) {} hmi_apis::Common_RCAccessMode::eType AccessModeFromString( const std::string& access_mode) { @@ -65,7 +66,8 @@ void RCOnRemoteControlSettingsNotification::DisallowRCFunctionality() { for (Apps::iterator it = apps.begin(); it != apps.end(); ++it) { application_manager::ApplicationSharedPtr app = *it; DCHECK(app); - application_manager_.ChangeAppsHMILevel(app->app_id(), mobile_apis::HMILevel::eType::HMI_NONE); + application_manager_.ChangeAppsHMILevel( + app->app_id(), mobile_apis::HMILevel::eType::HMI_NONE); const RCAppExtensionPtr extension = application_manager::AppExtensionPtr::static_pointer_cast< @@ -77,40 +79,47 @@ void RCOnRemoteControlSettingsNotification::DisallowRCFunctionality() { } void RCOnRemoteControlSettingsNotification::Run() { - LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_AUTO_TRACE(logger_); - if (!(*message_)[app_mngr::strings::msg_params].keyExists(message_params::kAllowed)) { - LOG4CXX_DEBUG(logger_, - "Notification is ignored due to \"allow\" parameter absense"); - LOG4CXX_DEBUG(logger_, "RC Functionality remains unchanged"); - return; - } + if (!(*message_)[app_mngr::strings::msg_params].keyExists( + message_params::kAllowed)) { + LOG4CXX_DEBUG(logger_, + "Notification is ignored due to \"allow\" parameter absense"); + LOG4CXX_DEBUG(logger_, "RC Functionality remains unchanged"); + return; + } - const bool is_allowed = (*message_)[app_mngr::strings::msg_params][message_params::kAllowed].asBool(); - if (is_allowed) { - hmi_apis::Common_RCAccessMode::eType access_mode = - hmi_apis::Common_RCAccessMode::INVALID_ENUM; - LOG4CXX_DEBUG(logger_, "Allowing RC Functionality"); - if ((*message_)[app_mngr::strings::msg_params].keyExists(message_params::kAccessMode)) { - const std::string access_mode_str = - (*message_)[app_mngr::strings::msg_params][message_params::kAccessMode].asString(); + const bool is_allowed = + (*message_)[app_mngr::strings::msg_params][message_params::kAllowed] + .asBool(); + if (is_allowed) { + hmi_apis::Common_RCAccessMode::eType access_mode = + hmi_apis::Common_RCAccessMode::INVALID_ENUM; + LOG4CXX_DEBUG(logger_, "Allowing RC Functionality"); + if ((*message_)[app_mngr::strings::msg_params].keyExists( + message_params::kAccessMode)) { + const std::string access_mode_str = + (*message_)[app_mngr::strings::msg_params] + [message_params::kAccessMode].asString(); - access_mode = AccessModeFromString(access_mode_str); - LOG4CXX_DEBUG(logger_, "Setting up access mode : " << access_mode_str); - } else { - access_mode = resource_allocation_manager_.GetAccessMode(); - LOG4CXX_DEBUG(logger_, - "No access mode received. Using last known: " - << AccessModeToString(access_mode)); - } - resource_allocation_manager_.SetAccessMode(access_mode); + access_mode = AccessModeFromString(access_mode_str); + LOG4CXX_DEBUG(logger_, "Setting up access mode : " << access_mode_str); } else { - LOG4CXX_DEBUG(logger_, "Disallowing RC Functionality"); - DisallowRCFunctionality(); - resource_allocation_manager_.ResetAllAllocations(); + access_mode = resource_allocation_manager_.GetAccessMode(); + LOG4CXX_DEBUG(logger_, + "No access mode received. Using last known: " + << AccessModeToString(access_mode)); + } + resource_allocation_manager_.SetAccessMode(access_mode); + } else { + LOG4CXX_DEBUG(logger_, "Disallowing RC Functionality"); + DisallowRCFunctionality(); + resource_allocation_manager_.ResetAllAllocations(); } } +RCOnRemoteControlSettingsNotification:: + ~RCOnRemoteControlSettingsNotification() {} } // 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 e122a02fc1..be4e360786 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 @@ -9,17 +9,20 @@ RCSetInteriorVehicleDataRequest::RCSetInteriorVehicleDataRequest( app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + policy::PolicyHandlerInterface& policy_handle, + ResourceAllocationManager& resource_allocation_manager) : application_manager::commands::RequestToHMI(message, application_manager, rpc_service, hmi_capabilities, - policy_handle) {} -RCSetInteriorVehicleDataRequest::~RCSetInteriorVehicleDataRequest(){} + policy_handle) { + UNUSED(resource_allocation_manager); +} +RCSetInteriorVehicleDataRequest::~RCSetInteriorVehicleDataRequest() {} void RCSetInteriorVehicleDataRequest::Run() { - LOG4CXX_AUTO_TRACE(logger_); - SendRequest(); + LOG4CXX_AUTO_TRACE(logger_); + SendRequest(); } } // namespace commands 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 6bc8b1fb9e..770431dec2 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 @@ -9,22 +9,26 @@ RCSetInteriorVehicleDataResponse::RCSetInteriorVehicleDataResponse( app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + policy::PolicyHandlerInterface& policy_handle, + ResourceAllocationManager& resource_allocation_manager) : application_manager::commands::ResponseFromHMI(message, application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle) { + UNUSED(resource_allocation_manager); +} void RCSetInteriorVehicleDataResponse::Run() { - LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_AUTO_TRACE(logger_); - app_mngr::event_engine::Event event(hmi_apis::FunctionID::RC_SetInteriorVehicleData); - event.set_smart_object(*message_); - event.raise(application_manager_.event_dispatcher()); + app_mngr::event_engine::Event event( + hmi_apis::FunctionID::RC_SetInteriorVehicleData); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); } -RCSetInteriorVehicleDataResponse::~RCSetInteriorVehicleDataResponse(){} +RCSetInteriorVehicleDataResponse::~RCSetInteriorVehicleDataResponse() {} } // 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 8c9158c78b..f70215fefc 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 @@ -16,18 +16,18 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") typedef std::map<std::string, mobile_apis::ButtonName::eType> ButtonsMap; ButtonPressRequest::ButtonPressRequest( - ResourceAllocationManager& resource_allocation_manager, const app_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) - : RCCommandRequest(resource_allocation_manager, - message, + policy::PolicyHandlerInterface& policy_handle, + ResourceAllocationManager& resource_allocation_manager) + : RCCommandRequest(message, application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle, + resource_allocation_manager) {} ButtonPressRequest::~ButtonPressRequest() {} 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 a6ac5ca0c1..88d6b962ac 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 @@ -9,12 +9,15 @@ ButtonPressResponse::ButtonPressResponse( app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + policy::PolicyHandlerInterface& policy_handle, + ResourceAllocationManager& resource_allocation_manager) : application_manager::commands::CommandResponseImpl(message, application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle) { + UNUSED(resource_allocation_manager); +} ButtonPressResponse::~ButtonPressResponse() {} void ButtonPressResponse::Run() { 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 2f2a1f87d2..1b207b6e91 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 @@ -12,18 +12,18 @@ using namespace message_params; CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") GetInteriorVehicleDataRequest::GetInteriorVehicleDataRequest( - ResourceAllocationManager& resource_allocation_manager, const app_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) - : RCCommandRequest(resource_allocation_manager, - message, + policy::PolicyHandlerInterface& policy_handle, + ResourceAllocationManager& resource_allocation_manager) + : RCCommandRequest(message, application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle, + resource_allocation_manager) {} bool CheckIfModuleTypeExistInCapabilities( const smart_objects::SmartObject& rc_capabilities, const std::string& module_type) { @@ -100,6 +100,8 @@ void GetInteriorVehicleDataRequest::on_event( SendResponse(result, result_code, response_info.c_str()); } +GetInteriorVehicleDataRequest::~GetInteriorVehicleDataRequest() {} + void GetInteriorVehicleDataRequest::ProccessSubscription( const NsSmartDeviceLink::NsSmartObjects::SmartObject& hmi_response) { LOG4CXX_AUTO_TRACE(logger_); @@ -142,8 +144,9 @@ void GetInteriorVehicleDataRequest::ProccessSubscription( LOG4CXX_TRACE(logger_, "request_subscribe = " << request_subscribe); LOG4CXX_TRACE(logger_, "response_subscribe = " << response_subscribe); if (request_subscribe == response_subscribe) { - const std::string module_type = - (*message_)[app_mngr::strings::msg_params][message_params::kModuleData][message_params::kModuleType].asString(); + const std::string module_type = + (*message_)[app_mngr::strings::msg_params][message_params::kModuleData] + [message_params::kModuleType].asString(); if (response_subscribe) { LOG4CXX_DEBUG(logger_, "SubscribeToInteriorVehicleData " << app->app_id() << " " @@ -173,7 +176,8 @@ bool GetInteriorVehicleDataRequest::HasRequestExcessiveSubscription() { const bool is_app_already_subscribed = extension->IsSubscibedToInteriorVehicleData( (*message_)[app_mngr::strings::msg_params] - [message_params::kModuleData][message_params::kModuleType].asString()); + [message_params::kModuleData] + [message_params::kModuleType].asString()); const bool app_wants_to_subscribe = (*message_)[app_mngr::strings::msg_params][message_params::kSubscribe] .asBool(); 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 7a57e93fe6..f1efcaed98 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 @@ -9,12 +9,15 @@ GetInteriorVehicleDataResponse::GetInteriorVehicleDataResponse( app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + policy::PolicyHandlerInterface& policy_handle, + ResourceAllocationManager& resource_allocation_manager) : application_manager::commands::CommandResponseImpl(message, application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle) { + UNUSED(resource_allocation_manager); +} GetInteriorVehicleDataResponse::~GetInteriorVehicleDataResponse() {} void GetInteriorVehicleDataResponse::Run() { 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 d1f11e80f9..1b5d76c7c8 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 @@ -13,36 +13,40 @@ OnInteriorVehicleDataNotification::OnInteriorVehicleDataNotification( app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + policy::PolicyHandlerInterface& policy_handler, + ResourceAllocationManager& resource_allocation_manager) : app_mngr::commands::CommandNotificationImpl(message, application_manager, rpc_service, hmi_capabilities, - policy_handler) {} + policy_handler) { + UNUSED(resource_allocation_manager); +} OnInteriorVehicleDataNotification::~OnInteriorVehicleDataNotification() {} void OnInteriorVehicleDataNotification::Run() { - LOG4CXX_AUTO_TRACE(logger_); - - const std::string module_type = - (*message_)[app_mngr::strings::msg_params][message_params::kModuleType].asString(); - - typedef std::vector<application_manager::ApplicationSharedPtr> AppPtrs; - AppPtrs apps = RCRPCPlugin::GetRCApplications(application_manager_); - - for (AppPtrs::iterator it = apps.begin(); it != apps.end(); ++it) { - DCHECK(*it); - application_manager::Application& app = **it; - - RCAppExtensionPtr extension = - application_manager::AppExtensionPtr::static_pointer_cast< - RCAppExtension>(app.QueryInterface(RCRPCPlugin::kRCPluginID)); - DCHECK(extension); - LOG4CXX_TRACE(logger_, "Check subscription for " << app.app_id()); - if (extension->IsSubscibedToInteriorVehicleData(module_type)) { - SendNotification(); - } + LOG4CXX_AUTO_TRACE(logger_); + + const std::string module_type = + (*message_)[app_mngr::strings::msg_params][message_params::kModuleType] + .asString(); + + typedef std::vector<application_manager::ApplicationSharedPtr> AppPtrs; + AppPtrs apps = RCRPCPlugin::GetRCApplications(application_manager_); + + for (AppPtrs::iterator it = apps.begin(); it != apps.end(); ++it) { + DCHECK(*it); + application_manager::Application& app = **it; + + RCAppExtensionPtr extension = + application_manager::AppExtensionPtr::static_pointer_cast< + RCAppExtension>(app.QueryInterface(RCRPCPlugin::kRCPluginID)); + DCHECK(extension); + LOG4CXX_TRACE(logger_, "Check subscription for " << app.app_id()); + if (extension->IsSubscibedToInteriorVehicleData(module_type)) { + SendNotification(); + } } } 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 738f51df54..1ae844def8 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 @@ -60,18 +60,18 @@ const std::map<std::string, std::string> GetModuleDataToCapabilitiesMapping() { CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") SetInteriorVehicleDataRequest::SetInteriorVehicleDataRequest( - ResourceAllocationManager& resource_allocation_manager, const app_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) - : RCCommandRequest(resource_allocation_manager, - message, + policy::PolicyHandlerInterface& policy_handle, + ResourceAllocationManager& resource_allocation_manager) + : RCCommandRequest(message, application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle, + resource_allocation_manager) {} SetInteriorVehicleDataRequest::~SetInteriorVehicleDataRequest() {} @@ -138,32 +138,33 @@ bool CheckIfModuleDataExistInCapabilities( return is_radio_data_valid && is_climate_data_valid; } - - void SetInteriorVehicleDataRequest::Execute() { LOG4CXX_AUTO_TRACE(logger_); auto module_data = - (*message_)[app_mngr::strings::msg_params][message_params::kModuleData]; - const std::string module_type = module_data[message_params::kModuleType].asString(); + (*message_)[app_mngr::strings::msg_params][message_params::kModuleData]; + const std::string module_type = + module_data[message_params::kModuleType].asString(); bool module_type_and_data_match = true; if (enums_value::kRadio == module_type) { - module_type_and_data_match = !(module_data.keyExists(message_params::kClimateControlData)); + module_type_and_data_match = + !(module_data.keyExists(message_params::kClimateControlData)); } if (enums_value::kClimate == module_type) { - module_type_and_data_match = !(module_data.keyExists(message_params::kRadioControlData)); + module_type_and_data_match = + !(module_data.keyExists(message_params::kRadioControlData)); } if (module_type_and_data_match) { - const smart_objects::SmartObject* rc_capabilities = - application_manager_.hmi_capabilities().rc_capability(); + const smart_objects::SmartObject* rc_capabilities = + application_manager_.hmi_capabilities().rc_capability(); if (rc_capabilities && !CheckIfModuleDataExistInCapabilities(*rc_capabilities, module_data)) { LOG4CXX_WARN(logger_, "Accessing not supported module data"); SendResponse(false, - mobile_apis::Result::UNSUPPORTED_RESOURCE, + mobile_apis::Result::UNSUPPORTED_RESOURCE, "Accessing not supported module data"); return; } @@ -181,7 +182,8 @@ void SetInteriorVehicleDataRequest::Execute() { } application_manager_.RemoveHMIFakeParameters(message_); SendHMIRequest(hmi_apis::FunctionID::RC_SetInteriorVehicleData, - &(*message_)[app_mngr::strings::msg_params], true); + &(*message_)[app_mngr::strings::msg_params], + true); } else { LOG4CXX_WARN(logger_, "Request module type & data mismatch!"); SendResponse(false, @@ -190,10 +192,11 @@ void SetInteriorVehicleDataRequest::Execute() { } } -void SetInteriorVehicleDataRequest::on_event(const app_mngr::event_engine::Event& event) { +void SetInteriorVehicleDataRequest::on_event( + const app_mngr::event_engine::Event& event) { LOG4CXX_AUTO_TRACE(logger_); - if (hmi_apis::FunctionID::RC_SetInteriorVehicleData != event.id()){ - return; + if (hmi_apis::FunctionID::RC_SetInteriorVehicleData != event.id()) { + return; } const smart_objects::SmartObject& hmi_response = event.smart_object(); @@ -208,22 +211,23 @@ void SetInteriorVehicleDataRequest::on_event(const app_mngr::event_engine::Event mobile_apis::Result::SUCCESS, mobile_apis::Result::WARNINGS); -// if (result) { -// response_params_[message_params::kModuleData] = -// value[json_keys::kResult][message_params::kModuleData]; -// } + // if (result) { + // response_params_[message_params::kModuleData] = + // value[json_keys::kResult][message_params::kModuleData]; + // } std::string info; GetInfo(hmi_response, info); SendResponse(result, result_code, info.c_str()); } -const smart_objects::SmartObject& ControlData(const smart_objects::SmartObject& module_data) { - const std::string module = module_data[message_params::kModuleType].asString(); +const smart_objects::SmartObject& ControlData( + const smart_objects::SmartObject& module_data) { + const std::string module = + module_data[message_params::kModuleType].asString(); if (enums_value::kRadio == module) { return module_data[message_params::kRadioControlData]; - } - else { + } else { return module_data[message_params::kClimateControlData]; } } @@ -232,10 +236,10 @@ bool SetInteriorVehicleDataRequest::AreAllParamsReadOnly( const smart_objects::SmartObject& module_data) { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& module_type_params = - ControlData(module_data); + ControlData(module_data); auto it = module_type_params.map_begin(); - std::vector<std::string> ro_params = - GetModuleReadOnlyParams(module_data[message_params::kModuleType].asString()); + std::vector<std::string> ro_params = GetModuleReadOnlyParams( + module_data[message_params::kModuleType].asString()); for (; it != module_type_params.map_end(); ++it) { if (!helpers::in_range(ro_params, it->first)) { return false; @@ -248,10 +252,10 @@ bool SetInteriorVehicleDataRequest::AreReadOnlyParamsPresent( const smart_objects::SmartObject& module_data) { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& module_type_params = - ControlData(module_data); + ControlData(module_data); auto it = module_type_params.map_begin(); - std::vector<std::string> ro_params = - GetModuleReadOnlyParams(module_data[message_params::kModuleType].asString()); + std::vector<std::string> ro_params = GetModuleReadOnlyParams( + module_data[message_params::kModuleType].asString()); for (; it != module_type_params.map_end(); ++it) { if (helpers::in_range(ro_params, it->first)) { return true; @@ -264,18 +268,21 @@ void SetInteriorVehicleDataRequest::CutOffReadOnlyParams( smart_objects::SmartObject& module_data) { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& module_type_params = - ControlData(module_data); + ControlData(module_data); auto it = module_type_params.map_begin(); - const std::string module_type = module_data[message_params::kModuleType].asString(); + const std::string module_type = + module_data[message_params::kModuleType].asString(); std::vector<std::string> ro_params = GetModuleReadOnlyParams(module_type); for (; it != module_type_params.map_end(); ++it) { if (helpers::in_range(ro_params, it->first)) { if (enums_value::kClimate == module_type) { module_data[message_params::kClimateControlData].erase(it->first); - LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameter: " << it->first); + LOG4CXX_DEBUG(logger_, + "Cutting-off READ ONLY parameter: " << it->first); } else if (enums_value::kRadio == module_type) { module_data[message_params::kRadioControlData].erase(it->first); - LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameter: " << it->first); + LOG4CXX_DEBUG(logger_, + "Cutting-off READ ONLY parameter: " << it->first); } } } @@ -283,13 +290,14 @@ void SetInteriorVehicleDataRequest::CutOffReadOnlyParams( AcquireResult::eType SetInteriorVehicleDataRequest::AcquireResource( const app_mngr::commands::MessageSharedPtr& message) { - LOG4CXX_AUTO_TRACE(logger_); - const std::string module_type = - (*message_)[app_mngr::strings::msg_params][message_params::kModuleData][message_params::kModuleType] - .asString(); - app_mngr::ApplicationSharedPtr app = - application_manager_.application(CommandRequestImpl::connection_key()); - return resource_allocation_manager_.AcquireResource(module_type, app->app_id()); + LOG4CXX_AUTO_TRACE(logger_); + const std::string module_type = + (*message_)[app_mngr::strings::msg_params][message_params::kModuleData] + [message_params::kModuleType].asString(); + app_mngr::ApplicationSharedPtr app = + application_manager_.application(CommandRequestImpl::connection_key()); + return resource_allocation_manager_.AcquireResource(module_type, + app->app_id()); } bool SetInteriorVehicleDataRequest::IsResourceFree( @@ -297,12 +305,13 @@ bool SetInteriorVehicleDataRequest::IsResourceFree( return resource_allocation_manager_.IsResourceFree(module_type); } -void SetInteriorVehicleDataRequest::SetResourceState( const std::string& module_type, - const ResourceState::eType state) { - LOG4CXX_AUTO_TRACE(logger_); - app_mngr::ApplicationSharedPtr app = - application_manager_.application(CommandRequestImpl::connection_key()); - resource_allocation_manager_.SetResourceState(module_type, app->app_id(), state); +void SetInteriorVehicleDataRequest::SetResourceState( + const std::string& module_type, const ResourceState::eType state) { + LOG4CXX_AUTO_TRACE(logger_); + app_mngr::ApplicationSharedPtr app = + application_manager_.application(CommandRequestImpl::connection_key()); + resource_allocation_manager_.SetResourceState( + module_type, app->app_id(), state); } } // namespace commands 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 a09d41aca1..2d5d0350e1 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 @@ -9,17 +9,20 @@ SetInteriorVehicleDataResponse::SetInteriorVehicleDataResponse( app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + policy::PolicyHandlerInterface& policy_handle, + ResourceAllocationManager& resource_allocation_manager) : application_manager::commands::CommandResponseImpl(message, application_manager, rpc_service, hmi_capabilities, - policy_handle) {} -SetInteriorVehicleDataResponse::~SetInteriorVehicleDataResponse(){} + policy_handle) { + UNUSED(resource_allocation_manager); +} +SetInteriorVehicleDataResponse::~SetInteriorVehicleDataResponse() {} void SetInteriorVehicleDataResponse::Run() { - LOG4CXX_AUTO_TRACE(logger_); - application_manager_.GetRPCService().SendMessageToMobile(message_); + LOG4CXX_AUTO_TRACE(logger_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc index 1cfcf07a64..d6aaaab04a 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc @@ -41,12 +41,12 @@ namespace rc_rpc_plugin { namespace commands { RCCommandRequest::RCCommandRequest( - rc_rpc_plugin::ResourceAllocationManager& resource_allocation_manager, const app_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) + policy::PolicyHandlerInterface& policy_handle, + rc_rpc_plugin::ResourceAllocationManager& resource_allocation_manager) : application_manager::commands::CommandRequestImpl(message, application_manager, rpc_service, 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 d6c1b492e7..d4f2353efd 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 @@ -53,7 +53,107 @@ #include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" + CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") +namespace application_manager { +using rc_rpc_plugin::ResourceAllocationManager; + +template <typename RCCommandType> +class RCCommandCreator : public CommandCreator { + public: + RCCommandCreator(ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + PolicyHandlerInterface& policy_handler, + ResourceAllocationManager& resource_allocation_manager) + : application_manager_(application_manager) + , rpc_service_(rpc_service) + , hmi_capabilities_(hmi_capabilities) + , policy_handler_(policy_handler) + , resource_allocation_manager_(resource_allocation_manager) {} + + private: + bool CanBeCreated() const override { + return true; + } + + CommandSharedPtr create( + const commands::MessageSharedPtr& message) const override { + CommandSharedPtr command(new RCCommandType(message, + application_manager_, + rpc_service_, + hmi_capabilities_, + policy_handler_, + resource_allocation_manager_)); + return command; + } + + ApplicationManager& application_manager_; + RPCService& rpc_service_; + HMICapabilities& hmi_capabilities_; + PolicyHandlerInterface& policy_handler_; + ResourceAllocationManager& resource_allocation_manager_; +}; + +struct RCInvalidCommand {}; + +template <> +class RCCommandCreator<RCInvalidCommand> : public CommandCreator { + public: + RCCommandCreator(ApplicationManager& application_manager, + RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + PolicyHandlerInterface& policy_handler, + ResourceAllocationManager& resource_allocation_manager) { + UNUSED(application_manager); + UNUSED(rpc_service); + UNUSED(hmi_capabilities); + UNUSED(policy_handler); + UNUSED(resource_allocation_manager); + } + + private: + bool CanBeCreated() const override { + return false; + } + + CommandSharedPtr create( + const commands::MessageSharedPtr& message) const override { + UNUSED(message); + return CommandSharedPtr(); + } +}; + +struct RCCommandCreatorFactory { + RCCommandCreatorFactory( + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + PolicyHandlerInterface& policy_handler, + ResourceAllocationManager& resource_allocation_manager) + : application_manager_(application_manager) + , rpc_service_(rpc_service) + , hmi_capabilities_(hmi_capabilities) + , policy_handler_(policy_handler) + , resource_allocation_manager_(resource_allocation_manager) {} + + template <typename RCCommandType> + CommandCreator& GetCreator() { + static RCCommandCreator<RCCommandType> res(application_manager_, + rpc_service_, + hmi_capabilities_, + policy_handler_, + resource_allocation_manager_); + return res; + } + ApplicationManager& application_manager_; + RPCService& rpc_service_; + HMICapabilities& hmi_capabilities_; + PolicyHandlerInterface& policy_handler_; + ResourceAllocationManager& resource_allocation_manager_; +}; +} namespace rc_rpc_plugin { using namespace application_manager; @@ -74,9 +174,26 @@ 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); + hmi_apis::messageType::eType message_type = + static_cast<hmi_apis::messageType::eType>( + (*message)[strings::params][strings::message_type].asInt()); + + hmi_apis::FunctionID::eType function_id = + static_cast<hmi_apis::FunctionID::eType>( + (*message)[strings::params][strings::function_id].asInt()); + + return get_hmi_creator_factory(function_id, message_type).create(message); } else { - return CreateMobileCommand(message, source); + mobile_apis::messageType::eType message_type = + static_cast<mobile_apis::messageType::eType>( + (*message)[strings::params][strings::message_type].asInt()); + + mobile_apis::FunctionID::eType function_id = + static_cast<mobile_apis::FunctionID::eType>( + (*message)[strings::params][strings::function_id].asInt()); + + return get_mobile_creator_factory(function_id, message_type) + .create(message); } } @@ -84,130 +201,100 @@ bool RCCommandFactory::IsAbleToProcess( const int32_t function_id, const application_manager::commands::Command::CommandSource message_source) const { - return get_creator_factory( - static_cast<hmi_apis::FunctionID::eType>(function_id), - hmi_apis::messageType::INVALID_ENUM, - message_source).isAble(); + using app_mngr::commands::Command; + if (Command::SOURCE_HMI == message_source) { + return get_hmi_creator_factory( + static_cast<hmi_apis::FunctionID::eType>(function_id), + hmi_apis::messageType::INVALID_ENUM).CanBeCreated(); + } else { + return get_mobile_creator_factory( + static_cast<mobile_api::FunctionID::eType>(function_id), + mobile_api::messageType::INVALID_ENUM).CanBeCreated(); + } } -ICommandCreator& RCCommandFactory::get_creator_factory( - hmi_apis::FunctionID::eType id, - hmi_apis::messageType::eType message_type, - application_manager::commands::Command::CommandSource source) const {} +CommandCreator& RCCommandFactory::get_mobile_creator_factory( + mobile_api::FunctionID::eType id, + mobile_api::messageType::eType message_type) const { + LOG4CXX_DEBUG(logger_, + "CreateMobileCommand function_id: " << id << " message_type: " + << message_type); + RCCommandCreatorFactory rc_factory(app_manager_, + rpc_service_, + hmi_capabilities_, + policy_handler_, + allocation_manager_); -CommandSharedPtr RCCommandFactory::CreateMobileCommand( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::commands::Command::CommandSource source) { - // TODO : rework factory same as in SDL commanf dactory - return CommandSharedPtr(); - - // CommandSharedPtr command; - // const int function_id = - // (*message)[strings::params][strings::function_id].asInt(); - // LOG4CXX_DEBUG(logger_, "CreateMobileCommand 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_, allocation_manager_)); - // } else { - // command.reset(new commands::ButtonPressResponse(message, - // app_manager_)); - // } - // break; - // } - // case mobile_apis::FunctionID::GetInteriorVehicleDataID: { - // if ((*message)[strings::params][strings::message_type] == - // static_cast<int>(application_manager::MessageType::kRequest)) { - // command.reset( - // new commands::GetInteriorVehicleDataRequest(message, - // app_manager_, allocation_manager_)); - // } else { - // command.reset(new commands::GetInteriorVehicleDataResponse( - // message, app_manager_)); - // } - // break; - // } - // case mobile_apis::FunctionID::SetInteriorVehicleDataID: { - // if ((*message)[strings::params][strings::message_type] == - // static_cast<int>(application_manager::MessageType::kRequest)) { - // command.reset( - // new commands::SetInteriorVehicleDataRequest(message, - // app_manager_)); - // } else { - // command.reset(new commands::SetInteriorVehicleDataResponse( - // message, app_manager_)); - // } - // break; - // } - // case mobile_apis::FunctionID::OnInteriorVehicleDataID: { - // command.reset(new commands::OnInteriorVehicleDataNotification( - // message, app_manager_)); - // break; - // } - // default: { break; } - // } - // return command; + switch (id) { + case mobile_apis::FunctionID::ButtonPressID: { + return mobile_api::messageType::request == message_type + ? rc_factory.GetCreator<commands::ButtonPressRequest>() + : rc_factory.GetCreator<commands::ButtonPressResponse>(); + } + case mobile_apis::FunctionID::GetInteriorVehicleDataID: { + return mobile_api::messageType::request == message_type + ? rc_factory + .GetCreator<commands::GetInteriorVehicleDataRequest>() + : rc_factory + .GetCreator<commands::GetInteriorVehicleDataResponse>(); + } + case mobile_apis::FunctionID::SetInteriorVehicleDataID: { + return mobile_api::messageType::request == message_type + ? rc_factory + .GetCreator<commands::SetInteriorVehicleDataRequest>() + : rc_factory + .GetCreator<commands::SetInteriorVehicleDataResponse>(); + } + case mobile_apis::FunctionID::OnInteriorVehicleDataID: { + return rc_factory + .GetCreator<commands::OnInteriorVehicleDataNotification>(); + } + default: { return rc_factory.GetCreator<RCInvalidCommand>(); } + } } -CommandSharedPtr RCCommandFactory::CreateHMICommand( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::commands::Command::CommandSource source) { - CommandSharedPtr command; - // TODO : rework factory same as in SDL commanf dactory - return command; - // const int function_id = - // (*message)[strings::params][strings::function_id].asInt(); - // LOG4CXX_DEBUG(logger_, "CreateHMICommand function_id: " << function_id); - // switch (function_id) { - // case hmi_apis::FunctionID::Buttons_ButtonPress: { - // if ((*message)[strings::params][strings::message_type] == - // static_cast<int>(application_manager::MessageType::kRequest)) { - // command.reset( - // new commands::RCButtonPressRequest(message, app_manager_)); - // } else { - // command.reset( - // new commands::RCButtonPressResponse(message, app_manager_)); - // } - // break; - // } - // case hmi_apis::FunctionID::RC_GetInteriorVehicleData: { - // if ((*message)[strings::params][strings::message_type] == - // static_cast<int>(application_manager::MessageType::kRequest)) { - // command.reset(new commands::RCGetInteriorVehicleDataRequest( - // message, app_manager_)); - // } else { - // command.reset(new commands::RCGetInteriorVehicleDataResponse( - // message, app_manager_)); - // } - // break; - // } - // case hmi_apis::FunctionID::RC_SetInteriorVehicleData: { - // if ((*message)[strings::params][strings::message_type] == - // static_cast<int>(application_manager::MessageType::kRequest)) { - // command.reset(new commands::RCSetInteriorVehicleDataRequest( - // message, app_manager_)); - // } else { - // command.reset(new commands::RCSetInteriorVehicleDataResponse( - // message, app_manager_)); - // } - // break; - // } - // case hmi_apis::FunctionID::RC_OnInteriorVehicleData: { - // command.reset(new commands::RCOnInteriorVehicleDataNotification( - // message, app_manager_)); - // break; - // } - // case hmi_apis::FunctionID::RC_OnRemoteControlSettings: { - // command.reset(new commands::RCOnRemoteControlSettingsNotification( - // message, app_manager_)); - // break; - // } - // default: { break; } - // } - // return command; -} +CommandCreator& RCCommandFactory::get_hmi_creator_factory( + hmi_apis::FunctionID::eType id, + hmi_apis::messageType::eType message_type) const { + LOG4CXX_DEBUG(logger_, + "CreateHMICommand function_id: " << id << " message_type: " + << message_type); -} // namespace application_manager + RCCommandCreatorFactory rc_factory(app_manager_, + rpc_service_, + hmi_capabilities_, + policy_handler_, + allocation_manager_); + + switch (id) { + case hmi_apis::FunctionID::Buttons_ButtonPress: { + return hmi_apis::messageType::request == message_type + ? rc_factory.GetCreator<commands::RCButtonPressRequest>() + : rc_factory.GetCreator<commands::RCButtonPressResponse>(); + } + case hmi_apis::FunctionID::RC_GetInteriorVehicleData: { + return hmi_apis::messageType::request == message_type + ? rc_factory + .GetCreator<commands::RCGetInteriorVehicleDataRequest>() + : rc_factory.GetCreator< + commands::RCGetInteriorVehicleDataResponse>(); + } + case hmi_apis::FunctionID::RC_SetInteriorVehicleData: { + return hmi_apis::messageType::request == message_type + ? rc_factory + .GetCreator<commands::RCSetInteriorVehicleDataRequest>() + : rc_factory.GetCreator< + commands::RCSetInteriorVehicleDataResponse>(); + } + case hmi_apis::FunctionID::RC_OnInteriorVehicleData: { + return rc_factory + .GetCreator<commands::RCOnInteriorVehicleDataNotification>(); + } + case hmi_apis::FunctionID::RC_OnRemoteControlSettings: { + return rc_factory + .GetCreator<commands::RCOnRemoteControlSettingsNotification>(); + } + default: { return rc_factory.GetCreator<RCInvalidCommand>(); } + } +} +} |