Update smack new api
authorDuyoung Jang <duyoung.jang@samsung.com>
Mon, 26 Aug 2013 04:54:10 +0000 (13:54 +0900)
committerDuyoung Jang <duyoung.jang@samsung.com>
Mon, 26 Aug 2013 04:54:10 +0000 (13:54 +0900)
Change-Id: If896728b409db8f77b27615ae1e8ec1d2aa8d704
Signed-off-by: Duyoung Jang <duyoung.jang@samsung.com>
CMakeLists.txt
inc/InstallerDefs.h
packaging/osp-installer.spec
src/Manager/CompatibilityManager.cpp
src/Manager/ConfigurationManager.cpp
src/Manager/PermissionManager.cpp
src/Manager/SmackManager.cpp
src/Manager/SmackManager.h

index 5c16308..b37b33a 100755 (executable)
@@ -83,7 +83,7 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -fvisibility=hidden")
 SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
 
 TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-appfw -lxml2 -lpkgmgr_installer -lpkgmgr_parser -lglib-2.0 -lapp2ext -ldl" -Wl,--allow-shlib-undefined)
-TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib -lcert-svc-vcore -ldpl-efl -lcert-svc -lcapi-system-info -lappcore-common -lpkgmgr-info -lpkgmgr-client -lvconf -lcap")
+TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib -lcert-svc-vcore -ldpl-efl -lcert-svc -lcapi-system-info -lappcore-common -lpkgmgr-info -lpkgmgr-client -lvconf -lcap -lprivilege-control")
 
 ADD_SUBDIRECTORY(plugin)
 
index 5e5c5dd..ace4fd3 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include "InstallerUtil.h"
 
-#define OSP_INSTALLER_VERSION "version=[20130826.1]"
+#define OSP_INSTALLER_VERSION "version=[20130826.2]"
 
 #define DIR_BIN                                L"/bin"
 #define DIR_INFO                       L"/info"
@@ -370,14 +370,4 @@ enum PrivilegeLevel
 
 };
 
-enum SmackDirType
-{
-       SMACK_DIR_TYPE_PRIVATE,
-       SMACK_DIR_TYPE_GROUP_RW,
-       SMACK_DIR_TYPE_PUBLIC_RO,
-       SMACK_DIR_TYPE_SETTINGS_RW,
-       SMACK_DIR_TYPE_ANY_LABEL,
-
-};
-
 #endif // _INSTALLER_DEFS_H_
index 3768eb9..19c5070 100755 (executable)
@@ -16,6 +16,7 @@ BuildRequires:  pkgconfig(pkgmgr-parser)
 BuildRequires:  pkgconfig(pkgmgr-info)
 BuildRequires:  pkgconfig(app2sd)
 BuildRequires:  pkgconfig(libwbxml2)
+BuildRequires:  pkgconfig(libprivilege-control)
 BuildRequires:  pkgconfig(osp-appfw)
 BuildRequires:  pkgconfig(dpl-efl)
 BuildRequires:  pkgconfig(cert-svc)
index 2835f2c..acc4700 100755 (executable)
@@ -452,7 +452,7 @@ CompatibilityManager::CreateOspInternalDirectories(const String& rootPath, const
 
        SmackManager smackManager;
        smackManager.Construct(__pContext);
-       smackManager.SetupPath(packageId, L"./Storagecard", SMACK_DIR_TYPE_ANY_LABEL, L"_");
+       smackManager.SetupPath(packageId, L"./Storagecard", APP_PATH_ANY_LABEL, L"_");
 
        ospShareAppIdPath.Append(packageId);
 
@@ -507,12 +507,12 @@ CompatibilityManager::CreateOspInternalDirectories(const String& rootPath, const
        res = InstallerUtil::CreateSymlink(ospShareAppIdPath, L"./shared/data", false);
        TryReturn(res == true, false, "CreateSymlink() failed, errno: %d (%s), link: ./shared/data -> %s", errno, strerror(errno), pOspShareAppIdPath.get());
 
-       smackManager.SetupPath(packageId, ospShareAppIdPath, SMACK_DIR_TYPE_PUBLIC_RO);
+       smackManager.SetupPath(packageId, ospShareAppIdPath, APP_PATH_PUBLIC_RO);
 
        res = InstallerUtil::CreateSymlink(ospShare2AppIdPath, L"./shared/trusted", false);
        TryReturn(res == true, false, " CreateSymlink() failed, errno: %d (%s), link: ./shared/trusted -> %s", errno, strerror(errno), pOspShare2AppIdPath.get());
 
-       smackManager.SetupPath(packageId, ospShare2AppIdPath, SMACK_DIR_TYPE_GROUP_RW);
+       smackManager.SetupPath(packageId, ospShare2AppIdPath, APP_PATH_GROUP_RW);
 
        AppLog("[Tizen::Io] CreateOspInternalDirectories() succeeded, rootPath: %ls", rootPath.GetPointer());
        return true;
index 0a89046..1dd068a 100755 (executable)
@@ -558,28 +558,28 @@ ConfigurationManager::CopyData(InstallationContext* pContext) const
        destPath = rootPath + DIR_DATA;
        InstallerUtil::CopyDirectory(srcPath, destPath, true);
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_PRIVATE);
 
        // setting
        srcPath = backupPath + DIR_SETTING;
        destPath = rootPath + DIR_SETTING;
        InstallerUtil::CopyDirectory(srcPath, destPath, true);
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_WRITE, false);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_SETTINGS_RW);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_SETTINGS_RW);
 
        // shared/data
        srcPath = backupPath + DIR_SHARED_DATA;
        destPath = rootPath + DIR_SHARED_DATA;
        InstallerUtil::CopyDirectory(srcPath, destPath, true);
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PUBLIC_RO);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_PUBLIC_RO);
 
        // shared/trust
        srcPath = backupPath + DIR_SHARED_TRUSTED;
        destPath = rootPath + DIR_SHARED_TRUSTED;
        InstallerUtil::CopyDirectory(srcPath, destPath, true);
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_GROUP_RW);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_GROUP_RW);
 
        return true;
 }
index d37bfe3..425538a 100755 (executable)
@@ -70,7 +70,7 @@ PermissionManager::SetDirectory(InstallationContext* pContext)
        // appRoot
        // InstallerUtil::ChangeOwner(appRootPath);
        InstallerUtil::ChangeMode(appRootPath, PERM_BASE | PERM_EXECUTE);
-       smackManager.SetupPath(packageId, appRootPath, SMACK_DIR_TYPE_ANY_LABEL, L"_");
+       smackManager.SetupPath(packageId, appRootPath, APP_PATH_ANY_LABEL, L"_");
 
        if (pContext->__isPreloaded == true)
        {
@@ -78,28 +78,28 @@ PermissionManager::SetDirectory(InstallationContext* pContext)
                preloadedAppPath += L"/";
                preloadedAppPath += packageId;
 
-               smackManager.SetupPath(packageId, preloadedAppPath, SMACK_DIR_TYPE_ANY_LABEL, L"_");
+               smackManager.SetupPath(packageId, preloadedAppPath, APP_PATH_ANY_LABEL, L"_");
        }
 
        // appRoot/bin
        destPath = appRootPath + DIR_BIN;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_EXECUTE, false);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_PRIVATE);
 
        // appRoot/info
        destPath = appRootPath + DIR_INFO;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, false);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_PRIVATE);
 
        // appRoot/res
        destPath = appRootPath + DIR_RES;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, false);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_PRIVATE);
 
        // appRoot/lib
        destPath = appRootPath + DIR_LIB;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_EXECUTE, false);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_PRIVATE);
 
        // appRoot/shared
        destPath = appRootPath + DIR_SHARED;
@@ -122,17 +122,17 @@ PermissionManager::SetDirectory(InstallationContext* pContext)
        // appRoot/shared/data
        destPath = appRootPath + DIR_SHARED_DATA;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PUBLIC_RO);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_PUBLIC_RO);
 
        // appRoot/shared/trusted
        destPath = appRootPath + DIR_SHARED_TRUSTED;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_GROUP_RW);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_GROUP_RW);
 
        // appRoot/contents
        destPath = appRootPath + DIR_CONTENTS;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, false);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_PRIVATE);
 
        // appRoot/setting
        destPath = appRootPath + DIR_SETTING;
@@ -148,7 +148,7 @@ PermissionManager::SetDirectory(InstallationContext* pContext)
                InstallerUtil::CreateSymlink(srcPath, settingXmlPath);
 
                InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_WRITE, false);
-               smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_SETTINGS_RW);
+               smackManager.SetupPath(packageId, destPath, APP_PATH_SETTINGS_RW);
        }
 
        // appRoot/data
@@ -166,7 +166,7 @@ PermissionManager::SetDirectory(InstallationContext* pContext)
                res = compatibilityManager.PrepareVirtualRoot(appRootPath, packageId);
                TryReturn(res == true, false, "[Tizen::Io] compatibilityManager.PrepareVirtualRoot(%ls) failed.", appRootPath.GetPointer());
        }
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_PRIVATE);
 
        String apiVersion = pContext->__apiVersion;
 
@@ -368,27 +368,27 @@ PermissionManager::ApplyPermissionForRds(InstallationContext* pContext)
 
        // appRoot
        InstallerUtil::ChangeMode(appRootPath, PERM_BASE | PERM_EXECUTE);
-       smackManager.SetupPath(packageId, appRootPath, SMACK_DIR_TYPE_ANY_LABEL, L"_");
+       smackManager.SetupPath(packageId, appRootPath, APP_PATH_ANY_LABEL, L"_");
 
        // appRoot/bin
        destPath = appRootPath + DIR_BIN;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_EXECUTE, false);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_PRIVATE);
 
        // appRoot/info
        destPath = appRootPath + DIR_INFO;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, false);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_PRIVATE);
 
        // appRoot/res
        destPath = appRootPath + DIR_RES;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, false);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_PRIVATE);
 
        // appRoot/lib
        destPath = appRootPath + DIR_LIB;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_EXECUTE, false);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_PRIVATE);
 
        // appRoot/shared
        destPath = appRootPath + DIR_SHARED;
@@ -401,22 +401,22 @@ PermissionManager::ApplyPermissionForRds(InstallationContext* pContext)
        // appRoot/shared/data
        destPath = appRootPath + DIR_SHARED_DATA;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PUBLIC_RO);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_PUBLIC_RO);
 
        // appRoot/shared/trusted
        destPath = appRootPath + DIR_SHARED_TRUSTED;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_GROUP_RW);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_GROUP_RW);
 
        // appRoot/setting
        destPath = appRootPath + DIR_SETTING;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_WRITE, false);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_SETTINGS_RW);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_SETTINGS_RW);
 
        // appRoot/data
        destPath = appRootPath + DIR_DATA;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
-       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
+       smackManager.SetupPath(packageId, destPath, APP_PATH_PRIVATE);
 
        return true;
 }
index 8e74194..6086ccd 100755 (executable)
@@ -19,7 +19,6 @@
  * @brief      This is the implementation file for %SmackManager class.
  */
 
-#include <dlfcn.h>
 #include <unique_ptr.h>
 
 #include <FAppPkgPackageInfo.h>
@@ -148,14 +147,6 @@ SmackManager::AddLabelSymlink(const String& symlink)
 }
 
 bool
-SmackManager::AddFriend(const Tizen::App::PackageId& packageId1, const Tizen::App::PackageId& packageId2)
-{
-       //int AddFriend(const char* pPackageId1, const char* pPackageId2);
-
-       return true;
-}
-
-bool
 SmackManager::EnablePermissions(const PackageId& packageId)
 {
        TryReturn(__pContext, false, "__pContext is null");
@@ -188,7 +179,7 @@ SmackManager::EnablePermissions(const PackageId& packageId)
 
                pList[count] = null;
 
-               res = EnablePermissions(pPackageId.get(), 1, pList, true);
+               res = EnablePermissions(pPackageId.get(), APP_TYPE_OSP, pList, true);
 
                for (int i = 0; pList[i] != null; i++)
                {
@@ -199,7 +190,7 @@ SmackManager::EnablePermissions(const PackageId& packageId)
        else
        {
                const char* pNullList[1] = {null};
-               res = EnablePermissions(pPackageId.get(), 1, pNullList, true);
+               res = EnablePermissions(pPackageId.get(), APP_TYPE_OSP, pNullList, true);
        }
 
        return true;
@@ -219,7 +210,7 @@ SmackManager::RevokePermissions(const PackageId& packageId)
 }
 
 bool
-SmackManager::SetupPath(const PackageId& packageId, const String& dirPath, SmackDirType type, const String& label)
+SmackManager::SetupPath(const PackageId& packageId, const String& dirPath, app_path_type_t type, const String& label)
 {
        int res = 0;
        String realPath;
@@ -238,7 +229,7 @@ SmackManager::SetupPath(const PackageId& packageId, const String& dirPath, Smack
 
        if (InstallerUtil::IsSymlink(dirPath) == true)
        {
-               res = SetupPath(pPackageId.get(), pPath.get(), (int) SMACK_DIR_TYPE_ANY_LABEL, "_");
+               res = SetupPath(pPackageId.get(), pPath.get(), APP_PATH_ANY_LABEL, "_");
                InstallerUtil::GetRealPath(dirPath, realPath);
        }
        else
@@ -249,7 +240,7 @@ SmackManager::SetupPath(const PackageId& packageId, const String& dirPath, Smack
        std::unique_ptr<char[]> pRealPath(_StringConverter::CopyToCharArrayN(realPath));
        TryReturn(pRealPath, false, "pRealPath is null.");
 
-       if (type == SMACK_DIR_TYPE_GROUP_RW)
+       if (type == APP_PATH_GROUP_RW)
        {
                TryReturn(__pContext, false, "__pContext is null.");
 
@@ -296,20 +287,20 @@ SmackManager::SetupPath(const PackageId& packageId, const String& dirPath, Smack
                std::unique_ptr<char[]> pGroupId(_StringConverter::CopyToCharArrayN(groupId));
                TryReturn(pGroupId, false, "pGroupId is null.");
 
-               res = SetupPath(pPackageId.get(), pRealPath.get(), (int) type, pGroupId.get());
+               res = SetupPath(pPackageId.get(), pRealPath.get(), type, pGroupId.get());
        }
-       else if (type == SMACK_DIR_TYPE_ANY_LABEL)
+       else if (type == APP_PATH_ANY_LABEL)
        {
                TryReturn(label.IsEmpty() == false, false, "label is empty.");
 
                std::unique_ptr<char[]> pAnyLabel(_StringConverter::CopyToCharArrayN(label));
                TryReturn(pAnyLabel, false, "pAnyLabel is null.");
 
-               res = SetupPath(pPackageId.get(), pRealPath.get(), (int) type, pAnyLabel.get());
+               res = SetupPath(pPackageId.get(), pRealPath.get(), type, pAnyLabel.get());
        }
        else
        {
-               res = SetupPath(pPackageId.get(), pRealPath.get(), (int) type);
+               res = SetupPath(pPackageId.get(), pRealPath.get(), type);
        }
 
        return true;
@@ -318,32 +309,9 @@ SmackManager::SetupPath(const PackageId& packageId, const String& dirPath, Smack
 int
 SmackManager::Install(const char* pPackageId)
 {
-       int ret = 0;
-       void* pHandle = null;
-       char* pErrorMsg = null;
-       int (*app_install)(const char*) = null;
-
-       pHandle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_GLOBAL);
-       if (!pHandle)
-       {
-               AppLog("Install(): dlopen() failed. [%s]", dlerror());
-               return -1;
-       }
-
-       app_install = reinterpret_cast <int (*)(const char*)>(dlsym(pHandle, "app_install"));
-       pErrorMsg = dlerror();
-       if ((pErrorMsg != null) || (app_install == null))
-       {
-               AppLog("Install(): dlsym() failed. [%s]", pErrorMsg);
-               dlclose(pHandle);
-               return -1;
-       }
-
-       AppLog("[smack] app_install(%s)", pPackageId);
-       ret = app_install(pPackageId);
-       AppLog("[smack] app_install(%s), result = [%d]", pPackageId, ret);
-
-       dlclose(pHandle);
+       AppLog("[smack] perm_app_install(%s)", pPackageId);
+       int ret = perm_app_install(pPackageId);
+       AppLog("[smack] perm_app_install(%s), result = [%d]", pPackageId, ret);
 
        return ret;
 }
@@ -351,32 +319,9 @@ SmackManager::Install(const char* pPackageId)
 int
 SmackManager::Uninstall(const char* pPackageId)
 {
-       int ret = 0;
-       void* pHandle = null;
-       char* pErrorMsg = null;
-       int (*app_uninstall)(const char*) = null;
-
-       pHandle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_GLOBAL);
-       if (!pHandle)
-       {
-               AppLog("Uninstall(): dlopen() failed. [%s]", dlerror());
-               return -1;
-       }
-
-       app_uninstall = reinterpret_cast <int (*)(const char*)>(dlsym(pHandle, "app_uninstall"));
-       pErrorMsg = dlerror();
-       if ((pErrorMsg != null) || (app_uninstall == null))
-       {
-               AppLog("Uninstall(): dlsym() failed. [%s]", pErrorMsg);
-               dlclose(pHandle);
-               return -1;
-       }
-
-       AppLog("[smack] app_uninstall(%s)", pPackageId);
-       ret = app_uninstall(pPackageId);
-       AppLog("[smack] app_uninstall(%s), result = [%d]", pPackageId, ret);
-
-       dlclose(pHandle);
+       AppLog("[smack] perm_app_uninstall(%s)", pPackageId);
+       int ret = perm_app_uninstall(pPackageId);
+       AppLog("[smack] perm_app_uninstall(%s), result = [%d]", pPackageId, ret);
 
        return ret;
 }
@@ -384,229 +329,50 @@ SmackManager::Uninstall(const char* pPackageId)
 int
 SmackManager::AddLabelDir(const char* pLabel, const char* pDirPath)
 {
-       int ret = 0;
-       void* pHandle = null;
-       char* pErrorMsg = null;
-       int (*app_label_dir)(const char*, const char*) = null;
-
-       pHandle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_GLOBAL);
-       if (!pHandle)
-       {
-               AppLog("AddLabelDir(): dlopen() failed. [%s]", dlerror());
-               return -1;
-       }
-
-       app_label_dir = reinterpret_cast <int (*)(const char*, const char*)>(dlsym(pHandle, "app_label_dir"));
-       pErrorMsg = dlerror();
-       if ((pErrorMsg != null) || (app_label_dir == null))
-       {
-               AppLog("AddLabelDir(): dlsym() failed. [%s]", pErrorMsg);
-               dlclose(pHandle);
-               return -1;
-       }
-
        AppLog("[smack] app_label_dir(%s, %s)", pLabel, pDirPath);
-       ret = app_label_dir(pLabel, pDirPath);
+       int ret = app_label_dir(pLabel, pDirPath);
        AppLog("[smack] app_label_dir(%s, %s), result = [%d]", pLabel, pDirPath, ret);
 
-       dlclose(pHandle);
-
-       return 0;
-}
-
-int
-SmackManager::AddFriend(const char* pPackageId1, const char* pPackageId2)
-{
-       int ret = 0;
-       void* pHandle = null;
-       char* pErrorMsg = null;
-       int (*app_add_friend)(const char*, const char*) = null;
-
-       pHandle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_GLOBAL);
-       if (!pHandle)
-       {
-               AppLog("AddFriend(): dlopen() failed. [%s]", dlerror());
-               return -1;
-       }
-
-       app_add_friend = reinterpret_cast <int (*)(const char*, const char*)>(dlsym(pHandle, "app_add_friend"));
-       pErrorMsg = dlerror();
-       if ((pErrorMsg != null) || (app_add_friend == null))
-       {
-               AppLog("AddFriend(): dlsym() failed. [%s]", pErrorMsg);
-               dlclose(pHandle);
-               return -1;
-       }
-
-       AppLog("[smack] app_add_friend(%s, %s)", pPackageId1, pPackageId2);
-       ret = app_add_friend(pPackageId1, pPackageId2);
-       AppLog("[smack] app_add_friend(%s, %s), result = [%d]", pPackageId1, pPackageId2, ret);
-
-       dlclose(pHandle);
-
-       return 0;
+       return ret;
 }
 
 int
-SmackManager::EnablePermissions(const char* pPackageId, int appType, const char** ppPermissions, bool persistent)
+SmackManager::EnablePermissions(const char* pPackageId, app_type_t appType, const char** ppPermissions, bool persistent)
 {
-       int ret = 0;
-       void* pHandle = null;
-       char* pErrorMsg = null;
-       int (*app_enable_permissions)(const char*, int, const char**, bool) = null;
+       AppLog("[smack] perm_app_enable_permissions(%s, %d)", pPackageId, appType);
+       int ret = perm_app_enable_permissions(pPackageId, appType, ppPermissions, persistent);
+       AppLog("[smack] perm_app_enable_permissions(%s, %d), result = [%d]", pPackageId, appType, ret);
 
-       pHandle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_GLOBAL);
-       if (!pHandle)
-       {
-               AppLog("EnablePermissions(): dlopen() failed. [%s]", dlerror());
-               return -1;
-       }
-
-       app_enable_permissions = reinterpret_cast <int (*)(const char*, int, const char**, bool)>(dlsym(pHandle, "app_enable_permissions"));
-       pErrorMsg = dlerror();
-       if ((pErrorMsg != null) || (app_enable_permissions == null))
-       {
-               AppLog("EnablePermissions(): dlsym() failed. [%s]", pErrorMsg);
-               dlclose(pHandle);
-               return -1;
-       }
-
-       AppLog("[smack] app_enable_permissions(%s, %d)", pPackageId, appType);
-       ret = app_enable_permissions(pPackageId, appType, ppPermissions, persistent);
-       AppLog("[smack] app_enable_permissions(%s, %d), result = [%d]", pPackageId, appType, ret);
-
-       dlclose(pHandle);
-
-       return 0;
+       return ret;
 }
 
 int
 SmackManager::RevokePermissions(const char* pPackageId)
 {
-       int ret = 0;
-       void* pHandle = null;
-       char* pErrorMsg = null;
-       int (*app_revoke_permissions)(const char*) = null;
-
-       pHandle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_GLOBAL);
-       if (!pHandle)
-       {
-               AppLog("RevokePermissions(): dlopen() failed. [%s][%s]", pPackageId, dlerror());
-               return -1;
-       }
+       AppLog("[smack] perm_app_revoke_permissions(%s)", pPackageId);
+       int ret = perm_app_revoke_permissions(pPackageId);
+       AppLog("[smack] perm_app_revoke_permissions(%s), result = [%d]", pPackageId, ret);
 
-       app_revoke_permissions = reinterpret_cast <int (*)(const char*)>(dlsym(pHandle, "app_revoke_permissions"));
-       pErrorMsg = dlerror();
-       if ((pErrorMsg != null) || (app_revoke_permissions == null))
-       {
-               AppLog("RevokePermissions(): dlsym() failed. [%s][%s]", pPackageId, pErrorMsg);
-               dlclose(pHandle);
-               return -1;
-       }
-
-       AppLog("[smack] app_revoke_permissions(%s)", pPackageId);
-       ret = app_revoke_permissions(pPackageId);
-       AppLog("[smack] app_revoke_permissions(%s), result = [%d]", pPackageId, ret);
-
-       dlclose(pHandle);
-
-       return 0;
+       return ret;
 }
 
 int
-SmackManager::SetupPath(const char* pPackageId, const char* pDirPath, int appPathType, const char* pGroupId)
+SmackManager::SetupPath(const char* pPackageId, const char* pDirPath, app_path_type_t appPathType, const char* pGroupId)
 {
        int ret = 0;
-       void* pHandle = null;
-       char* pErrorMsg = null;
-       int (*app_setup_path)(const char*, const char*, int, ...) = null;
-
-       pHandle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_GLOBAL);
-       if (!pHandle)
-       {
-               AppLog("dlopen() failed. [%s]", dlerror());
-               return -1;
-       }
-
-       app_setup_path = reinterpret_cast <int (*)(const char*, const char*, int, ...)>(dlsym(pHandle, "app_setup_path"));
-       pErrorMsg = dlerror();
-       if ((pErrorMsg != null) || (app_setup_path == null))
-       {
-               AppLog("dlsym() failed. [%s]", pErrorMsg);
-               dlclose(pHandle);
-               return -1;
-       }
 
        if (pGroupId == null)
        {
-               AppLog("[smack] app_setup_path(%s, %s, %d)", pPackageId, pDirPath, appPathType);
-               ret = app_setup_path(pPackageId, pDirPath, appPathType);
-               AppLog("[smack] app_setup_path(), result = [%d]", ret);
+               AppLog("[smack] perm_app_setup_path(%s, %s, %d)", pPackageId, pDirPath, appPathType);
+               ret = perm_app_setup_path(pPackageId, pDirPath, appPathType);
+               AppLog("[smack] perm_app_setup_path(), result = [%d]", ret);
        }
        else
        {
-               AppLog("[smack] app_setup_path(%s, %s, %d, %s)", pPackageId, pDirPath, appPathType, pGroupId);
-               ret = app_setup_path(pPackageId, pDirPath, appPathType, pGroupId);
-               AppLog("[smack] app_setup_path(), result = [%d]", ret);
+               AppLog("[smack] perm_app_setup_path(%s, %s, %d, %s)", pPackageId, pDirPath, appPathType, pGroupId);
+               ret = perm_app_setup_path(pPackageId, pDirPath, appPathType, pGroupId);
+               AppLog("[smack] perm_app_setup_path(), result = [%d]", ret);
        }
 
-       dlclose(pHandle);
-
        return ret;
 }
-
-ArrayList*
-SmackManager::GetPreloadedAppListN() const
-{
-       result r = E_SUCCESS;
-
-       std::unique_ptr< ArrayList > pList(new (std::nothrow) ArrayList());
-       TryReturn(pList, null, "pList is null.");
-
-       r = pList->Construct();
-       TryReturn(r == E_SUCCESS, null, "pList->Construct() failed.");
-
-       std::unique_ptr< Directory > pDir(new (std::nothrow) Directory());
-       TryReturn(pDir, null, "pDir is null.");
-
-       r = pDir->Construct(PATH_USR_APPS);
-       TryReturn(r == E_SUCCESS, null, "pDir->Construct() failed.");
-
-       std::unique_ptr< DirEnumerator > pDirEnum(pDir->ReadN());
-       TryReturn(pDirEnum, null, "pDirEnum is null.");
-
-       while (pDirEnum->MoveNext() == E_SUCCESS)
-       {
-               DirEntry entry = pDirEnum->GetCurrentDirEntry();
-               String entryName = entry.GetName();
-
-               if (entryName == L"." || entryName == L"..")
-               {
-                       continue;
-               }
-
-               if (entry.IsDirectory() == false)
-               {
-                       continue;
-               }
-
-               const int entryLength = entryName.GetLength();
-               if (entryLength != PACKAGE_ID_LENGTH)
-               {
-                       continue;
-               }
-
-               std::unique_ptr< String > pPackageId(new (std::nothrow) String(entryName));
-               TryReturn(pPackageId, null, "pPackageId is null.");
-
-               pList->Add(pPackageId.release());
-       }
-
-       if (pList->GetCount() <= 0)
-       {
-               AppLog("pList's count is 0.");
-               return null;
-       }
-
-       return pList.release();
-}
index 6356b7c..8941d07 100755 (executable)
@@ -23,6 +23,8 @@
 #ifndef _SMACK_MANAGER_H_
 #define _SMACK_MANAGER_H_
 
+#include <privilege-control.h>
+
 #include <FAppTypes.h>
 
 #include "InstallationContext.h"
@@ -39,26 +41,22 @@ public:
 
        bool AddLabelDir(const Tizen::Base::String& label, const Tizen::Base::String& dirPath, bool rootDirectory = false);
        bool AddLabelSymlink(const Tizen::Base::String& symlink);
-       bool AddFriend(const Tizen::App::PackageId& packageId1, const Tizen::App::PackageId& packageId2);
 
        bool EnablePermissions(const Tizen::App::PackageId& packageId);
        bool RevokePermissions(const Tizen::App::PackageId& packageId);
 
-       bool SetupPath(const Tizen::App::PackageId& packageId, const Tizen::Base::String& dirPath, SmackDirType type, const Tizen::Base::String& label = L"");
+       bool SetupPath(const Tizen::App::PackageId& packageId, const Tizen::Base::String& dirPath, app_path_type_t type, const Tizen::Base::String& label = L"");
 
 private:
        int Install(const char* pPackageId);
        int Uninstall(const char* pPackageId);
 
        int AddLabelDir(const char* pLabel, const char* pDirPath);
-       int AddFriend(const char* pPackageId1, const char* pPackageId2);
 
-       int EnablePermissions(const char* pPackageId, int appType, const char** ppPermissions, bool persistent);
+       int EnablePermissions(const char* pPackageId, app_type_t appType, const char** ppPermissions, bool persistent);
        int RevokePermissions(const char* pPackageId);
 
-       int SetupPath(const char* pPackageId, const char* pDirPath, int appPathType, const char* pGroupId = null);
-
-       Tizen::Base::Collection::ArrayList* GetPreloadedAppListN() const;
+       int SetupPath(const char* pPackageId, const char* pDirPath, app_path_type_t appPathType, const char* pGroupId = null);
 
 private:
        InstallationContext* __pContext;