[Release] wrt-installer_0.1.90
[framework/web/wrt-installer.git] / src / jobs / widget_install / job_widget_install.cpp
index e2b2086..4bbfe02 100644 (file)
@@ -38,6 +38,7 @@
 #include <dpl/sstream.h>
 #include <dpl/file_input.h>
 #include <dpl/utils/wrt_utility.h>
+#include <dpl/utils/path.h>
 #include <dpl/wrt-dao-ro/common_dao_types.h>
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <dpl/wrt-dao-ro/global_config.h>
 #include <widget_install/task_remove_backup.h>
 #include <widget_install/task_encrypt_resource.h>
 #include <widget_install/task_certificates.h>
-#include <widget_install/task_unzip.h>
 #include <widget_install/task_commons.h>
 #include <widget_install/task_prepare_reinstall.h>
 
 #include <widget_install/widget_install_errors.h>
 #include <widget_install/widget_install_context.h>
 #include <widget_install_to_external.h>
+#include <widget_install/widget_unzip.h>
 
 using namespace WrtDB;
 using namespace Jobs::Exceptions;
@@ -82,6 +83,7 @@ namespace // anonymous
 {
 const char * const CONFIG_XML = "config.xml";
 const char * const WITH_OSP_XML = "res/wgt/config.xml";
+const char * const OSP_MANIFEST_XML = "info/manifest.xml";
 
 //allowed: a-z, A-Z, 0-9
 const char* REG_TIZENID_PATTERN = "^[a-zA-Z0-9]{10}.{1,}$";
@@ -90,6 +92,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 =
@@ -121,12 +124,15 @@ class InstallerTaskFail :
 
     void StepFail()
     {
-        if (m_result == ConfigureResult::Deferred) {
-            ThrowMsg(Jobs::WidgetInstall::Exceptions::Deferred,
-                    "widget installation or update deferred!");
-        } else if (m_result == ConfigureResult::Failed_InvalidConfig) {
+        if (m_result == ConfigureResult::Failed_InvalidConfig) {
             ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetConfigFileInvalid,
                     "invalid config");
+        } else if (m_result == ConfigureResult::Failed_OpenZipError) {
+            ThrowMsg(Jobs::WidgetInstall::Exceptions::OpenZipFailed,
+                    "can't open wgt file");
+        } else if (m_result == ConfigureResult::Failed_UnzipError) {
+            ThrowMsg(Jobs::WidgetInstall::Exceptions::ExtractFileFailed,
+                    "can't extract wgt file");
         } else if (m_result == ConfigureResult::Failed_LowerVersion) {
             ThrowMsg(Jobs::WidgetInstall::Exceptions::PackageLowerVersion,
                     "package version is lower than installed version");
@@ -137,8 +143,11 @@ class InstallerTaskFail :
             ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
                     "widget is running");
         } else if (m_result == ConfigureResult::Failed_DrmError) {
-            ThrowMsg(Jobs::WidgetInstall::Exceptions::DRMFailed,
+            ThrowMsg(Jobs::WidgetInstall::Exceptions::DrmDecryptFailed,
                     "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!");
@@ -162,9 +171,8 @@ JobWidgetInstall::JobWidgetInstall(
     JobContextBase<WidgetInstallationStruct>(installerStruct),
     m_exceptionCaught(Jobs::Exceptions::Success)
 {
-    m_installerContext.m_quiet = m_jobStruct.m_quiet;
-
-    ConfigureResult result = PrePareInstallation(widgetPath);
+    m_installerContext.mode = m_jobStruct.m_installMode;
+    ConfigureResult result = prepareInstallation(widgetPath);
 
     if (result == ConfigureResult::Ok) {
         LogInfo("Configure installation succeeded");
@@ -172,16 +180,6 @@ JobWidgetInstall::JobWidgetInstall(
 
         AddTask(new TaskRecovery(m_installerContext));
 
-        // Create installation tasks
-        if (m_installerContext.widgetConfig.packagingType !=
-            WrtDB::PKG_TYPE_DIRECTORY_WEB_APP &&
-            m_installerContext.widgetConfig.packagingType !=
-            WrtDB::PKG_TYPE_HOSTED_WEB_APP &&
-            !m_isDRM)
-        {
-            AddTask(new TaskUnzip(m_installerContext));
-        }
-
         AddTask(new TaskWidgetConfig(m_installerContext));
         if (m_installerContext.widgetConfig.packagingType ==
             WrtDB::PKG_TYPE_HOSTED_WEB_APP)
@@ -194,7 +192,6 @@ JobWidgetInstall::JobWidgetInstall(
         }
 
         AddTask(new TaskFileManipulation(m_installerContext));
-
         AddTask(new TaskManifestFile(m_installerContext));
         if (m_installerContext.widgetConfig.packagingType ==
             PKG_TYPE_HYBRID_WEB_APP)
@@ -210,21 +207,12 @@ JobWidgetInstall::JobWidgetInstall(
         LogInfo("Widget Update");
         m_installerContext.job->SetProgressFlag(true);
 
-        if (m_jobStruct.m_installMode ==
-            InstallMode::REINSTALL_MODE_DIRECTORY)
+        if (m_installerContext.mode.command ==
+            InstallMode::Command::REINSTALL)
         {
             AddTask(new TaskPrepareReinstall(m_installerContext));
         }
 
-        if (m_installerContext.widgetConfig.packagingType !=
-            WrtDB::PKG_TYPE_HOSTED_WEB_APP &&
-            m_installerContext.widgetConfig.packagingType !=
-            WrtDB::PKG_TYPE_DIRECTORY_WEB_APP &&
-            !m_isDRM)
-        {
-            AddTask(new TaskUnzip(m_installerContext));
-        }
-
         AddTask(new TaskWidgetConfig(m_installerContext));
 
         if (m_installerContext.widgetConfig.packagingType ==
@@ -238,10 +226,10 @@ JobWidgetInstall::JobWidgetInstall(
             AddTask(new TaskEncryptResource(m_installerContext));
         }
 
-        if (m_installerContext.widgetConfig.packagingType !=
-            WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
-        {
+        if (m_installerContext.mode.extension !=
+                InstallMode::ExtensionType::DIR) {
             AddTask(new TaskUpdateFiles(m_installerContext));
+            AddTask(new TaskFileManipulation(m_installerContext));
         }
 
         AddTask(new TaskManifestFile(m_installerContext));
@@ -250,34 +238,23 @@ JobWidgetInstall::JobWidgetInstall(
         {
             AddTask(new TaskInstallOspsvc(m_installerContext));
         }
-        if (m_installerContext.widgetConfig.packagingType !=
-            WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
-        {
-            AddTask(new TaskRemoveBackupFiles(m_installerContext));
-        }
+        AddTask(new TaskCertificates(m_installerContext));
         AddTask(new TaskDatabase(m_installerContext));
         AddTask(new TaskAceCheck(m_installerContext));
         //TODO: remove widgetHandle from this task and move before database task
         // by now widget handle is needed in ace check
         // Any error in acecheck while update will break widget
         AddTask(new TaskSmack(m_installerContext));
-    } else if (result == ConfigureResult::Deferred) {
-        // Installation is deferred
-        LogInfo("Configure installation deferred");
-
-        AddTask(new InstallerTaskFail(result));
-    } else if (result >= ConfigureResult::Failed &&
-            result <= ConfigureResult::Failed_DrmError) {
+        AddTask(new TaskRemoveBackupFiles(m_installerContext));
+    } else {
         // Installation is not allowed to proceed due to widget update policy
         LogWarning("Configure installation failed!");
 
         AddTask(new InstallerTaskFail(result));
-    } else {
-        Assert(false && "Invalid configure result!");
     }
 }
 
-ConfigureResult JobWidgetInstall::PrePareInstallation(
+ConfigureResult JobWidgetInstall::prepareInstallation(
     const std::string &widgetPath)
 {
     ConfigureResult result;
@@ -286,32 +263,29 @@ ConfigureResult JobWidgetInstall::PrePareInstallation(
     Try
     {
         std::string tempDir;
-        if (m_jobStruct.m_installMode ==
-            InstallMode::REINSTALL_MODE_DIRECTORY)
-        {
-            std::ostringstream tempPathBuilder;
-            tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
-            tempPathBuilder << WrtDB::GlobalConfig::GetTmpDirPath();
-            tempPathBuilder << "/";
-            tempPathBuilder << widgetPath;
-            tempDir = tempPathBuilder.str();;
+        if (m_installerContext.mode.extension == InstallMode::ExtensionType::DIR) {
+            if (m_installerContext.mode.command ==
+                    InstallMode::Command::REINSTALL) {
+                std::ostringstream tempPathBuilder;
+                tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
+                tempPathBuilder << WrtDB::GlobalConfig::GetTmpDirPath();
+                tempPathBuilder << "/";
+                tempPathBuilder << widgetPath;
+                tempDir = tempPathBuilder.str();;
+            } else {
+                tempDir = widgetPath;
+            }
         } else {
             tempDir =
                 Jobs::WidgetInstall::createTempPath(
-                        m_jobStruct.m_installMode ==
-                            InstallMode::INSTALL_MODE_PRELOAD);
-        }
-
-        m_isDRM = isDRMWidget(widgetPath);
-        if (true == m_isDRM) {
-            LogDebug("decrypt DRM widget");
-            if (DecryptDRMWidget(widgetPath, tempDir)) {
-                LogDebug("Failed decrypt DRM widget");
-                return ConfigureResult::Failed_DrmError;
-            }
+                        m_installerContext.mode.rootPath ==
+                            InstallMode::RootPath::RO);
+            WidgetUnzip wgtUnzip;
+            wgtUnzip.unzipWgtFile(widgetPath, tempDir);
         }
 
         LogDebug("widgetPath:" << widgetPath);
+        LogDebug("tempPath:" << tempDir);
 
         m_installerContext.widgetConfig.packagingType =
             checkPackageType(widgetPath, tempDir);
@@ -319,9 +293,7 @@ ConfigureResult JobWidgetInstall::PrePareInstallation(
                 widgetPath,
                 tempDir,
                 m_installerContext.widgetConfig.packagingType,
-                m_isDRM,
-                m_jobStruct.m_installMode ==
-                    InstallMode::REINSTALL_MODE_DIRECTORY);
+                m_installerContext.mode.command == InstallMode::Command::REINSTALL);
         LogDebug("widget packaging type : " <<
                  m_installerContext.widgetConfig.packagingType.pkgType);
 
@@ -333,9 +305,24 @@ ConfigureResult JobWidgetInstall::PrePareInstallation(
         // Configure installation
         result = ConfigureInstallation(widgetPath, configData, tempDir);
     }
+    Catch(Exceptions::OpenZipFailed)
+    {
+        LogError("Failed to unzip for widget");
+        result = ConfigureResult::Failed_OpenZipError;
+    }
     Catch(Exceptions::ExtractFileFailed)
     {
-        LogError("Failed to create temporary path for widget");
+        LogError("Failed to unzip for widget");
+        result = ConfigureResult::Failed_UnzipError;
+    }
+    Catch(Exceptions::DrmDecryptFailed)
+    {
+        LogError("Failed to unzip for widget");
+        result = ConfigureResult::Failed_DrmError;
+    }
+    Catch(Exceptions::MissingConfig)
+    {
+        LogError("Failed to localize config.xml");
         result = ConfigureResult::Failed_InvalidConfig;
     }
 
@@ -449,24 +436,14 @@ void JobWidgetInstall::setTizenId(
 void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath,
                                                const std::string& tempPath)
 {
-    if (m_jobStruct.m_installMode ==
-         InstallMode::REINSTALL_MODE_DIRECTORY)
-    {
-        // replace widget path to installed path
-        m_installerContext.locations =
-            WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig.
-                                                 tzPkgid),
-                           widgetPath, tempPath,
-                           m_installerContext.widgetConfig.packagingType,
-                           m_installerContext.locationType);
-    } else {
-        m_installerContext.locations =
-            WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig.
-                                                 tzPkgid),
-                           widgetPath, tempPath,
-                           m_installerContext.widgetConfig.packagingType,
-                           m_installerContext.locationType);
-    }
+    m_installerContext.locations =
+        WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig.
+                                             tzPkgid),
+                       widgetPath, tempPath,
+                       m_installerContext.widgetConfig.packagingType,
+                       m_installerContext.mode.rootPath ==
+                           InstallMode::RootPath::RO,
+                           m_installerContext.mode.extension);
     m_installerContext.locations->registerAppid(
         DPL::ToUTF8String(m_installerContext.widgetConfig.tzAppid));
 
@@ -497,6 +474,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) {
@@ -556,13 +536,9 @@ bool JobWidgetInstall::validateTizenPackageID(
     std::string installPath =
         std::string(GlobalConfig::GetUserInstalledWidgetPath()) +
         "/" + pkgId;
-    std::string preinstallPath =
-        std::string(GlobalConfig::GetUserPreloadedWidgetPath()) +
-        "/" + pkgId;
 
     struct stat dirStat;
-    if ((stat(installPath.c_str(), &dirStat) == 0) ||
-        (stat(preinstallPath.c_str(), &dirStat) == 0))
+    if ((stat(installPath.c_str(), &dirStat) == 0))
     {
         return false;
     }
@@ -572,13 +548,14 @@ bool JobWidgetInstall::validateTizenPackageID(
 ConfigureResult JobWidgetInstall::checkWidgetUpdate(
     const WidgetUpdateInfo &update)
 {
-    LogInfo("incoming version = '" << update.incomingVersion);
-    LogInfo("Tizen AppID = " << update.tzAppId);
-
     if (update.existingVersion.IsNull() || update.incomingVersion.IsNull()) {
         return ConfigureResult::Failed;
     }
 
+    LogInfo("existing version = '" << update.existingVersion);
+    LogInfo("incoming version = '" << update.incomingVersion);
+    LogInfo("Tizen AppID = " << update.tzAppId);
+
     // Check running state
     bool isRunning = false;
     int ret =
@@ -639,58 +616,24 @@ ConfigureResult JobWidgetInstall::checkWidgetUpdate(
 
     m_installerContext.widgetConfig.tzAppid = update.tzAppId;
 
-    if (isUpperVersion(update.existingVersion, update.incomingVersion) ||
-        (m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_DIRECTORY) ||
-        (m_jobStruct.m_installMode == InstallMode::REINSTALL_MODE_DIRECTORY))
-    {
-        LogInfo("Whether widget policy allow proceed ok");
+    if (!!update.existingVersion ||
+            m_installerContext.mode.extension ==
+            InstallMode::ExtensionType::DIR) {
         return ConfigureResult::Updated;
-    } else {
-        return ConfigureResult::Failed_LowerVersion;
     }
 
     return ConfigureResult::Failed;
 }
 
-bool JobWidgetInstall::isUpperVersion(
-    const OptionalWidgetVersion &existingVersion,
-    const OptionalWidgetVersion &incomingVersion)
-{
-    LogInfo("Existing version = '" << *existingVersion);
-    LogInfo("Incoming version = '" << *incomingVersion);
-
-    if (!existingVersion && !incomingVersion) {
-        return false;
-    } else if (!existingVersion && !!incomingVersion) {
-        return false;
-    } else if (!!existingVersion && !incomingVersion) {
-        return true;
-    } else {
-        if (!existingVersion->IsWac() || !incomingVersion->IsWac()) {
-            return false;
-        } else {
-            if (*incomingVersion == *existingVersion) {
-                return false;
-            } else if (*incomingVersion > *existingVersion) {
-                return true;
-            } else {
-                return false;
-            }
-        }
-    }
-}
-
 ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
     const std::string &widgetSource,
     const std::string &tempPath,
     WrtDB::PackagingType pkgType,
-    bool isDRM,
     bool isReinstall)
 {
     // Parse config
     ParserRunner parser;
     ConfigParserData configInfo;
-
     Try
     {
         if (pkgType == PKG_TYPE_HOSTED_WEB_APP) {
@@ -699,101 +642,53 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
                              new RootParser<WidgetParser>(configInfo,
                                                           DPL::FromUTF32String(
                                                               L"widget"))));
-        } else if (pkgType == PKG_TYPE_DIRECTORY_WEB_APP) {
-            std::string configPath;
-            configPath = tempPath;
-            configPath += "/";
-            configPath += WITH_OSP_XML;
+        } else {
+            std::string configFile;
+            configFile = tempPath + "/" + CONFIG_XML;
+            if (!WrtUtilFileExists(configFile)) {
+                configFile = tempPath + "/" + WITH_OSP_XML;
+            }
 
             if (isReinstall) {
                 // checking RDS data directory
-                if (access(configPath.c_str(), F_OK) != 0) {
+                if (access(configFile.c_str(), F_OK) != 0) {
                     std::string tzAppId =
                         widgetSource.substr(widgetSource.find_last_of("/")+1);
                     WidgetDAOReadOnly dao(WidgetDAOReadOnly::getTzAppId(DPL::FromUTF8String(tzAppId)));
-                    configPath = DPL::ToUTF8String(*dao.getWidgetInstalledPath());
-                    configPath += "/";
-                    configPath += WITH_OSP_XML;
+                    configFile = DPL::ToUTF8String(*dao.getWidgetInstalledPath());
+                    configFile += "/";
+                    configFile += WITH_OSP_XML;
                 }
             }
-            parser.Parse(configPath,
-                         ElementParserPtr(
-                             new RootParser<WidgetParser>(
-                                 configInfo,
-                                 DPL::FromUTF32String(L"widget"))));
-        } else {
-            if (!isDRM) {
-                std::unique_ptr<DPL::ZipInput> zipFile(
-                    new DPL::ZipInput(widgetSource));
-
-                std::unique_ptr<DPL::ZipInput::File> configFile;
-
-                // Open config.xml file
-                if (pkgType == PKG_TYPE_HYBRID_WEB_APP) {
-                    configFile.reset(zipFile->OpenFile(WITH_OSP_XML));
-                } else {
-                    configFile.reset(zipFile->OpenFile(CONFIG_XML));
-                }
-
-                // Extract config
-                DPL::BinaryQueue buffer;
-                DPL::AbstractWaitableInputAdapter inputAdapter(configFile.get());
-                DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
-                DPL::Copy(&inputAdapter, &outputAdapter);
-                parser.Parse(&buffer,
-                             ElementParserPtr(
-                                 new RootParser<WidgetParser>(configInfo,
-                                                              DPL::
-                                                                  FromUTF32String(
-                                                                  L"widget"))));
-            } else {
-                // DRM widget
-                std::string configFile;
-                if (pkgType == PKG_TYPE_HYBRID_WEB_APP) {
-                    configFile = tempPath + "/" + WITH_OSP_XML;
-                } else {
-                    configFile = tempPath + "/" + CONFIG_XML;
-                }
 
-                parser.Parse(configFile,
-                             ElementParserPtr(
-                                 new RootParser<WidgetParser>(configInfo,
-                                                              DPL::
-                                                                  FromUTF32String(
-                                                                  L"widget"))));
+            if(!DPL::Utils::Path(configFile).Exists())
+            {
+                ThrowMsg(Exceptions::MissingConfig, "Config file not exists");
             }
+
+            parser.Parse(configFile,
+                    ElementParserPtr(
+                        new RootParser<WidgetParser>(configInfo,
+                            DPL::
+                            FromUTF32String(
+                                L"widget"))));
         }
     }
-    Catch(DPL::ZipInput::Exception::OpenFailed)
-    {
-        LogError("Failed to open widget package");
-        return ConfigParserData();
-    }
-    Catch(DPL::ZipInput::Exception::OpenFileFailed)
-    {
-        LogError("Failed to open config.xml file");
-        return ConfigParserData();
-    }
-    Catch(DPL::CopyFailed)
-    {
-        LogError("Failed to extract config.xml file");
-        return ConfigParserData();
-    }
-    Catch(DPL::FileInput::Exception::OpenFailed)
-    {
-        LogError("Failed to open config.xml file");
-        return ConfigParserData();
-    }
     Catch(ElementParser::Exception::ParseError)
     {
         LogError("Failed to parse config.xml file");
         return ConfigParserData();
     }
-    Catch(DPL::ZipInput::Exception::SeekFileFailed)
+    Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
     {
-        LogError("Failed to seek widget archive - corrupted package?");
+        LogError("Failed to find installed widget - give proper tizenId");
+        return ConfigParserData();
+    }
+    Catch(Exceptions::WidgetConfigFileNotFound){
+        LogError("Failed to find config.xml");
         return ConfigParserData();
     }
+
     return configInfo;
 }
 
@@ -992,75 +887,17 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType(
     const std::string &widgetSource,
     const std::string &tempPath)
 {
-    // Check installation type (direcotory/ or config.xml or widget.wgt)
-    if (m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_DIRECTORY ||
-         m_jobStruct.m_installMode == InstallMode::REINSTALL_MODE_DIRECTORY)
-    {
-        LogDebug("Install directly from directory");
-        return PKG_TYPE_DIRECTORY_WEB_APP;
-    }
     if (hasExtension(widgetSource, XML_EXTENSION)) {
         LogInfo("Hosted app installation");
         return PKG_TYPE_HOSTED_WEB_APP;
     }
 
-    if (m_isDRM) {
-        std::string configFile = tempPath + "/" + CONFIG_XML;
-        if (WrtUtilFileExists(configFile)) {
-            return PKG_TYPE_NOMAL_WEB_APP;
-        }
-
-        configFile = tempPath + "/" + WITH_OSP_XML;
-        if (WrtUtilFileExists(configFile)) {
-            return PKG_TYPE_HYBRID_WEB_APP;
-        }
-    } else {
-        std::unique_ptr<DPL::ZipInput> zipFile;
-
-        Try
-        {
-            // Open zip file
-            zipFile.reset(new DPL::ZipInput(widgetSource));
-        }
-        Catch(DPL::ZipInput::Exception::OpenFailed)
-        {
-            LogDebug("Failed to open widget package");
-            return PKG_TYPE_UNKNOWN;
-        }
-        Catch(DPL::ZipInput::Exception::SeekFileFailed)
-        {
-            LogError("Failed to seek widget package file");
-            return PKG_TYPE_UNKNOWN;
-        }
-
-        Try
-        {
-            // Open config.xml file in package root
-            std::unique_ptr<DPL::ZipInput::File> configFile(
-                zipFile->OpenFile(CONFIG_XML));
-            return PKG_TYPE_NOMAL_WEB_APP;
-        }
-        Catch(DPL::ZipInput::Exception::OpenFileFailed)
-        {
-            LogDebug("Could not find config.xml");
-        }
-
-        Try
-        {
-            // Open config.xml file in package root
-            std::unique_ptr<DPL::ZipInput::File> configFile(
-                zipFile->OpenFile(WITH_OSP_XML));
-
-            return PKG_TYPE_HYBRID_WEB_APP;
-        }
-        Catch(DPL::ZipInput::Exception::OpenFileFailed)
-        {
-            LogDebug("Could not find wgt/config.xml");
-            return PKG_TYPE_UNKNOWN;
-        }
+    std::string configFile = tempPath + "/" + OSP_MANIFEST_XML;
+    if (WrtUtilFileExists(configFile)) {
+        return PKG_TYPE_HYBRID_WEB_APP;
     }
 
-    return PKG_TYPE_UNKNOWN;
+    return PKG_TYPE_NOMAL_WEB_APP;
 }
 
 void JobWidgetInstall::setApplicationType(
@@ -1125,18 +962,11 @@ bool JobWidgetInstall::detectResourceEncryption(
 }
 
 void JobWidgetInstall::setInstallLocationType(
-    const
-    WrtDB::ConfigParserData &
-    configData)
+    const WrtDB::ConfigParserData & configData)
 {
     m_installerContext.locationType = INSTALL_LOCATION_TYPE_NOMAL;
-
-    if (m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_PRELOAD) {
-        m_installerContext.locationType =
-            INSTALL_LOCATION_TYPE_PRELOAD;
-    } else {
-        FOREACH(it, configData.settingsList)
-        {
+    if (m_installerContext.mode.installTime != InstallMode::InstallTime::PRELOAD) {
+        FOREACH(it, configData.settingsList) {
             if (it->m_name == SETTING_VALUE_INSTALLTOEXT_NAME &&
                 it->m_value ==
                 SETTING_VALUE_INSTALLTOEXT_PREPER_EXT)
@@ -1149,17 +979,39 @@ void JobWidgetInstall::setInstallLocationType(
     }
 }
 
-bool JobWidgetInstall::isDRMWidget(std::string /*widgetPath*/)
+bool JobWidgetInstall::checkSupportRDSUpdate(const WrtDB::ConfigParserData
+        &configInfo)
 {
-    /* TODO */
-    return false;
-}
+    if (m_installerContext.mode.command ==
+            InstallMode::Command::REINSTALL)
+    {
+        DPL::String configValue = SETTING_VALUE_ENCRYPTION_DISABLE;
+        DPL::String dbValue = SETTING_VALUE_ENCRYPTION_DISABLE;
 
-bool JobWidgetInstall::DecryptDRMWidget(std::string /*widgetPath*/,
-                                        std::string /*destPath*/)
-{
-    /* TODO */
-    return false;
+        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