1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_request.h"
#include "application_manager/message_helper.h"
#include "application_manager/policies/policy_handler_interface.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;
}
const auto& properties =
(*message_)[strings::msg_params][strings::properties];
const auto app_id(properties[strings::app_id].asString());
const auto properties_change_status =
policy_handler_.GetAppPropertiesStatus(properties, app_id);
using AppPropertiesState = policy::PolicyHandlerInterface::AppPropertiesState;
const bool is_properties_changed =
AppPropertiesState::NO_CHANGES != properties_change_status;
const bool is_new_app = policy_handler_.IsNewApplication(app_id);
policy_handler_.OnSetCloudAppProperties(*message_);
SendResponse(true, mobile_apis::Result::SUCCESS);
if (is_properties_changed || is_new_app) {
const auto notification =
MessageHelper::CreateOnAppPropertiesChangeNotification(
app_id, application_manager_);
application_manager_.GetRPCService().ManageHMICommand(notification);
}
}
void SetCloudAppPropertiesRequest::on_event(
const app_mngr::event_engine::Event& event) {
LOG4CXX_INFO(logger_, "SetCloudAppPropertiesRequest on_event");
}
} // namespace commands
} // namespace sdl_rpc_plugin
|