From 3703c42cff26379a47d15ac625a6bcf3293cd13f Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Wed, 10 Jul 2019 20:13:11 +0900 Subject: [PATCH] Parse 'addon' element - 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 --- src/wgt/step/configuration/step_parse.cc | 96 +++++++++++++++++++++----------- src/wgt/step/configuration/step_parse.h | 1 + src/wgt/step/pkgmgr/step_generate_xml.cc | 5 -- src/wgt/wgt_app_query_interface.cc | 13 ++++- 4 files changed, 75 insertions(+), 40 deletions(-) diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index ec94a82..9799b3e 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -192,10 +193,8 @@ bool StepParse::FillIconPaths(manifest_x* manifest) { auto app_info = GetManifestDataForKey( 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( 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(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(manifest->application->data); + for (auto& item : wgt_info->name_set()) { + AppendLabel(app, item.second, item.first); + } } author_x* author = reinterpret_cast(calloc(1, sizeof(author_x))); @@ -339,10 +340,8 @@ bool StepParse::FillMainApplicationInfo(manifest_x* manifest) { auto app_info = GetManifestDataForKey( 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( + 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( @@ -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(manifest->application->data); @@ -612,6 +628,9 @@ bool StepParse::FillAppControl(manifest_x* manifest) { GetManifestDataForKey( app_keys::kTizenApplicationAppControlsKey); + if (!manifest->application) + return true; + application_x* app = reinterpret_cast(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(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( - wgt::application_widget_keys::kTizenContentKey); - auto service_list = - GetManifestDataForKey( - wgt::application_widget_keys::kTizenServiceKey); + auto content_info = GetManifestDataForKey( + app_keys::kTizenContentKey); + auto service_list = GetManifestDataForKey( + 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( - wgt::application_widget_keys::kTizenApplicationKey); - auto wgt_info = - GetManifestDataForKey( - wgt::application_widget_keys::kTizenWidgetKey); + auto info = GetManifestDataForKey( + app_keys::kTizenApplicationKey); + auto wgt_info = GetManifestDataForKey( + app_keys::kTizenWidgetKey); + auto addon_info = GetManifestDataForKey( + 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(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; diff --git a/src/wgt/step/configuration/step_parse.h b/src/wgt/step/configuration/step_parse.h index e875f77..5c8593c 100644 --- a/src/wgt/step/configuration/step_parse.h +++ b/src/wgt/step/configuration/step_parse.h @@ -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); diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc index dc4dc71..f6537f9 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.cc +++ b/src/wgt/step/pkgmgr/step_generate_xml.cc @@ -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; } diff --git a/src/wgt/wgt_app_query_interface.cc b/src/wgt/wgt_app_query_interface.cc index c5abeda..736982c 100644 --- a/src/wgt/wgt_app_query_interface.cc +++ b/src/wgt/wgt_app_query_interface.cc @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -61,7 +62,8 @@ std::string WgtAppQueryInterface::GetPkgIdFromPath( return {}; std::vector> handlers = { std::make_shared(), - std::make_shared() + std::make_shared(), + std::make_shared() }; std::unique_ptr registry( new parser::ManifestHandlerRegistry(handlers)); @@ -75,11 +77,16 @@ std::string WgtAppQueryInterface::GetPkgIdFromPath( auto info = std::static_pointer_cast( parser->GetManifestData( wgt::application_widget_keys::kTizenApplicationKey)); - if (!info) { + + auto info_addon = std::static_pointer_cast( + 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; -- 2.7.4