From 647e632b382135bc5ab1e6f720e5c97dfcb2fa1f Mon Sep 17 00:00:00 2001 From: "hb.min" Date: Fri, 22 Mar 2013 16:55:21 +0900 Subject: [PATCH] Add wrapper for core PrivacyManager Change-Id: I6a9eaa73a410495635d73a13d022b911db1ba037 Signed-off-by: hb.min --- packaging/osp-appfw.spec | 1 + src/appfw/CMakeLists.txt | 1 + src/security/CMakeLists.txt | 1 + src/security/FSec_PrivacyManagerImpl.cpp | 61 ++++++++++++++++++++++++++++++-- 4 files changed, 62 insertions(+), 2 deletions(-) diff --git a/packaging/osp-appfw.spec b/packaging/osp-appfw.spec index 39b8495..738641a 100755 --- a/packaging/osp-appfw.spec +++ b/packaging/osp-appfw.spec @@ -51,6 +51,7 @@ BuildRequires: pkgconfig(zlib) BuildRequires: pkgconfig(drm-service-core-intel) BuildRequires: pkgconfig(haptic) BuildRequires: pkgconfig(x11) +BuildRequires: privacy-manager-client-devel BuildRequires: boost-devel BuildRequires: gettext-tools diff --git a/src/appfw/CMakeLists.txt b/src/appfw/CMakeLists.txt index a8674c1..0bcb50e 100644 --- a/src/appfw/CMakeLists.txt +++ b/src/appfw/CMakeLists.txt @@ -82,6 +82,7 @@ TARGET_LINK_LIBRARIES(${this_target} "-lz" ) TARGET_LINK_LIBRARIES(${this_target} "-lalarm" ) TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib -ldrm-service-core-intel") TARGET_LINK_LIBRARIES(${this_target} "-lecore" ) +TARGET_LINK_LIBRARIES(${this_target} "-lprivacy-manager-client" ) SET_TARGET_PROPERTIES(${this_target} diff --git a/src/security/CMakeLists.txt b/src/security/CMakeLists.txt index 8f6cc12..4faa46e 100755 --- a/src/security/CMakeLists.txt +++ b/src/security/CMakeLists.txt @@ -3,6 +3,7 @@ SET (this_target security) INCLUDE_DIRECTORIES( ${SLP_INCLUDE_DIRS} /usr/include/chromium + /usr/include/privacy_manager cert inc ./ diff --git a/src/security/FSec_PrivacyManagerImpl.cpp b/src/security/FSec_PrivacyManagerImpl.cpp index a15f317..e5b437a 100755 --- a/src/security/FSec_PrivacyManagerImpl.cpp +++ b/src/security/FSec_PrivacyManagerImpl.cpp @@ -21,9 +21,12 @@ */ #include +#include #include #include #include "FSec_PrivacyManagerImpl.h" +#include +#include using namespace Tizen::Base; using namespace Tizen::Base::Collection; @@ -48,24 +51,78 @@ _PrivacyManagerImpl::GetInstance(PrivacyManager& privacyManager) return privacyManager.__pPrivacyManagerImpl; } + +bool GetPrivacyAppPackageListNCallback(const char *package_id, void* user_data) +{ + result r = E_SUCCESS; + ArrayList* pList = static_cast < ArrayList* >(user_data); + + pList->Add(new String(package_id)); + return true; +} + Tizen::Base::Collection::IList* _PrivacyManagerImpl::GetPrivacyAppPackageListN(void) const { - return null; + ArrayList* pPackageIdList = null; + int ret = 0; + pPackageIdList = new ArrayList(); + pPackageIdList->Construct(); + + ret = privacy_manager_client_foreach_privacy_packages(GetPrivacyAppPackageListNCallback, pPackageIdList); + + return pPackageIdList; +} + +bool GetPrivacyInfoListNCallback(privacy_info_client_s* pPrivacy_info, void* user_data) +{ + result r = E_SUCCESS; + ArrayList* pList = static_cast < ArrayList* >(user_data); + + String pPrivacyId = String(pPrivacy_info->privacy_id); + bool isEnabled = pPrivacy_info->is_enabled; + + PrivacyInfo* pPrivacyInfo = new PrivacyInfo(); + r = pPrivacyInfo->Construct(pPrivacyId, isEnabled); + + pList->Add(pPrivacyInfo); + return true; } Tizen::Base::Collection::IList* _PrivacyManagerImpl::GetPrivacyInfoListN(const Tizen::App::PackageId& packageId) const { - return null; + int ret = 0; + ArrayList* pPrivacyIdList = null; + char* pAppId = null; + + pPrivacyIdList = new ArrayList(); + pPrivacyIdList->Construct(); + + pAppId = _StringConverter::CopyToCharArrayN(packageId); + + ret = privacy_manager_client_foreach_get_privacy_info(pAppId, GetPrivacyInfoListNCallback, (void *)pPrivacyIdList); + delete pAppId; + + return pPrivacyIdList; } result _PrivacyManagerImpl::SetAppPackagePrivacy(const Tizen::App::PackageId& packageId, const PrivacyInfo& privacyInfo) { result r = E_SUCCESS; + int ret = 0; + char* pPackageId = null; + char* pPrivacyId = null; + + bool isEnabled = false; + + pPackageId = _StringConverter::CopyToCharArrayN(packageId); + pPrivacyId = _StringConverter::CopyToCharArrayN(privacyInfo.GetId()); + isEnabled = privacyInfo.IsEnabled(); + ret = privacy_manager_client_set_package_privacy(pPackageId, pPrivacyId, isEnabled); return r; } -- 2.7.4