#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;
m_exceptionCaught(Jobs::Exceptions::Success)
{
m_installerContext.mode = m_jobStruct.m_installMode;
- ConfigureResult result = PrePareInstallation(widgetPath);
+ ConfigureResult result = prepareInstallation(widgetPath);
if (result == ConfigureResult::Ok) {
LogInfo("Configure installation succeeded");
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)
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 ==
}
}
-ConfigureResult JobWidgetInstall::PrePareInstallation(
+ConfigureResult JobWidgetInstall::prepareInstallation(
const std::string &widgetPath)
{
ConfigureResult result;
Jobs::WidgetInstall::createTempPath(
m_installerContext.mode.rootPath ==
InstallMode::RootPath::RO);
- }
-
- 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;
- }
+ WidgetUnzip wgtUnzip;
+ wgtUnzip.unzipWgtFile(widgetPath, tempDir);
}
LogDebug("widgetPath:" << widgetPath);
+ LogDebug("tempPath:" << tempDir);
m_installerContext.widgetConfig.packagingType =
checkPackageType(widgetPath, tempDir);
widgetPath,
tempDir,
m_installerContext.widgetConfig.packagingType,
- m_isDRM,
m_installerContext.mode.command == InstallMode::Command::REINSTALL);
LogDebug("widget packaging type : " <<
m_installerContext.widgetConfig.packagingType.pkgType);
const std::string &widgetSource,
const std::string &tempPath,
WrtDB::PackagingType pkgType,
- bool isDRM,
bool isReinstall)
{
// Parse config
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"))));
+ std::string configFile;
+ if (pkgType == PKG_TYPE_HYBRID_WEB_APP) {
+ configFile = tempPath + "/" + WITH_OSP_XML;
} 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"))));
+ configFile = tempPath + "/" + CONFIG_XML;
}
+
+ 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)
- {
- LogError("Failed to seek widget archive - corrupted package?");
- return ConfigParserData();
- }
Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
{
LogError("Failed to find installed widget - give proper tizenId");
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));
+ std::string configFile = tempPath + "/" + CONFIG_XML;
+ if (WrtUtilFileExists(configFile)) {
+ return PKG_TYPE_NOMAL_WEB_APP;
+ }
- return PKG_TYPE_HYBRID_WEB_APP;
- }
- Catch(DPL::ZipInput::Exception::OpenFileFailed)
- {
- LogDebug("Could not find wgt/config.xml");
- return PKG_TYPE_UNKNOWN;
- }
+ configFile = tempPath + "/" + WITH_OSP_XML;
+ if (WrtUtilFileExists(configFile)) {
+ return PKG_TYPE_HYBRID_WEB_APP;
}
return PKG_TYPE_UNKNOWN;
}
}
-bool JobWidgetInstall::isDRMWidget(std::string /*widgetPath*/)
-{
- /* TODO */
- return false;
-}
-
-bool JobWidgetInstall::DecryptDRMWidget(std::string /*widgetPath*/,
- std::string /*destPath*/)
-{
- /* TODO */
- return false;
-}
-
bool JobWidgetInstall::checkSupportRDSUpdate(const WrtDB::ConfigParserData
&configInfo)
{
* limitations under the License.
*/
/*
- * @file task_unzip.cpp
+ * @file widget_unzip.cpp
* @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
* @version 1.0
- * @brief Implementation file for installer task unzip
+ * @brief Implementation file for installer widget unzip
*/
-#include <widget_install/task_unzip.h>
+#include <widget_install/widget_unzip.h>
#include <widget_install/widget_install_errors.h>
#include <widget_install/widget_install_context.h>
#include <widget_install/job_widget_install.h>
namespace Jobs {
namespace WidgetInstall {
-TaskUnzip::TaskUnzip(InstallerContext &installerContext) :
- DPL::TaskDecl<TaskUnzip>(this),
- m_installerContext(installerContext)
-{
- // Install steps
- AddStep(&TaskUnzip::StepUnzipPrepare);
- AddStep(&TaskUnzip::StepUnzipProgress);
- AddStep(&TaskUnzip::StepUnzipFinished);
-}
-
-void TaskUnzip::ExtractFile(DPL::ZipInput::File *input,
+void WidgetUnzip::ExtractFile(DPL::ZipInput::File *input,
const std::string &destFileName)
{
Try
}
}
-void TaskUnzip::StepUnzipPrepare()
-{
- LogInfo("Prepare to unzip...");
-
- Try
- {
- m_zip.reset(new DPL::ZipInput(m_installerContext.locations->
- getWidgetSource()));
- LogInfo("Widget package comment: " << m_zip->GetGlobalComment());
-
- // Widget package must not be empty
- if (m_zip->empty()) {
- ThrowMsg(Exceptions::ZipEmpty,
- m_installerContext.locations->getWidgetSource());
- }
-
- // Set iterator to first file
- m_zipIterator = m_zip->begin();
- }
- Catch(DPL::ZipInput::Exception::OpenFailed)
- {
- ReThrowMsg(Exceptions::OpenZipFailed,
- m_installerContext.locations->getWidgetSource());
- }
- Catch(DPL::ZipInput::Exception::SeekFileFailed)
- {
- ThrowMsg(Exceptions::ExtractFileFailed,
- "m_installerContext.locations->getWidgetSource()");
- }
-}
-
-void TaskUnzip::StepUnzipProgress()
+void WidgetUnzip::unzipProgress(const std::string &destination)
{
// Show file info
LogInfo("Unzipping: '" << m_zipIterator->name <<
if (fileName[fileName.size() - 1] == '/') {
// This is path
- std::string newPath =
- m_installerContext.locations->getTemporaryPackageDir() + "/" +
+ std::string newPath = destination + "/" +
fileName.substr(0, fileName.size() - 1);
LogPedantic("Path to extract: " << newPath);
createTempPath(newPath);
} else {
// This is regular file
- std::string fileExtractPath =
- m_installerContext.locations->getTemporaryPackageDir() + "/" +
- fileName;
+ std::string fileExtractPath = destination + "/" + fileName;
LogPedantic("File to extract: " << fileExtractPath);
if (++m_zipIterator == m_zip->end()) {
LogInfo("Unzip progress finished successfuly");
} else {
- SwitchToStep(&TaskUnzip::StepUnzipProgress);
+ unzipProgress(destination);
}
-
- m_installerContext.job->UpdateProgress(
- InstallerContext::INSTALL_UNZIP_FILES,
- "Unzip widget files to temporary directory");
}
-void TaskUnzip::StepUnzipFinished()
+void WidgetUnzip::unzipWgtFile(const std::string &source, const std::string &destination)
{
- // Unzip finished, close internal structures
- m_zip.reset();
+ LogInfo("Prepare to unzip...");
+
+ Try
+ {
+ m_zip.reset(new DPL::ZipInput(source));
+ LogInfo("Widget package comment: " << m_zip->GetGlobalComment());
+
+ // Widget package must not be empty
+ if (m_zip->empty()) {
+ ThrowMsg(Exceptions::ZipEmpty, source);
+ }
+
+ // Set iterator to first file
+ m_zipIterator = m_zip->begin();
+
+ unzipProgress(destination);
- // Done
- LogInfo("Unzip finished");
+ // Unzip finished, close internal structures
+ m_zip.reset();
+
+ // Done
+ LogInfo("Unzip finished");
+ }
+ Catch(DPL::ZipInput::Exception::OpenFailed)
+ {
+ ReThrowMsg(Exceptions::OpenZipFailed, source);
+ }
+ Catch(DPL::ZipInput::Exception::SeekFileFailed)
+ {
+ ThrowMsg(Exceptions::ExtractFileFailed, source);
+ }
}
+
} //namespace WidgetInstall
} //namespace Jobs
* limitations under the License.
*/
/*
- * @file task_unzip.cpp
+ * @file widget_unzip.cpp
* @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
* @version 1.0
* @brief Implementation file for installer task unzip
*/
-#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_UNZIP_H
-#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_UNZIP_H
+#ifndef WIDGET_UNZIP_H
+#define WIDGET_UNZIP_H
#include <string>
-#include <memory>
#include <dpl/zip_input.h>
-#include <dpl/task.h>
-#include <dpl/encryption/resource_encryption.h>
-
-class InstallerContext;
namespace Jobs {
namespace WidgetInstall {
-class TaskUnzip :
- public DPL::TaskDecl<TaskUnzip>
+class WidgetUnzip
{
- private:
- // Installation context
- InstallerContext &m_installerContext;
+ public:
+ void unzipWgtFile(const std::string &source, const std::string &destination);
+ private:
// Unzip state
std::unique_ptr<DPL::ZipInput> m_zip;
DPL::ZipInput::const_iterator m_zipIterator;
- WRTEncryptor::ResourceEncryptor *m_resEnc;
-
- void ExtractFile(DPL::ZipInput::File *input,
- const std::string &destFileName);
+ void unzipProgress(const std::string &destination);
+ void ExtractFile(DPL::ZipInput::File *input, const std::string
+ &destFileName);
- void EncryptionFile(const std::string &fileName);
-
- // Steps
- void StepUnzipPrepare();
- void StepUnzipProgress();
- void StepUnzipFinished();
-
- public:
- TaskUnzip(InstallerContext &installerContext);
};
+
} //namespace WidgetInstall
} //namespace Jobs
-#endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_UNZIP_H
+#endif // WIDGET_UNZIP_H