2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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.
17 #ifndef _CONTEXT_TRIGGER_RULE_MANAGER_H_
18 #define _CONTEXT_TRIGGER_RULE_MANAGER_H_
22 #include <DatabaseManager.h>
39 int addRule(std::string creator, const char* pkgId, CtxJson1 rule, CtxJson1* ruleId);
40 int removeRule(int ruleId);
41 int enableRule(int ruleId);
42 int disableRule(int ruleId);
43 int getRuleById(std::string pkgId, int ruleId, CtxJson1* requestResult);
44 int getRuleIds(std::string pkgId, CtxJson1* requestResult);
45 int checkRule(std::string pkgId, int ruleId);
46 bool isRuleEnabled(int ruleId);
47 int pauseRuleWithItem(std::string& subject);
48 int pauseRule(int ruleId);
49 int resumeRuleWithItem(std::string& subject);
50 void handleRuleOfUninstalledPackage(std::string pkgId);
52 static bool isUninstalledPackage(std::string pkgId);
55 bool __reenableRule(void);
56 int __verifyRule(CtxJson1& rule, const char* creator);
57 int64_t __getDuplicatedRuleId(std::string pkgId, CtxJson1& rule);
58 bool __ruleEquals(CtxJson1& lRule, CtxJson1& rRule);
59 int __getUninstalledApp(void);
60 int __clearRuleOfUninstalledPackage(bool isInit = false);
61 void __applyTemplates(void);
63 std::set<std::string> __uninstalledPackages;
64 std::map<int, Rule*> __ruleMap;
65 DatabaseManager __dbManager;
66 }; /* class RuleManager */
68 } /* namespace trigger */
71 #endif /* End of _CONTEXT_TRIGGER_RULE_MANAGER_H_ */