2 // Copyright (c) 2012 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.
18 * @file FSec_PrivacyManagerImpl.cpp
19 * @brief This is the implementation for the _PrivacyManagerImpl class.
23 #include <privacy_manager_client.h>
24 #include <FSecPrivacyManager.h>
25 #include <FBaseSysLog.h>
26 #include "FSec_PrivacyManagerImpl.h"
27 #include <FBase_StringConverter.h>
28 #include <FSecPrivacyInfo.h>
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Security;
34 namespace Tizen { namespace Security
37 _PrivacyManagerImpl::_PrivacyManagerImpl(void)
42 _PrivacyManagerImpl::~_PrivacyManagerImpl(void)
47 const _PrivacyManagerImpl*
48 _PrivacyManagerImpl::GetInstance(PrivacyManager& privacyManager)
50 return privacyManager.__pPrivacyManagerImpl;
54 bool GetPrivacyAppPackageListNCallback(const char *package_id, void* user_data)
56 ArrayList* pList = static_cast < ArrayList* >(user_data);
58 pList->Add(new String(package_id));
62 Tizen::Base::Collection::IList*
63 _PrivacyManagerImpl::GetPrivacyAppPackageListN(void) const
65 ArrayList* pPackageIdList = null;
68 pPackageIdList = new ArrayList();
69 pPackageIdList->Construct();
71 ret = privacy_manager_client_foreach_privacy_packages(GetPrivacyAppPackageListNCallback, pPackageIdList);
73 return pPackageIdList;
76 bool GetPrivacyInfoListNCallback(privacy_info_client_s* pPrivacy_info, void* user_data)
79 ArrayList* pList = static_cast < ArrayList* >(user_data);
81 String pPrivacyId = String(pPrivacy_info->privacy_id);
82 bool isEnabled = pPrivacy_info->is_enabled;
84 PrivacyInfo* pPrivacyInfo = new PrivacyInfo();
85 r = pPrivacyInfo->Construct(pPrivacyId, isEnabled);
87 pList->Add(pPrivacyInfo);
91 Tizen::Base::Collection::IList*
92 _PrivacyManagerImpl::GetPrivacyInfoListN(const Tizen::App::PackageId& packageId) const
95 ArrayList* pPrivacyIdList = null;
98 pPrivacyIdList = new ArrayList();
99 pPrivacyIdList->Construct();
101 pAppId = _StringConverter::CopyToCharArrayN(packageId);
103 ret = privacy_manager_client_foreach_get_privacy_info(pAppId, GetPrivacyInfoListNCallback, (void *)pPrivacyIdList);
106 return pPrivacyIdList;
110 _PrivacyManagerImpl::SetAppPackagePrivacy(const Tizen::App::PackageId& packageId, const PrivacyInfo& privacyInfo)
112 result r = E_SUCCESS;
114 char* pPackageId = null;
115 char* pPrivacyId = null;
117 bool isEnabled = false;
119 pPackageId = _StringConverter::CopyToCharArrayN(packageId);
120 pPrivacyId = _StringConverter::CopyToCharArrayN(privacyInfo.GetId());
121 isEnabled = privacyInfo.IsEnabled();
123 ret = privacy_manager_client_set_package_privacy(pPackageId, pPrivacyId, isEnabled);
130 }} // Tizen::Security