Pass manifest_x directly to pkgmgr_parser API 53/51953/20 accepted/tizen/mobile/20151212.071403 accepted/tizen/tv/20151212.072839 accepted/tizen/wearable/20151212.074754 submit/tizen/20151211.155929
authorTomasz Iwanek <t.iwanek@samsung.com>
Tue, 17 Nov 2015 09:57:59 +0000 (10:57 +0100)
committerPawel Sikorski <p.sikorski@samsung.com>
Fri, 11 Dec 2015 16:00:21 +0000 (17:00 +0100)
manifest_x structure is prepared inside app-installers and
passed to API (according to changes) to prevent extra parsing
of xml file.

Each lang member is now assigned with value of DEFAULT_LOCALE macro as
pkgmgr-info expects this.

Application exec attribute was fixed to contain full path.

Requires: https://review.tizen.org/gerrit/54114

Requires submission together with: https://review.tizen.org/gerrit/51972

Change-Id: I480d1905b4e885756f8140210e56f8fcca58f455

14 files changed:
src/common/pkgmgr_interface.h
src/common/pkgmgr_registration.cc
src/common/pkgmgr_registration.h
src/common/step/step_copy_tep.cc
src/common/step/step_generate_xml.cc
src/common/step/step_recover_application.cc
src/common/step/step_register_app.cc
src/common/step/step_unregister_app.cc
src/common/step/step_update_app.cc
src/tpk/step/step_create_symbolic_link.cc
src/tpk/step/step_parse.cc
src/tpk/step/step_parse.h
src/wgt/step/step_parse.cc
src/wgt/step/step_parse.h

index 4429a00..79f189f 100644 (file)
@@ -5,10 +5,9 @@
 #ifndef COMMON_PKGMGR_INTERFACE_H_
 #define COMMON_PKGMGR_INTERFACE_H_
 
+#include <boost/filesystem/path.hpp>
 #include <manifest_parser/utils/logging.h>
 #include <pkgmgr_installer.h>
-
-#include <boost/filesystem/path.hpp>
 #include <memory>
 
 #include "common/app_query_interface.h"
index b839add..072a0fd 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <manifest_parser/utils/logging.h>
 #include <pkgmgr_installer.h>
+#include <pkgmgr_parser_db.h>
 #include <tzplatform_config.h>
 #include <unistd.h>
 
@@ -13,14 +14,6 @@ namespace bf = boost::filesystem;
 
 namespace {
 
-// TODO(sdi2): Check if data->removable is correctly setting
-// during parsing step.
-// Same check should be done for preload field.
-
-// Having a specific step to implement a installer commandline tool
-// for image build could be usefull also.
-const char* const kAppinstTags[] = {"removable=true", nullptr, };
-
 bool RegisterAuthorCertificate(
     const common_installer::CertificateInfo& cert_info,
     const std::string& pkgid, uid_t uid) {
@@ -68,53 +61,82 @@ int PkgmgrForeachPrivilegeCallback(const char* privilege_name,
   return PMINFO_R_OK;
 }
 
-}  // anonymous namespace
-
-namespace common_installer {
-
-bool RegisterAppInPkgmgrWithTep(const bf::path& tep_path,
-                         const bf::path& xml_path,
-                         const std::string & pkgid,
-                         const CertificateInfo & cert_info,
-                         uid_t uid,
-                         RequestMode request_mode) {
-  int ret = request_mode != RequestMode::GLOBAL ?
-      pkgmgr_parser_parse_usr_manifest_for_installation_withtep(
-          xml_path.c_str(), tep_path.c_str(),
-          uid, const_cast<char* const*>(kAppinstTags)) :
-      pkgmgr_parser_parse_manifest_for_installation_withtep(
-          xml_path.c_str(), tep_path.c_str(),
-          const_cast<char* const*>(kAppinstTags));
-
-  if (ret) {
-    LOG(ERROR) << "Failed to register package: " << xml_path << ", "
-        "error code=" << ret;
+bool AssignPackageTags(const std::string& pkgid, manifest_x* manifest,
+                       common_installer::RequestMode request_mode,
+                       bool is_update) {
+  int ret = pkgmgr_parser_preload_package_type(pkgid.c_str());
+  if (ret == -1) {
+    LOG(ERROR) << "pkgmgr_parser_preload_package_type failed";
     return false;
   }
-
-  if (!!cert_info.author_certificate.get()) {
-    if (!RegisterAuthorCertificate(cert_info, pkgid, uid)) {
-      LOG(ERROR) << "Failed to register author certificate";
+  // this flag is actually set by preloaded app update to "true" but it is never
+  // read anyway.
+  if (request_mode == common_installer::RequestMode::GLOBAL && is_update)
+    manifest->update = strdup("true");
+  else
+    manifest->update = strdup("false");
+  // external installation should alter this flag
+  manifest->installed_storage = strdup("installed_internal");
+
+  if (request_mode == common_installer::RequestMode::USER) {
+    manifest->preload = strdup("false");
+    manifest->removable = strdup("true");
+    manifest->readonly = strdup("false");
+    manifest->system = strdup("false");
+  } else {
+    switch (ret) {
+    case PM_PRELOAD_NONE:
+      manifest->preload = strdup("false");
+      manifest->removable = strdup("true");
+      manifest->readonly = strdup("false");
+      manifest->system = strdup("false");
+      break;
+    case PM_PRELOAD_RW_NORM:
+      manifest->preload = strdup("true");
+      manifest->removable = strdup("false");
+      manifest->readonly = strdup("true");
+      manifest->system = strdup("true");
+      break;
+    case PM_PRELOAD_RW_RM:
+      manifest->preload = strdup("true");
+      manifest->removable = strdup("true");
+      manifest->readonly = strdup("true");
+      manifest->system = strdup("false");
+      break;
+    default:
+      LOG(ERROR) <<
+          "Unknown value returned by pkgmgr_parser_preload_package_type";
       return false;
     }
   }
-
   return true;
 }
 
-bool RegisterAppInPkgmgr(const bf::path& xml_path,
+}  // anonymous namespace
+
+namespace common_installer {
+
+bool RegisterAppInPkgmgr(manifest_x* manifest,
+                         const bf::path& xml_path,
                          const std::string& pkgid,
                          const CertificateInfo& cert_info,
                          uid_t uid,
-                         RequestMode request_mode) {
+                         RequestMode request_mode,
+                         const boost::filesystem::path& tep_path) {
+  // Fill "non-xml" elements
+  if (!tep_path.empty())
+    manifest->tep_name = strdup(tep_path.c_str());
+
+  if (!AssignPackageTags(pkgid, manifest, request_mode, false))
+    return false;
+
   int ret = request_mode != RequestMode::GLOBAL ?
-      pkgmgr_parser_parse_usr_manifest_for_installation(
-          xml_path.c_str(), uid, const_cast<char* const*>(kAppinstTags)) :
-      pkgmgr_parser_parse_manifest_for_installation(
-          xml_path.c_str(), const_cast<char* const*>(kAppinstTags));
+      pkgmgr_parser_process_usr_manifest_x_for_installation(manifest,
+          xml_path.c_str(), uid) :
+      pkgmgr_parser_process_manifest_x_for_installation(manifest,
+          xml_path.c_str());
   if (ret) {
-    LOG(ERROR) << "Failed to register package: " << xml_path << ", "
-        "error code=" << ret;
+    LOG(ERROR) << "Failed to insert manifest into pkgmgr, error code=" << ret;
     return false;
   }
 
@@ -144,19 +166,22 @@ bool UpdateTepInfoInPkgmgr(const bf::path& tep_path, const std::string& pkgid,
   return true;
 }
 
-bool UpgradeAppInPkgmgr(const bf::path& xml_path, const std::string& pkgid,
-                        const CertificateInfo& cert_info, uid_t uid,
+bool UpgradeAppInPkgmgr(manifest_x* manifest,
+                        const bf::path& xml_path,
+                        const std::string& pkgid,
+                        const CertificateInfo& cert_info,
+                        uid_t uid,
                         RequestMode request_mode) {
+  if (!AssignPackageTags(pkgid, manifest, request_mode, true))
+    return false;
+
   int ret = request_mode != RequestMode::GLOBAL ?
-       pkgmgr_parser_parse_usr_manifest_for_upgrade(
-           xml_path.string().c_str(), uid,
-           const_cast<char* const*>(kAppinstTags)) :
-       pkgmgr_parser_parse_manifest_for_upgrade(
-           xml_path.string().c_str(),
-           const_cast<char* const*>(kAppinstTags));
+       pkgmgr_parser_process_usr_manifest_x_for_upgrade(manifest,
+          xml_path.c_str(), uid) :
+       pkgmgr_parser_process_manifest_x_for_upgrade(manifest, xml_path.c_str());
 
   if (ret != 0) {
-    LOG(ERROR) << "Failed to upgrade package: " << xml_path;
+    LOG(ERROR) << "Failed to update manifest in pkgmgr, error code=" << ret;
     return false;
   }
 
@@ -170,18 +195,18 @@ bool UpgradeAppInPkgmgr(const bf::path& xml_path, const std::string& pkgid,
   return true;
 }
 
-bool UnregisterAppInPkgmgr(const bf::path& xml_path,
+bool UnregisterAppInPkgmgr(manifest_x* manifest,
+                           const bf::path& xml_path,
                            const std::string& pkgid,
                            uid_t uid,
                            RequestMode request_mode) {
   int ret = request_mode != RequestMode::GLOBAL ?
-      pkgmgr_parser_parse_usr_manifest_for_uninstallation(
-          xml_path.string().c_str(), uid,
-          const_cast<char* const*>(kAppinstTags)) :
-      pkgmgr_parser_parse_manifest_for_uninstallation(
-          xml_path.string().c_str(), const_cast<char* const*>(kAppinstTags));
+      pkgmgr_parser_process_usr_manifest_x_for_uninstallation(manifest,
+          xml_path.c_str(), uid) :
+      pkgmgr_parser_process_manifest_x_for_uninstallation(manifest,
+          xml_path.c_str());
   if (ret) {
-    LOG(ERROR) << "Failed to unregister package: " << xml_path;
+    LOG(ERROR) << "Failed to delete manifest from pkgmgr, error code=" << ret;
     return false;
   }
 
index 9232c2d..86fc457 100644 (file)
@@ -27,18 +27,14 @@ namespace common_installer {
  *
  * \return true if success
  */
-bool RegisterAppInPkgmgr(const boost::filesystem::path& xml_path,
-                         const std::string& pkgid,
-                         const CertificateInfo& cert_info,
-                         uid_t uid,
-                         RequestMode request_mode);
-
-bool RegisterAppInPkgmgrWithTep(const boost::filesystem::path& tep_path,
+bool RegisterAppInPkgmgr(manifest_x* manifest,
                          const boost::filesystem::path& xml_path,
                          const std::string& pkgid,
                          const CertificateInfo& cert_info,
                          uid_t uid,
-                         RequestMode request_mode);
+                         RequestMode request_mode,
+                         const boost::filesystem::path& tep_path =
+                             boost::filesystem::path());
 
 /**
  * \brief Adapter interface for external PkgMgr module used for upgrading
@@ -52,7 +48,8 @@ bool RegisterAppInPkgmgrWithTep(const boost::filesystem::path& tep_path,
  *
  * \return true if success
  */
-bool UpgradeAppInPkgmgr(const boost::filesystem::path& xml_path,
+bool UpgradeAppInPkgmgr(manifest_x* manifest,
+                        const boost::filesystem::path& xml_path,
                         const std::string& pkgid,
                         const CertificateInfo& cert_info,
                         uid_t uid,
@@ -85,7 +82,8 @@ bool UpdateTepInfoInPkgmgr(const boost::filesystem::path& tep_path,
  *
  * \return true if success
  */
-bool UnregisterAppInPkgmgr(const boost::filesystem::path& xml_path,
+bool UnregisterAppInPkgmgr(manifest_x* manifest,
+                           const boost::filesystem::path& xml_path,
                            const std::string& pkgid,
                            uid_t uid,
                            RequestMode request_mode);
index f1d6f95..0d54c38 100644 (file)
@@ -46,7 +46,7 @@ Step::Status StepCopyTep::process() {
     context_->root_application_path.get() / context_->pkgid.get());
 
   bf::path tep_path =
-    context_->pkg_path.get() / "res" / context_->tep_path.get().filename();
+      context_->pkg_path.get() / "res" / context_->tep_path.get().filename();
   bs::error_code error;
 
   if (context_->is_tep_move.get()) {
index 5aad6ec..000f0f6 100644 (file)
@@ -33,6 +33,9 @@ void WriteUIApplicationAttributes(
   if (app->nodisplay)
     xmlTextWriterWriteAttribute(writer, BAD_CAST "nodisplay",
         BAD_CAST app->nodisplay);
+  if (app->multiple)
+    xmlTextWriterWriteAttribute(writer, BAD_CAST "multiple",
+        BAD_CAST app->multiple);
   if (app->launch_mode && strlen(app->launch_mode))
     xmlTextWriterWriteAttribute(writer, BAD_CAST "launch_mode",
         BAD_CAST app->launch_mode);
@@ -102,7 +105,7 @@ common_installer::Step::Status StepGenerateXml::GenerateApplicationCommonXml(
 
   for (label_x* label : GListRange<label_x*>(app->label)) {
     xmlTextWriterStartElement(writer, BAD_CAST "label");
-    if (label->lang && strlen(label->lang)) {
+    if (label->lang && strcmp(DEFAULT_LOCALE, label->lang) != 0) {
       xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
                                   BAD_CAST label->lang);
     }
@@ -140,10 +143,14 @@ common_installer::Step::Status StepGenerateXml::GenerateApplicationCommonXml(
     xmlTextWriterStartElement(writer, BAD_CAST "image");
     xmlTextWriterWriteAttribute(writer, BAD_CAST "name",
         BAD_CAST image->name);
-    if (image->lang) {
+    if (image->lang && strcmp(DEFAULT_LOCALE, image->lang) != 0) {
       xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
+
                                   BAD_CAST image->lang);
     }
+    if (image->section)
+      xmlTextWriterWriteAttribute(writer, BAD_CAST "section",
+                                  BAD_CAST image->section);
     xmlTextWriterEndElement(writer);
   }
 
@@ -283,7 +290,7 @@ common_installer::Step::Status StepGenerateXml::process() {
   for (label_x* label :
        GListRange<label_x*>(context_->manifest_data.get()->label)) {
     xmlTextWriterStartElement(writer, BAD_CAST "label");
-    if (label->lang && strlen(label->lang)) {
+    if (label->lang && strcmp(DEFAULT_LOCALE, label->lang) != 0) {
       xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
                                   BAD_CAST label->lang);
     }
@@ -309,11 +316,11 @@ common_installer::Step::Status StepGenerateXml::process() {
   for (description_x* description :
        GListRange<description_x*>(context_->manifest_data.get()->description)) {
     xmlTextWriterStartElement(writer, BAD_CAST "description");
-    if (description->lang && strlen(description->lang)) {
+    if (description->lang && strcmp(DEFAULT_LOCALE, description->lang) != 0) {
       xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
                                   BAD_CAST description->lang);
     }
-    xmlTextWriterWriteString(writer, BAD_CAST description->name);
+    xmlTextWriterWriteString(writer, BAD_CAST description->text);
     xmlTextWriterEndElement(writer);
   }
 
index ad948b0..b194e3b 100644 (file)
@@ -17,7 +17,8 @@ namespace pkgmgr {
 Step::Status StepRecoverApplication::RecoveryNew() {
   if (!SetXmlPaths())
     return Status::OK;
-  UnregisterAppInPkgmgr(context_->xml_path.get(),
+  UnregisterAppInPkgmgr(context_->manifest_data.get(),
+                        context_->xml_path.get(),
                         context_->pkgid.get(),
                         context_->uid.get(),
                         context_->request_mode.get());
@@ -31,11 +32,13 @@ Step::Status StepRecoverApplication::RecoveryUpdate() {
   }
   bf::path xml_path = bf::exists(context_->backup_xml_path.get()) ?
         context_->backup_xml_path.get() : context_->xml_path.get();
-  UnregisterAppInPkgmgr(xml_path,
+  UnregisterAppInPkgmgr(context_->manifest_data.get(),
+                        xml_path,
                         context_->pkgid.get(),
                         context_->uid.get(),
                         context_->request_mode.get());
-  if (!RegisterAppInPkgmgr(xml_path,
+  if (!RegisterAppInPkgmgr(context_->manifest_data.get(),
+                           xml_path,
                            context_->pkgid.get(),
                            context_->certificate_info.get(),
                            context_->uid.get(),
index 0b13603..fe537ab 100644 (file)
@@ -31,12 +31,13 @@ Step::Status StepRegisterApplication::precheck() {
 }
 
 Step::Status StepRegisterApplication::process() {
-  if (!RegisterAppInPkgmgrWithTep(context_->tep_path.get(),
-                                  context_->xml_path.get(),
-                                  context_->pkgid.get(),
-                                  context_->certificate_info.get(),
-                                  context_->uid.get(),
-                                  context_->request_mode.get())) {
+  if (!RegisterAppInPkgmgr(context_->manifest_data.get(),
+                           context_->xml_path.get(),
+                           context_->pkgid.get(),
+                           context_->certificate_info.get(),
+                           context_->uid.get(),
+                           context_->request_mode.get(),
+                           context_->tep_path.get())) {
     LOG(ERROR) << "Failed to register the app";
     return Step::Status::ERROR;
   }
@@ -46,7 +47,8 @@ Step::Status StepRegisterApplication::process() {
 }
 
 Step::Status StepRegisterApplication::undo() {
-  if (!UnregisterAppInPkgmgr(context_->xml_path.get(),
+  if (!UnregisterAppInPkgmgr(context_->manifest_data.get(),
+                             context_->xml_path.get(),
                              context_->pkgid.get(),
                              context_->uid.get(),
                              context_->request_mode.get())) {
index d906e83..9e00a78 100644 (file)
@@ -76,7 +76,8 @@ Step::Status StepUnregisterApplication::process() {
     return Status::ERROR;
   }
 
-  if (!UnregisterAppInPkgmgr(context_->xml_path.get(),
+  if (!UnregisterAppInPkgmgr(context_->manifest_data.get(),
+                             context_->xml_path.get(),
                              context_->pkgid.get(),
                              context_->uid.get(),
                              context_->request_mode.get())) {
@@ -94,7 +95,8 @@ Step::Status StepUnregisterApplication::process() {
 }
 
 Step::Status StepUnregisterApplication::undo() {
-  if (!RegisterAppInPkgmgr(context_->backup_xml_path.get(),
+  if (!RegisterAppInPkgmgr(context_->manifest_data.get(),
+                           context_->backup_xml_path.get(),
                            context_->pkgid.get(),
                            context_->certificate_info.get(),
                            context_->uid.get(),
index bdec89c..6c85f34 100644 (file)
@@ -33,7 +33,8 @@ Step::Status StepUpdateApplication::precheck() {
 }
 
 Step::Status StepUpdateApplication::process() {
-  if (!UpgradeAppInPkgmgr(context_->xml_path.get(),
+  if (!UpgradeAppInPkgmgr(context_->manifest_data.get(),
+                          context_->xml_path.get(),
                           context_->pkgid.get(),
                           context_->certificate_info.get(),
                           context_->uid.get(),
@@ -64,7 +65,8 @@ Step::Status StepUpdateApplication::undo() {
     }
   }
 
-  if (!UpgradeAppInPkgmgr(context_->backup_xml_path.get(),
+  if (!UpgradeAppInPkgmgr(context_->old_manifest_data.get(),
+                          context_->backup_xml_path.get(),
                           context_->pkgid.get(), certificate_info,
                           context_->uid.get(),
                           context_->request_mode.get())) {
index aab7b0d..8c1aab1 100644 (file)
@@ -43,9 +43,8 @@ bool CreateSymLink(application_x* app, InstallerContext* context) {
   }
 
   // Give an execution permission to the original executable
-  bf::path exec_path = bindir / bf::path(app->exec);
-  LOG(DEBUG) << "Giving exec permission to " << exec_path;
-  bf::permissions(exec_path, bf::owner_all |
+  LOG(DEBUG) << "Giving exec permission to " << app->exec;
+  bf::permissions(bf::path(app->exec), bf::owner_all |
       bf::group_read | bf::group_exe |
       bf::others_read | bf::others_exe, boost_error);
   if (boost_error) {
index 54ae4f5..87037ff 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <pkgmgr/pkgmgr_parser.h>
 
+#include <chrono>
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
@@ -101,6 +102,15 @@ bf::path StepParse::LocateConfigFile() const {
   return path;
 }
 
+bool StepParse::FillInstallationInfo(manifest_x* manifest) {
+  manifest->root_path = strdup(
+      (context_->root_application_path.get() / manifest->package).c_str());
+  manifest->installed_time =
+      strdup(std::to_string(std::chrono::system_clock::to_time_t(
+          std::chrono::system_clock::now())).c_str());
+  return true;
+}
+
 bool StepParse::FillPackageInfo(manifest_x* manifest) {
   std::shared_ptr<const PackageInfo> pkg_info =
       std::static_pointer_cast<const PackageInfo>(
@@ -128,6 +138,8 @@ bool StepParse::FillPackageInfo(manifest_x* manifest) {
   manifest->package = strdup(pkg_info->package().c_str());
   manifest->nodisplay_setting = strdup(pkg_info->nodisplay_setting().c_str());
   manifest->type = strdup("tpk");
+  manifest->appsetting = strdup("false");
+  manifest->support_disable = strdup("false");
   manifest->version = strdup(pkg_info->version().c_str());
   manifest->installlocation = strdup(pkg_info->install_location().c_str());
   manifest->api_version = strdup(pkg_info->api_version().c_str());
@@ -136,6 +148,8 @@ bool StepParse::FillPackageInfo(manifest_x* manifest) {
     label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
     if (!pair.first.empty())
       label->lang = strdup(pair.first.c_str());
+    else
+      label->lang = strdup(DEFAULT_LOCALE);
     label->name = strdup(pair.second.c_str());
     manifest->label = g_list_append(manifest->label, label);
   }
@@ -174,6 +188,7 @@ bool StepParse::FillAuthorInfo(manifest_x* manifest) {
   author->text = strdup(author_info->name().c_str());
   author->email = strdup(author_info->email().c_str());
   author->href = strdup(author_info->href().c_str());
+  author->lang = strdup(DEFAULT_LOCALE);
   manifest->author = g_list_append(manifest->author, author);
   return true;
 }
@@ -190,8 +205,9 @@ bool StepParse::FillDescription(manifest_x* manifest) {
 
   description_x* description = reinterpret_cast<description_x*>
       (calloc(1, sizeof(description_x)));
-  description->name = strdup(description_info->description().c_str());
-  description->lang = strdup(description_info->xml_lang().c_str());
+  description->text = strdup(description_info->description().c_str());
+  description->lang = !description_info->xml_lang().empty() ?
+      strdup(description_info->xml_lang().c_str()) : strdup(DEFAULT_LOCALE);
   manifest->description = g_list_append(manifest->description, description);
   return true;
 }
@@ -219,18 +235,37 @@ bool StepParse::FillServiceApplication(manifest_x* manifest) {
     return true;
 
   for (const auto& application : service_application_list->items) {
+    // if there is no app yet, set this app as mainapp
+    bool main_app = manifest->application == nullptr;
+
     application_x* service_app =
         static_cast<application_x*>(calloc(1, sizeof(application_x)));
     service_app->appid = strdup(application.sa_info.appid().c_str());
     service_app->autorestart =
         strdup(application.sa_info.auto_restart().c_str());
-    service_app->exec = strdup(application.sa_info.exec().c_str());
+    service_app->exec = strdup((context_->root_application_path.get()
+                           / manifest->package / "bin"
+                           / application.sa_info.exec()).c_str());
     service_app->onboot = strdup(application.sa_info.on_boot().c_str());
     service_app->type = strdup(application.sa_info.type().c_str());
     service_app->process_pool =
         strdup(application.sa_info.process_pool().c_str());
-
     service_app->component_type = strdup("svcapp");
+    service_app->mainapp = main_app ? strdup("true") : strdup("false");
+    service_app->enabled = strdup("true");
+    service_app->hwacceleration = strdup("default");
+    service_app->screenreader = strdup("use-system-setting");
+    service_app->recentimage = strdup("false");
+    service_app->launchcondition = strdup("false");
+    service_app->indicatordisplay = strdup("true");
+    service_app->effectimage_type = strdup("image");
+    service_app->guestmode_visibility = strdup("true");
+    service_app->permission_type = strdup("normal");
+    service_app->submode = strdup("false");
+    service_app->process_pool = strdup("false");
+    service_app->ambient_support = strdup("false");
+    service_app->package = strdup(manifest->package);
+    service_app->support_disable = strdup(manifest->support_disable);
     manifest->application = g_list_append(manifest->application, service_app);
 
     if (!FillAppControl(service_app,  application.app_control))
@@ -258,10 +293,15 @@ bool StepParse::FillUIApplication(manifest_x* manifest) {
     return true;
 
   for (const auto& application : ui_application_list->items) {
+    // if there is no app yet, set this app as mainapp
+    bool main_app = manifest->application == nullptr;
+
     application_x* ui_app =
         static_cast<application_x*>(calloc(1, sizeof(application_x)));
     ui_app->appid = strdup(application.ui_info.appid().c_str());
-    ui_app->exec = strdup(application.ui_info.exec().c_str());
+    ui_app->exec = strdup((context_->root_application_path.get()
+                           / manifest->package / "bin"
+                           / application.ui_info.exec()).c_str());
     ui_app->launch_mode = strdup(application.ui_info.launch_mode().c_str());
     ui_app->multiple = strdup(application.ui_info.multiple().c_str());
     ui_app->nodisplay = strdup(application.ui_info.nodisplay().c_str());
@@ -283,6 +323,19 @@ bool StepParse::FillUIApplication(manifest_x* manifest) {
         strdup(application.ui_info.submode_mainid().c_str());
     ui_app->hwacceleration =
         strdup(application.ui_info.hwacceleration().c_str());
+    ui_app->onboot = strdup("false");
+    ui_app->autorestart = strdup("false");
+    ui_app->component_type = strdup("uiapp");
+    ui_app->mainapp = main_app ? strdup("true") : strdup("false");
+    ui_app->enabled = strdup("true");
+    ui_app->screenreader = strdup("use-system-setting");
+    ui_app->recentimage = strdup("false");
+    ui_app->launchcondition = strdup("false");
+    ui_app->guestmode_visibility = strdup("true");
+    ui_app->permission_type = strdup("normal");
+    ui_app->ambient_support = strdup("false");
+    ui_app->package = strdup(manifest->package);
+    ui_app->support_disable = strdup(manifest->support_disable);
     manifest->application = g_list_append(manifest->application, ui_app);
 
     if (!FillAppControl(ui_app, application.app_control))
@@ -348,6 +401,7 @@ bool StepParse::FillApplicationIconPaths(application_x* app,
     // Current implementation is just for compatibility.
     icon->text = strdup(application_icon.path().c_str());
     icon->name = strdup(application_icon.path().c_str());
+    icon->lang = strdup(DEFAULT_LOCALE);
     app->icon = g_list_append(app->icon, icon);
   }
   return true;
@@ -366,7 +420,8 @@ bool StepParse::FillLabel(application_x* app, const T& label_list) {
     // Current implementation is just for compatibility.
     label->text = strdup(control.text().c_str());
     label->name = strdup(control.name().c_str());
-    label->lang = strdup(control.xml_lang().c_str());
+    label->lang = !control.xml_lang().empty() ?
+        strdup(control.xml_lang().c_str()) : strdup(DEFAULT_LOCALE);
     app->label = g_list_append(app->label, label);
   }
   return true;
@@ -393,9 +448,13 @@ bool StepParse::FillImage(application_x* app,
     image_x* image =
         static_cast<image_x*>(calloc(1, sizeof(image_x)));
     image->name = strdup(app_image.name().c_str());
-    std::string lang = app_image.lang();
+    const std::string& lang = app_image.lang();
     if (!lang.empty())
       image->lang = strdup(lang.c_str());
+    else
+      image->lang = strdup(DEFAULT_LOCALE);
+    if (!app_image.section().empty())
+      image->section = strdup(app_image.section().c_str());
     app->image = g_list_append(app->image, image);
   }
   return true;
@@ -459,6 +518,8 @@ bool StepParse::FillBackgroundCategoryInfo(application_x* app,
 bool StepParse::FillManifestX(manifest_x* manifest) {
   if (!FillPackageInfo(manifest))
     return false;
+  if (!FillInstallationInfo(manifest))
+    return false;
   if (!FillUIApplication(manifest))
     return false;
   if (!FillServiceApplication(manifest))
index 297e90d..0a02375 100644 (file)
@@ -42,6 +42,7 @@ class StepParse : public common_installer::Step {
   boost::filesystem::path path_;
 
  private:
+  bool FillInstallationInfo(manifest_x* manifest);
   bool FillPackageInfo(manifest_x* manifest);
   bool FillAuthorInfo(manifest_x* manifest);
   bool FillDescription(manifest_x* manifest);
index 72d2812..23266e1 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <string.h>
 
+#include <chrono>
 #include <cstdio>
 #include <cstdlib>
 #include <memory>
@@ -38,6 +39,7 @@
 namespace {
 
 const std::string kManifestVersion = "1.0.0";
+const char kTizenPackageXmlNamespace[] = "http://tizen.org/ns/packages";
 
 GList* GenerateMetadataListX(const wgt::parse::MetaDataInfo& meta_info) {
   GList* list = nullptr;
@@ -52,12 +54,31 @@ GList* GenerateMetadataListX(const wgt::parse::MetaDataInfo& meta_info) {
   return list;
 }
 
+void SetApplicationXDefaults(application_x* application) {
+  application->ambient_support = strdup("false");
+  application->effectimage_type = strdup("image");
+  application->enabled = strdup("true");
+  application->guestmode_visibility = strdup("true");
+  application->hwacceleration = strdup("default");
+  application->indicatordisplay = strdup("true");
+  application->launchcondition = strdup("false");
+  application->permission_type = strdup("normal");
+  application->process_pool = strdup("false");
+  application->recentimage = strdup("false");
+  application->screenreader = strdup("use-system-setting");
+  application->submode = strdup("false");
+  application->support_disable = strdup("false");
+  application->taskmanage = strdup("true");
+  application->ui_gadget = strdup("false");
+}
+
 }  // namespace
 
 namespace wgt {
 namespace parse {
 
 namespace app_keys = wgt::application_widget_keys;
+namespace sc = std::chrono;
 
 StepParse::StepParse(common_installer::InstallerContext* context,
                      bool check_start_file)
@@ -77,6 +98,15 @@ const std::string& StepParse::GetPackageVersion(
   return kManifestVersion;
 }
 
+bool StepParse::FillInstallationInfo(manifest_x* manifest) {
+  manifest->root_path = strdup(
+      (context_->root_application_path.get() / manifest->package).c_str());
+  manifest->installed_time =
+      strdup(std::to_string(sc::system_clock::to_time_t(
+          sc::system_clock::now())).c_str());
+  return true;
+}
+
 bool StepParse::FillIconPaths(manifest_x* manifest) {
   std::shared_ptr<const ApplicationIconsInfo> icons_info =
       std::static_pointer_cast<const ApplicationIconsInfo>(
@@ -85,6 +115,7 @@ bool StepParse::FillIconPaths(manifest_x* manifest) {
     for (auto& application_icon : icons_info->icons()) {
       icon_x* icon = reinterpret_cast<icon_x*> (calloc(1, sizeof(icon_x)));
       icon->text = strdup(application_icon.path().c_str());
+      icon->lang = strdup(DEFAULT_LOCALE);
       manifest->icon = g_list_append(manifest->icon, icon);
     }
   }
@@ -102,24 +133,29 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) {
 
   const std::string& version = wgt_info->version();
 
+  manifest->ns = strdup(kTizenPackageXmlNamespace);
   manifest->version = strdup(GetPackageVersion(version).c_str());
 
   for (auto& item : wgt_info->description_set()) {
     description_x* description = reinterpret_cast<description_x*>
         (calloc(1, sizeof(description_x)));
-    description->name = strdup(item.second.c_str());
-    description->lang = strdup(item.first.c_str());
+    description->text = strdup(item.second.c_str());
+    description->lang = item.first.c_str() ?
+        strdup(item.first.c_str()) : strdup(DEFAULT_LOCALE);
     manifest->description = g_list_append(manifest->description, description);
   }
 
   for (auto& item : wgt_info->name_set()) {
     label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
     label->name = strdup(item.second.c_str());
-    label->lang = strdup(item.first.c_str());
+    label->text = strdup(item.second.c_str());
+    label->lang = !item.first.empty() ?
+        strdup(item.first.c_str()) : strdup(DEFAULT_LOCALE);
     manifest->label = g_list_append(manifest->label, label);
   }
 
   manifest->type = strdup("wgt");
+  manifest->appsetting = strdup("false");
   manifest->nodisplay_setting = strdup("false");
 
   // For wgt package use the long name
@@ -128,7 +164,9 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) {
         reinterpret_cast<application_x*>(manifest->application->data);
     label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
     label->name = strdup(item.second.c_str());
-    label->lang = strdup(item.first.c_str());
+    label->text = strdup(item.second.c_str());
+    label->lang = !item.first.empty() ?
+        strdup(item.first.c_str()) : strdup(DEFAULT_LOCALE);
     app->label = g_list_append(app->label, label);
   }
 
@@ -139,6 +177,7 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) {
     author->email = strdup(wgt_info->author_email().c_str());
   if (!wgt_info->author_href().empty())
     author->href = strdup(wgt_info->author_href().c_str());
+  author->lang = strdup(DEFAULT_LOCALE);
   manifest->author = g_list_append(manifest->author, author);
 
   std::shared_ptr<const SettingInfo> settings_info =
@@ -179,13 +218,26 @@ bool StepParse::FillUIApplicationInfo(manifest_x* manifest) {
   application_x* application = reinterpret_cast<application_x*>(
       calloc(1, sizeof(application_x)));
   application->component_type = strdup("uiapp");
+  application->mainapp = strdup("true");
+  application->nodisplay = strdup("false");
+  application->multiple = strdup("false");
   application->appid = strdup(app_info->id().c_str());
+  SetApplicationXDefaults(application);
+  application->package = strdup(app_info->package().c_str());
+
+  application->exec =
+      strdup((context_->root_application_path.get() / app_info->package()
+              / "bin" / application->appid).c_str());
   application->type = strdup("webapp");
+  application->onboot = strdup("false");
+  application->autorestart = strdup("false");
+
   application->launch_mode = strdup(app_info->launch_mode().c_str());
   if (manifest->icon) {
     icon_x* icon = reinterpret_cast<icon_x*>(manifest->icon->data);
     icon_x* app_icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
     app_icon->text = strdup(icon->text);
+    app_icon->lang = strdup(icon->lang);
     application->icon = g_list_append(application->icon, app_icon);
   }
   manifest->application = g_list_append(manifest->application, application);
@@ -205,24 +257,34 @@ bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) {
     application_x* application = reinterpret_cast<application_x*>
         (calloc(1, sizeof(application_x)));
     application->component_type = strdup("svcapp");
+    application->mainapp = strdup("false");
+    application->nodisplay = strdup("false");
+    application->multiple = strdup("false");
     application->appid = strdup(service_info.id().c_str());
+    application->exec =
+        strdup((context_->root_application_path.get() / manifest->package
+                / "bin" / application->appid).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");
+    SetApplicationXDefaults(application);
+    application->package = strdup(manifest->package);
 
     for (auto& pair : service_info.names()) {
       label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
-      if (!pair.first.empty())
-        label->lang = strdup(pair.first.c_str());
+      label->lang = !pair.first.empty() ?
+          strdup(pair.first.c_str()) : strdup(DEFAULT_LOCALE);
       label->name = strdup(pair.second.c_str());
+      label->text = strdup(pair.second.c_str());
       application->label = g_list_append(application->label, label);
     }
 
     if (!service_info.icon().empty()) {
       icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
       icon->text = strdup(service_info.icon().c_str());
+      icon->lang = strdup(DEFAULT_LOCALE);
       application->icon = g_list_append(application->icon, icon);
     }
 
@@ -363,6 +425,8 @@ bool StepParse::FillManifestX(manifest_x* manifest) {
     return false;
   if (!FillWidgetInfo(manifest))
     return false;
+  if (!FillInstallationInfo(manifest))
+    return false;
   if (!FillPrivileges(manifest))
     return false;
   if (!FillAppControl(manifest))
index 69df372..c157aa0 100644 (file)
@@ -74,6 +74,7 @@ class StepParse : public common_installer::Step {
 
   const std::string& GetPackageVersion(const std::string& manifest_version);
 
+  bool FillInstallationInfo(manifest_x* manifest);
   bool FillIconPaths(manifest_x* manifest);
   bool FillWidgetInfo(manifest_x* manifest);
   bool FillUIApplicationInfo(manifest_x* manifest);