Parse extra elements in tpk::parse::StepParse 79/53679/4
authorTomasz Iwanek <t.iwanek@samsung.com>
Tue, 8 Dec 2015 12:44:29 +0000 (13:44 +0100)
committerPawel Sikorski <p.sikorski@samsung.com>
Wed, 9 Dec 2015 16:01:48 +0000 (08:01 -0800)
Added parsing for elements:
 - manifest/uiapplication/image,
 - manifest/label.

Requires: https://review.tizen.org/gerrit/53678

Change-Id: I955ce05b99ecdb0bcc336d300f66538d5331a7fa

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

index 2d99e33..5aad6ec 100644 (file)
@@ -136,6 +136,17 @@ common_installer::Step::Status StepGenerateXml::GenerateApplicationCommonXml(
     LOG(DEBUG) << "Icon was not found in package";
   }
 
+  for (image_x* image : GListRange<image_x*>(app->image)) {
+    xmlTextWriterStartElement(writer, BAD_CAST "image");
+    xmlTextWriterWriteAttribute(writer, BAD_CAST "name",
+        BAD_CAST image->name);
+    if (image->lang) {
+      xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
+                                  BAD_CAST image->lang);
+    }
+    xmlTextWriterEndElement(writer);
+  }
+
   for (appcontrol_x* appc : GListRange<appcontrol_x*>(app->appcontrol)) {
     xmlTextWriterStartElement(writer, BAD_CAST "app-control");
 
index 024ec3e..cd5357f 100644 (file)
@@ -132,6 +132,14 @@ bool StepParse::FillPackageInfo(manifest_x* manifest) {
   manifest->installlocation = strdup(pkg_info->install_location().c_str());
   manifest->api_version = strdup(pkg_info->api_version().c_str());
 
+  for (auto& pair : pkg_info->labels()) {
+    label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
+    if (!pair.first.empty())
+      label->lang = strdup(pair.first.c_str());
+    label->name = strdup(pair.second.c_str());
+    manifest->label = g_list_append(manifest->label, label);
+  }
+
   std::shared_ptr<const ProfileInfo> profile_info =
       std::static_pointer_cast<const ProfileInfo>(
           parser_->GetManifestData(ProfileInfo::Key()));
@@ -282,6 +290,8 @@ bool StepParse::FillUIApplication(manifest_x* manifest) {
       return false;
     if (!FillLabel(ui_app, application.label))
       return false;
+    if (!FillImage(ui_app, application.app_images))
+      return false;
     if (!FillMetadata(ui_app, application.meta_data))
       return false;
   }
@@ -372,6 +382,20 @@ bool StepParse::FillMetadata(application_x* app, const T& meta_data_list) {
   return true;
 }
 
+bool StepParse::FillImage(application_x* app,
+                          const tpk::parse::ApplicationImagesInfo& image_list) {
+  for (auto& app_image : image_list.images) {
+    image_x* image =
+        static_cast<image_x*>(calloc(1, sizeof(image_x)));
+    image->name = strdup(app_image.name().c_str());
+    std::string lang = app_image.lang();
+    if (!lang.empty())
+      image->lang = strdup(lang.c_str());
+    app->image = g_list_append(app->image, image);
+  }
+  return true;
+}
+
 bool StepParse::FillAccounts() {
   std::shared_ptr<const AccountInfo> account_info =
       std::static_pointer_cast<const AccountInfo>(parser_->GetManifestData(
index 2558de0..a4df33a 100644 (file)
@@ -8,6 +8,7 @@
 #include <boost/filesystem.hpp>
 #include <tpk_manifest_handlers/privileges_handler.h>
 #include <tpk_manifest_handlers/tpk_config_parser.h>
+#include <tpk_manifest_handlers/ui_and_service_application_infos.h>
 
 #include <memory>
 #include <set>
@@ -57,6 +58,8 @@ class StepParse : public common_installer::Step {
       bool FillLabel(application_x* manifest, const T& label_list);
   template <typename T>
       bool FillMetadata(application_x* manifest, const T& meta_data_list);
+  bool FillImage(application_x* app,
+                 const tpk::parse::ApplicationImagesInfo& label_list);
   bool FillAccounts();
   bool FillShortcuts();
   bool FillManifestX(manifest_x* manifest);