[Release] wrt-installer_0.1.54
authorJihoon Chung <jihoon.chung@samsung.com>
Wed, 8 May 2013 09:15:57 +0000 (18:15 +0900)
committerJihoon Chung <jihoon.chung@samsung.com>
Wed, 8 May 2013 09:16:14 +0000 (18:16 +0900)
packaging/wrt-installer.spec
src/jobs/job_exception_error.h
src/jobs/widget_install/job_widget_install.cpp
src/jobs/widget_install/job_widget_install.h
src/jobs/widget_install/task_file_manipulation.cpp
src/jobs/widget_install/task_file_manipulation.h
src/jobs/widget_install/task_update_files.cpp
src/jobs/widget_install/widget_install_errors.h
src/misc/widget_location.cpp
src/misc/widget_location.h

index bc8c952..34170e1 100644 (file)
@@ -1,7 +1,7 @@
-#git:framework/web/wrt-installer wrt-installer_0.1.53
+#git:framework/web/wrt-installer wrt-installer_0.1.54
 Name:       wrt-installer
 Summary:    Installer for tizen Webruntime
-Version:    0.1.53
+Version:    0.1.54
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
index 9aebb74..1caba99 100644 (file)
@@ -77,6 +77,7 @@ enum Type
     ErrorInstallOspServcie,                 ///< Failure in installing osp service
     ErrorPluginInstallationFailed,          ///< failure in plugin installation
     ErrorWidgetUninstallationFailed,        ///< failure in uninstallation
+    ErrorNotSupportRDSUpdate,               ///< failure in rds update
 
     ErrorUnknown = 140,                     ///< do not use this error code.
 };
index aa46a4e..72c2332 100644 (file)
@@ -90,6 +90,7 @@ const size_t PACKAGE_ID_LENGTH = 10;
 
 static const DPL::String SETTING_VALUE_ENCRYPTION = L"encryption";
 static const DPL::String SETTING_VALUE_ENCRYPTION_ENABLE = L"enable";
+static const DPL::String SETTING_VALUE_ENCRYPTION_DISABLE = L"disable";
 const DPL::String SETTING_VALUE_INSTALLTOEXT_NAME =
     L"install-location";
 const DPL::String SETTING_VALUE_INSTALLTOEXT_PREPER_EXT =
@@ -139,6 +140,9 @@ class InstallerTaskFail :
         } else if (m_result == ConfigureResult::Failed_DrmError) {
             ThrowMsg(Jobs::WidgetInstall::Exceptions::DRMFailed,
                     "drm failed");
+        } else if (m_result == ConfigureResult::Failed_NotSupportRDSUpdate) {
+            ThrowMsg(Jobs::WidgetInstall::Exceptions::NotSupportRDSUpdate,
+                    "RDS update failed");
         } else {
             ThrowMsg(Jobs::WidgetInstall::Exceptions::NotAllowed,
                     "widget installation or update not allowed!");
@@ -480,6 +484,9 @@ ConfigureResult JobWidgetInstall::ConfigureInstallation(
             // Already installed TizenAppId. return failed
             return ConfigureResult::Failed_AlreadyInstalled;
         }
+        if (!checkSupportRDSUpdate(configData)) {
+            return ConfigureResult::Failed_NotSupportRDSUpdate;
+        }
         m_installerContext.isUpdateMode = true;
     }
     Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) {
@@ -1104,5 +1111,40 @@ bool JobWidgetInstall::DecryptDRMWidget(std::string /*widgetPath*/,
     /* TODO */
     return false;
 }
+
+bool JobWidgetInstall::checkSupportRDSUpdate(const WrtDB::ConfigParserData
+        &configInfo)
+{
+    if (m_installerContext.mode.command ==
+            InstallMode::Command::REINSTALL)
+    {
+        DPL::String configValue = SETTING_VALUE_ENCRYPTION_DISABLE;
+        DPL::String dbValue = SETTING_VALUE_ENCRYPTION_DISABLE;
+
+        WidgetDAOReadOnly dao(m_installerContext.widgetConfig.tzAppid);
+        WrtDB::WidgetSettings widgetSettings;
+        dao.getWidgetSettings(widgetSettings);
+
+        FOREACH(it, widgetSettings) {
+            if (it->settingName == SETTING_VALUE_ENCRYPTION) {
+                dbValue = it->settingValue;
+            }
+        }
+
+        FOREACH(data, configInfo.settingsList)
+        {
+            if (data->m_name == SETTING_VALUE_ENCRYPTION) 
+            {
+                configValue = data->m_value;
+            }
+        }
+        if (configValue != dbValue) {
+            LogError("Not Support RDS mode because of encryption setting");
+            return false;
+        }
+    }
+
+    return true;
+}
 } //namespace WidgetInstall
 } //namespace Jobs
index 549c80d..7d5862d 100644 (file)
@@ -48,6 +48,7 @@ enum class ConfigureResult
     Failed_AlreadyInstalled,
     Failed_WidgetRunning,
     Failed_DrmError,
+    Failed_NotSupportRDSUpdate,
 };
 
 class JobWidgetInstall :
@@ -97,6 +98,7 @@ class JobWidgetInstall :
     bool validateTizenPackageID(const WrtDB::TizenPkgId &tizenPkgId);
     ConfigureResult checkWidgetUpdate(const WidgetUpdateInfo &update);
     void setApplicationType(const WrtDB::ConfigParserData &configInfo);
+    bool checkSupportRDSUpdate(const WrtDB::ConfigParserData &configInfo);
 
   public:
     /**
index e32607b..b1629de 100644 (file)
@@ -157,12 +157,14 @@ TaskFileManipulation::TaskFileManipulation(InstallerContext& context) :
             AddAbortStep(&TaskFileManipulation::StepAbortRenamePath);
         }
         AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir);
+        AddStep(&TaskFileManipulation::StepCreateSharedFolder);
         AddStep(&TaskFileManipulation::StepLinkForPreload);
 
     } else {
         AddStep(&TaskFileManipulation::StepPrepareExternalDir);
         AddStep(&TaskFileManipulation::StepInstallToExternal);
         AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir);
+        AddStep(&TaskFileManipulation::StepCreateSharedFolder);
 
         AddAbortStep(&TaskFileManipulation::StepAbortCreateExternalDir);
     }
@@ -406,5 +408,29 @@ void TaskFileManipulation::StepAbortCreateExternalDir()
     }
     WidgetInstallToExtSingleton::Instance().deinitialize();
 }
+
+void TaskFileManipulation::StepCreateSharedFolder()
+{
+    LogDebug("StepCreateSharedFolder");
+    std::string sharedPath = m_context.locations->getSharedRootDir();
+    LogDebug("Create shared directory : " <<
+            m_context.locations->getSharedRootDir());
+
+    WrtUtilMakeDir(sharedPath);
+
+    if (m_context.isUpdateMode) { //update
+        std::string backData = m_context.locations->getBackupSharedDir();
+        LogDebug("copy shared storage " << backData << " to " << sharedPath);
+        if (!DirectoryApi::DirectoryCopy(backData, sharedPath)) {
+            LogError("Failed to rename " << backData << " to " << sharedPath);
+            ThrowMsg(Exceptions::BackupFailed,
+                    "Error occurs copy shared strage files");
+        }
+    } else {
+        WrtUtilMakeDir(m_context.locations->getSharedResourceDir());
+        WrtUtilMakeDir(m_context.locations->getSharedDataDir());
+        WrtUtilMakeDir(m_context.locations->getSharedTrustedDir());
+    }
+}
 } //namespace WidgetInstall
 } //namespace Jobs
index 44b20f5..fc1d9ff 100644 (file)
@@ -39,6 +39,7 @@ class TaskFileManipulation :
     void StepCreateDirs();
     void StepRenamePath();
     void StepCreatePrivateStorageDir();
+    void StepCreateSharedFolder();
 
     void StepAbortRenamePath();
     void StepLinkForPreload();
index 69b7053..12af068 100644 (file)
@@ -71,6 +71,9 @@ void TaskUpdateFiles::StepBackupDirectory()
     LogDebug("backup resource directory path : " << backPath);
     std::string pkgPath = m_context.locations->getPackageInstallationDir();
 
+    if (0 == access(backPath.c_str(), F_OK)) {
+        WrtUtilRemove(backPath);
+    }
     LogDebug("copy : " << pkgPath << " to " << backPath);
     if ((rename(pkgPath.c_str(), backPath.c_str())) != 0) {
         LogError("Failed to rename " << pkgPath << " to " << backPath);
index 9e3f8c9..eb1a25e 100644 (file)
@@ -89,6 +89,7 @@ DECLARE_JOB_EXCEPTION(Base, AceCheckFailed, ErrorAceCheckFailed)
 DECLARE_JOB_EXCEPTION(Base, EncryptionFailed, ErrorEncryptionFailed)
 DECLARE_JOB_EXCEPTION(Base, InstallOspsvcFailed, ErrorInstallOspServcie)
 DECLARE_JOB_EXCEPTION(Base, PrivilegeLevelViolation, ErrorPrivilegeLevelViolation)
+DECLARE_JOB_EXCEPTION(Base, NotSupportRDSUpdate, ErrorNotSupportRDSUpdate)
 } //namespace
 } //namespace
 } //namespace
index adfbd44..a2905aa 100644 (file)
@@ -240,3 +240,29 @@ void WidgetLocation::registerAppid(const std::string & appid)
 {
     m_appid = appid;
 }
+
+std::string WidgetLocation::getSharedRootDir() const
+{
+    /* TODO : add wrt-commons*/
+    return getUserDataRootDir() + "/shared";
+}
+
+std::string WidgetLocation::getSharedResourceDir() const
+{
+    return getSharedRootDir() + "/res";
+}
+
+std::string WidgetLocation::getSharedDataDir() const
+{
+    return getSharedRootDir() + "/data";
+}
+
+std::string WidgetLocation::getSharedTrustedDir() const
+{
+    return getSharedRootDir() + "/trusted";
+}
+
+std::string WidgetLocation::getBackupSharedDir() const
+{
+    return getBackupDir() + "/shared";
+}
index 0cdcbdd..ad73d80 100644 (file)
@@ -124,6 +124,11 @@ class WidgetLocation
     std::string getBackupPrivateDir() const;  // /opt/apps/[pkg].backup/data
     std::string getUserDataRootDir() const; // /opt/usr/apps/[package]
     std::string getPrivateStorageDir() const; // /opt/usr/apps/[package]/data
+    std::string getSharedRootDir() const; // /opt/usr/apps/[package]/shared
+    std::string getSharedResourceDir() const; // /opt/usr/apps/[package]/shared/res
+    std::string getSharedDataDir() const; // /opt/usr/apps/[package]/shared/data
+    std::string getSharedTrustedDir() const; // /opt/usr/apps/[package]/shared/trusted
+    std::string getBackupSharedDir() const; // /opt/usr/apps/[package].backup/shared
 
     // Temporary paths
     /**