From: Soyoung Kim Date: Fri, 4 Jan 2013 07:57:46 +0000 (+0900) Subject: Modify app control element. X-Git-Tag: submit/trunk/20130116.075907~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c1921e20f0095fb6fe4c15418ac6887b8e8e552e;p=platform%2Fframework%2Fweb%2Fwrt-installer.git Modify app control element. [Issue#] N/A [Problem] N/A [Cause] N/A [Solution] - we should provide both appservcie and app-control for the present. - But appservice will be removed. [SCMRequest] have to release after wrt-commons_0.2.90 Change-Id: Ib5bbf07bc260f1ebd297cb7079beaf9c8af7434d --- diff --git a/configuration/config.tizen.xsd b/configuration/config.tizen.xsd index 1a5b1fb..ac081ab 100755 --- a/configuration/config.tizen.xsd +++ b/configuration/config.tizen.xsd @@ -56,6 +56,7 @@ + @@ -83,12 +84,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/configuration_parser/widget_parser.cpp b/src/configuration_parser/widget_parser.cpp index 5ef2769..d740ac3 100755 --- a/src/configuration_parser/widget_parser.cpp +++ b/src/configuration_parser/widget_parser.cpp @@ -1060,7 +1060,7 @@ class SettingParser : public ElementParser ConfigParserData::Setting m_setting; }; -class AppControlParser : public ElementParser +class AppServiceParser : public ElementParser { public: virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, @@ -1146,7 +1146,7 @@ class AppControlParser : public ElementParser m_data.appServiceList.push_back(serviceInfo); } - AppControlParser(ConfigParserData& data) : + AppServiceParser(ConfigParserData& data) : ElementParser(), m_src(DPL::OptionalString::Null), m_operation(DPL::OptionalString::Null), @@ -1164,6 +1164,315 @@ class AppControlParser : public ElementParser 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: @@ -1823,6 +2132,7 @@ class LiveboxParser : public ElementParser }; + ElementParser::ActionFunc WidgetParser::GetElementParser(const DPL::String& /*ns*/, const DPL::String& name) { @@ -1856,12 +2166,12 @@ WidgetParser::WidgetParser(ConfigParserData& data) : 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); @@ -1944,6 +2254,11 @@ ElementParserPtr WidgetParser::OnPrivilegeElement() return ElementParserPtr(new PrivilegeParser(m_data)); } +ElementParserPtr WidgetParser::OnAppServiceElement() +{ + return ElementParserPtr(new AppServiceParser(m_data)); +} + ElementParserPtr WidgetParser::OnAppControlElement() { return ElementParserPtr(new AppControlParser(m_data)); diff --git a/src/configuration_parser/widget_parser.h b/src/configuration_parser/widget_parser.h index 7670388..82b406c 100755 --- a/src/configuration_parser/widget_parser.h +++ b/src/configuration_parser/widget_parser.h @@ -79,6 +79,7 @@ class WidgetParser : public ElementParser ElementParserPtr OnSplashElement(); ElementParserPtr OnBackgroundElement(); ElementParserPtr OnPrivilegeElement(); + ElementParserPtr OnAppServiceElement(); ElementParserPtr OnAppControlElement(); ElementParserPtr OnCategoryElement(); ElementParserPtr OnLiveboxElement(); diff --git a/src/jobs/widget_install/task_manifest_file.cpp b/src/jobs/widget_install/task_manifest_file.cpp index 4a22574..b34b13c 100755 --- a/src/jobs/widget_install/task_manifest_file.cpp +++ b/src/jobs/widget_install/task_manifest_file.cpp @@ -547,6 +547,7 @@ void TaskManifestFile::writeManifest(const DPL::String & path) setWidgetManifest(manifest); setWidgetOtherInfo(uiApp); setAppServiceInfo(uiApp); + setAppControlInfo(uiApp); setAppCategory(uiApp); setLiveBoxInfo(manifest); @@ -765,6 +766,36 @@ void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp) } } +void TaskManifestFile::setAppControlInfo(UiApplication & uiApp) +{ + WrtDB::ConfigParserData::AppControlInfoList appControlList = + m_context.widgetConfig.configInfo.appControlList; + + if (appControlList.empty()) { + LogInfo("Widget doesn't contain app control"); + return; + } + + // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image; + FOREACH(it, appControlList) { + AppControl appControl; + if (!it->m_operation.empty()) { + appControl.addOperation(it->m_operation); //TODO: encapsulation? + } + if (!it->m_uriList.empty()) { + FOREACH(uri, it->m_uriList) { + appControl.addUri(*uri); + } + } + if (!it->m_mimeList.empty()) { + FOREACH(mime, it->m_mimeList) { + appControl.addMime(*mime); + } + } + uiApp.addAppControl(appControl); + } +} + void TaskManifestFile::setAppCategory(UiApplication &uiApp) { WrtDB::ConfigParserData::CategoryList categoryList = diff --git a/src/jobs/widget_install/task_manifest_file.h b/src/jobs/widget_install/task_manifest_file.h index 191bc49..ec9e12b 100755 --- a/src/jobs/widget_install/task_manifest_file.h +++ b/src/jobs/widget_install/task_manifest_file.h @@ -94,7 +94,9 @@ class TaskManifestFile : void setWidgetIcons(UiApplication & uiApp); void setWidgetManifest(Manifest & manifest); void setWidgetOtherInfo(UiApplication & uiApp); + /* please use AppControl. this function will be removed. */ void setAppServiceInfo(UiApplication & uiApp); + void setAppControlInfo(UiApplication & uiApp); void setAppCategory(UiApplication & uiApp); void setLiveBoxInfo(Manifest& manifest);