Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / pkgmgr_interface.h
index 8050f36..78a93c9 100644 (file)
@@ -5,17 +5,18 @@
 #ifndef COMMON_PKGMGR_INTERFACE_H_
 #define COMMON_PKGMGR_INTERFACE_H_
 
-#include <boost/filesystem/path.hpp>
-#include <boost/none.hpp>
-#include <boost/optional/optional.hpp>
 #include <manifest_parser/utils/logging.h>
 #include <pkgmgr_installer.h>
+
+#include <filesystem>
+#include <map>
 #include <memory>
+#include <optional>
 #include <string>
 
 #include "common/app_query_interface.h"
-#include "common/request.h"
 #include "common/utils/macros.h"
+#include "common/utils/request.h"
 
 namespace common_installer {
 
@@ -40,6 +41,8 @@ typedef std::shared_ptr<PkgMgrInterface> PkgMgrPtr;
  */
 class PkgmgrInstallerInterface {
  public:
+  virtual ~PkgmgrInstallerInterface() = default;
+
   virtual bool CreatePkgMgrInstaller(pkgmgr_installer** installer,
                              InstallationMode* mode) = 0;
   virtual bool ShouldCreateSignal() const = 0;
@@ -63,13 +66,40 @@ class PkgmgrInstaller : public PkgmgrInstallerInterface {
  */
 class PkgMgrInterface {
  public:
-  void SetAppQueryInterface(AppQueryInterface* interface);
+  /**
+   * Set current AppQueryInterface for request
+   *
+   * \param idx index of request
+   *
+   * \return True if setting was success. Otherwise, return false
+   */
+  bool SetAppQueryInterface(int idx);
+
+  /**
+   * Add AppQueryInterface for request
+   *
+   * \param idx index of request
+   * \param interface AppQueryInterface for request
+   */
+  void AddAppQueryInterface(int idx,
+      std::shared_ptr<AppQueryInterface> interface);
+
+  /**
+   * Get AppQueryInterface for current request
+   *
+   * \return AppQueryInterface ptr if current AppQueryInterface exist.
+   *         Otherwise, return null shared_ptr
+   */
+  std::shared_ptr<AppQueryInterface> GetAppQueryInterface();
+
   /**
    * Returns Request type passed from pkgmgr_installer
    *
+   * \param idx index of request
+   *
    * \return request type retrieved from pkgmgr_installer
    */
-  RequestType GetRequestType() const;
+  RequestType GetRequestType(int idx = 0) const;
 
   /**
    * Returns uid passed from pkgmgr_installer
@@ -81,9 +111,11 @@ class PkgMgrInterface {
   /**
    * Returns Request info passed from pkgmgr_installer
    *
+   * \param idx index of request
+   *
    * \return request info retrieved from pkgmgr_installer
    */
-  std::string GetRequestInfo() const;
+  std::string GetRequestInfo(int idx = 0) const;
 
   /**
    * Creates PkgMgrInterface
@@ -98,14 +130,14 @@ class PkgMgrInterface {
    */
   static PkgMgrPtr Create(int argc, char** argv,
         PkgmgrInstallerInterface* pkgmgr_installer_interface,
-        AppQueryInterface* interface = nullptr);
+        std::shared_ptr<AppQueryInterface> interface = nullptr);
 
   /**
   * Returns TEP path passed from pkgmgr_installer
   *
   * \return TEP path retrieved from pkgmgr_installer
   */
-  boost::filesystem::path GetTepPath() const;
+  std::filesystem::path GetTepPath() const;
 
   /**
   * Returns True if TEP file should be moved. Otherwise, return false
@@ -194,6 +226,20 @@ class PkgMgrInterface {
   bool GetSkipOptimization() const;
 
   /**
+   * Returns the number of request info count.
+   *
+   * \return The number of request info count.
+   */
+  int GetRequestInfoCount() const;
+
+  /**
+   * Returns whether recovery mode is set to cleanup or not.
+   *
+   * \return True if recovery mode is set to cleanup. Otherwise, return false.
+   */
+  bool GetRecoveryCleanup() const;
+
+  /**
    * Get Raw pointer to pkgmgr_installer object
    * NOTE: It should not be used (PkgMgrInterface can destroy it
    *
@@ -220,20 +266,21 @@ class PkgMgrInterface {
 
  private:
   explicit PkgMgrInterface(PkgmgrInstallerInterface* pkgmgr_installer_interface,
-                           AppQueryInterface* interface)
+                           std::shared_ptr<AppQueryInterface> interface)
       : pi_(nullptr),
         install_mode_(InstallationMode::ONLINE),
-        is_app_installed_(boost::none),
+        is_app_installed_(std::nullopt),
         pkgmgr_installer_interface_(pkgmgr_installer_interface),
         query_interface_(interface) {}
   int InitInternal(int argc, char** argv);
 
   pkgmgr_installer* pi_;
   InstallationMode install_mode_;
-  mutable boost::optional<bool> is_app_installed_;
+  mutable std::optional<bool> is_app_installed_;
   PkgmgrInstallerInterface* pkgmgr_installer_interface_;
 
-  AppQueryInterface* query_interface_;
+  std::shared_ptr<AppQueryInterface> query_interface_;
+  std::map<int, std::shared_ptr<AppQueryInterface>> query_interface_map_;
 
   SCOPE_LOG_TAG(PkgMgrInterface)
   DISALLOW_COPY_AND_ASSIGN(PkgMgrInterface);