Fixed can not install to sdcard
[framework/web/wrt-installer.git] / src / jobs / widget_install / job_widget_install.cpp
index 9bfad48..692b458 100644 (file)
@@ -48,8 +48,6 @@
 #include <libiriwrapper.h>
 #include <pkg-manager/pkgmgr_signal.h>
 #include <app_manager.h>
-//#include <drm_client.h>
-#include <drm-oem-intel.h> //temporary code
 
 #include "root_parser.h"
 #include "widget_parser.h"
@@ -94,7 +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";
 const DPL::String SETTING_VALUE_INSTALLTOEXT_NAME =
-    L"install-location-type";
+    L"install-location";
 const DPL::String SETTING_VALUE_INSTALLTOEXT_PREPER_EXT =
     L"prefer-external";
 
@@ -291,7 +289,7 @@ ConfigureResult JobWidgetInstall::PrePareInstallation(
     Try
     {
         std::string tempDir =
-            Jobs::WidgetInstall::createTempPath(m_jobStruct.m_preload);
+            Jobs::WidgetInstall::createTempPath(m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_PRELOAD);
 
         m_isDRM = isDRMWidget(widgetPath);
         if (true == m_isDRM) {
@@ -564,13 +562,8 @@ ConfigureResult JobWidgetInstall::checkWidgetUpdate(
 
     m_installerContext.widgetConfig.tzAppid = update.tzAppId;
 
-    WidgetUpdateMode::Type updateTypeCheckBit;
-    updateTypeCheckBit = CalcWidgetUpdatePolicy(update.existingVersion,
-                                                update.incomingVersion);
-    // Calc proceed flag
-    if ((m_jobStruct.updateMode & updateTypeCheckBit) > 0 ||
-        m_jobStruct.updateMode ==
-        WidgetUpdateMode::PolicyDirectoryForceInstall)
+    if (isUpperVersion(update.existingVersion, update.incomingVersion) ||
+        m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_DIRECTORY)
     {
         LogInfo("Whether widget policy allow proceed ok");
         return ConfigureResult::Updated;
@@ -581,34 +574,29 @@ ConfigureResult JobWidgetInstall::checkWidgetUpdate(
     return ConfigureResult::Failed;
 }
 
-WidgetUpdateMode::Type JobWidgetInstall::CalcWidgetUpdatePolicy(
+bool JobWidgetInstall::isUpperVersion(
     const OptionalWidgetVersion &existingVersion,
-    const OptionalWidgetVersion &incomingVersion) const
+    const OptionalWidgetVersion &incomingVersion)
 {
-    // Widget is installed, check versions
+    LogInfo("Existing version = '" << *existingVersion);
+    LogInfo("Incoming version = '" << *incomingVersion);
+
     if (!existingVersion && !incomingVersion) {
-        return WidgetUpdateMode::ExistingVersionEqual;
+        return false;
     } else if (!existingVersion && !!incomingVersion) {
-        return WidgetUpdateMode::ExistingVersionNewer;
+        return false;
     } else if (!!existingVersion && !incomingVersion) {
-        return WidgetUpdateMode::ExistingVersionOlder;
+        return true;
     } else {
-        LogInfo("Existing widget: version = '" << *existingVersion << "'");
-
-        if (!existingVersion->IsWac() && !incomingVersion->IsWac()) {
-            return WidgetUpdateMode::BothVersionsNotStd;
-        } else if (!existingVersion->IsWac()) {
-            return WidgetUpdateMode::ExistingVersionNotStd;
-        } else if (!incomingVersion->IsWac()) {
-            return WidgetUpdateMode::IncomingVersionNotStd;
+        if (!existingVersion->IsWac() || !incomingVersion->IsWac()) {
+            return false;
         } else {
-            // Both versions are WAC-comparable. Do compare.
             if (*incomingVersion == *existingVersion) {
-                return WidgetUpdateMode::ExistingVersionEqual;
+                return false;
             } else if (*incomingVersion > *existingVersion) {
-                return WidgetUpdateMode::ExistingVersionOlder;
+                return true;
             } else {
-                return WidgetUpdateMode::ExistingVersionNewer;
+                return false;
             }
         }
     }
@@ -903,8 +891,7 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType(
     const std::string &tempPath)
 {
     // Check installation type (direcotory/ or config.xml or widget.wgt)
-    if (WidgetUpdateMode::PolicyDirectoryForceInstall ==
-        m_jobStruct.updateMode)
+    if (m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_DIRECTORY)
     {
         LogDebug("Install directly from directory");
         return PKG_TYPE_DIRECTORY_WEB_APP;
@@ -1041,7 +1028,7 @@ void JobWidgetInstall::setInstallLocationType(
 {
     m_installerContext.locationType = INSTALL_LOCATION_TYPE_NOMAL;
 
-    if (true == m_jobStruct.m_preload) {
+    if (m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_PRELOAD) {
         m_installerContext.locationType =
             INSTALL_LOCATION_TYPE_PRELOAD;
     } else {
@@ -1059,54 +1046,17 @@ void JobWidgetInstall::setInstallLocationType(
     }
 }
 
-bool JobWidgetInstall::isDRMWidget(std::string widgetPath)
+bool JobWidgetInstall::isDRMWidget(std::string /*widgetPath*/)
 {
-    /* TODO :
-     * drm_bool_type_e is_drm_file = DRM_UNKNOWN;
-     * int ret = -1;
-     *
-     * ret = drm_is_drm_file(widgetPath.c_str(), &is_drm_file);
-     * if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file) {
-     */
-
-    /* blow code temporary code for drm. */
-    int ret = drm_oem_intel_isDrmFile(const_cast<char*>(widgetPath.c_str()));
-    if (1 == ret) {
-        return true;
-    } else {
-        return false;
-    }
+    /* TODO */
+    return false;
 }
 
-bool JobWidgetInstall::DecryptDRMWidget(std::string widgetPath,
-                                        std::string destPath)
+bool JobWidgetInstall::DecryptDRMWidget(std::string /*widgetPath*/,
+                                        std::string /*destPath*/)
 {
-    /* TODO :
-     * drm_trusted_sapps_decrypt_package_info_s package_info;
-     *
-     * strncpy(package_info.sadcf_filepath, widgetPath.c_str(),
-     *      sizeof(package_info.sadcf_filepath));
-     * strncpy(package_info.decrypt_filepath, destPath.c_str(),
-     *      sizeof(package_info.decrypt_filepath));
-     *
-     * drm_trusted_request_type_e requestType =
-     *  DRM_TRUSTED_REQ_TYPE_SAPPS_DECRYPT_PACKAGE;
-     *
-     * int ret = drm_trusted_handle_request(requestType,
-     *                                   (void *)&package_info, NULL);
-     * if (DRM_TRUSTED_RETURN_SUCCESS == ret) {
-     *  return true;
-     * } else {
-     *  return false;
-     * }
-     */
-    if (drm_oem_intel_decrypt_package(const_cast<char*>(widgetPath.c_str()),
-                                      const_cast<char*>(destPath.c_str())) != 0)
-    {
-        return true;
-    } else {
-        return false;
-    }
+    /* TODO */ 
+    return false;
 }
 } //namespace WidgetInstall
 } //namespace Jobs