Adjustment to application_x unification 05/48905/2 accepted/tizen/mobile/20151005.055456 accepted/tizen/tv/20151005.055510 accepted/tizen/wearable/20151005.055525 submit/tizen/20151005.030714
authorTomasz Iwanek <t.iwanek@samsung.com>
Thu, 1 Oct 2015 07:55:07 +0000 (09:55 +0200)
committerTomasz Iwanek <t.iwanek@samsung.com>
Fri, 2 Oct 2015 08:20:29 +0000 (10:20 +0200)
This patchset reworks app-installers according to changes in:
 - https://review.tizen.org/gerrit/#/c/48804/

Change-Id: I5cb319681b12d6f290f83d2f121c18bf3ef4fa88

13 files changed:
src/common/security_registration.cc
src/common/step/step_backup_icons.cc
src/common/step/step_create_icons.cc
src/common/step/step_generate_xml.cc
src/common/step/step_generate_xml.h
src/common/step/step_kill_apps.cc
src/common/step/step_recover_icons.cc
src/common/step/step_remove_icons.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_create_symbolic_link.cc
src/wgt/step/step_parse.cc

index fe0a1b1..06cb954 100644 (file)
@@ -154,24 +154,12 @@ namespace common_installer {
 bool RegisterSecurityContextForApps(
     const std::string& pkg_id, const boost::filesystem::path& path,
     manifest_x* manifest) {
-  for (uiapplication_x* ui = manifest->uiapplication;
-      ui != nullptr; ui = ui->next) {
-    if (!ui->appid) {
+  for (application_x* app = manifest->application;
+      app != nullptr; app = app->next) {
+    if (!app->appid) {
       return false;
     }
-    if (!RegisterSecurityContext(ui->appid, pkg_id,
-        path, manifest)) {
-      return false;
-    }
-  }
-
-  for (serviceapplication_x* svc =
-      manifest->serviceapplication;
-      svc != nullptr; svc = svc->next) {
-    if (!svc->appid) {
-      return false;
-    }
-    if (!RegisterSecurityContext(svc->appid, pkg_id,
+    if (!RegisterSecurityContext(app->appid, pkg_id,
         path, manifest)) {
       return false;
     }
@@ -181,23 +169,12 @@ bool RegisterSecurityContextForApps(
 
 bool UnregisterSecurityContextForApps(
     const std::string& pkg_id, manifest_x* manifest) {
-  for (uiapplication_x* ui = manifest->uiapplication;
-      ui != nullptr; ui = ui->next) {
-    if (!ui->appid) {
-      return false;
-    }
-    if (!UnregisterSecurityContext(ui->appid, pkg_id)) {
-      return false;
-    }
-  }
-
-  for (serviceapplication_x* svc =
-      manifest->serviceapplication;
-      svc != nullptr; svc = svc->next) {
-    if (!svc->appid) {
+  for (application_x* app = manifest->application;
+      app != nullptr; app = app->next) {
+    if (!app->appid) {
       return false;
     }
-    if (!UnregisterSecurityContext(svc->appid, pkg_id)) {
+    if (!UnregisterSecurityContext(app->appid, pkg_id)) {
       return false;
     }
   }
index 6e2758f..284cec7 100755 (executable)
@@ -19,14 +19,17 @@ namespace common_installer {
 namespace backup {
 
 Step::Status StepBackupIcons::process() {
-  uiapplication_x* ui = context_->old_manifest_data.get()->uiapplication;
+  application_x* app = context_->old_manifest_data.get()->application;
 
   // gather icon info
-  for (; ui != nullptr; ui = ui->next) {
+  for (; app != nullptr; app = app->next) {
+    if (strcmp(app->component_type, "uiapp") != 0)
+      continue;
+
     bf::path app_icon = bf::path(getIconPath(context_->uid.get()))
-        / bf::path(ui->appid);
-    if (ui->icon && ui->icon->text)
-      app_icon += bf::path(ui->icon->text).extension();
+        / bf::path(app->appid);
+    if (app->icon && app->icon->text)
+      app_icon += bf::path(app->icon->text).extension();
     else
       app_icon += ".png";
     bf::path icon_backup = GetBackupPathForIconFile(app_icon);
index c2383a9..f321c15 100644 (file)
@@ -27,16 +27,19 @@ Step::Status StepCreateIcons::process() {
     }
   }
 
-  uiapplication_x* ui = nullptr;
-  PKGMGR_LIST_MOVE_NODE_TO_HEAD(context_->manifest_data.get()->uiapplication,
-                                ui);
-  for (; ui; ui = ui->next) {
+  application_x* app = nullptr;
+  PKGMGR_LIST_MOVE_NODE_TO_HEAD(context_->manifest_data.get()->application,
+                                app);
+  for (; app; app = app->next) {
+    if (strcmp(app->component_type, "uiapp") != 0)
+      continue;
+
     // TODO(t.iwanek): this is ignoring icon locale as well as other steps
     // icons should be localized
-    if (ui->icon && ui->icon->text) {
-      bf::path source = GetIconRoot() / ui->icon->text;
+    if (app->icon && app->icon->text) {
+      bf::path source = GetIconRoot() / app->icon->text;
       if (bf::exists(source)) {
-        bf::path destination = icons_directory / ui->appid;
+        bf::path destination = icons_directory / app->appid;
         if (source.has_extension())
           destination += source.extension();
         else
index 83cd204..4107f9c 100755 (executable)
 namespace bs = boost::system;
 namespace bf = boost::filesystem;
 
-namespace common_installer {
-namespace pkgmgr {
-
-static void _writeUIApplicationAttributes(
-    xmlTextWriterPtr writer, uiapplication_x */*app*/) {
-    xmlTextWriterWriteAttribute(writer, BAD_CAST "taskmanage",
-        BAD_CAST "true");
+namespace {
+
+void WriteUIApplicationAttributes(
+    xmlTextWriterPtr writer, application_x *app) {
+  xmlTextWriterWriteAttribute(writer, BAD_CAST "taskmanage",
+      BAD_CAST "true");
+  if (app->nodisplay)
+    xmlTextWriterWriteAttribute(writer, BAD_CAST "nodisplay",
+        BAD_CAST app->nodisplay);
 }
 
-static void _writeServiceApplicationAttributes(
-    xmlTextWriterPtr writer, serviceapplication_x *app) {
+void WriteServiceApplicationAttributes(
+    xmlTextWriterPtr writer, application_x *app) {
   xmlTextWriterWriteAttribute(writer, BAD_CAST "auto-restart",
       BAD_CAST(app->autorestart ? app->autorestart : "false"));
   xmlTextWriterWriteAttribute(writer, BAD_CAST "on-boot",
@@ -43,10 +45,13 @@ static void _writeServiceApplicationAttributes(
       BAD_CAST(app->permission_type ? app->permission_type : ""));
 }
 
-template <typename T>
+}  // namespace
+
+namespace common_installer {
+namespace pkgmgr {
+
 common_installer::Step::Status StepGenerateXml::GenerateApplicationCommonXml(
-    T* app, xmlTextWriterPtr writer) {
-  // common appributes among uiapplication_x and serviceapplication_x
+    application_x* app, xmlTextWriterPtr writer, bool is_service) {
   xmlTextWriterWriteAttribute(writer, BAD_CAST "appid", BAD_CAST app->appid);
 
   // binary is a symbolic link named <appid> and is located in <pkgid>/<appid>
@@ -60,12 +65,10 @@ common_installer::Step::Status StepGenerateXml::GenerateApplicationCommonXml(
     xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST "capp");
 
   // app-specific attributes
-  if (std::is_same<T, uiapplication_x>::value)
-    _writeUIApplicationAttributes(
-        writer, reinterpret_cast<uiapplication_x *>(app));
-  if (std::is_same<T, serviceapplication_x>::value)
-    _writeServiceApplicationAttributes(
-        writer, reinterpret_cast<serviceapplication_x *>(app));
+  if (is_service)
+    WriteServiceApplicationAttributes(writer, app);
+  else
+    WriteUIApplicationAttributes(writer, app);
   if (app->label) {
     label_x* label = nullptr;
     LISTHEAD(app->label, label);
@@ -158,10 +161,8 @@ common_installer::Step::Status StepGenerateXml::precheck() {
     LOG(ERROR) << "pkgid attribute is empty";
     return Step::Status::INVALID_VALUE;   }
 
-  if ((!context_->manifest_data.get()->uiapplication) &&
-     (!context_->manifest_data.get()->serviceapplication)) {
-    LOG(ERROR) << "There is neither UI applications nor"
-               << "Services applications described!";
+  if (!context_->manifest_data.get()->application) {
+    LOG(ERROR) << "No application in package";
     return Step::Status::INVALID_VALUE;
   }
   // TODO(p.sikorski) check context_->uid.get()
@@ -256,25 +257,23 @@ common_installer::Step::Status StepGenerateXml::process() {
     }
   }
 
-  // add ui-application element per ui application
-  uiapplication_x* ui = nullptr;
-  PKGMGR_LIST_MOVE_NODE_TO_HEAD(context_->manifest_data.get()->uiapplication,
-                                ui);
-  for (; ui; ui = ui->next) {
-    xmlTextWriterStartElement(writer, BAD_CAST "ui-application");
-    if (ui->nodisplay)
-      xmlTextWriterWriteAttribute(writer, BAD_CAST "nodisplay",
-          BAD_CAST ui->nodisplay);
-    GenerateApplicationCommonXml(ui, writer);
-    xmlTextWriterEndElement(writer);
-  }
-  // add service-application element per service application
-  serviceapplication_x* svc = nullptr;
-  PKGMGR_LIST_MOVE_NODE_TO_HEAD(
-      context_->manifest_data.get()->serviceapplication, svc);
-  for (; svc; svc = svc->next) {
-    xmlTextWriterStartElement(writer, BAD_CAST "service-application");
-    GenerateApplicationCommonXml(svc, writer);
+  // add application
+  application_x* app = nullptr;
+  PKGMGR_LIST_MOVE_NODE_TO_HEAD(context_->manifest_data.get()->application,
+                                app);
+  for (; app; app = app->next) {
+    bool is_service = false;
+    if (strcmp(app->component_type, "uiapp") == 0) {
+      xmlTextWriterStartElement(writer, BAD_CAST "ui-application");
+    } else if (strcmp(app->component_type, "svcapp") == 0) {
+      is_service = true;
+      xmlTextWriterStartElement(writer, BAD_CAST "svc-application");
+    } else {
+      LOG(ERROR) << "Unknown application component_type";
+      xmlFreeTextWriter(writer);
+      return Status::ERROR;
+    }
+    GenerateApplicationCommonXml(app, writer, is_service);
     xmlTextWriterEndElement(writer);
   }
 
index 0e1b001..2f469ab 100644 (file)
@@ -25,11 +25,9 @@ class StepGenerateXml : public common_installer::Step {
   Status precheck() override;
 
  private:
-  // This function is used to generate common xml data
-  // for uiapplication_x and applicationservice_x, as these
-  // structures contain common elements
-  template <typename T>
-  Step::Status GenerateApplicationCommonXml(T* app, xmlTextWriterPtr writer);
+  Step::Status GenerateApplicationCommonXml(application_x* app,
+                                            xmlTextWriterPtr writer,
+                                            bool is_service);
 
   SCOPE_LOG_TAG(GenerateXML)
 };
index 4233f0e..1981967 100644 (file)
@@ -48,20 +48,13 @@ namespace pkgmgr {
 Step::Status StepKillApps::process() {
   manifest_x* old_manifest = context_->old_manifest_data.get() ?
       context_->old_manifest_data.get() : context_->manifest_data.get();
-  uiapplication_x* ui = nullptr;
-  PKGMGR_LIST_MOVE_NODE_TO_HEAD(old_manifest->uiapplication, ui);
+  application_x* ui = nullptr;
+  PKGMGR_LIST_MOVE_NODE_TO_HEAD(old_manifest->application, ui);
   for (; ui; ui = ui->next) {
     if (!ui->appid)
       continue;
     (void) KillApp(ui->appid);
   }
-  serviceapplication_x * svc = nullptr;
-  PKGMGR_LIST_MOVE_NODE_TO_HEAD(old_manifest->serviceapplication, svc);
-  for (; svc; svc = svc->next) {
-    if (!svc->appid)
-      continue;
-    (void) KillApp(svc->appid);
-  }
   return Status::OK;
 }
 
index 25d70de..aaf2dfd 100644 (file)
@@ -54,14 +54,17 @@ Step::Status StepRecoverIcons::RecoveryUpdate() {
 bool StepRecoverIcons::TryGatherIcons() {
   if (!context_->manifest_data.get())
     return false;
-  uiapplication_x* ui = nullptr;
-  PKGMGR_LIST_MOVE_NODE_TO_HEAD(context_->manifest_data.get()->uiapplication,
-                                ui);
-  for (; ui != nullptr; ui = ui->next) {
+  application_x* app = nullptr;
+  PKGMGR_LIST_MOVE_NODE_TO_HEAD(context_->manifest_data.get()->application,
+                                app);
+  for (; app != nullptr; app = app->next) {
+    if (strcmp(app->component_type, "uiapp") != 0)
+      continue;
+
     bf::path app_icon = bf::path(getIconPath(context_->uid.get()))
-      / bf::path(ui->appid);
-    if (ui->icon && ui->icon->text)
-      app_icon += bf::path(ui->icon->text).extension();
+      / bf::path(app->appid);
+    if (app->icon && app->icon->text)
+      app_icon += bf::path(app->icon->text).extension();
     else
       app_icon += ".png";
     bf::path icon_backup = GetBackupPathForIconFile(app_icon);
index 399655e..6de1de8 100644 (file)
@@ -29,14 +29,17 @@ Step::Status StepRemoveIcons::precheck() {
 }
 
 Step::Status StepRemoveIcons::process() {
-  uiapplication_x* ui = nullptr;
-  PKGMGR_LIST_MOVE_NODE_TO_HEAD(context_->manifest_data.get()->uiapplication,
-                                ui);
-  for (; ui != nullptr; ui = ui->next) {
+  application_x* app = nullptr;
+  PKGMGR_LIST_MOVE_NODE_TO_HEAD(context_->manifest_data.get()->application,
+                                app);
+  for (; app != nullptr; app = app->next) {
+    if (strcmp(app->component_type, "uiapp") != 0)
+      continue;
+
     bf::path app_icon = bf::path(getIconPath(context_->uid.get()))
-      / bf::path(ui->appid);
-    if (ui->icon && ui->icon->text)
-      app_icon += bf::path(ui->icon->text).extension();
+      / bf::path(app->appid);
+    if (app->icon && app->icon->text)
+      app_icon += bf::path(app->icon->text).extension();
     else
       app_icon += ".png";
     if (bf::exists(app_icon)) {
index 1a5a6ab..12edd7d 100644 (file)
@@ -9,10 +9,10 @@
 #include "common/step/step.h"
 #include "common/app_installer.h"
 #include "common/context_installer.h"
+#include "common/utils/clist_helpers.h"
 #include "common/utils/file_util.h"
 #include "common/utils/logging.h"
 
-
 namespace tpk {
 namespace filesystem {
 
@@ -22,54 +22,46 @@ typedef common_installer::Step::Status Status;
 
 namespace {
 
-template <typename T>
-bool CreateSymLink(T *app, ContextInstaller* context) {
+bool CreateSymLink(application_x* app, ContextInstaller* context) {
   boost::system::error_code boost_error;
+  bf::path bindir = context->pkg_path.get() /
+      bf::path("bin");
+  LOG(DEBUG) << "Creating dir: " << bindir;
+  if (!common_installer::CreateDir(bindir)) {
+    LOG(ERROR) << "Directory creation failure: " << bindir;
+    return false;
+  }
+
+  // Exec path
+  // Make a symlink with the name of appid, pointing exec file
+  bf::path symlink_path = bindir / bf::path(app->appid);
+  LOG(DEBUG) << "Creating symlink " << symlink_path << " pointing " <<
+      app->exec;
+  bf::create_symlink(bf::path(app->exec), symlink_path, boost_error);
+  if (boost_error) {
+    LOG(ERROR) << "Symlink creation failure: " << symlink_path;
+    return false;
+  }
 
-  for (; app != nullptr; app=app->next) {
-    bf::path bindir = context->pkg_path.get() /
-        bf::path("bin");
-    LOG(INFO) << "Creating dir: " << bindir;
-    if (!common_installer::CreateDir(bindir)) {
-      LOG(ERROR) << "Directory creation failure: " << bindir;
-      return false;
-    }
-
-    // Exec path
-    // Make a symlink with the name of appid, pointing exec file
-    bf::path symlink_path = bindir / bf::path(app->appid);
-    LOG(INFO) << "Creating symlink " << symlink_path << " pointing " <<
-        app->exec;
-    bf::create_symlink(bf::path(app->exec), symlink_path, boost_error);
-    if (boost_error) {
-      LOG(ERROR) << "Symlink creation failure: " << symlink_path;
-      return false;
-    }
-
-    // Give an execution permission to the original executable
-    bf::path exec_path = bindir / bf::path(app->exec);
-    LOG(INFO) << "Giving exec permission to " << exec_path;
-    bf::permissions(exec_path, bf::owner_all |
-        bf::group_read | bf::group_exe |
-        bf::others_read | bf::others_exe, boost_error);
-    if (boost_error) {
-      LOG(ERROR) << "Permission change failure";
-      return false;
-    }
+  // 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 |
+      bf::group_read | bf::group_exe |
+      bf::others_read | bf::others_exe, boost_error);
+  if (boost_error) {
+    LOG(ERROR) << "Permission change failure";
+    return false;
   }
   return true;
 }
 
-
-template <typename T>
-bool RemoveSymLink(T *app, ContextInstaller* context) {
+bool RemoveSymLink(application_x* app, ContextInstaller* context) {
   /* NOTE: Unlike WRT app, tpk apps have bin/ directory by default.
    * So we don't remove the bin/ directory.
    */
-  for (; app != nullptr; app=app->next) {
-    bf::path exec_path = bf::path(context->pkg_path.get()) / bf::path("bin");
-    bf::remove_all(exec_path / bf::path(app->appid));
-  }
+  bf::path exec_path = bf::path(context->pkg_path.get()) / bf::path("bin");
+  bf::remove_all(exec_path / bf::path(app->appid));
   return true;
 }
 
@@ -81,8 +73,8 @@ Status StepCreateSymbolicLink::precheck() {
     LOG(ERROR) << "manifest_data attribute is empty";
     return Step::Status::INVALID_VALUE;
   }
-  if (!(m->uiapplication || m->serviceapplication)) {
-    LOG(ERROR) << "Neither ui-application nor service-application exists";
+  if (!m->application) {
+    LOG(ERROR) << "Napplication exists";
     return Step::Status::ERROR;
   }
 
@@ -90,34 +82,26 @@ Status StepCreateSymbolicLink::precheck() {
 }
 
 Status StepCreateSymbolicLink::process() {
-  // Get manifest_x
-  manifest_x *m = context_->manifest_data.get();
-
-  // get ui-app and service-app
-  uiapplication_x *uiapp = m->uiapplication;
-  serviceapplication_x *svcapp = m->serviceapplication;
-
-  if (!CreateSymLink(uiapp, context_)) return Status::ERROR;
-  if (!CreateSymLink(svcapp, context_)) return Status::ERROR;
+  manifest_x* m = context_->manifest_data.get();
+  application_x* app = nullptr;
+  PKGMGR_LIST_MOVE_NODE_TO_HEAD(m->application, app);
+  for (; app; app = app->next) {
+    if (!CreateSymLink(app, context_))
+      return Status::ERROR;
+  }
   return Status::OK;
 }
 
 
 Status StepCreateSymbolicLink::undo() {
   manifest_x* m = context_->manifest_data.get();
-  uiapplication_x *uiapp = m->uiapplication;
-  serviceapplication_x *svcapp = m->serviceapplication;
-
   Step::Status ret = Status::OK;
-  if (!RemoveSymLink(uiapp, context_)) {
-    LOG(ERROR) << "Cannot remove Symboliclink for uiapp";
-    ret = Status::ERROR;
-  }
-  if (!RemoveSymLink(svcapp, context_)) {
-    LOG(ERROR) << "Cannot remove Symboliclink for svcapp";
-    ret = Status::ERROR;
+  application_x* app = nullptr;
+  PKGMGR_LIST_MOVE_NODE_TO_HEAD(m->application, app);
+  for (; app; app = app->next) {
+    if (!CreateSymLink(app, context_))
+      ret = Status::ERROR;
   }
-
   return ret;
 }
 
index 6013495..7ee3245 100644 (file)
@@ -185,16 +185,16 @@ bool StepParse::FillServiceApplication(manifest_x* manifest) {
     return true;
 
   for (const auto& application : service_application_list->items) {
-    serviceapplication_x* service_app =
-                          static_cast<serviceapplication_x*>
-                          (calloc(1, sizeof(serviceapplication_x)));
+    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->onboot = strdup(application.sa_info.on_boot().c_str());
     service_app->type = strdup(application.sa_info.type().c_str());
-    LISTADD(manifest->serviceapplication, service_app);
+    service_app->component_type = strdup("svcapp");
+    LISTADD(manifest->application, service_app);
 
     if (!FillAppControl(service_app,  application.app_control))
       return false;
@@ -218,16 +218,16 @@ bool StepParse::FillUIApplication(manifest_x* manifest) {
     return true;
 
   for (const auto& application : ui_application_list->items) {
-    uiapplication_x* ui_app =
-                       static_cast<uiapplication_x*>
-                       (calloc(1, sizeof(uiapplication_x)));
+    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->multiple = strdup(application.ui_info.multiple().c_str());
     ui_app->nodisplay = strdup(application.ui_info.nodisplay().c_str());
     ui_app->taskmanage = strdup(application.ui_info.taskmanage().c_str());
     ui_app->type = strdup(application.ui_info.type().c_str());
-    LISTADD(manifest->uiapplication, ui_app);
+    ui_app->component_type = strdup("uiapp");
+    LISTADD(manifest->application, ui_app);
 
     if (!FillAppControl(ui_app, application.app_control))
       return false;
@@ -243,14 +243,8 @@ bool StepParse::FillUIApplication(manifest_x* manifest) {
   return true;
 }
 
-template <typename T1, typename T2>
-bool StepParse::FillAppControl(T1* app, const T2& app_control_list) {
-  static_assert(
-      std::is_same<typename std::remove_pointer<T1>::type,
-                   uiapplication_x>::value ||
-      std::is_same<typename std::remove_pointer<T1>::type,
-                   serviceapplication_x>::value,
-      "T1 should be uiapplication_x or serviceapplication_x");
+template <typename T>
+bool StepParse::FillAppControl(application_x* app, const T& app_control_list) {
   if (app_control_list.empty())
     return true;
 
@@ -267,14 +261,9 @@ bool StepParse::FillAppControl(T1* app, const T2& app_control_list) {
   return true;
 }
 
-template <typename T1, typename T2>
-bool StepParse::FillDataControl(T1* app, const T2& data_control_list) {
-  static_assert(
-      std::is_same<typename std::remove_pointer<T1>::type,
-                   uiapplication_x>::value ||
-      std::is_same<typename std::remove_pointer<T1>::type,
-                   serviceapplication_x>::value,
-      "T1 should be uiapplication_x or serviceapplication_x");
+template <typename T>
+bool StepParse::FillDataControl(application_x* app,
+                                const T& data_control_list) {
   if (data_control_list.empty())
     return true;
 
@@ -289,14 +278,9 @@ bool StepParse::FillDataControl(T1* app, const T2& data_control_list) {
   return true;
 }
 
-template <typename T1, typename T2>
-bool StepParse::FillApplicationIconPaths(T1* app, const T2& icons_info) {
-  static_assert(
-      std::is_same<typename std::remove_pointer<T1>::type,
-                   uiapplication_x>::value ||
-      std::is_same<typename std::remove_pointer<T1>::type,
-                   serviceapplication_x>::value,
-      "T1 should be uiapplication_x or serviceapplication_x");
+template <typename T>
+bool StepParse::FillApplicationIconPaths(application_x* app,
+                                         const T& icons_info) {
   for (auto& application_icon : icons_info.icons()) {
     icon_x* icon = reinterpret_cast<icon_x*> (calloc(1, sizeof(icon_x)));
     // NOTE: name is an attribute, but the xml writer uses it as text.
@@ -309,14 +293,8 @@ bool StepParse::FillApplicationIconPaths(T1* app, const T2& icons_info) {
   return true;
 }
 
-template <typename T1, typename T2>
-bool StepParse::FillLabel(T1* app, const T2& label_list) {
-  static_assert(
-      std::is_same<typename std::remove_pointer<T1>::type,
-                   uiapplication_x>::value ||
-      std::is_same<typename std::remove_pointer<T1>::type,
-                   serviceapplication_x>::value,
-      "T1 should be uiapplication_x or serviceapplication_x");
+template <typename T>
+bool StepParse::FillLabel(application_x* app, const T& label_list) {
   if (label_list.empty())
     return true;
 
@@ -334,14 +312,8 @@ bool StepParse::FillLabel(T1* app, const T2& label_list) {
   return true;
 }
 
-template <typename T1, typename T2>
-bool StepParse::FillMetadata(T1* app, const T2& meta_data_list) {
-  static_assert(
-      std::is_same<typename std::remove_pointer<T1>::type,
-                   uiapplication_x>::value ||
-      std::is_same<typename std::remove_pointer<T1>::type,
-                   serviceapplication_x>::value,
-      "T1 should be uiapplication_x or serviceapplication_x");
+template <typename T>
+bool StepParse::FillMetadata(application_x* app, const T& meta_data_list) {
   if (meta_data_list.empty())
     return true;
 
index e312444..3df25a3 100644 (file)
@@ -46,16 +46,17 @@ class StepParse : public common_installer::Step {
   bool FillPrivileges(manifest_x* manifest);
   bool FillServiceApplication(manifest_x* manifest);
   bool FillUIApplication(manifest_x* manifest);
-  template <typename T1, typename T2>
-      bool FillAppControl(T1* manifest, const T2& app_control_list);
-  template <typename T1, typename T2> bool
-      FillDataControl(T1* manifest, const T2& data_control_list);
-  template <typename T1, typename T2>
-      bool FillApplicationIconPaths(T1* manifest, const T2& icons_info);
-  template <typename T1, typename T2>
-      bool FillLabel(T1* manifest, const T2& label_list);
-  template <typename T1, typename T2>
-      bool FillMetadata(T1* manifest, const T2& meta_data_list);
+  template <typename T>
+      bool FillAppControl(application_x* manifest, const T& app_control_list);
+  template <typename T>
+      bool FillDataControl(application_x* manifest, const T& data_control_list);
+  template <typename T>
+      bool FillApplicationIconPaths(application_x* manifest,
+                                    const T& icons_info);
+  template <typename T>
+      bool FillLabel(application_x* manifest, const T& label_list);
+  template <typename T>
+      bool FillMetadata(application_x* manifest, const T& meta_data_list);
   bool FillAccounts();
   bool FillManifestX(manifest_x* manifest);
 
index 6e13ba2..8fdfe98 100644 (file)
@@ -24,37 +24,20 @@ namespace bf = boost::filesystem;
 common_installer::Step::Status StepCreateSymbolicLink::process() {
   assert(context_->manifest_data.get());
   boost::system::error_code error;
-  uiapplication_x* ui = context_->manifest_data.get()->uiapplication;
-  serviceapplication_x* svc =
-      context_->manifest_data.get()->serviceapplication;
-  if ((!ui) && (!svc)) {
-     LOG(ERROR) << "There is neither UI applications nor"
-        << "Services applications described!";
+  application_x* app = context_->manifest_data.get()->application;
+  if (!app) {
+     LOG(ERROR) << "There is no application described!";
     return Step::Status::ERROR;
   }
   // add ui-application element per ui application
-  for (; ui != nullptr; ui = ui->next) {
+  for (; app != nullptr; app = app->next) {
     // binary is a symbolic link named <appid> and is located in <pkgid>/<appid>
     bf::path exec_path =
         context_->pkg_path.get()
             / bf::path("bin");
     common_installer::CreateDir(exec_path);
 
-    exec_path /= bf::path(ui->appid);
-
-    bf::create_symlink(bf::path(WRT_LAUNCHER), exec_path, error);
-    if (error) {
-      LOG(ERROR) << "Failed to set symbolic link "
-        << boost::system::system_error(error).what();
-      return Step::Status::ERROR;
-    }
-  }
-  for (; svc != nullptr; svc = svc->next) {
-    // binary is a symbolic link named <appid> and is located in <pkgid>/<appid>
-    bf::path exec_path = context_->pkg_path.get() / bf::path("bin");
-    common_installer::CreateDir(exec_path);
-
-    exec_path /= bf::path(svc->appid);
+    exec_path /= bf::path(app->appid);
 
     bf::create_symlink(bf::path(WRT_LAUNCHER), exec_path, error);
     if (error) {
@@ -69,15 +52,9 @@ common_installer::Step::Status StepCreateSymbolicLink::process() {
 }
 
 common_installer::Step::Status StepCreateSymbolicLink::undo() {
-  uiapplication_x* ui = context_->manifest_data.get()->uiapplication;
-  serviceapplication_x* svc = context_->manifest_data.get()->serviceapplication;
+  application_x* app = context_->manifest_data.get()->application;
 
-  for (; ui != nullptr; ui = ui->next) {
-    bf::path exec_path = context_->pkg_path.get() / bf::path("bin");
-    if (bf::exists(exec_path))
-      bf::remove_all(exec_path);
-  }
-  for (; svc != nullptr; svc = svc->next) {
+  for (; app != nullptr; app = app->next) {
     bf::path exec_path = context_->pkg_path.get() / bf::path("bin");
     if (bf::exists(exec_path))
       bf::remove_all(exec_path);
index a27653d..e374588 100755 (executable)
@@ -123,7 +123,7 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) {
     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());
-    LISTADD(manifest->uiapplication->label, label);
+    LISTADD(manifest->application->label, label);
   }
 
   author_x* author = reinterpret_cast<author_x*>(calloc(1, sizeof(author_x)));
@@ -170,25 +170,20 @@ bool StepParse::FillApplicationInfo(manifest_x* manifest) {
     return false;
   }
   // application data
-  manifest->serviceapplication = nullptr;
-  manifest->uiapplication = reinterpret_cast<uiapplication_x*>
-    (calloc (1, sizeof(uiapplication_x)));
-  manifest->uiapplication->appcontrol = nullptr;
-  manifest->uiapplication->icon =
+  manifest->application = reinterpret_cast<application_x*>
+    (calloc (1, sizeof(application_x)));
+  manifest->application->component_type = strdup("uiapp");
+  manifest->application->icon =
       reinterpret_cast<icon_x*> (calloc(1, sizeof(icon_x)));
-
-  manifest->uiapplication->appid = strdup(app_info->id().c_str());
-  manifest->uiapplication->type = strdup("webapp");
-
+  manifest->application->appid = strdup(app_info->id().c_str());
+  manifest->application->type = strdup("webapp");
+  manifest->package = strdup(app_info->package().c_str());
+  manifest->mainapp_id = strdup(app_info->id().c_str());
   if (manifest->icon) {
     icon_x* icon = nullptr;
     LISTHEAD(manifest->icon, icon);
-    manifest->uiapplication->icon->text = strdup(icon->text);
+    manifest->application->icon->text = strdup(icon->text);
   }
-  manifest->uiapplication->next = nullptr;
-
-  manifest->package = strdup(app_info->package().c_str());
-  manifest->mainapp_id = strdup(app_info->id().c_str());
 
   return true;
 }
@@ -205,7 +200,7 @@ bool StepParse::FillAppControl(manifest_x* manifest) {
       app_control->operation = strdup(control.operation().c_str());
       app_control->mime = strdup(control.mime().c_str());
       app_control->uri = strdup(control.uri().c_str());
-      LISTADD(manifest->uiapplication->appcontrol, app_control);
+      LISTADD(manifest->application->appcontrol, app_control);
     }
   }
   return true;
@@ -240,18 +235,11 @@ bool StepParse::FillMetadata(manifest_x* manifest) {
   if (!meta_info)
     return true;
 
-  uiapplication_x* ui_app = nullptr;
-  PKGMGR_LIST_MOVE_NODE_TO_HEAD(manifest->uiapplication, ui_app);
-  for (; ui_app; ui_app = ui_app->next) {
-    manifest->uiapplication->metadata =
-        GenerateMetadataListX(*meta_info, manifest->uiapplication->metadata);
-  }
-  serviceapplication_x* svc_app = nullptr;
-  PKGMGR_LIST_MOVE_NODE_TO_HEAD(manifest->serviceapplication, svc_app);
-  for (; svc_app; svc_app = svc_app->next) {
-    manifest->serviceapplication->metadata =
-        GenerateMetadataListX(*meta_info,
-                              manifest->serviceapplication->metadata);
+  application_x* app = nullptr;
+  PKGMGR_LIST_MOVE_NODE_TO_HEAD(manifest->application, app);
+  for (; app; app = app->next) {
+    manifest->application->metadata =
+        GenerateMetadataListX(*meta_info, manifest->application->metadata);
   }
   return true;
 }
@@ -391,7 +379,7 @@ common_installer::Step::Status StepParse::process() {
   LOG(DEBUG) << "  name        = " <<  name;
   LOG(DEBUG) << "  short_name  = " <<  short_name;
   LOG(DEBUG) << "  aplication version     = " <<  package_version;
-  LOG(DEBUG) << "  icon        = " <<  manifest->uiapplication->icon->text;
+  LOG(DEBUG) << "  icon        = " <<  manifest->application->icon->text;
   LOG(DEBUG) << "  api_version = " <<  info->required_version();
   LOG(DEBUG) << "  privileges -[";
   for (const auto& p : permissions) {