[Release] wrt-installer_0.1.92
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_smack.cpp
index 86dfbfd..31ab408 100644 (file)
@@ -91,9 +91,8 @@ void TaskSmack::StepSmackFolderLabeling()
             Jobs::WidgetInstall::TaskSmack::SmackFolderLabelingStep()");
 #ifdef WRT_SMACK_ENABLED
     /* /opt/usr/apps/[pkgid] directory's label is "_" */
-    if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
-                m_context.locations->getPackageInstallationDir().c_str(),
-                APP_PATH_ANY_LABEL, "_")) {
+    if (PC_OPERATION_SUCCESS != app_label_dir("_",
+                m_context.locations->getPackageInstallationDir().c_str())) {
         LogWarning("Add label to " <<
                 m_context.locations->getPackageInstallationDir());
     }
@@ -101,41 +100,40 @@ void TaskSmack::StepSmackFolderLabeling()
     /* res directory */
     std::string resDir = m_context.locations->getPackageInstallationDir() +
         "/res";
-
-    if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId, resDir.c_str(),
-                APP_PATH_PRIVATE)) {
+    if (PC_OPERATION_SUCCESS != app_label_dir(m_pkgId,
+                resDir.c_str())) {
         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_setup_path(m_pkgId,
-                    m_context.locations->getUserDataRootDir().c_str(),
-                    APP_PATH_GROUP_RW, "_")) {
+        if (PC_OPERATION_SUCCESS != app_label_dir("_",
+                    m_context.locations->getUserDataRootDir().c_str())) {
+            LogWarning("Add label to " << m_context.locations->getUserDataRootDir());
         }
     }
 
+    /* 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_setup_path(m_pkgId,
-                m_context.locations->getPrivateTempStorageDir().c_str(),
-                APP_PATH_PRIVATE))
+    if (PC_OPERATION_SUCCESS !=
+        app_label_dir(m_pkgId,
+                      m_context.locations->getPrivateTempStorageDir().c_str()))
     {
         LogWarning("Add label to " << m_context.locations->getPrivateTempStorageDir());
     }
 
     /* bin directory */
-    if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
-                m_context.locations->getBinaryDir().c_str(),
-                APP_PATH_PRIVATE)) {
+    if (PC_OPERATION_SUCCESS != app_label_dir(m_pkgId,
+                m_context.locations->getBinaryDir().c_str())) {
         LogWarning("Add label to " << m_context.locations->getBinaryDir());
     }
 
@@ -213,6 +211,7 @@ 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());
@@ -238,11 +237,16 @@ 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_setup_path(m_pkgId,
-                m_context.locations->getSharedResourceDir().c_str(),
-                APP_PATH_ANY_LABEL, "_")) {
-        LogWarning("Add label to " << m_context.locations->getSharedResourceDir());
+    if (PC_OPERATION_SUCCESS != app_label_dir("_",
+                m_context.locations->getSharedResourceDir().c_str())) {
+        return false;
     }
 
     /* shared/trusted directory */
@@ -260,20 +264,40 @@ bool TaskSmack::setLabelForSharedDir(const char* pkgId)
 
         LogDebug("sha1 label string : " << sha1String);
 
-        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());
+        if (PC_OPERATION_SUCCESS != app_label_shared_dir(pkgId,
+                    sha1String.c_str(),
+                    m_context.locations->getSharedTrustedDir().c_str())) {
+            return false;
         }
     }
 
     /* shared/data directory */
-    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());
+    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;
     }
 
+    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