TaskConfiguration::TaskConfiguration(InstallerContext& context) :
DPL::TaskDecl<TaskConfiguration>(this),
- m_context(context)
+ m_context(context),
+ m_widgetConfig(m_context.widgetConfig.configInfo)
{
AddStep(&TaskConfiguration::StartStep);
void TaskConfiguration::ParseXMLConfigStep()
{
- m_widgetConfig = getWidgetDataFromXML( //TODO: make one parsing of config.xml
+ parseWidgetXMLConfig(
m_context.requestedPath, m_tempDir,
m_context.widgetConfig.packagingType,
m_context.mode.command == InstallMode::Command::REINSTALL);
return false;
}
-ConfigParserData TaskConfiguration::getWidgetDataFromXML(
+void TaskConfiguration::parseWidgetXMLConfig(
const std::string &widgetSource,
const std::string &tempPath,
WrtDB::PackagingType pkgType,
{
// Parse config
ParserRunner parser;
- ConfigParserData configInfo;
Try
{
if (pkgType == PKG_TYPE_HOSTED_WEB_APP) {
parser.Parse(widgetSource,
ElementParserPtr(
- new RootParser<WidgetParser>(configInfo,
+ new RootParser<WidgetParser>(m_widgetConfig,
DPL::FromUTF32String(
L"widget"))));
} else {
#endif
parser.Parse(configFile,
ElementParserPtr(
- new RootParser<WidgetParser>(configInfo,
+ new RootParser<WidgetParser>(m_widgetConfig,
DPL::
FromUTF32String(
L"widget"))));
_E("Failed to find config.xml");
ThrowMsg(Exceptions::MissingConfig, "Parser exeption");
}
-
- return configInfo;
}
WidgetUpdateInfo TaskConfiguration::detectWidgetUpdate(
* @brief Implementation file for installer task widget config
*/
-#include <map>
-#include <sstream>
#include <string>
#include <sys/stat.h>
#include <dirent.h>
#include <dpl/wrt-dao-ro/config_parser_data.h>
#include <dpl/wrt-dao-rw/feature_dao.h>
-#include <libiriwrapper.h>
-#include <parser_runner.h>
-#include <root_parser.h>
-
#include <widget_install/job_widget_install.h>
#include <widget_install/task_process_config.h>
#include <widget_install/widget_install_context.h>
namespace { // anonymous
const DPL::String BR = DPL::FromUTF8String("<br>");
-const std::string WIDGET_NOT_COMPATIBLE = "This widget is "
- "not compatible with WRT.<br><br>";
-
-const char *const DEFAULT_LANGUAGE = "default";
-
-const char *const WRT_WIDGET_CONFIG_FILE_NAME = "config.xml";
-
const std::string WINDGET_INSTALL_NETWORK_ACCESS = "network access";
-
-const char WRT_WIDGETS_XML_SCHEMA[] = "/usr/etc/wrt-installer/widgets.xsd";
}
namespace Jobs {
{
AddStep(&TaskProcessConfig::StartStep);
AddStep(&TaskProcessConfig::ReadLocaleFolders);
- AddStep(&TaskProcessConfig::StepProcessConfigurationFile);
+ AddStep(&TaskProcessConfig::StepFillWidgetConfig);
AddStep(&TaskProcessConfig::ProcessLocalizedStartFiles);
AddStep(&TaskProcessConfig::ProcessBackgroundPageFile);
AddStep(&TaskProcessConfig::ProcessLocalizedIcons);
AddStep(&TaskProcessConfig::EndStep);
}
-void TaskProcessConfig::StepProcessConfigurationFile()
+void TaskProcessConfig::StepFillWidgetConfig()
{
- Try
+ if (!fillWidgetConfig(m_installContext.widgetConfig,
+ m_installContext.widgetConfig.configInfo))
{
- std::string path = m_installContext.locations->getConfigurationDir();
- _D("path: %s", path.c_str());
- processFile(path, m_installContext.widgetConfig);
+ _E("Widget configuration is illformed");
+ ThrowMsg(Exception::ConfigParseFailed, "Widget configuration is illformed");
}
- Catch(Exception::ConfigParseFailed)
- {
- _E("Parsing failed.");
- ReThrow(Exceptions::WidgetConfigFileInvalid);
- }
-
- m_installContext.job->UpdateProgress(
- InstallerContext::INSTALL_WIDGET_CONFIG1,
- "Parse elements of configuration file and save them");
}
void TaskProcessConfig::ReadLocaleFolders()
if (-1 == closedir(localeDir)) {
_E("Failed to close dir: %s with error: %s", localePath.c_str(), DPL::GetErrnoString().c_str());
}
+
+ m_installContext.job->UpdateProgress(InstallerContext::INSTALL_WIDGET_CONFIG1, "Read locale folders");
}
void TaskProcessConfig::ProcessLocalizedStartFiles()
bool TaskProcessConfig::isTizenWebApp() const
{
- bool ret = FALSE;
- if (m_installContext.widgetConfig.webAppType.appType
- == WrtDB::AppType::APP_TYPE_TIZENWEBAPP)
- {
- ret = TRUE;
- }
-
- return ret;
-}
-
-bool TaskProcessConfig::parseConfigurationFileBrowser(
- WrtDB::ConfigParserData& configInfo,
- const std::string& _currentPath)
-{
- ParserRunner parser;
- Try
- {
- parser.Parse(_currentPath, ElementParserPtr(new
- RootParser<
- WidgetParser>(
- configInfo,
- DPL::FromUTF32String(
- L"widget"))));
- }
- Catch(ElementParser::Exception::Base)
- {
- _E("Invalid widget configuration file!");
- return false;
- }
- return true;
-}
-
-bool TaskProcessConfig::parseConfigurationFileWidget(
- WrtDB::ConfigParserData& configInfo,
- const std::string& _currentPath)
-{
- std::string configFilePath;
- WrtUtilJoinPaths(configFilePath, _currentPath, WRT_WIDGET_CONFIG_FILE_NAME);
- if (!WrtUtilFileExists(configFilePath))
- {
- _E("Archive does not contain configuration file");
- return false;
- }
-
- _D("Configuration file: %s", configFilePath.c_str());
-
- Try
+ if (m_installContext.widgetConfig.webAppType.appType == WrtDB::AppType::APP_TYPE_TIZENWEBAPP)
{
- ParserRunner parser;
-#ifdef SCHEMA_VALIDATION_ENABLED
- if(!parser.Validate(configFilePath, WRT_WIDGETS_XML_SCHEMA))
- {
- _E("Invalid configuration file - schema validation failed");
- return false;
- }
-#endif
- parser.Parse(configFilePath,
- ElementParserPtr(new RootParser<WidgetParser>(
- configInfo,
- DPL::FromUTF32String(L"widget"))));
return true;
}
- Catch (ElementParser::Exception::Base)
- {
- _E("Invalid configuration file!");
- return false;
- }
-}
-
-bool TaskProcessConfig::locateAndParseConfigurationFile(
- const std::string& _currentPath,
- WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
- const std::string& baseFolder)
-{
- using namespace WrtDB;
-
- ConfigParserData& configInfo = pWidgetConfigInfo.configInfo;
-
- // check if this installation from browser, or not.
- size_t pos = _currentPath.rfind("/");
- std::ostringstream infoPath;
- infoPath << _currentPath.substr(pos + 1);
-
- if (infoPath.str() != WRT_WIDGET_CONFIG_FILE_NAME) {
- if (_currentPath.empty() || baseFolder.empty()) {
- return false;
- }
- // in case of general installation using wgt archive
- if (!parseConfigurationFileWidget(configInfo, _currentPath))
- {
- return false;
- }
- } else {
- // in case of browser installation
- if (!parseConfigurationFileBrowser(configInfo, _currentPath))
- {
- return false;
- }
- }
- if (!fillWidgetConfig(pWidgetConfigInfo, configInfo)) {
- return false;
- }
- return true;
+ return false;
}
bool TaskProcessConfig::fillWidgetConfig(
WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
WrtDB::ConfigParserData& configInfo)
{
- if (!!configInfo.widget_id) {
- if (!pWidgetConfigInfo.guid) {
- pWidgetConfigInfo.guid = configInfo.widget_id;
- _D("W3C Widget GUID : %ls", (*pWidgetConfigInfo.guid).c_str());
- } else {
- if (pWidgetConfigInfo.guid != configInfo.widget_id) {
- _E("Invalid archive");
- return false;
- }
- }
- }
- if (!!configInfo.tizenAppId) {
- if (DPL::ToUTF8String(pWidgetConfigInfo.tzAppid).compare(
- DPL::ToUTF8String(*configInfo.tizenAppId)) < 0)
- {
- _E("Invalid archive - Tizen App ID not same error");
- return false;
- }
- }
- if (!!configInfo.tizenPkgId) {
- if (pWidgetConfigInfo.tzPkgid != *configInfo.tizenPkgId) {
- _E("Invalid archive - Tizen Pkg ID not same error");
- return false;
- }
- }
+ pWidgetConfigInfo.guid = configInfo.widget_id;
+
if (!!configInfo.version) {
if (!pWidgetConfigInfo.version) {
pWidgetConfigInfo.version = configInfo.version;
return true;
}
-void TaskProcessConfig::processFile(
- const std::string& path,
- WrtDB::WidgetRegisterInfo &
- widgetConfiguration)
-{
- if (!locateAndParseConfigurationFile(path, widgetConfiguration,
- DEFAULT_LANGUAGE))
- {
- _W("Widget archive: Failed while parsing config file");
- ThrowMsg(Exception::ConfigParseFailed, path);
- }
-}
-
void TaskProcessConfig::StartStep()
{
_D("--------- <TaskProcessConfig> : START ----------");
WrtDB::LocaleSet m_localeFolders;
std::set<DPL::String> m_processedIconSet;
- void StepProcessConfigurationFile();
+ void StepFillWidgetConfig();
void ReadLocaleFolders();
void ProcessLocalizedStartFiles();
void ProcessStartFile(
bool isTizenWebApp() const;
bool parseVersionString(const std::string &version, long &majorVersion,
long &minorVersion, long µVersion) const;
- /**
- * This method is used to process the config.xml of widget, get
- * the corresponding configuration to pWidgetConfigInfo
- *
- * @param[in] path Specified the widget archive file path (absolute path).
- * @return Configuration information of widget
- */
- void processFile(const std::string& path,
- WrtDB::WidgetRegisterInfo &wConfig);
- bool locateAndParseConfigurationFile(
- const std::string& currentPath,
- WrtDB::WidgetRegisterInfo&
- pWidgetConfigInfo,
- const std::string& baseFolder);
- bool parseConfigurationFileBrowser(WrtDB::ConfigParserData& configInfo,
- const std::string& _currentPath);
- bool parseConfigurationFileWidget(WrtDB::ConfigParserData& configInfo,
- const std::string& _currentPath);
bool fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
WrtDB::ConfigParserData& configInfo);