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.
24 #include <privacy_manager_client.h>
26 #include <FSecPrivacyManager.h>
27 #include <FBaseSysLog.h>
28 #include <FBaseColArrayList.h>
29 #include <FSecPrivacyInfo.h>
31 #include "FSec_PrivacyManagerImpl.h"
32 #include <FBase_StringConverter.h>
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::Security;
38 namespace Tizen { namespace Security
41 _PrivacyManagerImpl::_PrivacyManagerImpl(void)
46 _PrivacyManagerImpl::~_PrivacyManagerImpl(void)
51 const _PrivacyManagerImpl*
52 _PrivacyManagerImpl::GetInstance(PrivacyManager& privacyManager)
54 return privacyManager.__pPrivacyManagerImpl;
58 bool GetPrivacyAppPackageListNCallback(const char *package_id, void* user_data)
60 ArrayList* pList = static_cast < ArrayList* >(user_data);
62 pList->Add(new String(package_id));
66 Tizen::Base::Collection::IList*
67 _PrivacyManagerImpl::GetPrivacyAppPackageListN(void) const
69 ArrayList* pPackageIdList = null;
72 pPackageIdList = new ArrayList();
73 pPackageIdList->Construct();
75 ret = privacy_manager_client_foreach_privacy_packages(GetPrivacyAppPackageListNCallback, pPackageIdList);
77 return pPackageIdList;
80 bool GetPrivacyInfoListNCallback(privacy_info_client_s* pPrivacy_info, void* user_data)
83 ArrayList* pList = static_cast < ArrayList* >(user_data);
85 String pPrivacyId = String(pPrivacy_info->privacy_id);
86 bool isEnabled = pPrivacy_info->is_enabled;
88 PrivacyInfo* pPrivacyInfo = new PrivacyInfo();
89 r = pPrivacyInfo->Construct(pPrivacyId, isEnabled);
91 pList->Add(pPrivacyInfo);
95 Tizen::Base::Collection::IList*
96 _PrivacyManagerImpl::GetPrivacyInfoListN(const Tizen::App::PackageId& packageId) const
99 ArrayList* pPrivacyIdList = null;
102 pPrivacyIdList = new ArrayList();
103 pPrivacyIdList->Construct();
105 pAppId = _StringConverter::CopyToCharArrayN(packageId);
107 ret = privacy_manager_client_foreach_get_privacy_info(pAppId, GetPrivacyInfoListNCallback, (void *)pPrivacyIdList);
110 return pPrivacyIdList;
114 _PrivacyManagerImpl::SetAppPackagePrivacy(const Tizen::App::PackageId& packageId, const PrivacyInfo& privacyInfo)
116 result r = E_SUCCESS;
118 char* pPackageId = null;
119 char* pPrivacyId = null;
121 bool isEnabled = false;
123 pPackageId = _StringConverter::CopyToCharArrayN(packageId);
124 pPrivacyId = _StringConverter::CopyToCharArrayN(privacyInfo.GetId());
125 isEnabled = privacyInfo.IsEnabled();
127 ret = privacy_manager_client_set_package_privacy(pPackageId, pPrivacyId, isEnabled);
134 }} // Tizen::Security