#include <widget_install/widget_install_context.h>
#include <widget_install/widget_install_errors.h>
#include <widget_parser.h>
-#include <wrt_error.h>
namespace { // anonymous
const DPL::String BR = DPL::FromUTF8String("<br>");
return;
}
- struct dirent* dirent;
+
+
struct stat statStruct;
- do {
- errno = 0;
- if ((dirent = readdir(localeDir))) {
- DPL::String dirName = DPL::FromUTF8String(dirent->d_name);
- std::string absoluteDirName = localePath + "/";
- absoluteDirName += dirent->d_name;
-
- if (stat(absoluteDirName.c_str(), &statStruct) != 0) {
- LogError("stat() failed with " << DPL::GetErrnoString());
- continue;
- }
+ struct dirent dirent;
+ struct dirent *result;
+ int return_code;
+ errno = 0;
+ for (return_code = readdir_r(localeDir, &dirent, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(localeDir, &dirent, &result))
+ {
+ DPL::String dirName = DPL::FromUTF8String(dirent.d_name);
+ std::string absoluteDirName = localePath + "/";
+ absoluteDirName += dirent.d_name;
- if (S_ISDIR(statStruct.st_mode)) {
- //Yes, we ignore current, parent & hidden directories
- if (dirName[0] != L'.') {
- LogDebug("Adding locale directory \"" << dirName << "\"");
- m_localeFolders.insert(dirName);
- }
+ if (stat(absoluteDirName.c_str(), &statStruct) != 0) {
+ LogError("stat() failed with " << DPL::GetErrnoString());
+ continue;
+ }
+
+ if (S_ISDIR(statStruct.st_mode)) {
+ //Yes, we ignore current, parent & hidden directories
+ if (dirName[0] != L'.') {
+ LogDebug("Adding locale directory \"" << dirName << "\"");
+ m_localeFolders.insert(dirName);
}
}
- } while (dirent);
+ }
- if (errno != 0) {
- LogError("readdir() failed with " << DPL::GetErrnoString());
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
}
if (-1 == TEMP_FAILURE_RETRY(closedir(localeDir))) {
<<
"] 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);
widgetVersion) const
{
if (widgetVersion.IsNull() || (*widgetVersion).empty()) {
- LogWarning("minVersion attribute is empty. WRT assumes platform "
- "supports this widget.");
- return true;
+ 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
minorWidget, microWidget))
{
LogWarning("Invalid format of widget version string.");
- return true;
+ return false;
}
//Parse supported version
bool TaskWidgetConfig::parseConfigurationFileBrowser(
WrtDB::ConfigParserData& configInfo,
- const std::string&
- _currentPath,
- int* pErrCode)
+ const std::string& _currentPath)
{
ParserRunner parser;
Try
Catch(ElementParser::Exception::Base)
{
LogError("Invalid widget configuration file!");
- *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
return false;
}
return true;
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;
- struct dirent* ptr = 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;
- errno = 0;
- while ((ptr = readdir(dir)) != NULL) { //Find configuration file, based on
- // its name
- 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);
+ LogDebug("Configuration file: " << configFilePath);
- 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;
- }
-
- has_config_xml = true;
- break;
- }
- }
- }
- 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<WidgetParser>(
+ 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.
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;
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);