diff options
author | ShobhitAd <adlakhshobhit@gmail.com> | 2018-11-13 10:36:42 -0500 |
---|---|---|
committer | ShobhitAd <adlakhashobhit@gmail.com> | 2018-11-20 12:45:22 -0500 |
commit | 1669b8e19869bbdcee2702a13c9e04ff94e649b5 (patch) | |
tree | 3d3729f7f662a9185a9bde8f09b3a8d9eae92c5a /src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands | |
parent | 0eb0f386f0cc43a1497b569d27415d775ea40ab5 (diff) | |
download | sdl_core-1669b8e19869bbdcee2702a13c9e04ff94e649b5.tar.gz |
Implement SetCloudAppProperties RPC in core
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands')
2 files changed, 103 insertions, 0 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc new file mode 100644 index 0000000000..b5c66e4400 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc @@ -0,0 +1,71 @@ +#include "sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + + SetCloudAppPropertiesRequest::SetCloudAppPropertiesRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler){} + + SetCloudAppPropertiesRequest::~SetCloudAppPropertiesRequest(){} + void SetCloudAppPropertiesRequest::Run(){ + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if ((*message_)[strings::msg_params].empty()) { + LOG4CXX_ERROR(logger_, strings::msg_params << " is empty."); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + smart_objects::SmartObject cloudapp_properties(smart_objects::SmartType_Map); + + cloudapp_properties[strings::msg_params][strings::app_name] = (*message_)[strings::msg_params][strings::app_name]; + cloudapp_properties[strings::msg_params][strings::app_id] = (*message_)[strings::msg_params][strings::app_id]; + + if ((*message_)[strings::msg_params].keyExists(strings::enabled)) { + smart_objects::SmartObject enabled = (*message_)[strings::msg_params][strings::enabled]; + cloudapp_properties[strings::msg_params][strings::enabled] = enabled; + } + if ((*message_)[strings::msg_params].keyExists(strings::cloud_app_auth_token)) { + smart_objects::SmartObject auth_token = (*message_)[strings::msg_params][strings::cloud_app_auth_token]; + cloudapp_properties[strings::msg_params][strings::cloud_app_auth_token] = auth_token; + } + if ((*message_)[strings::msg_params].keyExists(strings::cloud_transport_type)) { + smart_objects::SmartObject transport_type = (*message_)[strings::msg_params][strings::cloud_transport_type]; + cloudapp_properties[strings::msg_params][strings::cloud_transport_type] = transport_type; + } + if ((*message_)[strings::msg_params].keyExists(strings::hybrid_app_preference)) { + smart_objects::SmartObject hybrid_app_preference = (*message_)[strings::msg_params][strings::hybrid_app_preference]; + cloudapp_properties[strings::msg_params][strings::hybrid_app_preference] = hybrid_app_preference; + } + + policy_handler_.OnSetCloudAppProperties(cloudapp_properties); + SendResponse(true, mobile_apis::Result::SUCCESS); + + + } + + + void SetCloudAppPropertiesRequest::on_event(const app_mngr::event_engine::Event& event){ + LOG4CXX_INFO(logger_, "SetCloudAppPropertiesRequest on_event"); + } + + +} // namespace commands +} // namespace sdl_rpc_plugin
\ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc new file mode 100644 index 0000000000..b113f84131 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc @@ -0,0 +1,32 @@ +#include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" +#include "sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h" + + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + + SetCloudAppPropertiesResponse::SetCloudAppPropertiesResponse(const app_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) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler){} + + + SetCloudAppPropertiesResponse::~SetCloudAppPropertiesResponse(){} + + void SetCloudAppPropertiesResponse::Run(){ + LOG4CXX_AUTO_TRACE(logger_); + + rpc_service_.SendMessageToMobile(message_); + } + +} // namespace commands +} //namespace sdl_rpc_plugins |