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
91
92
93
94
95
|
#include "application_manager/commands/mobile/get_system_capability_request.h"
namespace application_manager {
namespace commands {
GetSystemCapabilityRequest::GetSystemCapabilityRequest(
const MessageSharedPtr& message, ApplicationManager& application_manager)
: CommandRequestImpl(message, application_manager) {}
GetSystemCapabilityRequest::~GetSystemCapabilityRequest() {}
void GetSystemCapabilityRequest::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 response_params(smart_objects::SmartType_Map);
mobile_apis::SystemCapabilityType::eType response_type =
static_cast<mobile_apis::SystemCapabilityType::eType>(
(*message_)[strings::msg_params][strings::system_capability_type]
.asInt());
response_params[strings::system_capability][strings::system_capability_type] =
response_type;
const HMICapabilities& hmi_capabilities =
application_manager_.hmi_capabilities();
switch (response_type) {
case mobile_apis::SystemCapabilityType::NAVIGATION: {
if (hmi_capabilities.navigation_capability()) {
response_params[strings::system_capability]
[strings::navigation_capability] =
*hmi_capabilities.navigation_capability();
} else {
SendResponse(false, mobile_apis::Result::DATA_NOT_AVAILABLE);
return;
}
break;
}
case mobile_apis::SystemCapabilityType::PHONE_CALL: {
if (hmi_capabilities.phone_capability()) {
response_params[strings::system_capability][strings::phone_capability] =
*hmi_capabilities.phone_capability();
} else {
SendResponse(false, mobile_apis::Result::DATA_NOT_AVAILABLE);
return;
}
break;
}
case mobile_apis::SystemCapabilityType::REMOTE_CONTROL: {
if (hmi_capabilities.rc_capability()) {
response_params[strings::system_capability][strings::rc_capability] =
*hmi_capabilities.rc_capability();
} else {
SendResponse(false, mobile_apis::Result::DATA_NOT_AVAILABLE);
return;
}
break;
}
case mobile_apis::SystemCapabilityType::VIDEO_STREAMING:
if (hmi_capabilities.video_streaming_capability()) {
response_params[strings::system_capability]
[strings::video_streaming_capability] =
*hmi_capabilities.video_streaming_capability();
} else {
SendResponse(false, mobile_apis::Result::DATA_NOT_AVAILABLE);
return;
}
break;
default: // Return unsupported resource
SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE);
return;
}
SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params);
}
void GetSystemCapabilityRequest::on_event(const event_engine::Event& event) {
LOG4CXX_INFO(logger_, "GetSystemCapabilityRequest on_event");
}
} // namespace commands
} // namespace application_manager
|