diff options
Diffstat (limited to 'src/hs-config.h')
-rw-r--r-- | src/hs-config.h | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/hs-config.h b/src/hs-config.h new file mode 100644 index 0000000..7cc5dd3 --- /dev/null +++ b/src/hs-config.h @@ -0,0 +1,74 @@ +/* + * 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 <array> +#include <vector> +#include <unordered_map> +#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<std::string, std::vector<struct recover_app_info>>; + +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); + struct handshake_info getHandshakeInfo(void) {return m_handshake_info;} + recover_map getRecoverMap(void) {return m_recover_map;} + +private: + int parseConfig(void); + std::vector<struct recover_app_info> 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<std::string, 3> 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
\ No newline at end of file |