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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_request.h"
#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
namespace commands {
GetCloudAppPropertiesRequest::GetCloudAppPropertiesRequest(
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) {}
GetCloudAppPropertiesRequest::~GetCloudAppPropertiesRequest() {}
void GetCloudAppPropertiesRequest::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;
}
std::string policy_app_id =
(*message_)[strings::msg_params][strings::app_id].asString();
policy::AppProperties app_properties;
const bool result =
policy_handler_.GetAppProperties(policy_app_id, app_properties);
if (!result) {
SendResponse(false,
mobile_apis::Result::DATA_NOT_AVAILABLE,
"Cloud app does not exist on module");
return;
}
policy::StringArray nicknames;
policy::StringArray app_hmi_types;
policy_handler_.GetInitialAppData(policy_app_id, &nicknames, &app_hmi_types);
smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
smart_objects::SmartObject properties(smart_objects::SmartType_Map);
smart_objects::SmartObject nicknames_array(smart_objects::SmartType_Array);
size_t i = 0;
for (std::string nickname : nicknames) {
nicknames_array[i] = nickname;
++i;
}
properties[strings::nicknames] = nicknames_array;
properties[strings::app_id] = policy_app_id;
properties[strings::enabled] = app_properties.enabled;
if (!app_properties.auth_token.empty()) {
properties[strings::auth_token] = app_properties.auth_token;
}
if (!app_properties.transport_type.empty()) {
properties[strings::cloud_transport_type] = app_properties.transport_type;
}
if (!app_properties.hybrid_app_preference.empty()) {
properties[strings::hybrid_app_preference] =
app_properties.hybrid_app_preference;
}
if (!app_properties.endpoint.empty()) {
properties[strings::endpoint] = app_properties.endpoint;
}
response_params[strings::properties] = properties;
SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params);
}
void GetCloudAppPropertiesRequest::on_event(
const app_mngr::event_engine::Event& event) {
LOG4CXX_INFO(logger_, "GetCloudAppPropertiesRequest on_event");
}
} // namespace commands
} // namespace sdl_rpc_plugin
|