#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 "parser_runner.h"
#include <widget_install/job_widget_install.h>
#include <widget_install/task_certify.h>
+#include <widget_install/task_certify_level.h>
#include <widget_install/task_widget_config.h>
#include <widget_install/task_file_manipulation.h>
#include <widget_install/task_ace_check.h>
#include <widget_install/task_database.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_pkg_info_update.h>
#include <widget_install/task_commons.h>
#include <widget_install/task_prepare_reinstall.h>
{
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,}$";
if (fileLen < extLen) {
LogError("Filename " << filename << " is shorter than extension "
<< extension);
- return false;
+ false;
}
return (0 == filename.compare(fileLen - extLen, extLen, extension));
}
m_exceptionCaught(Jobs::Exceptions::Success)
{
m_installerContext.mode = m_jobStruct.m_installMode;
+ getInstallerStruct().pkgmgrInterface->sendSignal(
+ PKGMGR_START_KEY,
+ PKGMGR_START_INSTALL);
+ getInstallerStruct().pkgmgrInterface->sendSignal(
+ PKGMGR_PROGRESS_KEY,
+ PKGMGR_START_VALUE);
ConfigureResult result = prepareInstallation(widgetPath);
if (result == ConfigureResult::Ok) {
- LogInfo("Configure installation succeeded");
+ LogDebug("Configure installation succeeded");
m_installerContext.job->SetProgressFlag(true);
AddTask(new TaskRecovery(m_installerContext));
AddTask(new TaskPrepareFiles(m_installerContext));
}
AddTask(new TaskCertify(m_installerContext));
+ AddTask(new TaskCertifyLevel(m_installerContext));
if (m_needEncryption) {
AddTask(new TaskEncryptResource(m_installerContext));
}
-
AddTask(new TaskFileManipulation(m_installerContext));
AddTask(new TaskManifestFile(m_installerContext));
if (m_installerContext.widgetConfig.packagingType ==
{
AddTask(new TaskInstallOspsvc(m_installerContext));
}
- AddTask(new TaskCertificates(m_installerContext));
AddTask(new TaskDatabase(m_installerContext));
AddTask(new TaskAceCheck(m_installerContext));
AddTask(new TaskSmack(m_installerContext));
+ AddTask(new TaskPkgInfoUpdate(m_installerContext));
} else if (result == ConfigureResult::Updated) {
- LogInfo("Configure installation updated");
- LogInfo("Widget Update");
+ LogDebug("Configure installation updated");
+ LogDebug("Widget Update");
m_installerContext.job->SetProgressFlag(true);
if (m_installerContext.mode.command ==
}
AddTask(new TaskCertify(m_installerContext));
+ AddTask(new TaskCertifyLevel(m_installerContext));
if (m_needEncryption) {
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 TaskInstallOspsvc(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
// Any error in acecheck while update will break widget
AddTask(new TaskSmack(m_installerContext));
AddTask(new TaskRemoveBackupFiles(m_installerContext));
+ AddTask(new TaskPkgInfoUpdate(m_installerContext));
} else {
// Installation is not allowed to proceed due to widget update policy
LogWarning("Configure installation failed!");
{
ConfigureResult result;
m_needEncryption = false;
-
Try
{
std::string tempDir;
setApplicationType(configData);
m_needEncryption = detectResourceEncryption(configData);
setInstallLocationType(configData);
+ m_installerContext.callerPkgId =
+ DPL::FromUTF8String(getInstallerStruct().pkgmgrInterface->getCallerId());
+ LogDebug("Caller Package Id : " << m_installerContext.callerPkgId);
// Configure installation
result = ConfigureInstallation(widgetPath, configData, tempDir);
LogError("Failed to unzip for widget");
result = ConfigureResult::Failed_DrmError;
}
+ Catch(Exceptions::MissingConfig)
+ {
+ LogError("Failed to localize config.xml");
+ result = ConfigureResult::Failed_InvalidConfig;
+ }
+ Catch(Exceptions::WidgetConfigFileInvalid)
+ {
+ LogError("Invalid configuration file");
+ result = ConfigureResult::Failed_InvalidConfig;
+ }
+ Catch(DPL::Exception)
+ {
+ LogError("Unknown exception");
+ result = ConfigureResult::Failed;
+ }
return result;
}
break;
}
m_installerContext.widgetConfig.tzPkgid = pkgId;
- LogInfo("tizen_id name was generated by WRT: " <<
+ LogDebug("tizen_id name was generated by WRT: " <<
m_installerContext.widgetConfig.tzPkgid);
}
m_installerContext.
widgetConfig.
tzPkgid));
- LogInfo("Tizen App Id : " << m_installerContext.widgetConfig.tzAppid);
- LogInfo("Tizen Pkg Id : " << m_installerContext.widgetConfig.tzPkgid);
- LogInfo("W3C Widget GUID : " << m_installerContext.widgetConfig.guid);
+ LogDebug("Tizen App Id : " << m_installerContext.widgetConfig.tzAppid);
+ LogDebug("Tizen Pkg Id : " << m_installerContext.widgetConfig.tzPkgid);
+ LogDebug("W3C Widget GUID : " << m_installerContext.widgetConfig.guid);
}
void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath,
widgetPath, tempPath,
m_installerContext.widgetConfig.packagingType,
m_installerContext.mode.rootPath ==
- InstallMode::RootPath::RO);
+ InstallMode::RootPath::RO,
+ m_installerContext.mode.extension);
m_installerContext.locations->registerAppid(
DPL::ToUTF8String(m_installerContext.widgetConfig.tzAppid));
- LogInfo("widgetSource " << widgetPath);
+ LogDebug("widgetSource " << widgetPath);
}
ConfigureResult JobWidgetInstall::ConfigureInstallation(
}
Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) {
result = ConfigureResult::Ok;
- getInstallerStruct().pkgmgrInterface->sendSignal(
- PKGMGR_START_KEY,
- PKGMGR_START_INSTALL);
m_installerContext.isUpdateMode = false;
if (!validateTizenApplicationID(
bool JobWidgetInstall::validateTizenApplicationID(
const WrtDB::TizenAppId &tizenAppId)
{
- LogInfo("tizen application ID = [" << tizenAppId << "]");
+ LogDebug("tizen application ID = [" << tizenAppId << "]");
regex_t reg;
if (regcomp(®, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED) != 0) {
return ConfigureResult::Failed;
}
- LogInfo("existing version = '" << update.existingVersion);
- LogInfo("incoming version = '" << update.incomingVersion);
- LogInfo("Tizen AppID = " << update.tzAppId);
+ LogDebug("existing version = '" << update.existingVersion);
+ LogDebug("incoming version = '" << update.incomingVersion);
+ LogDebug("Tizen AppID = " << update.tzAppId);
// Check running state
bool isRunning = false;
LogError("Fail to terminate running application");
return ConfigureResult::Failed_WidgetRunning;
}
- LogInfo("terminate application");
+ LogDebug("terminate application");
}
}
// Parse config
ParserRunner parser;
ConfigParserData configInfo;
-
Try
{
if (pkgType == PKG_TYPE_HOSTED_WEB_APP) {
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 {
- std::string configFile;
- if (pkgType == PKG_TYPE_HYBRID_WEB_APP) {
- configFile = tempPath + "/" + WITH_OSP_XML;
- } else {
- configFile = tempPath + "/" + CONFIG_XML;
+
+ if(!DPL::Utils::Path(configFile).Exists())
+ {
+ ThrowMsg(Exceptions::MissingConfig, "Config file not exists");
}
parser.Parse(configFile,
LogError("Failed to find installed widget - give proper tizenId");
return ConfigParserData();
}
+ Catch(Exceptions::WidgetConfigFileNotFound){
+ LogError("Failed to find config.xml");
+ return ConfigParserData();
+ }
return configInfo;
}
const ConfigParserData &configInfo,
const WrtDB::TizenAppId &tizenId)
{
- LogInfo("Checking up widget package for config.xml...");
+ LogDebug("Checking up widget package for config.xml...");
OptionalWidgetVersion incomingVersion;
if (!configInfo.version.IsNull()) {
out << std::endl;
- LogInfo(out.str());
+ LogDebug(out.str());
}
WrtDB::PackagingType JobWidgetInstall::checkPackageType(
const std::string &widgetSource,
const std::string &tempPath)
{
- // Check installation type (direcotory/ or config.xml or widget.wgt)
- if (m_installerContext.mode.extension == InstallMode::ExtensionType::DIR) {
- LogDebug("Install directly from directory");
- return PKG_TYPE_DIRECTORY_WEB_APP;
- }
if (hasExtension(widgetSource, XML_EXTENSION)) {
- LogInfo("Hosted app installation");
+ LogDebug("Hosted app installation");
return PKG_TYPE_HOSTED_WEB_APP;
}
- std::string configFile = tempPath + "/" + CONFIG_XML;
- if (WrtUtilFileExists(configFile)) {
- return PKG_TYPE_NOMAL_WEB_APP;
- }
-
- configFile = tempPath + "/" + WITH_OSP_XML;
+ 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(
const WrtDB::ConfigParserData &configInfo)
{
+ AppType widgetAppType = APP_TYPE_UNKNOWN;
FOREACH(iterator, configInfo.nameSpaces) {
- LogInfo("namespace = [" << *iterator << "]");
- AppType currentAppType = APP_TYPE_UNKNOWN;
-
- if (*iterator == ConfigurationNamespace::W3CWidgetNamespaceName) {
- continue;
- } else if (
- *iterator ==
- ConfigurationNamespace::WacWidgetNamespaceNameForLinkElement ||
- *iterator ==
- ConfigurationNamespace::WacWidgetNamespaceName)
- {
- currentAppType = APP_TYPE_WAC20;
- } else if (*iterator ==
- ConfigurationNamespace::TizenWebAppNamespaceName)
- {
- currentAppType = APP_TYPE_TIZENWEBAPP;
- }
+ LogDebug("namespace = [" << *iterator << "]");
- if (m_installerContext.widgetConfig.webAppType ==
- APP_TYPE_UNKNOWN)
- {
- m_installerContext.widgetConfig.webAppType = currentAppType;
- } else if (m_installerContext.widgetConfig.webAppType ==
- currentAppType)
- {
- continue;
+ if (*iterator == ConfigurationNamespace::TizenWebAppNamespaceName) {
+ if (widgetAppType != APP_TYPE_UNKNOWN &&
+ widgetAppType != APP_TYPE_TIZENWEBAPP)
+ {
+ LogError("To many namespaces declared in configuration fileA.");
+ ThrowMsg(Exceptions::WidgetConfigFileInvalid,
+ "Config.xml has more than one valid namespace");
+ }
+ widgetAppType = APP_TYPE_TIZENWEBAPP;
} else {
- ThrowMsg(Exceptions::WidgetConfigFileInvalid,
- "Config.xml has more than one namespace");
+ LogDebug("Namespace ignored.");
}
}
- // If there is no define, type set to WAC 2.0
- if (m_installerContext.widgetConfig.webAppType == APP_TYPE_UNKNOWN) {
- m_installerContext.widgetConfig.webAppType = APP_TYPE_WAC20;
- }
+ m_installerContext.widgetConfig.webAppType = widgetAppType;
- LogInfo("type = [" <<
+ LogDebug("type = [" <<
m_installerContext.widgetConfig.webAppType.getApptypeToString() <<
"]");
}