ConfigParserData::Setting m_setting;
};
-class AppServiceParser : public ElementParser
-{
- public:
- virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
- {
- return &IgnoringParser::Create;
- }
-
- virtual void Accept(const XmlAttribute& attribute)
- {
- if (attribute.name == L"src") {
- m_src = attribute.value;
- } else if (attribute.name == L"operation") {
- m_operation = attribute.value;
- } else if (attribute.name == L"scheme") {
- m_scheme = attribute.value;
- } else if (attribute.name == L"mime") {
- m_mime = attribute.value;
- } else if (attribute.name == L"disposition") {
- if (attribute.value == L"inline")
- m_disposition =
- ConfigParserData::ServiceInfo::Disposition::INLINE;
- }
- }
-
- 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_src.IsNull()) {
- LogWarning("service element must have target attribute");
- return;
- } else if (m_operation.IsNull()) {
- LogWarning("service element must have operation attribute");
- return;
- }
- NormalizeString(m_src);
- NormalizeString(m_operation);
- NormalizeString(m_scheme);
- NormalizeString(m_mime);
-
- // exception
- DPL::String ignoreUri(L"file");
-
- if (!m_scheme.IsNull() && *m_scheme == ignoreUri)
- {
- LogInfo("exception : '" << *m_scheme << "' scheme will be ignored.");
- m_scheme = DPL::OptionalString::Null;
- }
-
- // verify duplicate element
- DPL::String wildString(L"*/*");
- DPL::String nullString(L"");
- ConfigParserData::ServiceInfo serviceInfo(
- m_src.IsNull() ? nullString : *m_src,
- m_operation.IsNull() ? nullString : *m_operation,
- m_scheme.IsNull() ? nullString : *m_scheme,
- m_mime.IsNull() ? nullString : *m_mime,
- m_disposition);
-
- FOREACH(iterator, m_data.appServiceList) {
- if (iterator->m_operation == serviceInfo.m_operation &&
- // check scheme
- (iterator->m_scheme == serviceInfo.m_scheme ||
- // check input scheme is "*/*" case
- (iterator->m_scheme == wildString &&
- serviceInfo.m_scheme != nullString) ||
- // check iterator scheme is "*/*" case
- (serviceInfo.m_scheme == wildString &&
- iterator->m_scheme != nullString)) &&
-
- (iterator->m_mime == serviceInfo.m_mime ||
- // check input mime is "*/*" case
- (iterator->m_mime == wildString &&
- serviceInfo.m_mime != nullString) ||
- // check iterator mime is "*/*" case
- (serviceInfo.m_mime == wildString &&
- iterator->m_mime != nullString)))
- {
- ThrowMsg(Exception::ParseError,
- "service operation is duplicated " +
- DPL::ToUTF8String(*m_operation));
- }
- }
- m_data.appServiceList.push_back(serviceInfo);
- }
-
- AppServiceParser(ConfigParserData& data) :
- ElementParser(),
- m_src(DPL::OptionalString::Null),
- m_operation(DPL::OptionalString::Null),
- m_scheme(DPL::OptionalString::Null),
- m_mime(DPL::OptionalString::Null),
- m_disposition(ConfigParserData::ServiceInfo::Disposition::WINDOW),
- m_data(data)
- {}
-
- private:
- DPL::OptionalString m_src;
- DPL::OptionalString m_operation;
- DPL::OptionalString m_scheme;
- DPL::OptionalString m_mime;
- ConfigParserData::ServiceInfo::Disposition m_disposition;
- ConfigParserData& m_data;
-};
-
class AppControlParser : public ElementParser
{
public:
m_map[L"link"] = DPL::MakeDelegate(this, &WidgetParser::OnLinkElement);
m_map[L"setting"] =
DPL::MakeDelegate(this, &WidgetParser::OnSettingElement);
- // TODO: appservice will be removed
- m_map[L"appservice"] = DPL::MakeDelegate(this,
- &WidgetParser::OnAppServiceElement);
m_map[L"application"] = DPL::MakeDelegate(
this,
&WidgetParser::
return ElementParserPtr(new PrivilegeParser(m_data));
}
-ElementParserPtr WidgetParser::OnAppServiceElement()
-{
- return ElementParserPtr(new AppServiceParser(m_data));
-}
-
ElementParserPtr WidgetParser::OnAppControlElement()
{
return ElementParserPtr(new AppControlParser(m_data));