Implement parsing res-control 82/258682/8
authorIlho Kim <ilho159.kim@samsung.com>
Mon, 24 May 2021 07:25:47 +0000 (16:25 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Thu, 17 Jun 2021 05:15:35 +0000 (14:15 +0900)
Requires:
 - https://review.tizen.org/gerrit/#/c/platform/core/appfw/tpk-manifest-handlers/+/258681/

Change-Id: Ie09bd3f2a30cbc4f8d45e4992e6b0ec4a22d69ab
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/common/step/configuration/step_parse_manifest.cc
src/common/step/configuration/step_parse_manifest.h

index bfd7389..b11ce10 100644 (file)
@@ -495,6 +495,8 @@ bool StepParseManifest::FillWidgetApplication(manifest_x* manifest) {
       return false;
     if (!FillMetadata(widget_app, application.meta_data))
       return false;
+    if (!FillResControl(widget_app, application.res_controls))
+      return false;
   }
   return true;
 }
@@ -574,6 +576,8 @@ bool StepParseManifest::FillServiceApplication(manifest_x* manifest) {
     if (!FillBackgroundCategoryInfo(service_app,
         application.background_category))
       return false;
+    if (!FillResControl(service_app, application.res_controls))
+      return false;
   }
   return true;
 }
@@ -679,6 +683,8 @@ bool StepParseManifest::FillUIApplication(manifest_x* manifest) {
       return false;
     if (!FillSplashScreen(ui_app, application.app_splashscreens))
       return false;
+    if (!FillResControl(ui_app, application.res_controls))
+      return false;
   }
   return true;
 }
@@ -759,6 +765,8 @@ bool StepParseManifest::FillWatchApplication(manifest_x* manifest) {
     if (!FillBackgroundCategoryInfo(watch_app,
         watch_application.background_category))
       return false;
+    if (!FillResControl(watch_app, watch_application.res_controls))
+      return false;
     manifest->application = g_list_append(manifest->application, watch_app);
   }
   return true;
@@ -1035,6 +1043,33 @@ bool StepParseManifest::FillSplashScreen(application_x* app,
   return true;
 }
 
+template <typename T>
+bool StepParseManifest::FillResControl(application_x* app,
+    const T& res_control_list) {
+  for (auto& res_control : res_control_list) {
+    if (res_control.resource_type().empty())
+      continue;
+
+    res_control_x* rc =
+        static_cast<res_control_x*>(calloc(1, sizeof(res_control_x)));
+    if (!rc) {
+      LOG(ERROR) << "Out of memory";
+      return false;
+    }
+
+    rc->res_type = strdup(res_control.resource_type().c_str());
+    if (!res_control.min_res_version().empty())
+      rc->min_res_version = strdup(res_control.min_res_version().c_str());
+    if (!res_control.max_res_version().empty())
+      rc->max_res_version = strdup(res_control.max_res_version().c_str());
+    if (!res_control.auto_close().empty())
+      rc->auto_close = strdup(res_control.auto_close().c_str());
+
+    app->res_control = g_list_prepend(app->res_control, rc);
+  }
+  return true;
+}
+
 void StepParseManifest::GetLegacySplashScreenFromMetadata(application_x* app,
     const std::string& key, const std::string& val) {
   std::string operation;
@@ -1236,6 +1271,8 @@ bool StepParseManifest::FillComponentBasedApplicationInfo(
       return false;
     if (!FillSplashScreen(app, application.app_splashscreens))
       return false;
+    if (!FillResControl(app, application.res_controls))
+      return false;
   }
 
   return true;
index eadea72..7d824b2 100644 (file)
@@ -104,6 +104,8 @@ class StepParseManifest : public common_installer::Step {
   template <typename T>
   bool FillSplashScreen(application_x* app,
       const T& splashscreen_list);
+  template <typename T>
+  bool FillResControl(application_x* app, const T& res_control_list);
   bool FillExtraInfo(manifest_x* manifest);
   bool FillManifestX(manifest_x* manifest);