From b94ee32391b6740cc930c9e091978c0a02114367 Mon Sep 17 00:00:00 2001 From: Soyoung Kim Date: Wed, 7 Nov 2012 12:09:33 +0900 Subject: [PATCH] Add category element at manifest and config.xml [Issue#] N/A [Problem] N/A [Cause] N/A [Solution] Add category element at config.xml so modify parse. Add app-control element instead of appservice. because appservice will be removed at manifest.xml. --- configuration/config.tizen.xsd | 44 +++++++++++++++ src/configuration_parser/widget_parser.cpp | 75 +++++++++++++++++++++++--- src/configuration_parser/widget_parser.h | 3 +- src/jobs/widget_install/manifest.cpp | 15 ++++-- src/jobs/widget_install/manifest.h | 24 +++++---- src/jobs/widget_install/task_manifest_file.cpp | 27 ++++++++-- src/jobs/widget_install/task_manifest_file.h | 1 + 7 files changed, 161 insertions(+), 28 deletions(-) diff --git a/configuration/config.tizen.xsd b/configuration/config.tizen.xsd index 701e6c3..490795e 100755 --- a/configuration/config.tizen.xsd +++ b/configuration/config.tizen.xsd @@ -44,6 +44,7 @@ + @@ -70,4 +71,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/configuration_parser/widget_parser.cpp b/src/configuration_parser/widget_parser.cpp index 1ead3f3..20ec69e 100644 --- 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 ServiceParser : public ElementParser +class AppControlParser : public ElementParser { public: virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, @@ -1146,7 +1146,7 @@ class ServiceParser : public ElementParser m_data.appServiceList.push_back(serviceInfo); } - ServiceParser(ConfigParserData& data) : + AppControlParser(ConfigParserData& data) : ElementParser(), m_src(DPL::OptionalString::Null), m_operation(DPL::OptionalString::Null), @@ -1417,6 +1417,55 @@ class PrivilegeParser : public ElementParser bool m_properNamespace; }; +class CategoryParser : 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"name") { + if (attribute.value.size() > 0) { + m_name = attribute.value; + } + } + } + + virtual void Accept(const Element& /*element*/) + { + } + + virtual void Accept(const Text& /*text*/) + { + } + + virtual void Verify() + { + if (m_name.IsNull()) { + LogWarning("name attribute of category element is mandatory - ignoring"); + return; + } + + if (m_data.categoryList.find(*m_name) == + m_data.categoryList.end()) { + m_data.categoryList.insert(*m_name); + } + } + + explicit CategoryParser(ConfigParserData& data) : + m_data(data) + { + } + + private: + DPL::OptionalString m_name; + ConfigParserData& m_data; +}; + ElementParser::ActionFunc WidgetParser::GetElementParser(const DPL::String& /*ns*/, const DPL::String& name) { @@ -1449,11 +1498,16 @@ WidgetParser::WidgetParser(ConfigParserData& data) : m_map[L"link"] = DPL::MakeDelegate(this, &WidgetParser::OnLinkElement); m_map[L"setting"] = DPL::MakeDelegate(this, &WidgetParser::OnSettingElement); - m_map[L"appservice"] = DPL::MakeDelegate(this, &WidgetParser::OnServiceElement); + // TODO: appservice will be removed + m_map[L"appservice"] = DPL::MakeDelegate(this, &WidgetParser::OnAppControlElement); 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, + &WidgetParser::OnAppControlElement); + m_map[L"category"] = DPL::MakeDelegate(this, + &WidgetParser::OnCategoryElement); } ElementParserPtr WidgetParser::OnNameElement() @@ -1511,11 +1565,6 @@ ElementParserPtr WidgetParser::OnSettingElement() return ElementParserPtr(new SettingParser(m_data)); } -ElementParserPtr WidgetParser::OnServiceElement() -{ - return ElementParserPtr(new ServiceParser(m_data)); -} - ElementParserPtr WidgetParser::OnApplicationElement() { return ElementParserPtr(new ApplicationParser(m_data)); @@ -1536,6 +1585,16 @@ ElementParserPtr WidgetParser::OnPrivilegeElement() return ElementParserPtr(new PrivilegeParser(m_data)); } +ElementParserPtr WidgetParser::OnAppControlElement() +{ + return ElementParserPtr(new AppControlParser(m_data)); +} + +ElementParserPtr WidgetParser::OnCategoryElement() +{ + return ElementParserPtr(new CategoryParser(m_data)); +} + void WidgetParser::Accept(const Element& element) { if (element.ns != ConfigurationNamespace::W3CWidgetNamespaceName && diff --git a/src/configuration_parser/widget_parser.h b/src/configuration_parser/widget_parser.h index 64d09be..8f8b78d 100644 --- a/src/configuration_parser/widget_parser.h +++ b/src/configuration_parser/widget_parser.h @@ -75,11 +75,12 @@ class WidgetParser : public ElementParser ElementParserPtr OnAccessElement(); ElementParserPtr OnLinkElement(); ElementParserPtr OnSettingElement(); - ElementParserPtr OnServiceElement(); ElementParserPtr OnApplicationElement(); ElementParserPtr OnSplashElement(); ElementParserPtr OnBackgroundElement(); ElementParserPtr OnPrivilegeElement(); + ElementParserPtr OnAppControlElement(); + ElementParserPtr OnCategoryElement(); virtual ActionFunc GetElementParser(const DPL::String& ns, const DPL::String& name); diff --git a/src/jobs/widget_install/manifest.cpp b/src/jobs/widget_install/manifest.cpp index f231d02..46f367c 100644 --- a/src/jobs/widget_install/manifest.cpp +++ b/src/jobs/widget_install/manifest.cpp @@ -210,7 +210,7 @@ void ServiceApplication::serialize(xmlTextWriterPtr writer) writeElementWithOneAttribute(writer, "icon", i->getString(), "xml:lang", i->getLang(), i->hasLang()); } - FOREACH(a, this->applicationService) + FOREACH(a, this->appControl) { a->serialize(writer); } @@ -242,10 +242,16 @@ void UiApplication::serialize(xmlTextWriterPtr writer) writeElementWithOneAttribute(writer, "icon", i->getString(), "xml:lang", i->getLang(), i->hasLang()); } - FOREACH(a, this->applicationService) + FOREACH(a, this->appControl) { a->serialize(writer); } + FOREACH(c, this->appCategory) + { + startElement(writer, "category"); + writeAttribute(writer, "name", *c); + endElement(writer); + } endElement(writer); } @@ -272,9 +278,9 @@ void ImeApplication::serialize(xmlTextWriterPtr writer) endElement(writer); } -void ApplicationService::serialize(xmlTextWriterPtr writer) +void AppControl::serialize(xmlTextWriterPtr writer) { - startElement(writer, "application-service"); + startElement(writer, "app-control"); FOREACH(o, this->operation) { startElement(writer, "operation"); @@ -295,6 +301,5 @@ void ApplicationService::serialize(xmlTextWriterPtr writer) } endElement(writer); } - } //namespace Jobs } //namespace WidgetInstall diff --git a/src/jobs/widget_install/manifest.h b/src/jobs/widget_install/manifest.h index 84894dd..ecbedee 100644 --- a/src/jobs/widget_install/manifest.h +++ b/src/jobs/widget_install/manifest.h @@ -61,6 +61,7 @@ typedef StringWithLang LabelType, IconType, DescriptionType; typedef DPL::String NcnameType, NmtokenType, AnySimpleType, LangType; typedef DPL::String OperationType, MimeType, UriType, TypeType, PackageType; typedef DPL::OptionalString InstallLocationType, CategoriesType; +typedef DPL::String AppCategoryType; /** * xmllib2 wrappers @@ -103,10 +104,10 @@ typedef Author AuthorType; /** * @brief application-service element */ -class ApplicationService +class AppControl { public: - ApplicationService() {} + AppControl() {} void addOperation(const OperationType &x) { this->operation.push_back(x); } void addUri(const UriType &x) { this->uri.push_back(x); } void addMime(const MimeType &x) { this->mime.push_back(x); } @@ -117,7 +118,7 @@ private: std::list mime; //attr name AnySimpleType }; -typedef ApplicationService ApplicationServiceType; +typedef AppControl AppControlType; /** * @brief ime-application element @@ -160,9 +161,9 @@ public: void setType(const TypeType &x) { this->type = x; } void addLabel(const LabelType &x) { this->label.push_back(x); } void addIcon(const IconType &x) { this->icon.push_back(x); } - void addApplicationService(const ApplicationServiceType &x) + void addAppControl(const AppControlType &x) { - this->applicationService.push_back(x); + this->appControl.push_back(x); } void serialize(xmlTextWriterPtr writer); private: @@ -173,7 +174,7 @@ private: TypeType type; std::list label; //attr name AnySimpleType std::list icon; //attr name AnySimpleType - std::list applicationService; //attr name AnySimpleType + std::list appControl; //attr name AnySimpleType }; typedef ServiceApplication ServiceApplicationType; @@ -195,9 +196,13 @@ public: void setCategories(const NcnameType &x) { this->categories = x; } void addLabel(const LabelType &x) { this->label.push_back(x); } void addIcon(const IconType &x) { this->icon.push_back(x); } - void addApplicationService(const ApplicationServiceType &x) + void addAppControl(const AppControlType &x) { - this->applicationService.push_back(x); + this->appControl.push_back(x); + } + void addAppCategory(const AppCategoryType &x) + { + this->appCategory.push_back(x); } void serialize(xmlTextWriterPtr writer); private: @@ -211,7 +216,8 @@ private: CategoriesType categories; std::list label; std::list icon; - std::list applicationService; + std::list appControl; + std::list appCategory; }; typedef UiApplication UiApplicationType; diff --git a/src/jobs/widget_install/task_manifest_file.cpp b/src/jobs/widget_install/task_manifest_file.cpp index fb7af25..908c698 100755 --- a/src/jobs/widget_install/task_manifest_file.cpp +++ b/src/jobs/widget_install/task_manifest_file.cpp @@ -548,6 +548,7 @@ void TaskManifestFile::writeManifest(const DPL::String & path) setWidgetManifest(manifest); setWidgetOtherInfo(uiApp); setAppServiceInfo(uiApp); + setAppCategory(uiApp); manifest.addUiApplication(uiApp); manifest.generate(path); @@ -759,17 +760,33 @@ void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp) // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image; FOREACH(it, appServiceList) { - ApplicationService appService; + AppControl appControl; if (!it->m_operation.empty()) { - appService.addOperation(it->m_operation); //TODO: encapsulation? + appControl.addOperation(it->m_operation); //TODO: encapsulation? } if (!it->m_scheme.empty()) { - appService.addUri(it->m_scheme); + appControl.addUri(it->m_scheme); } if (!it->m_mime.empty()) { - appService.addMime(it->m_mime); + appControl.addMime(it->m_mime); + } + uiApp.addAppControl(appControl); + } +} + +void TaskManifestFile::setAppCategory(UiApplication &uiApp) +{ + WrtDB::ConfigParserData::CategoryList categoryList = + m_context.widgetConfig.configInfo.categoryList; + + if (categoryList.empty()) { + LogInfo("Widget doesn't contain application category"); + return; + } + FOREACH(it, categoryList) { + if (!(*it).empty()) { + uiApp.addAppCategory(*it); } - uiApp.addApplicationService(appService); } } diff --git a/src/jobs/widget_install/task_manifest_file.h b/src/jobs/widget_install/task_manifest_file.h index 86edffe..adffa7e 100644 --- a/src/jobs/widget_install/task_manifest_file.h +++ b/src/jobs/widget_install/task_manifest_file.h @@ -93,6 +93,7 @@ class TaskManifestFile : void setWidgetManifest(Manifest & manifest); void setWidgetOtherInfo(UiApplication & uiApp); void setAppServiceInfo(UiApplication & uiApp); + void setAppCategory(UiApplication & uiApp); void generateWidgetName(Manifest & manifest, UiApplication &uiApp, const DPL::OptionalString& tag, DPL::OptionalString name, bool & defaultNameSaved); void generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag, const DPL::String& language, bool & defaultIconSaved); -- 2.7.4