From 80ef52df00969a1547b18af00053ea38717dc4b5 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Tue, 20 Oct 2015 16:44:06 +0200 Subject: [PATCH] Parse and generate service application element in wgt-backend wgt::parse::StepParse should use ServiceInfo from manifest handler to generate information for tag in platform manifest file. Requires submit: https://review.tizen.org/gerrit/49880 Change-Id: I1e83ef5800c1b335e0845adb5a5d39b306cc3748 --- src/tpk/step/step_parse.cc | 2 +- src/wgt/step/step_parse.cc | 71 +++++++++++++++++++++++++++++++++++++++++++--- src/wgt/step/step_parse.h | 3 +- 3 files changed, 70 insertions(+), 6 deletions(-) diff --git a/src/tpk/step/step_parse.cc b/src/tpk/step/step_parse.cc index 68ec2c5..909b1b9 100644 --- a/src/tpk/step/step_parse.cc +++ b/src/tpk/step/step_parse.cc @@ -150,7 +150,7 @@ bool StepParse::FillDescription(manifest_x* manifest) { description_x* description = reinterpret_cast (calloc(1, sizeof(description_x))); - description->text = strdup(description_info->description().c_str()); + description->name = strdup(description_info->description().c_str()); description->lang = strdup(description_info->xml_lang().c_str()); manifest->description = g_list_append(manifest->description, description); return true; diff --git a/src/wgt/step/step_parse.cc b/src/wgt/step/step_parse.cc index d9752ca..fb188af 100755 --- a/src/wgt/step/step_parse.cc +++ b/src/wgt/step/step_parse.cc @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -164,11 +165,11 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) { return true; } -bool StepParse::FillApplicationInfo(manifest_x* manifest) { +bool StepParse::FillUIApplicationInfo(manifest_x* manifest) { std::shared_ptr app_info = std::static_pointer_cast( parser_->GetManifestData(app_keys::kTizenApplicationKey)); - if (!app_info.get()) { + if (!app_info) { LOG(ERROR) << "Application info manifest data has not been found."; return false; } @@ -191,6 +192,58 @@ bool StepParse::FillApplicationInfo(manifest_x* manifest) { return true; } +bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) { + std::shared_ptr service_list = + std::static_pointer_cast( + parser_->GetManifestData(app_keys::kTizenServiceKey)); + if (!service_list) + return true; + for (auto& service_info : service_list->services) { + application_x* application = reinterpret_cast + (calloc(1, sizeof(application_x))); + application->component_type = strdup("svcapp"); + application->appid = strdup(service_info.id().c_str()); + application->type = strdup("webapp"); + application->onboot = + service_info.on_boot() ? strdup("true") : strdup("false"); + application->autorestart = + service_info.auto_restart() ? strdup("true") : strdup("false"); + + for (auto& pair : service_info.names()) { + label_x* label = reinterpret_cast(calloc(1, sizeof(label_x))); + if (!pair.first.empty()) + label->lang = strdup(pair.first.c_str()); + label->name = strdup(pair.second.c_str()); + application->label = g_list_append(application->label, label); + } + + if (!service_info.icon().empty()) { + icon_x* icon = reinterpret_cast(calloc(1, sizeof(icon_x))); + icon->text = strdup(service_info.icon().c_str()); + application->icon = g_list_append(application->icon, icon); + } + + // TODO(t.iwanek): what about description, how is it different from name? + + for (auto& category : service_info.categories()) { + application->category = g_list_append(application->category, + strdup(category.c_str())); + } + + for (auto& pair : service_info.metadata_set()) { + metadata_x* item = reinterpret_cast( + calloc(1, sizeof(metadata_x))); + item->key = strdup(pair.first.c_str()); + if (!pair.second.empty()) + item->value = strdup(pair.second.c_str()); + application->metadata = g_list_append(application->metadata, item); + } + + manifest->application = g_list_append(manifest->application, application); + } + return true; +} + bool StepParse::FillAppControl(manifest_x* manifest) { std::shared_ptr app_info_list = std::static_pointer_cast( @@ -283,7 +336,7 @@ bool StepParse::FillExtraManifestInfo(manifest_x* manifest) { bool StepParse::FillManifestX(manifest_x* manifest) { if (!FillIconPaths(manifest)) return false; - if (!FillApplicationInfo(manifest)) + if (!FillUIApplicationInfo(manifest)) return false; if (!FillWidgetInfo(manifest)) return false; @@ -295,6 +348,12 @@ bool StepParse::FillManifestX(manifest_x* manifest) { return false; if (!FillMetadata(manifest)) return false; + // TODO(t.iwanek): fix adding ui application element + // for now adding application service is added here because rest of code + // assumes that there is one application at manifest->application + // so this must execute last + if (!FillServiceApplicationInfo(manifest)) + return false; if (!FillExtraManifestInfo(manifest)) return false; return true; @@ -317,7 +376,11 @@ common_installer::Step::Status StepParse::process() { } if (check_start_file_) { if (!parser_->HasValidStartFile()) { - LOG(ERROR) << "No valid start file" << parser_->GetErrorMessage(); + LOG(ERROR) << parser_->GetErrorMessage(); + return common_installer::Step::Status::ERROR; + } + if (!parser_->HasValidServicesStartFiles()) { + LOG(ERROR) << parser_->GetErrorMessage(); return common_installer::Step::Status::ERROR; } } diff --git a/src/wgt/step/step_parse.h b/src/wgt/step/step_parse.h index 19b5631..d204397 100644 --- a/src/wgt/step/step_parse.h +++ b/src/wgt/step/step_parse.h @@ -45,7 +45,8 @@ class StepParse : public common_installer::Step { bool FillIconPaths(manifest_x* manifest); bool FillWidgetInfo(manifest_x* manifest); - bool FillApplicationInfo(manifest_x* manifest); + bool FillUIApplicationInfo(manifest_x* manifest); + bool FillServiceApplicationInfo(manifest_x* manifest); bool FillAppControl(manifest_x* manifest); bool FillPrivileges(manifest_x* manifest); bool FillCategories(manifest_x* manifest); -- 2.7.4