ConfigParserData::Setting m_setting;
};
-class AppControlParser : public ElementParser
+class AppServiceParser : public ElementParser
{
public:
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
m_data.appServiceList.push_back(serviceInfo);
}
- AppControlParser(ConfigParserData& data) :
+ AppServiceParser(ConfigParserData& data) :
ElementParser(),
m_src(DPL::OptionalString::Null),
m_operation(DPL::OptionalString::Null),
ConfigParserData& m_data;
};
+class AppControlParser : public ElementParser
+{
+ public:
+ struct SourceParser : 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*/)
+ {
+ }
+
+ virtual void Accept(const XmlAttribute& attribute)
+ {
+ if (attribute.name == L"name") {
+ if (attribute.value.size() > 0) {
+ m_value = attribute.value;
+ NormalizeString(m_value);
+ }
+ }
+ }
+
+ virtual void Verify()
+ {
+ if (m_value.IsNull() || *m_value== L"") {
+ return;
+ }
+
+ m_data.m_src = *m_value;
+ }
+
+ SourceParser(ConfigParserData::AppControlInfo& data) :
+ ElementParser(),
+ m_properNamespace(false),
+ m_data(data)
+ {
+ }
+
+ private:
+ bool m_properNamespace;
+ DPL::OptionalString m_value;
+ ConfigParserData::AppControlInfo& m_data;
+ };
+
+ struct OperationParser : 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*/)
+ {
+ }
+
+ virtual void Accept(const XmlAttribute& attribute)
+ {
+ if (attribute.name == L"name") {
+ if (attribute.value.size() > 0) {
+ m_value = attribute.value;
+ NormalizeString(m_value);
+ }
+ }
+ }
+
+ virtual void Verify()
+ {
+ if (m_value.IsNull() || *m_value== L"") {
+ return;
+ }
+
+ m_data.m_operation = *m_value;
+ }
+
+ OperationParser(ConfigParserData::AppControlInfo& data) :
+ ElementParser(),
+ m_properNamespace(false),
+ m_data(data)
+ {
+ }
+
+ private:
+ bool m_properNamespace;
+ DPL::OptionalString m_value;
+ ConfigParserData::AppControlInfo& m_data;
+ };
+
+ struct UriParser : 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*/)
+ {
+ }
+
+ virtual void Accept(const XmlAttribute& attribute)
+ {
+ if (attribute.name == L"name") {
+ if (attribute.value.size() > 0) {
+ m_value = attribute.value;
+ NormalizeString(m_value);
+ }
+ }
+ }
+
+ virtual void Verify()
+ {
+ if (m_value.IsNull() || *m_value == L"") {
+ return;
+ }
+
+ DPL::String wildString(L"*/*");
+ if ((m_data.m_uriList.find(wildString) ==
+ m_data.m_uriList.end())
+ && (m_data.m_uriList.find(*m_value) ==
+ m_data.m_uriList.end())) {
+
+ m_data.m_uriList.insert(*m_value);
+ } else {
+ LogDebug("Ignoring uri with name" <<
+ DPL::ToUTF8String(*m_value));
+ }
+ }
+
+ UriParser(ConfigParserData::AppControlInfo& data) :
+ ElementParser(),
+ m_properNamespace(false),
+ m_data(data)
+ {
+ }
+
+ private:
+ bool m_properNamespace;
+ DPL::OptionalString m_value;
+ ConfigParserData::AppControlInfo& m_data;
+ };
+
+ struct MimeParser : 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*/)
+ {
+ }
+
+ virtual void Accept(const XmlAttribute& attribute)
+ {
+ if (attribute.name == L"name") {
+ if (attribute.value.size() > 0) {
+ m_value = attribute.value;
+ NormalizeString(m_value);
+ }
+ }
+ }
+
+ virtual void Verify()
+ {
+ if (m_value.IsNull() || *m_value == L"") {
+ return;
+ }
+
+ DPL::String wildString(L"*/*");
+ if ((m_data.m_mimeList.find(wildString) ==
+ m_data.m_mimeList.end())
+ && (m_data.m_mimeList.find(*m_value) ==
+ m_data.m_mimeList.end())) {
+ m_data.m_mimeList.insert(*m_value);
+ } else {
+ LogDebug("Ignoring mime with name" <<
+ DPL::ToUTF8String(*m_value));
+ }
+ }
+
+ MimeParser(ConfigParserData::AppControlInfo& data) :
+ ElementParser(),
+ m_properNamespace(false),
+ m_data(data)
+ {
+ }
+
+ private:
+ bool m_properNamespace;
+ DPL::OptionalString m_value;
+ ConfigParserData::AppControlInfo& m_data;
+ };
+
+ virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+ const DPL::String& name)
+ {
+ if (name == L"src") {
+ return DPL::MakeDelegate(this, &AppControlParser::OnSourceElement);
+ } else if (name == L"operation") {
+ return DPL::MakeDelegate(this, &AppControlParser::OnOperationElement);
+ } else if (name == L"uri") {
+ return DPL::MakeDelegate(this, &AppControlParser::OnUriElement);
+ } else if (name == L"mime") {
+ return DPL::MakeDelegate(this, &AppControlParser::OnMimeElement);
+ } else {
+ return &IgnoringParser::Create;
+ }
+ }
+
+ virtual void Accept(const XmlAttribute& attribute)
+ {
+ }
+
+ virtual void Accept(const Element& element)
+ {
+ LogWarning("namespace for app service = " << element.ns);
+ if (element.ns == ConfigurationNamespace::W3CWidgetNamespaceName) {
+ ThrowMsg(Exception::ParseError,
+ "Wrong xml namespace for widget element");
+ }
+ }
+
+ virtual void Accept(const Text& /*text*/)
+ {
+ ThrowMsg(Exception::ParseError, "param element must be empty");
+ }
+
+ virtual void Verify()
+ {
+ if (m_appControl.m_src == L""){
+ LogWarning("service element must have src element");
+ return;
+ }
+
+ if (m_appControl.m_operation == L""){
+ LogWarning("service element must have operation element");
+ return;
+ }
+
+ FOREACH(iterator, m_data.appControlList) {
+ if (iterator->m_src == m_appControl.m_src &&
+ iterator->m_operation == m_appControl.m_operation )
+ {
+ ThrowMsg(Exception::ParseError,
+ "app control element is duplicated " +
+ DPL::ToUTF8String(m_appControl.m_src) + ", " +
+ DPL::ToUTF8String(m_appControl.m_operation));
+ }
+ }
+ m_data.appControlList.push_back(m_appControl);
+ }
+
+ ElementParserPtr OnSourceElement()
+ {
+ return ElementParserPtr(new SourceParser(m_appControl));
+ }
+
+ ElementParserPtr OnOperationElement()
+ {
+ return ElementParserPtr(new OperationParser(m_appControl));
+ }
+
+ ElementParserPtr OnUriElement()
+ {
+ return ElementParserPtr(new UriParser(m_appControl));
+ }
+
+ ElementParserPtr OnMimeElement()
+ {
+ return ElementParserPtr(new MimeParser(m_appControl));
+ }
+
+ AppControlParser(ConfigParserData& data) :
+ ElementParser(),
+ m_data(data),
+ m_appControl(L"")
+ {
+ }
+
+ private:
+ ConfigParserData& m_data;
+ ConfigParserData::AppControlInfo m_appControl;
+};
+
class ApplicationParser : public ElementParser
{
public:
};
+
ElementParser::ActionFunc WidgetParser::GetElementParser(const DPL::String& /*ns*/,
const DPL::String& name)
{
m_map[L"setting"] =
DPL::MakeDelegate(this, &WidgetParser::OnSettingElement);
// TODO: appservice will be removed
- m_map[L"appservice"] = DPL::MakeDelegate(this, &WidgetParser::OnAppControlElement);
+ m_map[L"appservice"] = DPL::MakeDelegate(this, &WidgetParser::OnAppServiceElement);
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);
- m_map[L"appcontrol"] = DPL::MakeDelegate(this,
+ m_map[L"app-control"] = DPL::MakeDelegate(this,
&WidgetParser::OnAppControlElement);
m_map[L"category"] = DPL::MakeDelegate(this,
&WidgetParser::OnCategoryElement);
return ElementParserPtr(new PrivilegeParser(m_data));
}
+ElementParserPtr WidgetParser::OnAppServiceElement()
+{
+ return ElementParserPtr(new AppServiceParser(m_data));
+}
+
ElementParserPtr WidgetParser::OnAppControlElement()
{
return ElementParserPtr(new AppControlParser(m_data));