Parse new elements for component-based application 91/200691/8
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 28 Feb 2019 07:42:46 +0000 (16:42 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 13 Mar 2019 02:31:35 +0000 (11:31 +0900)
Requires:
 - https://review.tizen.org/gerrit/#/c/platform/core/appfw/pkgmgr-info/+/200568/
 - https://review.tizen.org/gerrit/#/c/platform/core/appfw/tpk-manifest-handlers/+/200669/
 - https://review.tizen.org/gerrit/#/c/platform/core/appfw/app-installers/+/200691/
 - https://review.tizen.org/gerrit/#/c/platform/core/appfw/amd/+/200773/

Change-Id: Ia2a277fd0eaff0c8ad761294b4f45bf29c8e99a4
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/common/step/configuration/step_parse_manifest.cc
src/common/step/configuration/step_parse_manifest.h

index dd81151..0a5b1e4 100644 (file)
@@ -13,6 +13,7 @@
 #include <tpk_manifest_handlers/common/appdefined_privilege_handler.h>
 #include <tpk_manifest_handlers/application_manifest_constants.h>
 #include <tpk_manifest_handlers/author_handler.h>
+#include <tpk_manifest_handlers/component_based_application_handler.h>
 #include <tpk_manifest_handlers/dependencies_handler.h>
 #include <tpk_manifest_handlers/description_handler.h>
 #include <tpk_manifest_handlers/feature_handler.h>
@@ -212,14 +213,31 @@ bool StepParseManifest::FillPackageInfo(manifest_x* manifest) {
   auto watch_application_list =
       std::static_pointer_cast<const tpk::parse::WatchApplicationInfoList>(
           parser_->GetManifestData(app_keys::kWatchApplicationKey));
+  auto component_based_application_list =
+      std::static_pointer_cast<
+          const tpk::parse::ComponentBasedApplicationInfoList>(
+              parser_->GetManifestData(
+                  app_keys::kComponentBasedApplicationKey));
 
   // mandatory check
   if (!ui_application_list && !service_application_list &&
-      !widget_application_list && !watch_application_list) {
+      !widget_application_list && !watch_application_list &&
+      !component_based_application_list) {
     LOG(ERROR) << "UI Application or Service Application or Widget Application "
-                  "or Watch Application are mandatory and has not been found.";
+                  "or Watch Application or Component-Based Application "
+                  "are mandatory and has not been found.";
     return false;
   }
+  if (component_based_application_list) {
+    for (const auto& app : component_based_application_list->items) {
+      if (app.components.components().empty()) {
+        LOG(ERROR) << "Frame-Component or Service-Component is mandatory and "
+                      "has not been found.";
+        return false;
+      }
+    }
+  }
+
 
   int support_mode_val = GetSupportModeVal(pkg_info->support_mode());
 
@@ -1173,6 +1191,100 @@ bool StepParseManifest::FillExtraInfo(manifest_x* manifest) {
   return true;
 }
 
+template <typename T>
+bool StepParseManifest::FillComponentInfo(application_x* app,
+                                          const T& component_list) {
+  for (auto& component : component_list.components()) {
+    component_x* comp =
+        static_cast<component_x*>(calloc(1, sizeof(component_x)));
+    if (!comp) {
+      LOG(ERROR) << "Out of memory";
+      return false;
+    }
+
+    comp->id = strdup(component.id().c_str());
+    comp->type = strdup(component.type().c_str());
+    comp->launch_mode = strdup(component.launch_mode().c_str());
+
+    app->components = g_list_append(app->components, comp);
+  }
+
+  return true;
+}
+
+bool StepParseManifest::FillComponentBasedApplicationInfo(
+    manifest_x* manifest) {
+  std::shared_ptr<const tpk::parse::ComponentBasedApplicationInfoList>
+      component_based_application_list = std::static_pointer_cast<
+          const tpk::parse::ComponentBasedApplicationInfoList>(
+              parser_->GetManifestData(
+                  app_keys::kComponentBasedApplicationKey));
+  if (!component_based_application_list)
+    return true;
+
+  for (const auto& application : component_based_application_list->items) {
+    int package_support_mode_val = atoi(manifest->support_mode);
+    int app_support_mode_val = package_support_mode_val |
+        GetSupportModeVal(application.app_info.support_mode());
+
+    application_x* app =
+        static_cast<application_x*>(calloc(1, sizeof(application_x)));
+    if (!app) {
+      LOG(ERROR) << "Out of memory";
+      return false;
+    }
+
+    app->appid = strdup(application.app_info.appid().c_str());
+    app->launch_mode = strdup(application.app_info.launch_mode().c_str());
+    app->multiple = strdup(application.app_info.multiple().c_str());
+    app->nodisplay = strdup(application.app_info.nodisplay().c_str());
+    app->support_mode = strdup((std::to_string(app_support_mode_val)).c_str());
+    app->taskmanage = strdup(application.app_info.taskmanage().c_str());
+    if (!application.app_info.type().empty())
+      app->type = strdup(application.app_info.type().c_str());
+    else
+      app->type = strdup("c++app");
+    app->indicatordisplay =
+        strdup(application.app_info.indicator_display().c_str());
+    app->component_type = strdup("componentbasedapp");
+    app->hwacceleration = strdup(application.app_info.hwacceleration().c_str());
+    app->onboot = strdup("false");
+    app->autorestart = strdup("false");
+    app->mainapp = strdup(application.app_info.mainapp().c_str());
+    app->screenreader = strdup("use-system-setting");
+    app->recentimage = strdup("false");
+    app->launchcondition = strdup("false");
+    app->guestmode_visibility = strdup("true");
+    app->permission_type = strdup("normal");
+    app->support_ambient = strdup("false");
+    app->effectimage_type = strdup("image");
+    app->submode = strdup("false");
+    app->process_pool = strdup("false");
+    app->package = strdup(manifest->package);
+    app->support_disable = strdup(manifest->support_disable);
+    app->launch_mode = strdup("single");
+    app->api_version = strdup(manifest->api_version);
+    manifest->application = g_list_append(manifest->application, app);
+    if (bf::path(application.app_info.exec().c_str()).is_absolute()) {
+      app->exec = strdup(application.app_info.exec().c_str());
+    } else {
+      app->exec = strdup((context_->root_application_path.get()
+                          / manifest->package / "bin"
+                          / application.app_info.exec()).c_str());
+    }
+    if (!FillLabel(app, application.label))
+      return false;
+    if (!FillImage(app, application.app_images))
+      return false;
+    if (!FillBackgroundCategoryInfo(app, application.background_category))
+      return false;
+    if (!FillComponentInfo(app, application.components))
+      return false;
+  }
+
+  return true;
+}
+
 bool StepParseManifest::FillManifestX(manifest_x* manifest) {
   if (!FillPackageInfo(manifest))
     return false;
@@ -1200,6 +1312,8 @@ bool StepParseManifest::FillManifestX(manifest_x* manifest) {
     return false;
   if (!FillDependencyInfo(manifest))
     return false;
+  if (!FillComponentBasedApplicationInfo(manifest))
+    return false;
   return true;
 }
 
index 4496359..9959113 100644 (file)
@@ -73,6 +73,7 @@ class StepParseManifest : public common_installer::Step {
   bool FillWatchApplication(manifest_x* manifest);
   bool FillTrustAnchorInfo(manifest_x* manifest);
   bool FillDependencyInfo(manifest_x* manifest);
+  bool FillComponentBasedApplicationInfo(manifest_x* manifest);
   int GetSupportModeVal(std::string support_mode);
   bool CheckFeatures();
   void AppendSplashScreen(application_x* app, const std::string& src,
@@ -103,6 +104,9 @@ class StepParseManifest : public common_installer::Step {
   template <typename T>
   bool FillSplashScreen(application_x* app,
       const T& splashscreen_list);
+  template <typename T>
+  bool FillComponentInfo(application_x* app,
+      const T& component_list);
   bool FillExtraInfo(manifest_x* manifest);
   bool FillManifestX(manifest_x* manifest);