virtual void Accept(const Element& element)
{
- if (element.ns == ConfigurationNamespace::W3CWidgetNamespaceName) {
+ // for tizen web apps WARP should be used
+ if (element.ns == ConfigurationNamespace::W3CWidgetNamespaceName ||
+ element.ns == ConfigurationNamespace::TizenWebAppNamespaceName)
+ {
m_standardType = STANDARD_TYPE_WARP;
}
if (element.ns == ConfigurationNamespace::JilWidgetNamespaceName) {
DPL::OptionalString m_href;
};
-class MinVersionParser : public ElementParser
-{
- public:
- virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
- {
- return &DenyAllParser::Create;
- }
-
- virtual void Accept(const XmlAttribute& attribute)
- {
- if (m_properNamespace) {
- ThrowMsg(Exception::ParseError,
- "attirubte: '" + DPL::ToUTF8String(attribute.name) +
- "' in min-version element not allowed");
- }
- }
-
- virtual void Accept(const Element& element)
- {
- if (element.ns == ConfigurationNamespace::WacWidgetNamespaceName) {
- m_properNamespace = true;
- }
-
- LogDebug("element min-version");
- }
-
- virtual void Accept(const Text& text)
- {
- if (m_properNamespace) {
- m_minVersion = text.value;
- LogDebug("min-version value: " << m_minVersion);
- }
- }
-
- virtual void Verify()
- {
- if (m_properNamespace) {
- if (m_minVersion.IsNull()) {
- ThrowMsg(Exception::ParseError,
- "min-version element must have value");
- }
-
- DPL::OptionalFloat version = ParseMinVersion(*m_minVersion);
- if (version.IsNull()) {
- ThrowMsg(Exception::ParseError,
- "min-version element must have value"
- " that can be parsed to float");
- }
-
- if (m_data.minVersionRequiredFound.IsNull()) {
- m_data.minVersionRequiredFound = 1;
- m_data.minVersionRequired = version;
- LogDebug("MinVersionRequired = " << version);
- } else {
- ThrowMsg(Exception::ParseError,
- "multiple min-version elements not allowed");
- }
- }
- }
-
- MinVersionParser(ConfigParserData& data) :
- ElementParser(),
- m_properNamespace(false),
- m_data(data),
- m_minVersion()
- {
- LogDebug("MinVersionParser created");
- }
-
- private:
- bool m_properNamespace;
- ConfigParserData& m_data;
- DPL::OptionalString m_minVersion;
-
- static DPL::OptionalFloat ParseMinVersion(const DPL::String& value)
- {
- DPL::OptionalString normalizedValue = value;
- NormalizeString(normalizedValue);
- if (!(*normalizedValue).empty()) {
- char* reterr = NULL;
- errno = 0;
- float valueFloat =
- strtof(DPL::ToUTF8String(value).c_str(), &reterr);
- if (errno != 0 ||
- std::string(reterr) == DPL::ToUTF8String(value) ||
- valueFloat <= 0.0) {
- return DPL::OptionalFloat::Null;
- } else {
- return valueFloat;
- }
- }
- return DPL::OptionalFloat::Null;
- }
-};
-
-// tag: <back supported=true>
-class BackParser : public ElementParser
-{
- public:
- virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
- {
- return &IgnoringParser::Create;
- }
-
- virtual void Accept(const XmlAttribute& attribute)
- {
- LogDebug("attribute");
- if (attribute.name == L"supported") {
- if (attribute.value == L"true") {
- m_backSupported = true;
- } else {
- m_backSupported = false;
- }
- }
- }
-
- virtual void Accept(const Element&)
- {
- LogDebug("element");
- //if empty back element will be passed, we say true
- m_data.backSupported = true;
- }
-
- virtual void Accept(const Text&)
- {
- LogDebug("text");
- ThrowMsg(Exception::ParseError, "back element must be empty");
- }
-
- virtual void Verify()
- {
- m_data.backSupported = m_backSupported;
- }
-
- BackParser(ConfigParserData& data) :
- ElementParser(),
- m_backSupported(false),
- m_data(data)
- {
- }
-
- private:
- bool m_backSupported;
- ConfigParserData& m_data;
-};
-
class SettingParser : public ElementParser
{
public:
DPL::MakeDelegate(this, &WidgetParser::OnPreferenceElement);
m_map[L"flash"] = DPL::MakeDelegate(this, &WidgetParser::OnFlashElement);
m_map[L"link"] = DPL::MakeDelegate(this, &WidgetParser::OnLinkElement);
- m_map[L"min-version"] =
- DPL::MakeDelegate(this, &WidgetParser::OnMinVersionElement);
- m_map[L"back"] = DPL::MakeDelegate(this, &WidgetParser::OnBackElement);
m_map[L"pkgname"] = DPL::MakeDelegate(this, &WidgetParser::OnPkgnameElement);
m_map[L"setting"] =
DPL::MakeDelegate(this, &WidgetParser::OnSettingElement);
return ElementParserPtr(new LinkParser(m_data));
}
-ElementParserPtr WidgetParser::OnMinVersionElement()
-{
- return ElementParserPtr(new MinVersionParser(m_data));
-}
-
-ElementParserPtr WidgetParser::OnBackElement()
-{
- return ElementParserPtr(new BackParser(m_data));
-}
-
ElementParserPtr WidgetParser::OnPkgnameElement()
{
return ElementParserPtr(new PkgnameParser(m_data));
void WidgetParser::Accept(const Element& element)
{
- if (element.ns != ConfigurationNamespace::W3CWidgetNamespaceName) {
+ if (element.ns != ConfigurationNamespace::W3CWidgetNamespaceName &&
+ element.ns != ConfigurationNamespace::TizenWebAppNamespaceName)
+ {
ThrowMsg(Exception::ParseError,
"Wrong xml namespace for widget element");
}
} else if (attribute.name == L"version") {
m_version = attribute.value;
NormalizeString(m_version);
+ } else if (attribute.name == L"min-version") {
+ LogInfo("min-version attribute was found. Value: " << attribute.value);
+ m_minVersion = attribute.value;
+ NormalizeString(m_minVersion);
+ m_data.minVersionRequired = m_minVersion;
} else if (attribute.name == L"height") {
DPL::OptionalString value = attribute.value;
NormalizeString(value);
} else {
LogWarning("Ignoring subsequent default locale");
}
- } else if (DPL::StringCompare(L"xmlns", attribute.name) < 0) {
- LogWarning("namespace domain" << attribute.name);
- LogWarning("namespace value " << attribute.value);
- DPL::OptionalString ns = attribute.value;
-
- if (attribute.name == L"xmlns:wac") {
- m_nameSpaces.push_back(attribute.value);
- } else if (attribute.name == L"xmlns:tizen") {
- m_nameSpaces.push_back(attribute.value);
- } else if (attribute.name == L"xmlns:jil") {
- m_nameSpaces.push_back(attribute.value);
- }
+
+ //Any other value consider as a namespace definition
+ } else if (attribute.name == L"xmlns" ||
+ attribute.ns == m_nameSpaces[L"xmlns"]) {
+ LogInfo("Namespace domain: " << attribute.name);
+ LogInfo("Namespace value: " << attribute.value);
+ m_nameSpaces[attribute.name] = attribute.value;
+ } else {
+ LogError("Unknown attirbute: namespace=" << attribute.ns <<
+ ", name=" << attribute.name <<
+ ", value=" << attribute.value);
}
}
}
m_data.defaultlocale = m_defaultlocale;
FOREACH(ns, m_nameSpaces) {
- m_data.nameSpaces.insert(*ns);
+ m_data.nameSpaces.insert(ns->second);
}
}