Merge "implement TEP install, update" into tizen
[platform/core/appfw/app-installers.git] / src / common / pkgmgr_interface.h
1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache 2.0 license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMMON_PKGMGR_INTERFACE_H_
6 #define COMMON_PKGMGR_INTERFACE_H_
7
8 #include <pkgmgr_installer.h>
9
10 #include <memory>
11
12 #include "common/app_query_interface.h"
13 #include "common/request.h"
14 #include "common/utils/macros.h"
15 #include "common/utils/logging.h"
16 #include <boost/filesystem/path.hpp>
17
18 namespace common_installer {
19
20 class PkgMgrInterface;
21 typedef std::shared_ptr<PkgMgrInterface> PkgMgrPtr;
22
23 /**
24  * \brief Encapsulates pkgmgr API which handles parsing backend options
25  *        and returns values/modes for installation process.
26  */
27 class PkgMgrInterface {
28  public:
29   /**
30    * Returns Request type passed from pkgmgr_installer
31    *
32    * \return request type retrieved from pkgmgr_installer
33    */
34   RequestType GetRequestType() const;
35
36   /**
37    * Returns Request info passed from pkgmgr_installer
38    *
39    * \return request info retrieved from pkgmgr_installer
40    */
41   const char *GetRequestInfo() const;
42
43   /**
44    * Creates PkgMgrInterface
45    *
46    * \param argc main() argc argument passed to the backend
47    * \param argv main() argv argument passed to the backend
48    * \param interface pointer to AppQueryInterface
49    *
50    * \return Smart pointer to the PkgMgrInterface
51    */
52   static PkgMgrPtr Create(int argc, char** argv,
53         AppQueryInterface* interface = nullptr);
54
55   /**
56   * Returns TEP path passed from pkgmgr_installer
57   *
58   * \return TEP path retrieved from pkgmgr_installer
59   */
60   boost::filesystem::path GetTepPath() const;
61
62   /**
63   * Returns True if TEP file should be moved. Otherwise, return false
64   *
65   * \return True if TEP file should be moved. Otherwise, return false
66   */
67   bool GetIsTepMove();
68
69   /**
70    * Get Raw pointer to pkgmgr_installer object
71    * NOTE: It should not be used (PkgMgrInterface can destroy it
72    *
73    * \return raw pkgmgr_installer pointer
74    */
75   DEPRECATED pkgmgr_installer *GetRawPi() const { return pi_; }
76
77   /** PkgMgrInstance destructor. */
78   ~PkgMgrInterface();
79
80  private:
81   explicit PkgMgrInterface(AppQueryInterface* interface)
82       : pi_(nullptr),
83         is_app_installed_(false),
84         query_interface_(interface) {}
85   int InitInternal(int argc, char** argv);
86
87   pkgmgr_installer* pi_;
88   bool is_app_installed_;
89   AppQueryInterface* query_interface_;
90
91   SCOPE_LOG_TAG(PkgMgrInterface)
92   DISALLOW_COPY_AND_ASSIGN(PkgMgrInterface);
93 };
94
95 }  // namespace common_installer
96
97 #endif  // COMMON_PKGMGR_INTERFACE_H_