AddStep(&TaskConfiguration::StartStep);
AddStep(&TaskConfiguration::SetupTempDirStep);
- AddStep(&TaskConfiguration::CheckPackageTypeStep);
-
+ AddStep(&TaskConfiguration::UnzipConfigurationStep);
AddStep(&TaskConfiguration::ParseXMLConfigStep);
+ AddStep(&TaskConfiguration::UnzipWidgetFileStep);
+ AddStep(&TaskConfiguration::CheckPackageTypeStep);
AddStep(&TaskConfiguration::TizenIdStep);
AddStep(&TaskConfiguration::CheckAppRunningStateStep);
Jobs::WidgetInstall::createTempPath(
m_context.mode.rootPath ==
InstallMode::RootPath::RO);
+ }
+}
+
+void TaskConfiguration::UnzipConfigurationStep()
+{
+ _D("UnzipConfigurationStep");
+ if (m_context.mode.extension != InstallMode::ExtensionType::DIR) {
+ if(!hasExtension(m_context.requestedPath, XML_EXTENSION)) //unzip everything except xml files
+ {
+ WidgetUnzip wgtUnzip;
+ wgtUnzip.unzipConfiguration(m_context.requestedPath, m_tempDir);
+ m_configuration += m_tempDir + "/" + CONFIG_XML;
+ } else{
+ m_configuration += m_context.requestedPath;
+ }
+ } else {
+ if (m_context.mode.command == InstallMode::Command::REINSTALL) {
+ std::string configFile = m_tempDir + "/" + CONFIG_XML;
+ if (!WrtUtilFileExists(configFile)) {
+ configFile = m_tempDir + "/" + WITH_OSP_XML;
+ if (!WrtUtilFileExists(configFile)) {
+ std::string tzAppId = m_context.requestedPath.
+ substr(m_context.requestedPath.find_last_of("/")+1);
+ WidgetDAOReadOnly dao(WidgetDAOReadOnly::getTzAppId(
+ DPL::FromUTF8String(tzAppId)));
+ configFile = DPL::ToUTF8String(*dao.getWidgetInstalledPath());
+ configFile += "/";
+ configFile += WITH_OSP_XML;
+ }
+ }
+ m_configuration = configFile;
+ } else {
+ m_configuration = m_tempDir + "/" + WITH_OSP_XML;
+ }
+ }
+ _D("m_configuration : %s", m_configuration.c_str());
+}
+
+void TaskConfiguration::UnzipWidgetFileStep()
+{
+ _D("UnzipWidgetFileStep");
+ if (m_context.mode.extension != InstallMode::ExtensionType::DIR) {
if(!hasExtension(m_context.requestedPath, XML_EXTENSION)) //unzip everything except xml files
{
WidgetUnzip wgtUnzip;
void TaskConfiguration::ParseXMLConfigStep()
{
- parseWidgetXMLConfig(
- m_context.requestedPath, m_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));
+ _D("ParseXMLConfigStep");
+ // Parse config
+ ParserRunner parser;
+ Try
+ {
+ if(!DPL::Utils::Path(m_configuration).Exists())
+ {
+ ThrowMsg(Exceptions::MissingConfig, "Config file not exists");
+ }
+
+#ifdef SCHEMA_VALIDATION_ENABLED
+ if(!parser.Validate(configFilePath, WRT_WIDGETS_XML_SCHEMA))
+ {
+ _E("Invalid configuration file - schema validation failed");
+ ThrowMsg(Exceptions::WidgetConfigFileInvalid, "Failed to parse config.xml file");
+ }
+#endif
+ parser.Parse(m_configuration,
+ ElementParserPtr(
+ new RootParser<WidgetParser>(m_widgetConfig,
+ DPL::
+ FromUTF32String(
+ L"widget"))));
+ }
+ Catch(ElementParser::Exception::ParseError)
+ {
+ _E("Failed to parse config.xml file");
+ ThrowMsg(Exceptions::WidgetConfigFileInvalid, "Parser exeption");
+ }
+ Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
+ {
+ _E("Failed to find installed widget - give proper tizenId");
+ ThrowMsg(Exceptions::RDSDeltaFailure, "WidgetNotExist");
+ }
+ Catch(Exceptions::WidgetConfigFileNotFound){
+ _E("Failed to find config.xml");
+ ThrowMsg(Exceptions::MissingConfig, "Parser exeption");
+ }
+
+ if (!WrtUtilRemove(m_configuration)) {
+ _E("Error occurs during removing %s", m_configuration.c_str());
+ }
+
}
void TaskConfiguration::TizenIdStep()
return false;
}
-void TaskConfiguration::parseWidgetXMLConfig(
- const std::string &widgetSource,
- const std::string &tempPath,
- WrtDB::PackagingType pkgType,
- bool isReinstall)
-{
- // Parse config
- ParserRunner parser;
- Try
- {
- if (pkgType == PKG_TYPE_HOSTED_WEB_APP) {
- parser.Parse(widgetSource,
- ElementParserPtr(
- new RootParser<WidgetParser>(m_widgetConfig,
- DPL::FromUTF32String(
- L"widget"))));
- } else {
- std::string configFile;
- configFile = tempPath + "/" + CONFIG_XML;
- if (!WrtUtilFileExists(configFile)) {
- configFile = tempPath + "/" + WITH_OSP_XML;
- }
-
- if (isReinstall) {
- // checking RDS data directory
- 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)));
- configFile = DPL::ToUTF8String(*dao.getWidgetInstalledPath());
- configFile += "/";
- configFile += WITH_OSP_XML;
- }
- }
-
- if(!DPL::Utils::Path(configFile).Exists())
- {
- ThrowMsg(Exceptions::MissingConfig, "Config file not exists");
- }
-
-#ifdef SCHEMA_VALIDATION_ENABLED
- if(!parser.Validate(configFilePath, WRT_WIDGETS_XML_SCHEMA))
- {
- _E("Invalid configuration file - schema validation failed");
- ThrowMsg(Exceptions::WidgetConfigFileInvalid, "Failed to parse config.xml file");
- }
-#endif
- parser.Parse(configFile,
- ElementParserPtr(
- new RootParser<WidgetParser>(m_widgetConfig,
- DPL::
- FromUTF32String(
- L"widget"))));
- }
- }
- Catch(ElementParser::Exception::ParseError)
- {
- _E("Failed to parse config.xml file");
- ThrowMsg(Exceptions::WidgetConfigFileInvalid, "Parser exeption");
- }
- Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
- {
- _E("Failed to find installed widget - give proper tizenId");
- ThrowMsg(Exceptions::RDSDeltaFailure, "WidgetNotExist");
- }
- Catch(Exceptions::WidgetConfigFileNotFound){
- _E("Failed to find config.xml");
- ThrowMsg(Exceptions::MissingConfig, "Parser exeption");
- }
-}
-
WidgetUpdateInfo TaskConfiguration::detectWidgetUpdate(
const ConfigParserData &configInfo,
const WrtDB::TizenAppId &tizenId)
namespace {
const char *const DRM_LIB_PATH = "/usr/lib/libdrm-service-core-tizen.so";
const size_t SPACE_SIZE = 1024 * 1024;
+const char *const WEB_APP_CONFIG_XML= "config.xml";
+const char *const HYBRID_CONFIG_XML = "res/wgt/config.xml";
struct PathAndFilePair
{
}
}
+void WidgetUnzip::unzipConfiguration(const std::string &source,
+ const std::string &destination)
+{
+ _D("unzipConfiguration");
+ Try {
+ std::string wgtFile = getDecryptedPackage(source);
+ _D("wgtFile : %s", wgtFile.c_str());
+
+ std::unique_ptr<DPL::ZipInput> zipFile(new DPL::ZipInput(source));
+
+ std::unique_ptr<DPL::ZipInput::File> configFile;
+
+ Try {
+ configFile.reset(zipFile->OpenFile(HYBRID_CONFIG_XML));
+ } Catch(DPL::ZipInput::Exception::OpenFileFailed) {
+ configFile.reset(zipFile->OpenFile(WEB_APP_CONFIG_XML));
+ }
+
+ std::string extractPath = destination + "/" + WEB_APP_CONFIG_XML;
+ ExtractFile(configFile.get(), extractPath);
+ }
+ Catch(DPL::ZipInput::Exception::OpenFailed)
+ {
+ ReThrowMsg(Exceptions::OpenZipFailed, source);
+ }
+ Catch(DPL::ZipInput::Exception::OpenFileFailed)
+ {
+ ThrowMsg(Exceptions::ExtractFileFailed, "config.xml");
+ }
+ Catch(Exceptions::DrmDecryptFailed)
+ {
+ ReThrowMsg(Exceptions::ExtractFileFailed, source);
+ }
+}
+
} //namespace WidgetInstall
} //namespace Jobs