Add category element at manifest and config.xml
authorSoyoung Kim <sy037.kim@samsung.com>
Wed, 7 Nov 2012 03:09:33 +0000 (12:09 +0900)
committerGerrit Code Review <gerrit2@kim11>
Thu, 20 Dec 2012 07:40:42 +0000 (16:40 +0900)
[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
src/configuration_parser/widget_parser.cpp
src/configuration_parser/widget_parser.h
src/jobs/widget_install/manifest.cpp
src/jobs/widget_install/manifest.h
src/jobs/widget_install/task_manifest_file.cpp
src/jobs/widget_install/task_manifest_file.h

index 701e6c3..490795e 100755 (executable)
@@ -44,6 +44,7 @@
     </xs:complexType>
 </xs:element>
 
+<!-- TODO : appservice will be removed. Please use app-control-->
 <xs:element name="appservice">
     <xs:complexType>
         <xs:attribute name="src" type="xs:NCName" use="required"/>
     </xs:complexType>
 </xs:element>
 
+<xs:element name="app-control">
+  <xs:complexType>
+    <xs:sequence>
+      <xs:choice maxOccurs="unbounded">
+        <xs:element ref="packages:src"/>
+        <xs:element ref="packages:operation"/>
+        <xs:element ref="packages:scheme"/>
+        <xs:element ref="packages:mime"/>
+      </xs:choice>
+    </xs:sequence>
+  </xs:complexType>
+</xs:element>
+
+<xs:element name="category">
+  <xs:complexType>
+    <xs:anyAttribute processContents="lax"/>
+  </xs:complexType>
+</xs:element>
+
+<xs:element name="src">
+  <xs:complexType>
+    <xs:attribute name="name" type="xs:NCName" use="required"/>
+  </xs:complexType>
+</xs:element>
+
+<xs:element name="operation">
+  <xs:complexType>
+    <xs:attribute name="name" type="tizen:appserviceOperationType" use="required"/>
+  </xs:complexType>
+</xs:element>
+
+<xs:element name="scheme">
+  <xs:complexType>
+    <xs:attribute name="name" type="xs:string" use="optional"/>
+  </xs:complexType>
+</xs:element>
+
+<xs:element name="mime">
+  <xs:complexType>
+    <xs:attribute name="name" type="xs:string" use="optional"/>
+  </xs:complexType>
+</xs:element>
+
 </xs:schema>
index 1ead3f3..20ec69e 100644 (file)
@@ -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 &&
index 64d09be..8f8b78d 100644 (file)
@@ -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);
index f231d02..46f367c 100644 (file)
@@ -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
index 84894dd..ecbedee 100644 (file)
@@ -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<MimeType> 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<LabelType> label; //attr name AnySimpleType
     std::list<IconType> icon; //attr name AnySimpleType
-    std::list<ApplicationServiceType> applicationService; //attr name AnySimpleType
+    std::list<AppControlType> 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<LabelType> label;
     std::list<IconType> icon;
-    std::list<ApplicationServiceType> applicationService;
+    std::list<AppControlType> appControl;
+    std::list<AppCategoryType> appCategory;
 };
 
 typedef UiApplication UiApplicationType;
index fb7af25..908c698 100755 (executable)
@@ -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);
     }
 }
 
index 86edffe..adffa7e 100644 (file)
@@ -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);