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.
16 #ifndef HOMESCREEN_CONFIG_H
17 #define HOMESCREEN_CONFIG_H
21 #include <unordered_map>
22 #include "hs-helper.h"
24 struct handshake_info {
25 int times; // sleep times
26 int sleep; // sleep x ms
29 struct recover_app_info {
30 std::string appid; // application id like "dashboard"
31 std::string area; // application default display area
32 bool visibility; // the visibility when system starting
35 using recover_map = std::unordered_map<std::string, std::vector<struct recover_app_info>>;
39 HS_Config() : m_hs_conf(nullptr), m_lastmode(nullptr), m_handshake_info({20000, 50}) {}
40 ~HS_Config() {json_object_put(m_hs_conf);json_object_put(m_lastmode);}
41 HS_Config(HS_Config const &) = delete;
42 HS_Config &operator=(HS_Config const &) = delete;
43 HS_Config(HS_Config &&) = delete;
44 HS_Config &operator=(HS_Config &&) = delete;
47 const struct handshake_info* getHandshakeInfo(void) const {return &m_handshake_info;}
48 const recover_map* getRecoverMap(void) const {return &m_recover_map;}
51 int parseConfig(void);
52 std::vector<struct recover_app_info> getRecoverAppInfo(struct json_object *obj);
54 const std::string hs_conf_json = "hs-conf.json";
55 const std::string lastmode_json = "lastmode.json";
56 const std::string key_handshake = "handshake";
57 const std::string key_times = "times";
58 const std::string key_sleep = "sleep";
59 const std::string key_recover = "recover";
60 const std::string key_appid = "appid";
61 const std::string key_visibility = "visibility";
62 const std::string key_area = "area";
63 const std::array<std::string, 3> keys_recover_type = { // based on hs-conf.json
69 struct json_object *m_hs_conf;
70 struct json_object *m_lastmode;
71 recover_map m_recover_map;
72 struct handshake_info m_handshake_info;
74 #endif // HOMESCREEN_CONFIG_H