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.
5 #ifndef COMMON_PKGMGR_INTERFACE_H_
6 #define COMMON_PKGMGR_INTERFACE_H_
8 #include <pkgmgr_installer.h>
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>
18 namespace common_installer {
20 class PkgMgrInterface;
21 typedef std::shared_ptr<PkgMgrInterface> PkgMgrPtr;
24 * \brief Encapsulates pkgmgr API which handles parsing backend options
25 * and returns values/modes for installation process.
27 class PkgMgrInterface {
30 * Returns Request type passed from pkgmgr_installer
32 * \return request type retrieved from pkgmgr_installer
34 RequestType GetRequestType() const;
37 * Returns Request info passed from pkgmgr_installer
39 * \return request info retrieved from pkgmgr_installer
41 const char *GetRequestInfo() const;
44 * Creates PkgMgrInterface
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
50 * \return Smart pointer to the PkgMgrInterface
52 static PkgMgrPtr Create(int argc, char** argv,
53 AppQueryInterface* interface = nullptr);
56 * Returns TEP path passed from pkgmgr_installer
58 * \return TEP path retrieved from pkgmgr_installer
60 boost::filesystem::path GetTepPath() const;
63 * Returns True if TEP file should be moved. Otherwise, return false
65 * \return True if TEP file should be moved. Otherwise, return false
70 * Get Raw pointer to pkgmgr_installer object
71 * NOTE: It should not be used (PkgMgrInterface can destroy it
73 * \return raw pkgmgr_installer pointer
75 DEPRECATED pkgmgr_installer *GetRawPi() const { return pi_; }
77 /** PkgMgrInstance destructor. */
81 explicit PkgMgrInterface(AppQueryInterface* interface)
83 is_app_installed_(false),
84 query_interface_(interface) {}
85 int InitInternal(int argc, char** argv);
87 pkgmgr_installer* pi_;
88 bool is_app_installed_;
89 AppQueryInterface* query_interface_;
91 SCOPE_LOG_TAG(PkgMgrInterface)
92 DISALLOW_COPY_AND_ASSIGN(PkgMgrInterface);
95 } // namespace common_installer
97 #endif // COMMON_PKGMGR_INTERFACE_H_