2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FSec_PrivacyManagerImpl.cpp
20 * @brief This is the implementation for the _PrivacyManagerImpl class.
24 #include <privacy_manager_client.h>
25 #include <FSecPrivacyManager.h>
26 #include <FBaseSysLog.h>
27 #include "FSec_PrivacyManagerImpl.h"
28 #include <FBase_StringConverter.h>
29 #include <FSecPrivacyInfo.h>
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Security;
35 namespace Tizen { namespace Security
38 _PrivacyManagerImpl::_PrivacyManagerImpl(void)
43 _PrivacyManagerImpl::~_PrivacyManagerImpl(void)
48 const _PrivacyManagerImpl*
49 _PrivacyManagerImpl::GetInstance(PrivacyManager& privacyManager)
51 return privacyManager.__pPrivacyManagerImpl;
55 bool GetPrivacyAppPackageListNCallback(const char *package_id, void* user_data)
58 ArrayList* pList = static_cast < ArrayList* >(user_data);
60 pList->Add(new String(package_id));
64 Tizen::Base::Collection::IList*
65 _PrivacyManagerImpl::GetPrivacyAppPackageListN(void) const
67 ArrayList* pPackageIdList = null;
70 pPackageIdList = new ArrayList();
71 pPackageIdList->Construct();
73 ret = privacy_manager_client_foreach_privacy_packages(GetPrivacyAppPackageListNCallback, pPackageIdList);
75 return pPackageIdList;
78 bool GetPrivacyInfoListNCallback(privacy_info_client_s* pPrivacy_info, void* user_data)
81 ArrayList* pList = static_cast < ArrayList* >(user_data);
83 String pPrivacyId = String(pPrivacy_info->privacy_id);
84 bool isEnabled = pPrivacy_info->is_enabled;
86 PrivacyInfo* pPrivacyInfo = new PrivacyInfo();
87 r = pPrivacyInfo->Construct(pPrivacyId, isEnabled);
89 pList->Add(pPrivacyInfo);
93 Tizen::Base::Collection::IList*
94 _PrivacyManagerImpl::GetPrivacyInfoListN(const Tizen::App::PackageId& packageId) const
97 ArrayList* pPrivacyIdList = null;
100 pPrivacyIdList = new ArrayList();
101 pPrivacyIdList->Construct();
103 pAppId = _StringConverter::CopyToCharArrayN(packageId);
105 ret = privacy_manager_client_foreach_get_privacy_info(pAppId, GetPrivacyInfoListNCallback, (void *)pPrivacyIdList);
108 return pPrivacyIdList;
112 _PrivacyManagerImpl::SetAppPackagePrivacy(const Tizen::App::PackageId& packageId, const PrivacyInfo& privacyInfo)
114 result r = E_SUCCESS;
116 char* pPackageId = null;
117 char* pPrivacyId = null;
119 bool isEnabled = false;
121 pPackageId = _StringConverter::CopyToCharArrayN(packageId);
122 pPrivacyId = _StringConverter::CopyToCharArrayN(privacyInfo.GetId());
123 isEnabled = privacyInfo.IsEnabled();
125 ret = privacy_manager_client_set_package_privacy(pPackageId, pPrivacyId, isEnabled);
132 }} // Tizen::Security