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"
23 /* -------------------------------------HS_PeripheryManager------------------------------------------ */
25 HS_PeripheryManager* HS_PeripheryManager::me = nullptr;
28 * HS_PeripheryManager init function
37 int HS_PeripheryManager::init(afb_api_t api)
39 HS_Restriction* restriction = new HS_Restriction();
40 int ret = restriction->init(api);
42 HMI_ERROR("homescreen-service","restriction init failed.");
45 periphery_list[restriction->getAppid()] = restriction;
57 * HS_PeripheryManager instance pointer
60 HS_PeripheryManager* HS_PeripheryManager::instance(void)
63 me = new HS_PeripheryManager();
71 * - api : the api serving the request
72 * - event : event name
73 * - object : event json object
79 void HS_PeripheryManager::onEvent(afb_api_t api, const char *event, struct json_object *object)
81 for(auto m : periphery_list)
82 m.second->onEvent(api, event, object);
85 /* -------------------------------------HS_Restriction------------------------------------------ */
88 * HS_Restriction init function
97 int HS_Restriction::init(afb_api_t api)
101 wm_proxy.subscribe(api, HS_WmProxy::Event_ScreenUpdated);
109 * - api : the api serving the request
110 * - event : event name
111 * - object : event json object
117 void HS_Restriction::onEvent(afb_api_t api, const char *event, struct json_object *object)
119 auto ip = concerned_event_list.find(std::string(event));
120 if(ip != concerned_event_list.end()) {
121 HMI_NOTICE("homescreen-service","[%s] event received.", event);
122 (this->*(ip->second))(api, object);
127 * restriction on function
130 * - api : the api serving the request
131 * - object : event json object
137 void HS_Restriction::restrictionOn(afb_api_t api, struct json_object *object)
143 * restriction off function
146 * - api : the api serving the request
147 * - object : event json object
153 void HS_Restriction::restrictionOff(afb_api_t api, struct json_object *object)