Add timer for restriction mode
[apps/agl-service-windowmanager.git] / src / policy_manager / policy_manager.hpp
1 /*
2  * Copyright (c) 2018 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 #ifndef TMCAGLWM_POLICY_MANAGER_HPP
18 #define TMCAGLWM_POLICY_MANAGER_HPP
19
20
21 #include <unordered_map>
22 #include <vector>
23
24
25 struct json_object;
26 struct sd_event;
27
28 class PolicyManager {
29
30 public:
31     explicit PolicyManager();
32     ~PolicyManager() = default;
33
34     using Handler = std::function<void(json_object *)>;
35
36     int initialize();
37     int inputEvent(json_object* json_in, PolicyManager::Handler notify_state);
38     std::string roleToCategory(const char* role);
39
40 private:
41     // Disable copy and move
42     PolicyManager(PolicyManager const &) = delete;
43     PolicyManager &operator=(PolicyManager const &) = delete;
44     PolicyManager(PolicyManager &&) = delete;
45     PolicyManager &operator=(PolicyManager &&) = delete;
46
47     // Convert map
48     std::unordered_map<std::string, int> eventname2no_;
49     std::unordered_map<std::string, int> categoryname2no_;
50     std::unordered_map<std::string, int> areaname2no_;
51
52     std::unordered_map<std::string, std::string> role2category_;
53     std::unordered_map<std::string, std::string> category2role_;
54     std::unordered_map<std::string, std::string> role2defaultarea_;
55
56     int initializeSdEventLoop();
57
58     // Load role.db
59     int loadRoleDb();
60
61     const char* getStringFromJson(json_object* obj, const char* key);
62     int inputJsonFilie(const char* file, json_object** obj);
63     std::vector<std::string> parseString(std::string str, char delimiter);
64     std::string deleteSpace(std::string str);
65
66 };
67
68
69 extern const char* getStringFromJson(json_object* obj, const char* key);
70 extern int getIntFromJson(json_object* obj, const char* key);
71
72
73 #endif  // TMCAGLWM_POLICY_MANAGER_HPP