1 #pragma once
2 #include <sdbusplus/server.hpp>
3 #include "version.hpp"
4 
5 namespace phosphor
6 {
7 namespace software
8 {
9 namespace manager
10 {
11 
12 /** @class Manager
13  *  @brief Contains a map of Version dbus objects.
14  *  @details The software image manager class that contains the Version dbus
15  *           objects and their version ids.
16  */
17 class Manager
18 {
19     public:
20         /** @brief Constructs Manager Class
21          *
22          * @param[in] bus - The Dbus bus object
23          */
24         Manager(sdbusplus::bus::bus& bus) : bus(bus){};
25 
26         /**
27          * @brief Verify and untar the tarball. Verify the manifest file.
28          *        Create and populate the version and filepath interfaces.
29          *
30          * @param[in]  tarballFilePath - Tarball path.
31          * @param[out] result          - 0 if successful.
32          */
33          int processImage(const std::string& tarballFilePath);
34 
35         /**
36          * @brief Erase specified entry d-bus object
37          *        and deletes the image file.
38          *
39          * @param[in] entryId - unique identifier of the entry
40          */
41         void erase(std::string entryId);
42 
43     private:
44         /** @brief Persistent map of Version dbus objects and their
45           * version id */
46         std::map<std::string, std::unique_ptr<Version>> versions;
47 
48         /** @brief Persistent sdbusplus DBus bus connection. */
49         sdbusplus::bus::bus& bus;
50 
51         /**
52          * @brief Untar the tarball.
53          *
54          * @param[in]  tarballFilePath - Tarball path.
55          * @param[in]  extractDirPath  - Dir path to extract tarball ball to.
56          * @param[out] result          - 0 if successful.
57          */
58         static int unTar(const std::string& tarballFilePath,
59                          const std::string& extractDirPath);
60 };
61 
62 } // namespace manager
63 } // namespace software
64 } // namespace phosphor
65