Revert "add event tabble"
[apps/agl-service-homescreen.git] / src / hs-periphery.cpp
1 /*
2  * Copyright (c) 2019 TOYOTA MOTOR CORPORATION
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include "hs-periphery.h"
18 #include "hs-proxy.h"
19 #include "hmi-debug.h"
20 #include "hs-clientmanager.h"
21
22 static const char _restriction_on[] = "RestrictionOn";
23 static const char _restriction_off[] = "RestrictionOff";
24
25 /* -------------------------------------HS_PeripheryManager------------------------------------------ */
26
27 HS_PeripheryManager* HS_PeripheryManager::me = nullptr;
28
29 /**
30  * HS_PeripheryManager init function
31  *
32  * #### Parameters
33  *  - Nothing
34  *
35  * #### Return
36  * init result
37  *
38  */
39 int HS_PeripheryManager::init(afb_api_t api)
40 {
41     return m_restriction.init(api);
42 }
43
44 /**
45  * get instance
46  *
47  * #### Parameters
48  *  - Nothing
49  *
50  * #### Return
51  * HS_PeripheryManager instance pointer
52  *
53  */
54 HS_PeripheryManager* HS_PeripheryManager::instance(void)
55 {
56     if(me == nullptr)
57         me = new HS_PeripheryManager();
58     return me;
59 }
60
61 /**
62  * event function
63  *
64  * #### Parameters
65  *  - api : the api serving the request
66  *  - event  : event name
67  *  - object : event json object
68  *
69  * #### Return
70  * None
71  *
72  */
73 void HS_PeripheryManager::onEvent(afb_api_t api, const char *event, struct json_object *object)
74 {
75     m_restriction.onEvent(api, event, object);
76 }
77
78 /* -------------------------------------HS_Restriction------------------------------------------ */
79
80 /**
81  * HS_Restriction init function
82  *
83  * #### Parameters
84  *  - Nothing
85  *
86  * #### Return
87  * init result
88  *
89  */
90 int HS_Restriction::init(afb_api_t api)
91 {
92     HS_WmProxy wm_proxy;
93     // TBD
94     wm_proxy.subscribe(api, HS_WmProxy::Event_ScreenUpdated);
95     return 0;
96 }
97
98 /**
99  * event function
100  *
101  * #### Parameters
102  *  - api : the api serving the request
103  *  - event  : event name
104  *  - object : event json object
105  *
106  * #### Return
107  * None
108  *
109  */
110 void HS_Restriction::onEvent(afb_api_t api, const char *event, struct json_object *object)
111 {
112     if(!isConcernedEvent(event))
113         return;
114
115     std::string ev = event;
116     std::size_t pos = ev.find("/");
117     if(pos != std::string::npos) {
118         ev = ev.substr(pos + 1);
119     }
120     else {
121         HMI_ERROR("homescreen-service","received event is error.");
122         return;
123     }
124
125     if(ev == _restriction_on) {
126         restrictionOn(api, object);
127     }
128     else if(ev == _restriction_off) {
129         restrictionOff(api, object);
130     }
131     else {
132     }
133 }
134
135 /**
136  * restriction on function
137  *
138  * #### Parameters
139  *  - api : the api serving the request
140  *  - object : event json object
141  *
142  * #### Return
143  * None
144  *
145  */
146 void HS_Restriction::restrictionOn(afb_api_t api, struct json_object *object)
147 {
148
149 }
150
151 /**
152  * restriction off function
153  *
154  * #### Parameters
155  *  - api : the api serving the request
156  *  - object : event json object
157  *
158  * #### Return
159  * None
160  *
161  */
162 void HS_Restriction::restrictionOff(afb_api_t api, struct json_object *object)
163 {
164
165 }