Change smack labeling api
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_smack.cpp
index 31ab408..86dfbfd 100644 (file)
@@ -91,8 +91,9 @@ void TaskSmack::StepSmackFolderLabeling()
             Jobs::WidgetInstall::TaskSmack::SmackFolderLabelingStep()");
 #ifdef WRT_SMACK_ENABLED
     /* /opt/usr/apps/[pkgid] directory's label is "_" */
-    if (PC_OPERATION_SUCCESS != app_label_dir("_",
-                m_context.locations->getPackageInstallationDir().c_str())) {
+    if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+                m_context.locations->getPackageInstallationDir().c_str(),
+                APP_PATH_ANY_LABEL, "_")) {
         LogWarning("Add label to " <<
                 m_context.locations->getPackageInstallationDir());
     }
@@ -100,40 +101,41 @@ void TaskSmack::StepSmackFolderLabeling()
     /* res directory */
     std::string resDir = m_context.locations->getPackageInstallationDir() +
         "/res";
-    if (PC_OPERATION_SUCCESS != app_label_dir(m_pkgId,
-                resDir.c_str())) {
+
+    if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId, resDir.c_str(),
+                APP_PATH_PRIVATE)) {
         LogWarning("Add label to " << resDir);
     }
 
+    /* data directory */
+    if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+                m_context.locations->getPrivateStorageDir().c_str(),
+                APP_PATH_PRIVATE)) {
+        LogWarning("Add label to " << m_context.locations->getPrivateStorageDir());
+    }
+
     /* for prealod */
     if (m_context.mode.installTime == InstallMode::InstallTime::PRELOAD &&
             m_context.mode.extension != InstallMode::ExtensionType::DIR)
     {
-        if (PC_OPERATION_SUCCESS != app_label_dir("_",
-                    m_context.locations->getUserDataRootDir().c_str())) {
-            LogWarning("Add label to " << m_context.locations->getUserDataRootDir());
+        if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+                    m_context.locations->getUserDataRootDir().c_str(),
+                    APP_PATH_GROUP_RW, "_")) {
         }
     }
 
-    /* data directory */
-    if (PC_OPERATION_SUCCESS !=
-        app_label_dir(m_pkgId,
-                      m_context.locations->getPrivateStorageDir().c_str()))
-    {
-        LogWarning("Add label to " << m_context.locations->getPrivateStorageDir());
-    }
-
     /* tmp directory */
-    if (PC_OPERATION_SUCCESS !=
-        app_label_dir(m_pkgId,
-                      m_context.locations->getPrivateTempStorageDir().c_str()))
+    if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+                m_context.locations->getPrivateTempStorageDir().c_str(),
+                APP_PATH_PRIVATE))
     {
         LogWarning("Add label to " << m_context.locations->getPrivateTempStorageDir());
     }
 
     /* bin directory */
-    if (PC_OPERATION_SUCCESS != app_label_dir(m_pkgId,
-                m_context.locations->getBinaryDir().c_str())) {
+    if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+                m_context.locations->getBinaryDir().c_str(),
+                APP_PATH_PRIVATE)) {
         LogWarning("Add label to " << m_context.locations->getBinaryDir());
     }
 
@@ -211,7 +213,6 @@ void TaskSmack::StepAbortSmack()
 #ifdef WRT_SMACK_ENABLED
     /* TODO :
     std::string id = DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
-    std::string id = DPL::ToUTF8String(m_context.widgetConfig.tzPkgid);
     char* appId = NULL;
     appId = (char*)calloc(1, id.length() + 1);
     snprintf(appId, id.length() + 1, "%s", id.c_str());
@@ -237,16 +238,11 @@ void TaskSmack::StepSetEndofInstallation()
 
 bool TaskSmack::setLabelForSharedDir(const char* pkgId)
 {
-    /* shared directory */
-    if (PC_OPERATION_SUCCESS != app_label_dir("*",
-                m_context.locations->getSharedRootDir().c_str())) {
-        return false;
-    }
-
     /* shared/res directory */
-    if (PC_OPERATION_SUCCESS != app_label_dir("_",
-                m_context.locations->getSharedResourceDir().c_str())) {
-        return false;
+    if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+                m_context.locations->getSharedResourceDir().c_str(),
+                APP_PATH_ANY_LABEL, "_")) {
+        LogWarning("Add label to " << m_context.locations->getSharedResourceDir());
     }
 
     /* shared/trusted directory */
@@ -264,40 +260,20 @@ bool TaskSmack::setLabelForSharedDir(const char* pkgId)
 
         LogDebug("sha1 label string : " << sha1String);
 
-        if (PC_OPERATION_SUCCESS != app_label_shared_dir(pkgId,
-                    sha1String.c_str(),
-                    m_context.locations->getSharedTrustedDir().c_str())) {
-            return false;
+        if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+                    m_context.locations->getSharedTrustedDir().c_str(),
+                    APP_PATH_GROUP_RW, sha1String.c_str())) {
+            LogWarning("Add label to " << m_context.locations->getBinaryDir());
         }
     }
 
     /* shared/data directory */
-    std::string dataLabel = std::string(pkgId) + "_shareddata";
-    TizenPkgIdList pkgList = WidgetDAOReadOnly::getTizenPkgidList();
-    const char** pList = new (std::nothrow) const char*[pkgList.size() + 1];
-
-    int index = 0;
-    FOREACH(app, pkgList) {
-        std::string id = DPL::ToUTF8String(*app);
-        char *pId = new char[id.size() + 1];
-        snprintf(pId, id.length() + 1, "%s", id.c_str());
-        pList[index++] = pId;
+    if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+                m_context.locations->getSharedDataDir().c_str(),
+                APP_PATH_PUBLIC_RO)) {
+        LogWarning("Add label to " << m_context.locations->getSharedDataDir());
     }
 
-    pList[index] = NULL;
-    if (PC_OPERATION_SUCCESS != app_label_shared_dir(pkgId,
-                dataLabel.c_str(),
-                m_context.locations->getSharedDataDir().c_str())) {
-        freeList(pList);
-        return false;
-    }
-    if (PC_OPERATION_SUCCESS != app_label_shared_dir(pkgId,
-                "*",
-                m_context.locations->getSharedDataDir().c_str())) {
-        freeList(pList);
-        return false;
-    }
-    freeList(pList);
     return true;
 }
 } //namespace WidgetInstall