2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
\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
8 * http://www.apache.org/licenses/LICENSE-2.0
\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
17 #include <PrivacyManager.h>
\r
18 #include <SocketClient.h>
\r
19 #include <PrivacyIdInfo.h>
\r
20 #include <algorithm>
\r
24 std::mutex PrivacyManager::m_singletonMutex;
\r
25 PrivacyManager* PrivacyManager::m_pInstance = NULL;
\r
26 const std::string PrivacyManager::INTERFACE_NAME("PrivacyInfoService");
\r
28 PrivacyManager::PrivacyManager(void)
\r
30 std::unique_ptr<SocketClient> pSocketClient(new SocketClient(INTERFACE_NAME));
\r
31 m_pSocketClient = std::move(pSocketClient);
\r
35 PrivacyManager::getInstance(void)
\r
37 std::lock_guard<std::mutex> guard(m_singletonMutex);
\r
38 if (m_pInstance == NULL)
\r
39 m_pInstance = new PrivacyManager();
\r
44 PrivacyManager::addAppPackagePrivacyInfo(const std::string pkgId, const std::list < std::string >& pList)
\r
48 std::list < std::string > privacyList;
\r
50 result = PrivacyIdInfo::getPrivacyIdListFromPrivilegeList(pList, privacyList);
\r
51 if (result != PRIV_MGR_ERROR_SUCCESS )
\r
54 if (privacyList.size() == 0)
\r
55 return PRIV_MGR_ERROR_SUCCESS;
\r
57 m_pSocketClient->connect();
\r
58 m_pSocketClient->call("addPrivacyInfo", pkgId, privacyList, &result);
\r
59 m_pSocketClient->disconnect();
\r
65 PrivacyManager::removeAppPackagePrivacyInfo(const std::string pkgId)
\r
68 m_pSocketClient->connect();
\r
69 m_pSocketClient->call("removePrivacyInfo", pkgId, pkgId, &result);
\r
70 m_pSocketClient->disconnect();
\r
76 PrivacyManager::setPrivacySetting(const std::string pkgId, const std::string privacyId, bool isEnabled)
\r
79 m_pSocketClient->connect();
\r
80 m_pSocketClient->call("setPrivacySetting", pkgId, privacyId, isEnabled, &result);
\r
81 m_pSocketClient->disconnect();
\r
87 PrivacyManager::getPrivacyAppPackages(std::list < std::string >& pList)
\r
91 SocketClient* p = new SocketClient(INTERFACE_NAME);
\r
93 p->call("getPrivacyAppPackages", &result, &size, &pList);
\r
100 PrivacyManager::getAppPackagePrivacyInfo(const std::string pkgId, std::list < std::pair <std::string, bool > > & list)
\r
103 std::unique_ptr <SocketClient> pSocketClient (new SocketClient(INTERFACE_NAME));
\r
106 pSocketClient->connect();
\r
107 pSocketClient->call("getAppPackagePrivacyInfo", pkgId, &result, &list);
\r
109 pSocketClient->disconnect();
\r
111 for (std::list < std::pair <std::string, bool > >::const_iterator iter = list.begin(); iter != list.end(); ++iter){
\r
112 LOGD(" %s : %d", iter->first.c_str(), iter->second);
\r
119 PrivacyManager::isUserPrompted(const std::string pkgId, bool& isPrompted)
\r
123 std::unique_ptr <SocketClient> pSocketClient (new SocketClient(INTERFACE_NAME));
\r
126 pSocketClient->connect();
\r
127 pSocketClient->call("isUserPrompted", pkgId, &result, &isPrompted);
\r
128 pSocketClient->disconnect();
\r
136 PrivacyManager::setUserPrompted(const std::string pkgId, bool prompted)
\r
140 std::unique_ptr <SocketClient> pSocketClient (new SocketClient(INTERFACE_NAME));
\r
143 pSocketClient->connect();
\r
144 pSocketClient->call("setUserPrompted", pkgId, prompted, &result);
\r
145 pSocketClient->disconnect();
\r