Support <tizen:privilege>
authorJihoon Chung <jihoon.chung@samsung.com>
Tue, 11 Dec 2012 00:42:00 +0000 (09:42 +0900)
committerJihoon Chung <jihoon.chung@samsung.com>
Thu, 13 Dec 2012 00:05:16 +0000 (09:05 +0900)
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] Implement tizen:privilege for plugin features
[SCMRequest] N/A

Change-Id: I85f5634bbca8a07a479a6d050a9a59b30281a4eb

src/configuration_parser/widget_parser.cpp [changed mode: 0755->0644]
src/configuration_parser/widget_parser.h

old mode 100755 (executable)
new mode 100644 (file)
index 1fe1150..8144fbb
@@ -1335,6 +1335,70 @@ class BackgroundParser : public ElementParser
     ConfigParserData& m_data;
 };
 
+class PrivilegeParser : public ElementParser
+{
+  public:
+    virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+            const DPL::String& name)
+    {
+        return &IgnoringParser::Create;
+    }
+
+    virtual void Accept(const Text& /*text*/)
+    {
+    }
+
+    virtual void Accept(const Element& element)
+    {
+        if (element.ns ==
+            ConfigurationNamespace::TizenWebAppNamespaceName)
+        {
+            m_properNamespace = true;
+        }
+        LogDebug("element");
+    }
+
+    virtual void Accept(const XmlAttribute& attribute)
+    {
+        if (m_properNamespace) {
+            if (attribute.name == L"name") {
+                m_feature.name = attribute.value;
+            }
+        }
+        m_feature.required = true;
+    }
+
+    virtual void Verify()
+    {
+        LibIri::Wrapper iri(DPL::ToUTF8String(m_feature.name).c_str());
+
+        if (m_feature.name != L"") {
+            if (iri.Validate()) {
+                if (m_data.featuresList.find(m_feature) ==
+                    m_data.featuresList.end()) {
+                    m_data.featuresList.insert(m_feature);
+                } else {
+                    LogDebug("Ignoring feature with name" <<
+                             DPL::ToUTF8String(m_feature.name));
+                }
+            }
+        }
+    }
+
+    PrivilegeParser(ConfigParserData& data) :
+        ElementParser(),
+        m_data(data),
+        m_feature(L""),
+        m_properNamespace(false)
+    {
+    }
+
+  private:
+    ConfigParserData& m_data;
+    ConfigParserData::Feature m_feature;
+    bool m_properNamespace;
+};
+
 ElementParser::ActionFunc WidgetParser::GetElementParser(const DPL::String& /*ns*/,
         const DPL::String& name)
 {
@@ -1371,6 +1435,7 @@ WidgetParser::WidgetParser(ConfigParserData& data) :
     m_map[L"application"] = DPL::MakeDelegate(this, &WidgetParser::OnApplicationElement);
     m_map[L"splash"] = DPL::MakeDelegate(this, &WidgetParser::OnSplashElement);
     m_map[L"background"] = DPL::MakeDelegate(this, &WidgetParser::OnBackgroundElement);
+    m_map[L"privilege"] = DPL::MakeDelegate(this, &WidgetParser::OnPrivilegeElement);
 }
 
 ElementParserPtr WidgetParser::OnNameElement()
@@ -1448,6 +1513,11 @@ ElementParserPtr WidgetParser::OnBackgroundElement()
     return ElementParserPtr(new BackgroundParser(m_data));
 }
 
+ElementParserPtr WidgetParser::OnPrivilegeElement()
+{
+    return ElementParserPtr(new PrivilegeParser(m_data));
+}
+
 void WidgetParser::Accept(const Element& element)
 {
     if (element.ns != ConfigurationNamespace::W3CWidgetNamespaceName &&
index 159e583..64d09be 100644 (file)
@@ -79,6 +79,7 @@ class WidgetParser : public ElementParser
     ElementParserPtr OnApplicationElement();
     ElementParserPtr OnSplashElement();
     ElementParserPtr OnBackgroundElement();
+    ElementParserPtr OnPrivilegeElement();
 
     virtual ActionFunc GetElementParser(const DPL::String& ns,
             const DPL::String& name);