Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / installer / app_installer.h
index ad2b8ea..6cb0627 100644 (file)
@@ -8,14 +8,14 @@
 
 #include <manifest_parser/utils/logging.h>
 
-#include <boost/bind.hpp>
-
+#include <algorithm>
 #include <list>
 #include <memory>
 #include <string>
 #include <utility>
 
 #include "common/archive_info.h"
+#include "common/history_logger.h"
 #include "common/pkgmgr_interface.h"
 #include "common/pkgmgr_signal.h"
 #include "common/step/step.h"
@@ -29,7 +29,7 @@ namespace common_installer {
  *        the lists of steps and runs each of the step in the configured
  *        order.
  */
-class AppInstaller {
+class AppInstaller : public Step::IStepErrorSignal {
  public:
   /** Enumeration of possible returned Results */
   enum class Result {
@@ -51,6 +51,9 @@ class AppInstaller {
   /** virtual desctructor */
   virtual ~AppInstaller();
 
+  /** error handler for sending error signal */
+  void on_error(Step::Status result, const std::string& error) override;
+
   /**
    * \brief Adds new step to installer by specified type
    *        Type of template parameter is used to create requested step
@@ -67,8 +70,7 @@ class AppInstaller {
   void AddStep(Args&&... args) {
     std::unique_ptr<Step> step(
         new StepT(context_.get(), std::forward<Args>(args)...));
-    step->on_error.connect(
-        boost::bind(&AppInstaller::HandleStepError, this, _1, _2));
+    step->connect(this);
     steps_.emplace_back(std::move(step));
   }
 
@@ -106,8 +108,7 @@ class AppInstaller {
   void AddStepAtIndex(unsigned int index, Args&&... args) {
     std::unique_ptr<Step> step(
         new StepT(context_.get(), std::forward<Args>(args)...));
-    step->on_error.connect(
-        boost::bind(&AppInstaller::HandleStepError, this, _1, _2));
+    step->connect(this);
     std::list<std::unique_ptr<Step>> tmpList;
     tmpList.emplace_back(std::move(step));
     auto it = steps_.begin();
@@ -141,8 +142,7 @@ class AppInstaller {
 
     std::unique_ptr<Step> step(
         new StepT(context_.get(), std::forward<Args>(args)...));
-    step->on_error.connect(
-        boost::bind(&AppInstaller::HandleStepError, this, _1, _2));
+    step->connect(this);
     *it = std::move(step);
   }
 
@@ -172,8 +172,7 @@ class AppInstaller {
 
     std::unique_ptr<Step> step(
         new StepT(context_.get(), std::forward<Args>(args)...));
-    step->on_error.connect(
-        boost::bind(&AppInstaller::HandleStepError, this, _1, _2));
+    step->connect(this);
     steps_.insert(it, std::move(step));
   }
 
@@ -203,8 +202,7 @@ class AppInstaller {
 
     std::unique_ptr<Step> step(
         new StepT(context_.get(), std::forward<Args>(args)...));
-    step->on_error.connect(
-        boost::bind(&AppInstaller::HandleStepError, this, _1, _2));
+    step->connect(this);
     steps_.insert(++it, std::move(step));
   }
 
@@ -289,21 +287,23 @@ class AppInstaller {
   std::list<std::unique_ptr<Step>>::iterator it_;
 
   // data used to send signal
-  std::unique_ptr<PkgmgrSignal> pi_;
+  std::unique_ptr<PkgmgrSignal> ps_;
 
+  bool SendStartIfNotSent(bool is_skippable);
   void SendProgress(int progress);
   void SendFinished(Step::Status status);
   Step::Status SafeExecute(std::unique_ptr<Step> const& step_ptr,
                            Step::Status (Step::*method)(),
                            std::string name);
   void HandleStepError(Step::Status result, const std::string& error);
+  std::string GetPackageVersion();
 
   std::shared_ptr<utils::FileLogBackend> failure_logger_;
   Step::Status status_;
   Result result_;
-  void LogHistory(bool success);
 
   int index_;
+  HistoryLogger history_logger_;
 
   friend class InstallerRunner;