/* * Copyright (c) 2019 TOYOTA MOTOR CORPORATION * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef HOMESCREEN_CONFIG_H #define HOMESCREEN_CONFIG_H #include #include #include #include "hs-helper.h" struct handshake_info { int times; // sleep times int sleep; // sleep x ms }; struct recover_app_info { std::string appid; // application id like "dashboard" std::string area; // application default display area bool visibility; // the visibility when system starting }; using recover_map = std::unordered_map>; class HS_Config { public: HS_Config() : m_hs_conf(nullptr), m_lastmode(nullptr), m_handshake_info({20000, 50}) {} ~HS_Config() {json_object_put(m_hs_conf);json_object_put(m_lastmode);} HS_Config(HS_Config const &) = delete; HS_Config &operator=(HS_Config const &) = delete; HS_Config(HS_Config &&) = delete; HS_Config &operator=(HS_Config &&) = delete; int readConfig(void); const struct handshake_info* getHandshakeInfo(void) const {return &m_handshake_info;} const recover_map* getRecoverMap(void) const {return &m_recover_map;} private: int parseConfig(void); std::vector getRecoverAppInfo(struct json_object *obj); const std::string hs_conf_json = "hs-conf.json"; const std::string lastmode_json = "lastmode.json"; const std::string key_handshake = "handshake"; const std::string key_times = "times"; const std::string key_sleep = "sleep"; const std::string key_recover = "recover"; const std::string key_appid = "appid"; const std::string key_visibility = "visibility"; const std::string key_area = "area"; const std::array keys_recover_type = { // based on hs-conf.json "hs-apps", "default-lastmode", "normal-apps" }; struct json_object *m_hs_conf; struct json_object *m_lastmode; recover_map m_recover_map; struct handshake_info m_handshake_info; }; #endif // HOMESCREEN_CONFIG_H