2 * Copyright (c) 2019 TOYOTA MOTOR CORPORATION
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "hs-periphery.h"
19 #include "hmi-debug.h"
20 #include "hs-clientmanager.h"
22 static const char _restriction_on[] = "RestrictionOn";
23 static const char _restriction_off[] = "RestrictionOff";
25 /* -------------------------------------HS_PeripheryManager------------------------------------------ */
27 HS_PeripheryManager* HS_PeripheryManager::me = nullptr;
30 * HS_PeripheryManager init function
39 int HS_PeripheryManager::init(afb_api_t api)
41 return m_restriction.init(api);
51 * HS_PeripheryManager instance pointer
54 HS_PeripheryManager* HS_PeripheryManager::instance(void)
57 me = new HS_PeripheryManager();
65 * - api : the api serving the request
66 * - event : event name
67 * - object : event json object
73 void HS_PeripheryManager::onEvent(afb_api_t api, const char *event, struct json_object *object)
75 m_restriction.onEvent(api, event, object);
78 /* -------------------------------------HS_Restriction------------------------------------------ */
81 * HS_Restriction init function
90 int HS_Restriction::init(afb_api_t api)
94 wm_proxy.subscribe(api, HS_WmProxy::Event_ScreenUpdated);
102 * - api : the api serving the request
103 * - event : event name
104 * - object : event json object
110 void HS_Restriction::onEvent(afb_api_t api, const char *event, struct json_object *object)
112 if(!isConcernedEvent(event))
115 std::string ev = event;
116 std::size_t pos = ev.find("/");
117 if(pos != std::string::npos) {
118 ev = ev.substr(pos + 1);
121 HMI_ERROR("homescreen-service","received event is error.");
125 if(ev == _restriction_on) {
126 restrictionOn(api, object);
128 else if(ev == _restriction_off) {
129 restrictionOff(api, object);
136 * restriction on function
139 * - api : the api serving the request
140 * - object : event json object
146 void HS_Restriction::restrictionOn(afb_api_t api, struct json_object *object)
152 * restriction off function
155 * - api : the api serving the request
156 * - object : event json object
162 void HS_Restriction::restrictionOff(afb_api_t api, struct json_object *object)