AppInstaller logic export 98/93998/15
authorPiotr Ganicz <p.ganicz@samsung.com>
Mon, 24 Oct 2016 14:04:29 +0000 (16:04 +0200)
committerBartlomiej Kunikowski <b.kunikowski@partner.samsung.com>
Wed, 22 Nov 2017 09:13:53 +0000 (09:13 +0000)
This commit gather the logic of choosing proper steps sequence
to app-installer repository. All backends have to prepare their
own sequences for each pkgmgr request. The default implementation
of such methods is provided and there is no need for overriding
each function in backends.

    Submit together:
     - https://review.tizen.org/gerrit/#/c/93999/
     - https://review.tizen.org/gerrit/#/c/94000/

Change-Id: Ice10a836c28786f92f6fdd8bc0d23a6c7febce19
Signed-off-by: Damian Pietruchowski <d.pietruchow@samsung.com>
src/common/app_installer.cc
src/common/app_installer.h

index ef2cf99..c5cb483 100644 (file)
@@ -13,6 +13,7 @@
 #include "common/installer_context.h"
 #include "common/pkgmgr_interface.h"
 #include "common/pkgmgr_signal.h"
+#include "common/step/configuration/step_fail.h"
 
 namespace {
 
@@ -38,6 +39,71 @@ AppInstaller::AppInstaller(const char* package_type, PkgMgrPtr pkgmgr)
 AppInstaller::~AppInstaller() {
 }
 
+void AppInstaller::Init() {
+  switch (pkgmgr_->GetRequestType()) {
+    case RequestType::Install:
+      InstallSteps();
+      break;
+    case RequestType::Update:
+      UpdateSteps();
+      break;
+    case RequestType::Uninstall:
+      UninstallSteps();
+      break;
+    case RequestType::Reinstall:
+      ReinstallSteps();
+      break;
+    case RequestType::Delta:
+      DeltaSteps();
+      break;
+    case RequestType::Move:
+      MoveSteps();
+      break;
+    case RequestType::Recovery:
+      RecoverySteps();
+      break;
+    case RequestType::MountInstall:
+      MountInstallSteps();
+      break;
+    case RequestType::MountUpdate:
+      MountUpdateSteps();
+      break;
+    case RequestType::ManifestDirectInstall:
+      ManifestDirectInstallSteps();
+      break;
+    case RequestType::ManifestDirectUpdate:
+      ManifestDirectUpdateSteps();
+      break;
+    case RequestType::ManifestPartialInstall:
+      ManifestPartialInstallSteps();
+      break;
+    case RequestType::ManifestPartialUpdate:
+      ManifestPartialUpdateSteps();
+      break;
+    case RequestType::PartialUninstall:
+      PartialUninstallSteps();
+      break;
+    case RequestType::ReadonlyUpdateInstall:
+      ReadonlyUpdateInstallSteps();
+      break;
+    case RequestType::ReadonlyUpdateUninstall:
+      ReadonlyUpdateUninstallSteps();
+      break;
+    case RequestType::EnablePkg:
+      EnablePkgSteps();
+      break;
+    case RequestType::DisablePkg:
+      DisablePkgSteps();
+      break;
+    case RequestType::MigrateExtImg:
+      MigrateExtImgSteps();
+      break;
+    default:
+      UnknownSteps();
+      break;
+  }
+}
+
 AppInstaller::Result AppInstaller::Run() {
   std::list<std::unique_ptr<Step>>::iterator it(steps_.begin());
   std::list<std::unique_ptr<Step>>::iterator itStart(steps_.begin());
@@ -149,6 +215,29 @@ AppInstaller::Result AppInstaller::Run() {
   return ret;
 }
 
+void AppInstaller::InstallSteps() { UnknownSteps(); }
+void AppInstaller::UpdateSteps() { UnknownSteps(); }
+void AppInstaller::UninstallSteps() { UnknownSteps(); }
+void AppInstaller::ReinstallSteps() { UnknownSteps(); }
+void AppInstaller::DeltaSteps() { UnknownSteps(); }
+void AppInstaller::MoveSteps() { UnknownSteps(); }
+void AppInstaller::RecoverySteps() { UnknownSteps(); }
+void AppInstaller::MountInstallSteps() { UnknownSteps(); }
+void AppInstaller::MountUpdateSteps() { UnknownSteps(); }
+void AppInstaller::ManifestDirectInstallSteps() { UnknownSteps(); }
+void AppInstaller::ManifestDirectUpdateSteps() { UnknownSteps(); }
+void AppInstaller::ManifestPartialInstallSteps() { UnknownSteps(); }
+void AppInstaller::ManifestPartialUpdateSteps() { UnknownSteps(); }
+void AppInstaller::PartialUninstallSteps() { UnknownSteps(); }
+void AppInstaller::ReadonlyUpdateInstallSteps() { UnknownSteps(); }
+void AppInstaller::ReadonlyUpdateUninstallSteps() { UnknownSteps(); }
+void AppInstaller::DisablePkgSteps() { UnknownSteps(); }
+void AppInstaller::EnablePkgSteps() { UnknownSteps(); }
+void AppInstaller::MigrateExtImgSteps() { UnknownSteps(); }
+void AppInstaller::UnknownSteps() {
+  AddStep<configuration::StepFail>();
+}
+
 void AppInstaller::HandleStepError(Step::Status result,
                                         const std::string& error) {
   if (pi_)
index 78c1e1a..1bc614c 100644 (file)
@@ -118,9 +118,32 @@ class AppInstaller {
   PkgMgrPtr pkgmgr_;
   std::unique_ptr<InstallerContext> context_;
 
+  void Init();
+
  private:
   std::list<std::unique_ptr<Step>> steps_;
 
+  virtual void InstallSteps();
+  virtual void UpdateSteps();
+  virtual void UninstallSteps();
+  virtual void ReinstallSteps();
+  virtual void DeltaSteps();
+  virtual void MoveSteps();
+  virtual void RecoverySteps();
+  virtual void MountInstallSteps();
+  virtual void MountUpdateSteps();
+  virtual void ManifestDirectInstallSteps();
+  virtual void ManifestDirectUpdateSteps();
+  virtual void ManifestPartialInstallSteps();
+  virtual void ManifestPartialUpdateSteps();
+  virtual void PartialUninstallSteps();
+  virtual void ReadonlyUpdateInstallSteps();
+  virtual void ReadonlyUpdateUninstallSteps();
+  virtual void DisablePkgSteps();
+  virtual void EnablePkgSteps();
+  virtual void MigrateExtImgSteps();
+  virtual void UnknownSteps();
+
   // data used to send signal
   std::unique_ptr<PkgmgrSignal> pi_;