TaskConfiguration::TaskConfiguration(InstallerContext& context) :
DPL::TaskDecl<TaskConfiguration>(this),
- m_context(context),
- m_result(ConfigureResult::Unknown)
+ m_context(context)
{
AddStep(&TaskConfiguration::StartStep);
AddStep(&TaskConfiguration::PrepareInstallationStep);
void TaskConfiguration::AppendTasklistStep()
{
- // TODO: (job_install_refactoring) do not store config result anywhere
- m_context.confResult = m_result;
-
- if (m_result == ConfigureResult::Ok) {
+ if (!m_context.isUpdateMode) {
_D("TaskConfiguration -> new installation task list");
m_context.job->appendNewInstallationTaskList();
- } else if (m_result == ConfigureResult::Updated) {
+ } else {
_D("TaskConfiguration -> update installation task list");
m_context.job->appendUpdateInstallationTaskList();
- } else {
- _D("TaskConfiguration -> failure task list");
- m_context.job->appendFailureTaskList();
}
}
{
// TODO: (job_install_refactoring) clean up this task
std::string widgetPath = m_context.requestedPath;
- ConfigureResult result;
+ bool result;
m_context.needEncryption = false;
- Try
- {
- std::string tempDir;
- if (m_context.mode.extension == InstallMode::ExtensionType::DIR) {
- if (m_context.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;
- }
+ std::string tempDir;
+ if (m_context.mode.extension == InstallMode::ExtensionType::DIR) {
+ if (m_context.mode.command ==
+ InstallMode::Command::REINSTALL) {
+ std::ostringstream tempPathBuilder;
+ tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
+ tempPathBuilder << WrtDB::GlobalConfig::GetTmpDirPath();
+ tempPathBuilder << "/";
+ tempPathBuilder << widgetPath;
+ tempDir = tempPathBuilder.str();
} else {
- tempDir =
- Jobs::WidgetInstall::createTempPath(
- m_context.mode.rootPath ==
- InstallMode::RootPath::RO);
- WidgetUnzip wgtUnzip;
- wgtUnzip.unzipWgtFile(widgetPath, tempDir);
+ tempDir = widgetPath;
}
+ } else {
+ tempDir =
+ Jobs::WidgetInstall::createTempPath(
+ m_context.mode.rootPath ==
+ InstallMode::RootPath::RO);
+ WidgetUnzip wgtUnzip;
+ wgtUnzip.unzipWgtFile(widgetPath, tempDir);
+ }
+
+ _D("widgetPath: %s", widgetPath.c_str());
+ _D("tempPath: %s", tempDir.c_str());
+
+ m_context.widgetConfig.packagingType =
+ checkPackageType(widgetPath, tempDir);
+ ConfigParserData configData = getWidgetDataFromXML(
+ widgetPath,
+ tempDir,
+ m_context.widgetConfig.packagingType,
+ m_context.mode.command == InstallMode::Command::REINSTALL);
+ _D("widget packaging type : %d", static_cast<WrtDB::PkgType>(m_context.widgetConfig.packagingType.pkgType));
+
+ setTizenId(configData);
+ setApplicationType(configData);
+ m_context.needEncryption = detectResourceEncryption(configData);
+ setInstallLocationType(configData);
+ // TODO: (job_install_refactoring) hide this call
+ m_context.callerPkgId =
+ DPL::FromUTF8String(m_context.job->GetInstallerStruct().pkgmgrInterface->getCallerId());
+ _D("Caller Package Id : %s", DPL::ToUTF8String(m_context.callerPkgId).c_str());
- _D("widgetPath:%s", widgetPath.c_str());
- _D("tempPath:%s", tempDir.c_str());
-
- m_context.widgetConfig.packagingType =
- checkPackageType(widgetPath, tempDir);
- ConfigParserData configData = getWidgetDataFromXML(
- widgetPath,
- tempDir,
- m_context.widgetConfig.packagingType,
- m_context.mode.command == InstallMode::Command::REINSTALL);
- _D("widget packaging type : %d", m_context.widgetConfig.packagingType.pkgType);
-
- setTizenId(configData);
- setApplicationType(configData);
- m_context.needEncryption = detectResourceEncryption(configData);
- setInstallLocationType(configData);
- // TODO: (job_install_refactoring) hide this call
- m_context.callerPkgId =
- DPL::FromUTF8String(m_context.job->GetInstallerStruct().pkgmgrInterface->getCallerId());
- _D("Caller Package Id : %ls", m_context.callerPkgId.c_str());
-
- // Configure installation
- result = ConfigureInstallation(widgetPath, configData, tempDir);
- // TODO: (job_install_refactoring) hide this call
- m_context.job->GetInstallerStruct().pkgmgrInterface->sendSignal(
- PKGMGR_PROGRESS_KEY,
- PKGMGR_START_VALUE);
- }
- Catch(Exceptions::OpenZipFailed)
- {
- _E("Failed to unzip for widget");
- result = ConfigureResult::Failed_OpenZipError;
- }
- Catch(Exceptions::ExtractFileFailed)
- {
- _E("Failed to unzip for widget");
- result = ConfigureResult::Failed_UnzipError;
- }
- Catch(Exceptions::DrmDecryptFailed)
- {
- _E("Failed to unzip for widget");
- result = ConfigureResult::Failed_DrmError;
- }
- Catch(Exceptions::MissingConfig)
- {
- _E("Failed to localize config.xml");
- result = ConfigureResult::Failed_InvalidConfig;
- }
- Catch(Exceptions::WidgetConfigFileInvalid)
- {
- _E("Invalid configuration file");
- result = ConfigureResult::Failed_InvalidConfig;
- }
- Catch(DPL::Exception)
- {
- _E("Unknown exception");
- result = ConfigureResult::Failed;
- }
+ // Configure installation
+ result = ConfigureInstallation(widgetPath, configData, tempDir);
+ // TODO: (job_install_refactoring) hide this call
+ m_context.job->GetInstallerStruct().pkgmgrInterface->sendSignal(
+ PKGMGR_PROGRESS_KEY,
+ PKGMGR_START_VALUE);
- m_result = result;
+ m_context.isUpdateMode = result;
}
void TaskConfiguration::setTizenId(
_D("widgetSource %s", widgetPath.c_str());
}
-ConfigureResult TaskConfiguration::ConfigureInstallation(
+bool TaskConfiguration::ConfigureInstallation(
const std::string &widgetSource,
const WrtDB::ConfigParserData &configData,
const std::string &tempPath)
{
- ConfigureResult result = ConfigureResult::Failed;
+ bool result;
+
WidgetUpdateInfo update;
// checking installed web application
Try {
- // checking existing application is installed
- WidgetDAOReadOnly dao(m_context.widgetConfig.tzAppid);
// no excpetion means, it isn't update mode
// TODO: (job_install_refactoring) hide this call/
m_context.job->GetInstallerStruct().pkgmgrInterface->sendSignal(
update = detectWidgetUpdate(configData,
m_context.widgetConfig.tzAppid);
result = checkWidgetUpdate(update);
- if (result != ConfigureResult::Updated) {
+ if (!result) {
// Already installed TizenAppId. return failed
- return ConfigureResult::Failed_AlreadyInstalled;
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::PackageAlreadyInstalled,
+ "package is already installed");
}
if (!checkSupportRDSUpdate(configData)) {
- return ConfigureResult::Failed_NotSupportRDSUpdate;
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::NotSupportRDSUpdate,
+ "RDS update failed");
}
- m_context.isUpdateMode = true;
+ result = true;
}
Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) {
// TODO: (job_install_refactoring) hide this call
m_context.job->GetInstallerStruct().pkgmgrInterface->sendSignal(
PKGMGR_START_KEY,
PKGMGR_START_INSTALL);
- result = ConfigureResult::Ok;
- m_context.isUpdateMode = false;
+ result = false;
if (!validateTizenApplicationID(
m_context.widgetConfig.tzAppid))
{
_E("tizen application ID is already used");
- return ConfigureResult::Failed_InvalidConfig;
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetConfigFileInvalid,
+ "invalid config");
}
if (!validateTizenPackageID(m_context.widgetConfig.tzPkgid)) {
_E("tizen package ID is already used");
- return ConfigureResult::Failed_AlreadyInstalled;
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::PackageAlreadyInstalled,
+ "package is already installed");
}
}
return true;
}
-ConfigureResult TaskConfiguration::checkWidgetUpdate(
+bool TaskConfiguration::checkWidgetUpdate(
const WidgetUpdateInfo &update)
{
if (update.existingVersion.IsNull() || update.incomingVersion.IsNull()) {
- return ConfigureResult::Failed;
+ return false;
}
_D("existing version = '%ls", update.existingVersion->Raw().c_str());
&isRunning);
if (APP_MANAGER_ERROR_NONE != ret) {
_E("Fail to get running state");
- return ConfigureResult::Failed_WidgetRunning;
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
+ "widget is running");
}
if (true == isRunning) {
&appCtx);
if (APP_MANAGER_ERROR_NONE != ret) {
_E("Fail to get app_context");
- return ConfigureResult::Failed_WidgetRunning;
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
+ "widget is running");
}
// terminate app_context_h
if (APP_MANAGER_ERROR_NONE != ret) {
_E("Fail to terminate running application");
app_context_destroy(appCtx);
- return ConfigureResult::Failed_WidgetRunning;
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
+ "widget is running");
} else {
app_context_destroy(appCtx);
// app_manager_terminate_app isn't sync API
&isStillRunning);
if (APP_MANAGER_ERROR_NONE != ret) {
_E("Fail to get running state");
- return ConfigureResult::Failed_WidgetRunning;
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
+ "widget is running");
}
if (!isStillRunning) {
break;
}
if (isStillRunning) {
_E("Fail to terminate running application");
- return ConfigureResult::Failed_WidgetRunning;
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
+ "widget is running");
}
_D("terminate application");
}
if (!!update.existingVersion ||
m_context.mode.extension ==
InstallMode::ExtensionType::DIR) {
- return ConfigureResult::Updated;
+ return true;
}
- return ConfigureResult::Failed;
+ return false;
}
ConfigParserData TaskConfiguration::getWidgetDataFromXML(
Catch(ElementParser::Exception::ParseError)
{
_E("Failed to parse config.xml file");
- return ConfigParserData();
+ ThrowMsg(Exceptions::WidgetConfigFileInvalid, "Parser exeption");
}
Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
{
_E("Failed to find installed widget - give proper tizenId");
- return ConfigParserData();
+ ThrowMsg(Exceptions::RDSDeltaFailure, "WidgetNotExist");
}
Catch(Exceptions::WidgetConfigFileNotFound){
_E("Failed to find config.xml");
- return ConfigParserData();
+ ThrowMsg(Exceptions::MissingConfig, "Parser exeption");
}
return configInfo;
+++ /dev/null
-/*
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file task_installer_fail.cpp
- * @version 1.0
- * @brief implementation file for failure task
- */
-#include "task_installer_fail.h"
-
-#include <widget_install/widget_install_errors.h>
-
-using namespace WrtDB;
-using namespace Jobs::Exceptions;
-
-namespace Jobs {
-namespace WidgetInstall {
-
-void InstallerTaskFail::StepFail()
-{
- 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");
- } else if (m_result == ConfigureResult::Failed_AlreadyInstalled) {
- ThrowMsg(Jobs::WidgetInstall::Exceptions::PackageAlreadyInstalled,
- "package is already installed");
- } else if (m_result == ConfigureResult::Failed_WidgetRunning) {
- ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError,
- "widget is running");
- } else if (m_result == ConfigureResult::Failed_DrmError) {
- 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!");
- }
-}
-
-InstallerTaskFail::InstallerTaskFail(ConfigureResult result) :
- DPL::TaskDecl<InstallerTaskFail>(this),
- m_result(result)
-{
- AddStep(&InstallerTaskFail::StepFail);
-}
-
-}
-}