Add metadata information to the manifest file 10/41810/2
authorTomasz Iwanek <t.iwanek@samsung.com>
Fri, 12 Jun 2015 12:19:13 +0000 (14:19 +0200)
committerTomasz Iwanek <t.iwanek@samsung.com>
Wed, 17 Jun 2015 15:20:36 +0000 (17:20 +0200)
Change-Id: I38c19667042f40c1629ff1886ceeaba67108b065

src/common/step/step_generate_xml.cc
src/wgt/step/step_parse.cc
src/wgt/step/step_parse.h

index 73ab4d8..322668c 100755 (executable)
@@ -130,6 +130,19 @@ Step::Status StepGenerateXml::GenerateApplicationCommonXml(T* app,
 
     xmlTextWriterEndElement(writer);
   }
+
+  metadata_x* meta = nullptr;
+  PKGMGR_LIST_MOVE_NODE_TO_HEAD(app->metadata, meta);
+  for (; meta; meta = meta->next) {
+    xmlTextWriterStartElement(writer, BAD_CAST "metadata");
+    xmlTextWriterWriteAttribute(writer, BAD_CAST "key",
+        BAD_CAST meta->key);
+    if (meta->value)
+      xmlTextWriterWriteAttribute(writer, BAD_CAST "value",
+          BAD_CAST meta->value);
+    xmlTextWriterEndElement(writer);
+  }
+
   return Step::Status::OK;
 }
 
index 45e467c..10662ca 100644 (file)
 
 #include "wgt/wgt_backend_data.h"
 
+#include "utils/clist_helpers.h"
+
 namespace {
 
 const std::string kManifestVersion = "1.0.0";
 
+metadata_x* GenerateMetadataListX(const wgt::parse::MetaDataInfo& meta_info,
+    metadata_x* head) {
+  for (auto& meta : meta_info.metadata()) {
+    metadata_x* new_meta =
+        static_cast<metadata_x*>(calloc(1, sizeof(metadata_x)));
+    new_meta->key = strdup(meta.first.c_str());
+    if (!meta.second.empty())
+      new_meta->value = strdup(meta.second.c_str());
+    LISTADD(head, new_meta);
+  }
+  return head;
 }
 
+}  // namespace
+
 namespace wgt {
 namespace parse {
 
@@ -193,6 +208,29 @@ bool StepParse::FillPrivileges(manifest_x* manifest) {
   return true;
 }
 
+bool StepParse::FillMetadata(manifest_x* manifest) {
+  std::shared_ptr<const MetaDataInfo> meta_info =
+      std::static_pointer_cast<const MetaDataInfo>(parser_->GetManifestData(
+          app_keys::kTizenMetaDataKey));
+  if (!meta_info)
+    return true;
+
+  uiapplication_x* ui_app = nullptr;
+  PKGMGR_LIST_MOVE_NODE_TO_HEAD(manifest->uiapplication, ui_app);
+  for (; ui_app; ui_app = ui_app->next) {
+    manifest->uiapplication->metadata =
+        GenerateMetadataListX(*meta_info, manifest->uiapplication->metadata);
+  }
+  serviceapplication_x* svc_app = nullptr;
+  PKGMGR_LIST_MOVE_NODE_TO_HEAD(manifest->serviceapplication, svc_app);
+  for (; svc_app; svc_app = svc_app->next) {
+    manifest->serviceapplication->metadata =
+        GenerateMetadataListX(*meta_info,
+                              manifest->serviceapplication->metadata);
+  }
+  return true;
+}
+
 bool StepParse::FillManifestX(manifest_x* manifest) {
   if (!FillIconPaths(manifest))
     return false;
@@ -204,6 +242,8 @@ bool StepParse::FillManifestX(manifest_x* manifest) {
     return false;
   if (!FillAppControl(manifest))
     return false;
+  if (!FillMetadata(manifest))
+    return false;
   return true;
 }
 
index 38783b3..3704651 100644 (file)
@@ -45,6 +45,7 @@ class StepParse : public common_installer::Step {
   bool FillApplicationInfo(manifest_x* manifest);
   bool FillAppControl(manifest_x* manifest);
   bool FillPrivileges(manifest_x* manifest);
+  bool FillMetadata(manifest_x* manifest);
   bool FillManifestX(manifest_x* manifest);
 
   std::unique_ptr<parser::ManifestParser> parser_;