Gunnar Mills | e91d321 | 2017-04-19 15:42:47 -0500 | [diff] [blame] | 1 | #pragma once |
Eddie James | 9440f49 | 2017-08-30 11:34:16 -0500 | [diff] [blame] | 2 | #include <sdbusplus/server.hpp> |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 3 | #include "version.hpp" |
Gunnar Mills | e91d321 | 2017-04-19 15:42:47 -0500 | [diff] [blame] | 4 | |
| 5 | namespace phosphor |
| 6 | { |
| 7 | namespace software |
| 8 | { |
| 9 | namespace manager |
| 10 | { |
| 11 | |
Eddie James | 9440f49 | 2017-08-30 11:34:16 -0500 | [diff] [blame] | 12 | namespace MatchRules = sdbusplus::bus::match::rules; |
| 13 | |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 14 | /** @class Manager |
| 15 | * @brief Contains a map of Version dbus objects. |
| 16 | * @details The software image manager class that contains the Version dbus |
| 17 | * objects and their version ids. |
Gunnar Mills | e91d321 | 2017-04-19 15:42:47 -0500 | [diff] [blame] | 18 | */ |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 19 | class Manager |
| 20 | { |
| 21 | public: |
| 22 | /** @brief Constructs Manager Class |
| 23 | * |
| 24 | * @param[in] bus - The Dbus bus object |
| 25 | */ |
Eddie James | 9440f49 | 2017-08-30 11:34:16 -0500 | [diff] [blame] | 26 | Manager(sdbusplus::bus::bus& bus) : |
| 27 | bus(bus), |
| 28 | versionMatch( |
| 29 | bus, |
| 30 | MatchRules::interfacesRemoved() + |
| 31 | MatchRules::path(SOFTWARE_OBJPATH), |
| 32 | std::bind( |
| 33 | std::mem_fn(&Manager::removeVersion), |
| 34 | this, |
| 35 | std::placeholders::_1)){}; |
Gunnar Mills | e91d321 | 2017-04-19 15:42:47 -0500 | [diff] [blame] | 36 | |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 37 | /** |
| 38 | * @brief Verify and untar the tarball. Verify the manifest file. |
| 39 | * Create and populate the version and filepath interfaces. |
| 40 | * |
| 41 | * @param[in] tarballFilePath - Tarball path. |
| 42 | * @param[out] result - 0 if successful. |
| 43 | */ |
| 44 | int processImage(const std::string& tarballFilePath); |
| 45 | |
Leonel Gonzalez | 50d559c | 2017-07-07 14:38:25 -0500 | [diff] [blame] | 46 | /** |
| 47 | * @brief Erase specified entry d-bus object |
| 48 | * and deletes the image file. |
| 49 | * |
| 50 | * @param[in] entryId - unique identifier of the entry |
| 51 | */ |
| 52 | void erase(std::string entryId); |
| 53 | |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 54 | private: |
Eddie James | 9440f49 | 2017-08-30 11:34:16 -0500 | [diff] [blame] | 55 | /** @brief Callback function for Software.Version match. |
| 56 | * @details Removes a version object. |
| 57 | * |
| 58 | * @param[in] msg - Data associated with subscribed signal |
| 59 | */ |
| 60 | void removeVersion(sdbusplus::message::message& msg); |
| 61 | |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 62 | /** @brief Persistent map of Version dbus objects and their |
| 63 | * version id */ |
| 64 | std::map<std::string, std::unique_ptr<Version>> versions; |
| 65 | |
| 66 | /** @brief Persistent sdbusplus DBus bus connection. */ |
| 67 | sdbusplus::bus::bus& bus; |
| 68 | |
Eddie James | 9440f49 | 2017-08-30 11:34:16 -0500 | [diff] [blame] | 69 | /** @brief sdbusplus signal match for Software.Version */ |
| 70 | sdbusplus::bus::match_t versionMatch; |
| 71 | |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 72 | /** |
| 73 | * @brief Untar the tarball. |
| 74 | * |
| 75 | * @param[in] tarballFilePath - Tarball path. |
| 76 | * @param[in] extractDirPath - Dir path to extract tarball ball to. |
| 77 | * @param[out] result - 0 if successful. |
| 78 | */ |
| 79 | static int unTar(const std::string& tarballFilePath, |
| 80 | const std::string& extractDirPath); |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 81 | }; |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 82 | |
Gunnar Mills | e91d321 | 2017-04-19 15:42:47 -0500 | [diff] [blame] | 83 | } // namespace manager |
| 84 | } // namespace software |
| 85 | } // namespace phosphor |