[Release] wrt-installer_0.1.98 submit/tizen_2.2/20130714.154914
authorsung-su.kim <sung-su.kim@samsung.com>
Fri, 12 Jul 2013 04:20:31 +0000 (13:20 +0900)
committersung-su.kim <sung-su.kim@samsung.com>
Fri, 12 Jul 2013 04:20:51 +0000 (13:20 +0900)
Change-Id: I3e1e421508a0cae124c6a66ab13322d63dcecc62

15 files changed:
packaging/wrt-installer.spec
src/configuration_parser/widget_parser.cpp
src/configuration_parser/widget_parser.h
src/jobs/widget_install/ace_registration.cpp
src/jobs/widget_install/job_widget_install.cpp
src/jobs/widget_install/task_certify.cpp
src/jobs/widget_install/task_manifest_file.cpp
src/jobs/widget_install/task_manifest_file.h
src/jobs/widget_install/task_prepare_reinstall.cpp
src/jobs/widget_install/task_smack.cpp
src/jobs/widget_install/task_widget_config.cpp
src/jobs/widget_install/widget_install_errors.h
src/jobs/widget_install/widget_unzip.cpp
src/jobs/widget_install/widget_unzip.h
src/misc/widget_location.cpp

index 6a6c8b4..f1744bc 100644 (file)
@@ -1,7 +1,7 @@
 #git:framework/web/wrt-installer
 Name:       wrt-installer
 Summary:    Installer for tizen Webruntime
-Version:    0.1.97
+Version:    0.1.98
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
index 00c9fc3..c002eb1 100644 (file)
@@ -821,83 +821,6 @@ class PreferenceParser : public ElementParser
     ConfigParserData& m_data;
 };
 
-class LinkParser : public ElementParser
-{
-  public:
-    virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
-                                        const DPL::String& /*name*/)
-    {
-        return &DenyAllParser::Create;
-    }
-
-    virtual void Accept(const XmlAttribute& attribute)
-    {
-        if (m_properNamespace) {
-            LogDebug("attribute");
-            if (attribute.name == L"rel") {
-                if (attribute.value != L"describedby") {
-                    ThrowMsg(Exception::ParseError,
-                             "rel attribute must have describedby value");
-                }
-            } else if (attribute.name == L"type") {} else if (attribute.name ==
-                                                              L"href")
-            {
-                LogDebug("here is href");
-                m_href = attribute.value;
-            } else {
-                ThrowMsg(Exception::ParseError,
-                         "unknown attribute '" +
-                         DPL::ToUTF8String(attribute.name) +
-                         "' in link element");
-            }
-        }
-    }
-
-    virtual void Accept(const Element& element)
-    {
-        if (element.ns ==
-            ConfigurationNamespace::WacWidgetNamespaceNameForLinkElement)
-        {
-            m_properNamespace = true;
-        }
-        LogDebug("element");
-    }
-
-    virtual void Accept(const Text&)
-    {
-        if (m_properNamespace) {
-            LogDebug("text");
-            ThrowMsg(Exception::ParseError, "link element must be empty");
-        }
-    }
-
-    virtual void Verify()
-    {
-        if (!m_href) {
-            ThrowMsg(Exception::ParseError,
-                     "link element must have href attribute");
-        }
-
-        LibIri::Wrapper iri(DPL::ToUTF8String(*m_href).c_str());
-        if (!iri.Validate()) { // TODO: Better uri validator ?
-            ThrowMsg(Exception::ParseError,
-                     "href attribute must be a valid iri/uri/url");
-        }
-    }
-
-    LinkParser(ConfigParserData& data) :
-        ElementParser(),
-        m_properNamespace(false),
-        m_data(data),
-        m_href(DPL::OptionalString::Null)
-    {}
-
-  private:
-    bool m_properNamespace;
-    ConfigParserData& m_data;
-    DPL::OptionalString m_href;
-};
-
 class SettingParser : public ElementParser
 {
   public:
@@ -2687,7 +2610,6 @@ WidgetParser::WidgetParser(ConfigParserData& data) :
         DPL::MakeDelegate(this, &WidgetParser::OnContentElement);
     m_map[L"preference"] =
         DPL::MakeDelegate(this, &WidgetParser::OnPreferenceElement);
-    m_map[L"link"] = DPL::MakeDelegate(this, &WidgetParser::OnLinkElement);
     m_map[L"setting"] =
         DPL::MakeDelegate(this, &WidgetParser::OnSettingElement);
     m_map[L"application"] = DPL::MakeDelegate(
@@ -2764,11 +2686,6 @@ ElementParserPtr WidgetParser::OnPreferenceElement()
     return ElementParserPtr(new PreferenceParser(m_data));
 }
 
-ElementParserPtr WidgetParser::OnLinkElement()
-{
-    return ElementParserPtr(new LinkParser(m_data));
-}
-
 ElementParserPtr WidgetParser::OnSettingElement()
 {
     return ElementParserPtr(new SettingParser(m_data));
index b56e89a..f59b725 100644 (file)
 namespace ConfigurationNamespace {
 static const DPL::String W3CWidgetNamespaceName =
     L"http://www.w3.org/ns/widgets";
-static const DPL::String WacWidgetNamespaceNameForLinkElement =
-    L"http://wacapps.net/ns/widgets#";
-static const DPL::String WacWidgetNamespaceName =
-    L"http://wacapps.net/ns/widgets";
 static const DPL::String TizenWebAppNamespaceName =
     L"http://tizen.org/ns/widgets";
 }
 
 namespace PluginsPrefix {
 const char * const W3CPluginsPrefix = "http://www.w3.org/";
-const char * const WACPluginsPrefix = "http://wacapps.net/api/";
 const char * const TIZENPluginsPrefix = "http://tizen.org/api/";
 }
 
@@ -72,7 +67,6 @@ class WidgetParser : public ElementParser
     ElementParserPtr OnContentElement();
     ElementParserPtr OnPreferenceElement();
     ElementParserPtr OnAccessElement();
-    ElementParserPtr OnLinkElement();
     ElementParserPtr OnSettingElement();
     ElementParserPtr OnApplicationElement();
     ElementParserPtr OnSplashElement();
index ac266d1..b028ba5 100644 (file)
@@ -52,12 +52,8 @@ bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle,
 {
     LogDebug("Updating Ace database");
     struct widget_info wi;
-    DPL::OptionalString os;
 
     switch (widgetConfig.webAppType.appType) {
-    case WrtDB::APP_TYPE_WAC20:
-        wi.type = WAC20;
-        break;
     case WrtDB::APP_TYPE_TIZENWEBAPP:
         wi.type = Tizen;
         break;
@@ -149,9 +145,7 @@ bool registerAceWidgetFromDB(const WrtDB::DbWidgetHandle& widgetHandle)
         WidgetDAOReadOnly dao(widgetHandle);
 
         WidgetType type = dao.getWidgetType();
-        if (type == WrtDB::APP_TYPE_WAC20) {
-            wi.type = WAC20;
-        } else if (type == WrtDB::APP_TYPE_TIZENWEBAPP) {
+        if (type == WrtDB::APP_TYPE_TIZENWEBAPP) {
             wi.type = Tizen;
         } else {
             LogError("Unknown application type");
index 70cca13..c77fcf3 100644 (file)
@@ -926,20 +926,6 @@ void JobWidgetInstall::setApplicationType(
                          "Config.xml has more than one valid namespace");
             }
             widgetAppType = APP_TYPE_TIZENWEBAPP;
-        } else if (
-            *iterator ==
-            ConfigurationNamespace::WacWidgetNamespaceNameForLinkElement ||
-            *iterator ==
-            ConfigurationNamespace::WacWidgetNamespaceName)
-        {
-            if (widgetAppType != APP_TYPE_UNKNOWN &&
-                widgetAppType != APP_TYPE_WAC20)
-            {
-                LogError("To many namespaces declared in configuration fileB.");
-                ThrowMsg(Exceptions::WidgetConfigFileInvalid,
-                         "Config.xml has more than one valid namespace");
-            }
-            widgetAppType = APP_TYPE_WAC20;
         } else {
             LogDebug("Namespace ignored.");
         }
index 2b3d81d..e5d1533 100644 (file)
@@ -241,8 +241,6 @@ void TaskCertify::stepSignature()
     SignatureFileInfoSet::reverse_iterator iter = signatureFiles.rbegin();
     LogInfo("Number of signatures: " << signatureFiles.size());
 
-    bool complianceMode = GlobalDAOReadOnly::getComplianceMode();
-
     for (; iter != signatureFiles.rend(); ++iter) {
         LogInfo("Checking signature with id=" << iter->getFileNumber());
         SignatureData data(widgetPath + iter->getFileName(),
@@ -253,24 +251,15 @@ void TaskCertify::stepSignature()
             xml.initialize(data, GlobalConfig::GetSignatureXmlSchema());
             xml.read(data);
 
-            WrtSignatureValidator::AppType appType =
-                WrtSignatureValidator::WAC20;
-
-            if (m_contextData.widgetConfig.webAppType ==
-                APP_TYPE_TIZENWEBAPP)
-            {
-                appType = WrtSignatureValidator::TIZEN;
-            }
-
             WrtSignatureValidator::Result result;
 
             WrtSignatureValidator validator(
-                    appType,
+                    WrtSignatureValidator::TIZEN,
                     !GlobalSettings::
                     OCSPTestModeEnabled(),
                     !GlobalSettings::
                     CrlTestModeEnabled(),
-                    complianceMode);
+                    false);
 
             result = validator.check(data, widgetPath);
 
index 99b34a1..b4eb7db 100755 (executable)
@@ -54,6 +54,7 @@
 #include <dpl/localization/LanguageTagsProvider.h>
 
 #define DEFAULT_ICON_NAME   "icon.png"
+#define DEFAULT_PREVIEW_NAME   "preview.png"
 
 using namespace WrtDB;
 
@@ -323,16 +324,13 @@ void TaskManifestFile::stepCopyLiveboxFiles()
             if (preview.empty()) {
                 continue;
             }
-            // copy preview image to shared directory
             sourceFile << m_context.locations->getSourceDir() << "/";
             sourceFile << preview;
             targetFile << m_context.locations->getSharedDataDir() << "/";
             targetFile << (**boxIt).m_liveboxId << ".";
-            targetFile << DPL::ToUTF8String((*sizeIt).m_size) << ".preview.png";
+            targetFile << DPL::ToUTF8String((*sizeIt).m_size) << "." << DEFAULT_PREVIEW_NAME;
 
-            DPL::FileInput input(sourceFile.str());
-            DPL::FileOutput output(targetFile.str());
-            DPL::Copy(&input, &output);
+            DynamicBoxFileCopy(sourceFile.str(), targetFile.str());
 
             // clear stream objects
             sourceFile.str("");
@@ -343,26 +341,39 @@ void TaskManifestFile::stepCopyLiveboxFiles()
         if (icon.empty()) {
             continue;
         }
-        // copy icon to shared directory
         sourceFile << m_context.locations->getSourceDir() << "/";
         sourceFile << icon;
         targetFile << m_context.locations->getSharedDataDir() << "/";
-        targetFile << (**boxIt).m_liveboxId << ".icon.png";
+        targetFile << (**boxIt).m_liveboxId << "." << DEFAULT_ICON_NAME;
 
-        DPL::FileInput input(sourceFile.str());
-        DPL::FileOutput output(targetFile.str());
-        DPL::Copy(&input, &output);
+        DynamicBoxFileCopy(sourceFile.str(), targetFile.str());
 
         // clear stream objects
         sourceFile.str("");
         targetFile.str("");
     }
-
     m_context.job->UpdateProgress(
         InstallerContext::INSTALL_COPY_LIVEBOX_FILES,
         "Livebox files copy Finished");
 }
 
+void TaskManifestFile::DynamicBoxFileCopy(const std::string& sourceFile,
+                                          const std::string& targetFile)
+{
+    Try
+    {
+        DPL::FileInput input(sourceFile);
+        DPL::FileOutput output(targetFile);
+        DPL::Copy(&input, &output);
+    }
+    Catch(DPL::Exception)
+    {
+        LogError("Copying Dynamic Box File Failed. " << sourceFile
+                                                     << " to " << targetFile);
+        ReThrowMsg(Exceptions::DynamicBoxFailed, "Dynamic Box File Copy Failed.");
+    }
+}
+
 void TaskManifestFile::stepBackupIconFiles()
 {
     LogDebug("Backup Icon Files");
index efb1881..4bcc3b3 100644 (file)
@@ -120,6 +120,8 @@ class TaskManifestFile :
                             const DPL::OptionalString& tag,
                             const DPL::String& language,
                             bool & defaultIconSaved);
+    void DynamicBoxFileCopy(const std::string& sourceFile,
+                            const std::string& targetFile);
 
     //for widget update
     void backupIconFiles();
index 20a209c..772375a 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <stdio.h>
 #include <fstream>
+#include <unistd.h>
 
 #include <dpl/task.h>
 #include <dpl/string.h>
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
index 7834597..2be933c 100644 (file)
@@ -593,9 +593,6 @@ bool TaskWidgetConfig::isFeatureAllowed(WrtDB::AppType appType,
     if (strstr(feature, PluginsPrefix::TIZENPluginsPrefix) == feature) {
         // Tizen WebApp feature
         featureType = APP_TYPE_TIZENWEBAPP;
-    } else if (strstr(feature, PluginsPrefix::WACPluginsPrefix) == feature) {
-        // WAC 2.0 feature
-        featureType = APP_TYPE_WAC20;
     } else if (strstr(feature, PluginsPrefix::W3CPluginsPrefix) == feature) {
         // W3C standard feature
         // Both WAC and TIZEN WebApp are possible to use W3C plugins
@@ -666,8 +663,6 @@ bool TaskWidgetConfig::isMinVersionCompatible(
     std::string version;
     if (appType == WrtDB::AppType::APP_TYPE_TIZENWEBAPP) {
         version = WrtDB::GlobalConfig::GetTizenVersion();
-    } else if (appType == WrtDB::AppType::APP_TYPE_WAC20) {
-        version = WrtDB::GlobalConfig::GetWACVersion();
     } else {
         LogWarning("Invaild AppType");
         return false;
index 89be530..3ef2a79 100644 (file)
@@ -75,6 +75,7 @@ DECLARE_JOB_EXCEPTION(Base, RemovingFolderFailure, ErrorFatalError)
 DECLARE_JOB_EXCEPTION(Base, RemovingFileFailure, ErrorFatalError)
 DECLARE_JOB_EXCEPTION(Base, CreateVconfFailure, ErrorFatalError)
 DECLARE_JOB_EXCEPTION(Base, CopyIconFailed, ErrorFatalError)
+DECLARE_JOB_EXCEPTION(Base, DynamicBoxFailed, ErrorFatalError)
 DECLARE_JOB_EXCEPTION(Base, FileOperationFailed, ErrorFatalError)
 DECLARE_JOB_EXCEPTION(Base, InstallToExternalFailed, ErrorFatalError)
 DECLARE_JOB_EXCEPTION(Base, BackupFailed, ErrorFatalError)
index df96243..5605ec2 100644 (file)
 #include <dpl/wrt-dao-ro/global_config.h>
 #include <task_commons.h>
 #include <sys/stat.h>
+#include <dlfcn.h>
 
 using namespace WrtDB;
 
 namespace {
+const char *const DRM_LIB_PATH = "/usr/lib/libdrm-service-core-tizen.so";
+
 struct PathAndFilePair
 {
     std::string path;
@@ -145,10 +148,95 @@ void WidgetUnzip::unzipProgress(const std::string &destination)
     }
 }
 
-std::string WidgetUnzip::decryptDrmPackage(const std::string &source)
+bool WidgetUnzip::isDRMPackage(const std::string &source)
+{
+    LogDebug("Enter : isDRMPackage()");
+    int ret = 0;
+    void* pHandle = NULL;
+    char* pErrorMsg = NULL;
+    int (*drm_oem_sapps_is_drm_file)(const char* pDcfPath, int dcfPathLen);
+
+    pHandle = dlopen(DRM_LIB_PATH, RTLD_LAZY | RTLD_GLOBAL);
+    if (!pHandle) {
+        LogError("dlopen failed : " << source << " [" << dlerror() << "]");
+        return false;
+    }
+
+    drm_oem_sapps_is_drm_file = reinterpret_cast <int (*)(const char*, int)>
+        (dlsym(pHandle, "drm_oem_sapps_is_drm_file"));
+    pErrorMsg = dlerror();
+    if ((pErrorMsg != NULL) || (drm_oem_sapps_is_drm_file == NULL)) {
+        LogError("dlopen failed : " << source << " [" << dlerror() << "]");
+        dlclose(pHandle);
+        return false;
+    }
+
+    ret = drm_oem_sapps_is_drm_file(source.c_str(), source.length());
+    dlclose(pHandle);
+    if (1 == ret) {
+        LogInfo(source << " is DRM file");
+        return true;
+    }
+    LogInfo(source << " isn't DRM file");
+    return false;
+}
+
+bool WidgetUnzip::decryptDRMPackage(const std::string &source, const std::string
+        &decryptedSource)
+{
+    LogDebug("Enter : decryptDRMPackage()");
+    int ret = 0;
+    void* pHandle = NULL;
+    char* pErrorMsg = NULL;
+    int (*drm_oem_sapps_decrypt_package)(const char* pDcfPath, int dcfPathLen,
+            const char* pDecryptedFile, int decryptedFileLen);
+
+    pHandle = dlopen(DRM_LIB_PATH, RTLD_LAZY | RTLD_GLOBAL);
+    if (!pHandle) {
+        LogError("dlopen failed : " << source << " [" << dlerror() << "]");
+        return false;
+    }
+
+    drm_oem_sapps_decrypt_package = reinterpret_cast <int (*)(const char*, int,
+            const char*, int)>
+        (dlsym(pHandle, "drm_oem_sapps_decrypt_package"));
+    pErrorMsg = dlerror();
+    if ((pErrorMsg != NULL) || (drm_oem_sapps_decrypt_package == NULL)) {
+        LogError("dlopen failed : " << source << " [" << dlerror() << "]");
+        dlclose(pHandle);
+        return false;
+    }
+
+    ret = drm_oem_sapps_decrypt_package(source.c_str(), source.length(),
+            decryptedSource.c_str(), decryptedSource.length());
+    dlclose(pHandle);
+    if (1 == ret) {
+        LogInfo(source << " is decrypted : " << decryptedSource);
+        return true;
+    }
+    return false;
+}
+
+std::string WidgetUnzip::getDecryptedPackage(const std::string &source)
 {
     LogInfo("Check DRM...");
-    // TODO : check drm
+    if (isDRMPackage(source)) {
+        std::string decryptedFile;
+        size_t found = source.find_last_of(".wgt");
+        if (found == std::string::npos) {
+            decryptedFile += source + "_tmp.wgt";
+        } else {
+            decryptedFile += source.substr(0, source.find_last_not_of(".wgt") +
+                    1) + "_tmp.wgt";
+        }
+
+        LogDebug("decrypted file name : " << decryptedFile);
+        if (decryptDRMPackage(source, decryptedFile)) {
+            LogError("Failed decrypt drm file");
+            ThrowMsg(Exceptions::DrmDecryptFailed, source);
+        }
+        return decryptedFile;
+    }
     return source;
 }
 
@@ -158,7 +246,7 @@ void WidgetUnzip::unzipWgtFile(const std::string &source, const std::string &des
     std::string wgtFile;
     Try
     {
-        wgtFile = decryptDrmPackage(source);
+        wgtFile = getDecryptedPackage(source);
         LogDebug("wgtFile : " << wgtFile);
 
         m_zip.reset(new DPL::ZipInput(wgtFile));
index 77a0b57..25e1293 100644 (file)
@@ -41,7 +41,10 @@ class WidgetUnzip
     void unzipProgress(const std::string &destination);
     void ExtractFile(DPL::ZipInput::File *input, const std::string
             &destFileName);
-    std::string decryptDrmPackage(const std::string &source);
+    bool isDRMPackage(const std::string &source);
+    bool decryptDRMPackage(const std::string &source, const std::string
+            &decryptedSource);
+    std::string getDecryptedPackage(const std::string &source);
 
 };
 
index 71f8b28..40b2129 100644 (file)
@@ -19,6 +19,7 @@
  */
 #include "widget_location.h"
 
+#include <unistd.h>
 #include <dpl/utils/wrt_utility.h>
 #include <dpl/wrt-dao-ro/global_config.h>
 #include <dpl/assert.h>