Parse 'addon' element 44/209744/15
authorJunghoon Park <jh9216.park@samsung.com>
Wed, 10 Jul 2019 11:13:11 +0000 (20:13 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Tue, 13 Aug 2019 01:11:12 +0000 (01:11 +0000)
- Requires :
  https://review.tizen.org/gerrit/#/c/platform/core/appfw/wgt-manifest-handlers/+/209520/
  https://review.tizen.org/gerrit/#/c/platform/core/appfw/app-installers/+/210406/

Change-Id: Icd20bf982b0cd7107bbbbaa9ec6d971df000847d
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
src/wgt/step/configuration/step_parse.cc
src/wgt/step/configuration/step_parse.h
src/wgt/step/pkgmgr/step_generate_xml.cc
src/wgt/wgt_app_query_interface.cc

index ec94a82..9799b3e 100644 (file)
@@ -16,6 +16,7 @@
 #include <common/utils/glist_range.h>
 #include <manifest_parser/utils/version_number.h>
 #include <wgt_manifest_handlers/account_handler.h>
+#include <wgt_manifest_handlers/addon_handler.h>
 #include <wgt_manifest_handlers/app_control_handler.h>
 #include <wgt_manifest_handlers/appdefined_privilege_handler.h>
 #include <wgt_manifest_handlers/application_icons_handler.h>
@@ -192,10 +193,8 @@ bool StepParse::FillIconPaths(manifest_x* manifest) {
   auto app_info =
       GetManifestDataForKey<const wgt::parse::TizenApplicationInfo>(
              app_keys::kTizenApplicationKey);
-  if (!app_info) {
-    LOG(ERROR) << "Application info manifest data has not been found.";
-    return false;
-  }
+  if (!app_info.get())
+    return true;
   auto icons_info =
     GetManifestDataForKey<const wgt::parse::ApplicationIconsInfo>(
            app_keys::kIconsKey);
@@ -273,11 +272,13 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) {
   manifest->nodisplay_setting = strdup("false");
   manifest->installed_storage = strdup("installed_internal");
 
-  // For wgt package use the long name
-  application_x* app =
-      reinterpret_cast<application_x*>(manifest->application->data);
-  for (auto& item : wgt_info->name_set()) {
-    AppendLabel(app, item.second, item.first);
+  if (manifest->application) {
+    // For wgt package use the long name
+    application_x* app =
+        reinterpret_cast<application_x*>(manifest->application->data);
+    for (auto& item : wgt_info->name_set()) {
+      AppendLabel(app, item.second, item.first);
+    }
   }
 
   author_x* author = reinterpret_cast<author_x*>(calloc(1, sizeof(author_x)));
@@ -339,10 +340,8 @@ bool StepParse::FillMainApplicationInfo(manifest_x* manifest) {
   auto app_info =
       GetManifestDataForKey<const wgt::parse::TizenApplicationInfo>(
              app_keys::kTizenApplicationKey);
-  if (!app_info) {
-    LOG(ERROR) << "Application info manifest data has not been found.";
-    return false;
-  }
+  if (!app_info.get())
+    return true;
   bool has_watch_category = false;
   bool has_ime = false;
   bool has_downloadable_font = false;
@@ -432,6 +431,21 @@ bool StepParse::FillMainApplicationInfo(manifest_x* manifest) {
   return true;
 }
 
+bool StepParse::FillAddonInfo(manifest_x* manifest) {
+  auto addon_info = GetManifestDataForKey<const wgt::parse::AddonInfo>(
+      app_keys::kTizenAddonKey);
+  if (!addon_info)
+    return true;
+
+  char *pkg = strdup(addon_info->package().c_str());
+  if (!pkg)
+    return false;
+
+  manifest->package = pkg;
+
+  return true;
+}
+
 bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) {
   auto service_list =
       GetManifestDataForKey<const wgt::parse::ServiceList>(
@@ -564,7 +578,6 @@ bool StepParse::FillWidgetApplicationInfo(manifest_x* manifest) {
   return true;
 }
 
-
 bool StepParse::FillBackgroundCategoryInfo(manifest_x* manifest) {
   auto manifest_data = parser_->GetManifestData(
       app_keys::kTizenBackgroundCategoryKey);
@@ -575,6 +588,9 @@ bool StepParse::FillBackgroundCategoryInfo(manifest_x* manifest) {
   if (!bc_list)
     return true;
 
+  if (!manifest->application)
+    return true;
+
   application_x* app =
       reinterpret_cast<application_x*>(manifest->application->data);
 
@@ -612,6 +628,9 @@ bool StepParse::FillAppControl(manifest_x* manifest) {
       GetManifestDataForKey<const wgt::parse::AppControlInfoList>(
              app_keys::kTizenApplicationAppControlsKey);
 
+  if (!manifest->application)
+    return true;
+
   application_x* app =
       reinterpret_cast<application_x*>(manifest->application->data);
   if (app_info_list) {
@@ -722,6 +741,9 @@ bool StepParse::FillCategories(manifest_x* manifest) {
   if (!category_info)
     return true;
 
+  if (!manifest->application)
+    return true;
+
   application_x* app =
       reinterpret_cast<application_x*>(manifest->application->data);
   // there is one app atm
@@ -806,6 +828,8 @@ bool StepParse::FillManifestX(manifest_x* manifest) {
     return false;
   if (!FillMainApplicationInfo(manifest))
     return false;
+  if (!FillAddonInfo(manifest))
+    return false;
   if (!FillWidgetInfo(manifest))
     return false;
   if (!FillInstallationInfo(manifest))
@@ -898,12 +922,10 @@ common_installer::Step::Status StepParse::process() {
     }
   } else {
     // making backup of content data and services content data
-    auto content_info =
-      GetManifestDataForKey<const wgt::parse::ContentInfo>(
-              wgt::application_widget_keys::kTizenContentKey);
-    auto service_list =
-      GetManifestDataForKey<const wgt::parse::ServiceList>(
-              wgt::application_widget_keys::kTizenServiceKey);
+    auto content_info = GetManifestDataForKey<const wgt::parse::ContentInfo>(
+        app_keys::kTizenContentKey);
+    auto service_list = GetManifestDataForKey<const wgt::parse::ServiceList>(
+        app_keys::kTizenServiceKey);
     if (content_info)
       backend_data->content.set(*content_info);
     if (service_list)
@@ -911,12 +933,12 @@ common_installer::Step::Status StepParse::process() {
   }
 
   // Copy data from ManifestData to InstallerContext
-  auto info =
-      GetManifestDataForKey<const wgt::parse::TizenApplicationInfo>(
-              wgt::application_widget_keys::kTizenApplicationKey);
-  auto wgt_info =
-      GetManifestDataForKey<const wgt::parse::WidgetInfo>(
-              wgt::application_widget_keys::kTizenWidgetKey);
+  auto info = GetManifestDataForKey<const wgt::parse::TizenApplicationInfo>(
+      app_keys::kTizenApplicationKey);
+  auto wgt_info = GetManifestDataForKey<const wgt::parse::WidgetInfo>(
+      app_keys::kTizenWidgetKey);
+  auto addon_info = GetManifestDataForKey<const wgt::parse::AddonInfo>(
+      app_keys::kTizenAddonKey);
 
   std::string name;
   const auto& name_set = wgt_info->name_set();
@@ -933,7 +955,8 @@ common_installer::Step::Status StepParse::process() {
     short_name = short_name_set.begin()->second;
 
   const std::string& package_version = wgt_info->version();
-  const std::string& required_api_version = info->required_version();
+  const std::string& required_api_version = addon_info.get() ?
+      addon_info->required_version() : info->required_version();
 
   manifest_x* manifest =
       static_cast<manifest_x*>(calloc(1, sizeof(manifest_x)));
@@ -972,14 +995,23 @@ common_installer::Step::Status StepParse::process() {
     backend_data->settings.set(*settings_info);
 
   LOG(DEBUG) << " Read data -[ ";
-  LOG(DEBUG) << "App id: " << info->id();
-  LOG(DEBUG) << "  package     = " <<  info->package();
-  LOG(DEBUG) << "  id          = " <<  info->id();
+  if (info.get())
+    LOG(DEBUG) << "App id: " << info->id();
+  if (info.get())
+    LOG(DEBUG) << "  package     = " <<  info->package();
+  else if (addon_info.get())
+    LOG(DEBUG) << "  package     = " <<  addon_info->package();
+  if (info.get())
+    LOG(DEBUG) << "  id          = " <<  info->id();
   LOG(DEBUG) << "  name        = " <<  name;
   LOG(DEBUG) << "  short_name  = " <<  short_name;
   LOG(DEBUG) << "  aplication version     = " <<  package_version;
-  LOG(DEBUG) << "  api_version = " <<  info->required_version();
-  LOG(DEBUG) << "  launch_mode = " <<  info->launch_mode();
+  if (info.get())
+    LOG(DEBUG) << "  api_version = " <<  info->required_version();
+  else if (addon_info.get())
+    LOG(DEBUG) << "  api_version = " <<  addon_info->required_version();
+  if (info.get())
+    LOG(DEBUG) << "  launch_mode = " <<  info->launch_mode();
   LOG(DEBUG) << "  privileges -[";
   for (const auto& p : permissions) {
     LOG(DEBUG) << "    " << p;
index e875f77..5c8593c 100644 (file)
@@ -59,6 +59,7 @@ class StepParse : public common_installer::Step {
   bool FillIconPaths(manifest_x* manifest);
   bool FillWidgetInfo(manifest_x* manifest);
   bool FillMainApplicationInfo(manifest_x* manifest);
+  bool FillAddonInfo(manifest_x* manifest);
   bool FillServiceApplicationInfo(manifest_x* manifest);
   bool FillWidgetApplicationInfo(manifest_x* manifest);
   bool FillAppControl(manifest_x* manifest);
index dc4dc71..f6537f9 100644 (file)
@@ -322,11 +322,6 @@ common_installer::Step::Status StepGenerateXml::precheck() {
     return Step::Status::PACKAGE_NOT_FOUND;
   }
 
-  if (!context_->manifest_data.get()->application) {
-    LOG(ERROR) << "No application in package";
-    return Step::Status::INVALID_VALUE;
-  }
-
   return Step::Status::OK;
 }
 
index c5abeda..736982c 100644 (file)
@@ -21,6 +21,7 @@
 #include <manifest_parser/utils/logging.h>
 #include <wgt_manifest_handlers/application_manifest_constants.h>
 #include <wgt_manifest_handlers/tizen_application_handler.h>
+#include <wgt_manifest_handlers/addon_handler.h>
 #include <wgt_manifest_handlers/widget_handler.h>
 
 #include <tzplatform_config.h>
@@ -61,7 +62,8 @@ std::string WgtAppQueryInterface::GetPkgIdFromPath(
     return {};
   std::vector<std::shared_ptr<parser::ManifestHandler>> handlers = {
     std::make_shared<wgt::parse::WidgetHandler>(),
-    std::make_shared<wgt::parse::TizenApplicationHandler>()
+    std::make_shared<wgt::parse::TizenApplicationHandler>(),
+    std::make_shared<wgt::parse::AddonHandler>()
   };
   std::unique_ptr<parser::ManifestHandlerRegistry> registry(
       new parser::ManifestHandlerRegistry(handlers));
@@ -75,11 +77,16 @@ std::string WgtAppQueryInterface::GetPkgIdFromPath(
   auto info = std::static_pointer_cast<const wgt::parse::TizenApplicationInfo>(
       parser->GetManifestData(
           wgt::application_widget_keys::kTizenApplicationKey));
-  if (!info) {
+
+  auto info_addon = std::static_pointer_cast<const wgt::parse::AddonInfo>(
+      parser->GetManifestData(
+          wgt::application_widget_keys::kTizenAddonKey));
+
+  if (!info && !info_addon) {
     ci::RemoveAll(tmp_path);
     return {};
   }
-  std::string pkg_id = info->package();
+  std::string pkg_id = !info ? info_addon->package() : info->package();
 
   ci::RemoveAll(tmp_path);
   return pkg_id;