Parse and generate shortcut information in platform manifest 00/49700/1 accepted/tizen/mobile/20151021.013217 accepted/tizen/tv/20151021.013227 accepted/tizen/wearable/20151021.013236 submit/tizen/20151020.153751
authorTomasz Iwanek <t.iwanek@samsung.com>
Fri, 16 Oct 2015 14:19:43 +0000 (16:19 +0200)
committerTomasz Iwanek <t.iwanek@samsung.com>
Mon, 19 Oct 2015 08:09:42 +0000 (10:09 +0200)
Shortcut information is not present in manifest_x structure.
Therefore, additional data member is introduced in context
(same case as for accounts).

Requires submit: https://review.tizen.org/gerrit/49699

Change-Id: I0a814933d08a926ba9b3484ee67fc8bf00363ab7

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

index e0ac906..61006cc 100644 (file)
@@ -49,11 +49,24 @@ class AccountInfo {
   std::vector<SingleAccountInfo> accounts_;
 };
 
+// TODO(t.iwanek): this structure should be unified for manifest handlers of
+// wgt and tpk packages
+struct ShortcutInfo {
+  std::string app_id;
+  std::string extra_data;
+  std::string extra_key;
+  std::string icon;
+  std::vector<std::pair<std::string, std::string>> labels;
+};
+
+using ShortcutListInfo = std::vector<ShortcutInfo>;
+
 class ExtraManifestData {
  public:
   ExtraManifestData() {}
 
   Property<AccountInfo> account_info;
+  Property<ShortcutListInfo> shortcut_info;
 };
 
 class BackendData {
index a4da910..a6fed57 100755 (executable)
@@ -362,6 +362,39 @@ common_installer::Step::Status StepGenerateXml::process() {
     xmlTextWriterEndElement(writer);
   }
 
+  const auto& shortcuts =
+      context_->manifest_plugins_data.get().shortcut_info.get();
+  if (!shortcuts.empty()) {
+    xmlTextWriterStartElement(writer, BAD_CAST "shortcut-list");
+    for (auto& shortcut : shortcuts) {
+      xmlTextWriterStartElement(writer, BAD_CAST "shortcut");
+      if (!shortcut.app_id.empty())
+        xmlTextWriterWriteAttribute(writer, BAD_CAST "appid",
+                                    BAD_CAST shortcut.app_id.c_str());
+      if (!shortcut.app_id.empty())
+        xmlTextWriterWriteAttribute(writer, BAD_CAST "extra_data",
+                                    BAD_CAST shortcut.extra_data.c_str());
+      if (!shortcut.app_id.empty())
+        xmlTextWriterWriteAttribute(writer, BAD_CAST "extra_key",
+                                    BAD_CAST shortcut.extra_key.c_str());
+      if (!shortcut.icon.empty()) {
+        xmlTextWriterStartElement(writer, BAD_CAST "icon");
+        xmlTextWriterWriteString(writer, BAD_CAST shortcut.icon.c_str());
+        xmlTextWriterEndElement(writer);
+      }
+      for (auto& label : shortcut.labels) {
+        xmlTextWriterStartElement(writer, BAD_CAST "label");
+        if (!label.first.empty())
+          xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
+                                      BAD_CAST label.first.c_str());
+        xmlTextWriterWriteString(writer, BAD_CAST label.second.c_str());
+        xmlTextWriterEndElement(writer);
+      }
+      xmlTextWriterEndElement(writer);
+    }
+    xmlTextWriterEndElement(writer);
+  }
+
   xmlTextWriterEndElement(writer);
 
   xmlTextWriterEndDocument(writer);
index 1b0dbf6..e2dc8e8 100644 (file)
@@ -11,6 +11,7 @@
 #include <tpk_manifest_handlers/package_handler.h>
 #include <tpk_manifest_handlers/privileges_handler.h>
 #include <tpk_manifest_handlers/service_application_handler.h>
+#include <tpk_manifest_handlers/shortcut_handler.h>
 #include <tpk_manifest_handlers/ui_application_handler.h>
 #include <manifest_parser/manifest_constants.h>
 
@@ -350,6 +351,27 @@ bool StepParse::FillAccounts() {
   return true;
 }
 
+bool StepParse::FillShortcuts() {
+  std::shared_ptr<const ShortcutListInfo> shortcut_info =
+      std::static_pointer_cast<const ShortcutListInfo>(parser_->GetManifestData(
+          app_keys::kShortcutListKey));
+  if (!shortcut_info)
+    return true;
+
+  common_installer::ShortcutListInfo list;
+  for (auto& shortcut : shortcut_info->shortcuts) {
+    common_installer::ShortcutInfo single_info;
+    single_info.app_id = shortcut.app_id;
+    single_info.extra_data = shortcut.extra_data;
+    single_info.extra_key = shortcut.extra_key;
+    single_info.icon = shortcut.icon;
+    single_info.labels =  shortcut.labels;
+    list.push_back(single_info);
+  }
+  context_->manifest_plugins_data.get().shortcut_info.set(list);
+  return true;
+}
+
 bool StepParse::FillManifestX(manifest_x* manifest) {
   if (!FillPackageInfo(manifest))
     return false;
@@ -361,6 +383,8 @@ bool StepParse::FillManifestX(manifest_x* manifest) {
     return false;
   if (!FillAccounts())
     return false;
+  if (!FillShortcuts())
+    return false;
   return true;
 }
 
index ad964f6..2558de0 100644 (file)
@@ -58,6 +58,7 @@ class StepParse : public common_installer::Step {
   template <typename T>
       bool FillMetadata(application_x* manifest, const T& meta_data_list);
   bool FillAccounts();
+  bool FillShortcuts();
   bool FillManifestX(manifest_x* manifest);
 
   std::unique_ptr<tpk::parse::TPKConfigParser> parser_;