Modify Checker and cache update
[platform/core/security/privacy-manager.git] / server / src / PrivacyManagerServer.cpp
1 /*\r
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved\r
3  *\r
4  *    Licensed under the Apache License, Version 2.0 (the "License");\r
5  *    you may not use this file except in compliance with the License.\r
6  *    You may obtain a copy of the License at\r
7  *\r
8  *        http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  *    Unless required by applicable law or agreed to in writing, software\r
11  *    distributed under the License is distributed on an "AS IS" BASIS,\r
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  *    See the License for the specific language governing permissions and\r
14  *    limitations under the License.\r
15  */\r
16 \r
17 #include <sstream>\r
18 #include <dlog.h>\r
19 #include <Utils.h>\r
20 #include <PrivacyManagerServer.h>\r
21 #include <PrivacyManagerTypes.h>\r
22 #include <PrivacyDb.h>\r
23 \r
24 std::mutex PrivacyManagerServer::m_singletonMutex;\r
25 PrivacyManagerServer* PrivacyManagerServer::m_pInstance = NULL;\r
26 \r
27 void\r
28 PrivacyManagerServer::createDB(void)\r
29 {\r
30 \r
31 }\r
32 \r
33 int\r
34 PrivacyManagerServer::setPrivacySetting(const std::string pkgId, const std::string privacyId, bool enabled)\r
35 {\r
36         int res = PrivacyDb::getInstance()->setPrivacySetting(pkgId, privacyId, enabled);\r
37         TryReturn( res == PRIV_MGR_ERROR_SUCCESS, res, , "privacyDb::setPrivacySetting : %d", res);\r
38 \r
39         res = m_notificationServer.notify(pkgId, privacyId);\r
40         TryReturn( res == PRIV_MGR_ERROR_SUCCESS, res, , "NotificationServer::notify : %d", res);\r
41 \r
42         return res;\r
43 }\r
44 \r
45 int\r
46 PrivacyManagerServer::getPrivacyAppPackages(std::list <std::string>& list)\r
47 {\r
48         return PrivacyDb::getInstance()->getPrivacyAppPackages(list);\r
49 }\r
50 \r
51 int\r
52 PrivacyManagerServer::getAppPackagePrivacyInfo(const std::string pkgId, std::list < std::pair < std::string, bool > >& privacyInfoList)\r
53 {\r
54         return PrivacyDb::getInstance()->getAppPackagePrivacyInfo(pkgId, privacyInfoList);\r
55 }\r
56 \r
57 \r
58 int\r
59 PrivacyManagerServer::addAppPackagePrivacyInfo(const std::string pkgId, const std::list < std::string > privilegeList)\r
60 {\r
61         return PrivacyDb::getInstance()->addAppPackagePrivacyInfo(pkgId, privilegeList);\r
62 }\r
63 \r
64 int\r
65 PrivacyManagerServer::removeAppPackagePrivacyInfo(const std::string pkgId)\r
66 {\r
67         return PrivacyDb::getInstance()->removeAppPackagePrivacyInfo(pkgId);\r
68 }\r
69 \r
70 int\r
71 PrivacyManagerServer::isUserPrompted(const std::string pkgId, bool& isPrompted)\r
72 {\r
73         return PrivacyDb::getInstance()->isUserPrompted(pkgId, isPrompted);\r
74 }\r
75 \r
76 int\r
77 PrivacyManagerServer::setUserPrompted(const std::string pkgId, bool prompted)\r
78 {\r
79         return PrivacyDb::getInstance()->setUserPrompted(pkgId, prompted);\r
80 }\r
81 \r
82 PrivacyManagerServer::PrivacyManagerServer(void)\r
83 {\r
84 \r
85 }\r
86 \r
87 PrivacyManagerServer*\r
88 PrivacyManagerServer::getInstance(void)\r
89 {\r
90         LOGI("enter");\r
91         std::lock_guard < std::mutex > guard(m_singletonMutex);\r
92 \r
93         if (m_pInstance == NULL)\r
94         {       \r
95                 m_pInstance = new PrivacyManagerServer();\r
96                 \r
97                 m_pInstance->m_notificationServer.initialize();\r
98         }\r
99         LOGI("leave");\r
100         return m_pInstance;\r
101 }