X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fjobs%2Fwidget_install%2Ftask_widget_config.cpp;h=d7c3640b3bf122767dfb5f662d256a70d0ea44cb;hb=df7b007c93bbec244392ef29d3a244cba9f9a781;hp=d4702f81f64e380b32091d2d9392d5537da9d307;hpb=1d9b2d83d7f8c99af1c3b89792c96e29e5eea7a2;p=framework%2Fweb%2Fwrt-installer.git diff --git a/src/jobs/widget_install/task_widget_config.cpp b/src/jobs/widget_install/task_widget_config.cpp index d4702f8..d7c3640 100644 --- a/src/jobs/widget_install/task_widget_config.cpp +++ b/src/jobs/widget_install/task_widget_config.cpp @@ -44,7 +44,6 @@ #include #include #include -#include namespace { // anonymous const DPL::String BR = DPL::FromUTF8String("
"); @@ -479,30 +478,6 @@ void TaskWidgetConfig::StepVerifyFeatures() << "] cannot be allowed to use [" << DPL::ToUTF8String(it->name) + "] feature"); - } - if (!WrtDB::FeatureDAOReadOnly::isFeatureInstalled( - DPL::ToUTF8String(it->name))) - { - LogWarning("Feature not found. Checking if required :[" << - DPL::ToUTF8String(it->name) << "]"); - - if (it->required) { - /** - * WL-3210 The WRT MUST inform the user if a widget cannot be - * installed because one or more required features are not - * supported. - */ - std::ostringstream os; - os << - "Widget cannot be installed, required feature is missing:[" - << DPL::ToUTF8String(it->name) << "]"; - if (!GlobalSettings::TestModeEnabled() && !isTizenWebApp()) { - std::string label = os.str(); - createInstallPopup(PopupType::WIDGET_WRONG_FEATURE_INFO, - label); - } - ThrowMsg(Exceptions::WidgetConfigFileInvalid, os.str()); - } } else { newList.insert(*it); featureInfo += DPL::ToUTF8String(it->name); @@ -589,9 +564,13 @@ bool TaskWidgetConfig::isMinVersionCompatible( widgetVersion) const { if (widgetVersion.IsNull() || (*widgetVersion).empty()) { - LogWarning("minVersion attribute is empty. WRT assumes platform " - "supports this widget."); - return false; + if (appType == WrtDB::AppType::APP_TYPE_TIZENWEBAPP) { + return false; + } else { + LogWarning("minVersion attribute is empty. WRT assumes platform " + "supports this widget."); + return true; + } } //Parse widget version @@ -647,9 +626,7 @@ bool TaskWidgetConfig::isTizenWebApp() const bool TaskWidgetConfig::parseConfigurationFileBrowser( WrtDB::ConfigParserData& configInfo, - const std::string& - _currentPath, - int* pErrCode) + const std::string& _currentPath) { ParserRunner parser; Try @@ -664,7 +641,6 @@ bool TaskWidgetConfig::parseConfigurationFileBrowser( Catch(ElementParser::Exception::Base) { LogError("Invalid widget configuration file!"); - *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE; return false; } return true; @@ -672,100 +648,41 @@ bool TaskWidgetConfig::parseConfigurationFileBrowser( bool TaskWidgetConfig::parseConfigurationFileWidget( WrtDB::ConfigParserData& configInfo, - const std::string& - _currentPath, - int* pErrCode) + const std::string& _currentPath) { - ParserRunner parser; - - //TODO: rewrite this madness - std::string cfgAbsPath; - DIR* dir = NULL; - - dir = opendir(_currentPath.c_str()); - if (dir == NULL) { - *pErrCode = WRT_ERR_UNKNOWN; + std::string configFilePath; + WrtUtilJoinPaths(configFilePath, _currentPath, WRT_WIDGET_CONFIG_FILE_NAME); + if (!WrtUtilFileExists(configFilePath)) + { + LogError("Archive does not contain configuration file"); return false; } - bool has_config_xml = false; - struct dirent ptr; - struct dirent *result; - int return_code; - errno = 0; - //Find configuration file, based on its name - for (return_code = readdir_r(dir, &ptr, &result); - result != NULL && return_code == 0; - return_code = readdir_r(dir, &ptr, &result)) - { - if (ptr.d_type == DT_REG) { - if (!strcmp(ptr.d_name, WRT_WIDGET_CONFIG_FILE_NAME)) { - std::string dName(ptr.d_name); - WrtUtilJoinPaths(cfgAbsPath, _currentPath, dName); - - //Parse widget configuration file - LogDebug("Found config: " << cfgAbsPath); - - Try - { - parser.Parse(cfgAbsPath, ElementParserPtr(new - RootParser< - WidgetParser>( - configInfo, - DPL - :: - FromUTF32String( - L"widget")))); - } - Catch(ElementParser::Exception::Base) - { - LogError("Invalid widget configuration file!"); - // _rethrown_exception.Dump(); - *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE; - if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) { - LogError( - "Failed to close dir: " << _currentPath << - " with error: " - << DPL::GetErrnoString()); - } - return false; - } + LogDebug("Configuration file: " << configFilePath); - has_config_xml = true; - break; - } - } - } - if (errno != 0) { - LogError("readdir_r() failed with " << DPL::GetErrnoString()); - } - errno = 0; - if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) { - LogError("Failed to close dir: " << _currentPath << " with error: " - << DPL::GetErrnoString()); + Try + { + ParserRunner parser; + parser.Parse(configFilePath, + ElementParserPtr(new RootParser( + configInfo, + DPL::FromUTF32String(L"widget")))); + return true; } - - //We must have config.xml so leaveing if we doesn't - if (!has_config_xml) { - LogError("Invalid archive"); - *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE; + Catch (ElementParser::Exception::Base) + { + LogError("Invalid configuration file!"); return false; } - return true; } bool TaskWidgetConfig::locateAndParseConfigurationFile( const std::string& _currentPath, WrtDB::WidgetRegisterInfo& pWidgetConfigInfo, - const std::string& baseFolder, - int* pErrCode) + const std::string& baseFolder) { using namespace WrtDB; - if (!pErrCode) { - return false; - } - ConfigParserData& configInfo = pWidgetConfigInfo.configInfo; // check if this installation from browser, or not. @@ -775,26 +692,22 @@ bool TaskWidgetConfig::locateAndParseConfigurationFile( if (infoPath.str() != WRT_WIDGET_CONFIG_FILE_NAME) { if (_currentPath.empty() || baseFolder.empty()) { - *pErrCode = WRT_ERR_INVALID_ARG; return false; } // in case of general installation using wgt archive - if (!parseConfigurationFileWidget(configInfo, _currentPath, - pErrCode)) + if (!parseConfigurationFileWidget(configInfo, _currentPath)) { return false; } } else { // in case of browser installation - if (!parseConfigurationFileBrowser(configInfo, _currentPath, - pErrCode)) + if (!parseConfigurationFileBrowser(configInfo, _currentPath)) { return false; } } if (!fillWidgetConfig(pWidgetConfigInfo, configInfo)) { - *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE; return false; } return true; @@ -851,10 +764,8 @@ void TaskWidgetConfig::processFile( WrtDB::WidgetRegisterInfo & widgetConfiguration) { - int pErrCode; - if (!locateAndParseConfigurationFile(path, widgetConfiguration, - DEFAULT_LANGUAGE, &pErrCode)) + DEFAULT_LANGUAGE)) { LogWarning("Widget archive: Failed while parsing config file"); ThrowMsg(Exception::ConfigParseFailed, path);