Remove unnecessary logs
[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.notifySettingChanged(pkgId, privacyId);\r
40         TryReturn( res == PRIV_MGR_ERROR_SUCCESS, res, , "NotificationServer::notifySettingChanged : %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         int res = PrivacyDb::getInstance()->removeAppPackagePrivacyInfo(pkgId);\r
68         TryReturn( res == PRIV_MGR_ERROR_SUCCESS, res, , "privacyDb::removeAppPackagePrivacyInfo : %d", res);\r
69 \r
70         res = m_notificationServer.notifyPkgRemoved(pkgId);\r
71         TryReturn( res == PRIV_MGR_ERROR_SUCCESS, res, , "NotificationServer::notifyPkgRemoved : %d", res);\r
72 \r
73         return res;\r
74 }\r
75 \r
76 int\r
77 PrivacyManagerServer::isUserPrompted(const std::string pkgId, bool& isPrompted)\r
78 {\r
79         return PrivacyDb::getInstance()->isUserPrompted(pkgId, isPrompted);\r
80 }\r
81 \r
82 int\r
83 PrivacyManagerServer::setUserPrompted(const std::string pkgId, bool prompted)\r
84 {\r
85         return PrivacyDb::getInstance()->setUserPrompted(pkgId, prompted);\r
86 }\r
87 \r
88 PrivacyManagerServer::PrivacyManagerServer(void)\r
89 {\r
90 \r
91 }\r
92 \r
93 PrivacyManagerServer*\r
94 PrivacyManagerServer::getInstance(void)\r
95 {\r
96         LOGI("enter");\r
97         std::lock_guard < std::mutex > guard(m_singletonMutex);\r
98 \r
99         if (m_pInstance == NULL)\r
100         {       \r
101                 m_pInstance = new PrivacyManagerServer();\r
102                 \r
103                 m_pInstance->m_notificationServer.initialize();\r
104         }\r
105         LOGI("leave");\r
106         return m_pInstance;\r
107 }