Gunnar Mills | 392f294 | 2017-04-12 11:04:37 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <sdbusplus/bus.hpp> |
| 4 | #include "xyz/openbmc_project/Software/Version/server.hpp" |
Leonel Gonzalez | e423368 | 2017-07-07 14:38:25 -0500 | [diff] [blame] | 5 | #include "xyz/openbmc_project/Object/Delete/server.hpp" |
Gunnar Mills | ef4781f | 2017-04-19 11:28:24 -0500 | [diff] [blame] | 6 | #include "xyz/openbmc_project/Common/FilePath/server.hpp" |
Leonel Gonzalez | e423368 | 2017-07-07 14:38:25 -0500 | [diff] [blame] | 7 | #include <functional> |
Gunnar Mills | 392f294 | 2017-04-12 11:04:37 -0500 | [diff] [blame] | 8 | |
| 9 | namespace phosphor |
| 10 | { |
| 11 | namespace software |
| 12 | { |
| 13 | namespace manager |
| 14 | { |
| 15 | |
Leonel Gonzalez | e423368 | 2017-07-07 14:38:25 -0500 | [diff] [blame] | 16 | typedef std::function<void(std::string)> eraseFunc; |
| 17 | |
Gunnar Mills | 392f294 | 2017-04-12 11:04:37 -0500 | [diff] [blame] | 18 | using VersionInherit = sdbusplus::server::object::object< |
Gunnar Mills | ef4781f | 2017-04-19 11:28:24 -0500 | [diff] [blame] | 19 | sdbusplus::xyz::openbmc_project::Software::server::Version, |
Leonel Gonzalez | e423368 | 2017-07-07 14:38:25 -0500 | [diff] [blame] | 20 | sdbusplus::xyz::openbmc_project::Object::server::Delete, |
Gunnar Mills | ef4781f | 2017-04-19 11:28:24 -0500 | [diff] [blame] | 21 | sdbusplus::xyz::openbmc_project::Common::server::FilePath>; |
Gunnar Mills | 392f294 | 2017-04-12 11:04:37 -0500 | [diff] [blame] | 22 | |
| 23 | /** @class Version |
| 24 | * @brief OpenBMC version software management implementation. |
| 25 | * @details A concrete implementation for xyz.openbmc_project.Software.Version |
| 26 | * DBus API. |
| 27 | */ |
| 28 | class Version : public VersionInherit |
| 29 | { |
| 30 | public: |
| 31 | /** @brief Constructs Version Software Manager |
| 32 | * |
Gunnar Mills | cebd102 | 2017-04-17 16:10:15 -0500 | [diff] [blame] | 33 | * @param[in] bus - The Dbus bus object |
| 34 | * @param[in] objPath - The Dbus object path |
| 35 | * @param[in] versionId - The version identifier |
| 36 | * @param[in] versionPurpose - The version purpose |
Gunnar Mills | ef4781f | 2017-04-19 11:28:24 -0500 | [diff] [blame] | 37 | * @param[in] filePath - The image filesystem path |
Gunnar Mills | 392f294 | 2017-04-12 11:04:37 -0500 | [diff] [blame] | 38 | */ |
| 39 | Version(sdbusplus::bus::bus& bus, |
| 40 | const std::string& objPath, |
Gunnar Mills | cebd102 | 2017-04-17 16:10:15 -0500 | [diff] [blame] | 41 | const std::string& versionId, |
Gunnar Mills | ef4781f | 2017-04-19 11:28:24 -0500 | [diff] [blame] | 42 | VersionPurpose versionPurpose, |
| 43 | const std::string& filePath) : VersionInherit( |
Gunnar Mills | 392f294 | 2017-04-12 11:04:37 -0500 | [diff] [blame] | 44 | bus, (objPath).c_str(), true) |
| 45 | { |
| 46 | // Set properties. |
Gunnar Mills | cebd102 | 2017-04-17 16:10:15 -0500 | [diff] [blame] | 47 | purpose(versionPurpose); |
Gunnar Mills | 392f294 | 2017-04-12 11:04:37 -0500 | [diff] [blame] | 48 | version(versionId); |
Gunnar Mills | ef4781f | 2017-04-19 11:28:24 -0500 | [diff] [blame] | 49 | path(filePath); |
Gunnar Mills | 392f294 | 2017-04-12 11:04:37 -0500 | [diff] [blame] | 50 | // Emit deferred signal. |
| 51 | emit_object_added(); |
| 52 | } |
| 53 | |
| 54 | /** |
Gunnar Mills | cebd102 | 2017-04-17 16:10:15 -0500 | [diff] [blame] | 55 | * @brief Read the manifest file to get the value of the key. |
Gunnar Mills | 392f294 | 2017-04-12 11:04:37 -0500 | [diff] [blame] | 56 | * |
Gunnar Mills | cebd102 | 2017-04-17 16:10:15 -0500 | [diff] [blame] | 57 | * @return The value of the key. |
Gunnar Mills | 392f294 | 2017-04-12 11:04:37 -0500 | [diff] [blame] | 58 | **/ |
Gunnar Mills | cebd102 | 2017-04-17 16:10:15 -0500 | [diff] [blame] | 59 | static std::string getValue(const std::string& manifestFilePath, |
| 60 | std::string key); |
Gunnar Mills | 392f294 | 2017-04-12 11:04:37 -0500 | [diff] [blame] | 61 | |
| 62 | /** |
Gunnar Mills | cebd102 | 2017-04-17 16:10:15 -0500 | [diff] [blame] | 63 | * @brief Get the Version id. |
Gunnar Mills | 392f294 | 2017-04-12 11:04:37 -0500 | [diff] [blame] | 64 | * |
| 65 | * @return The id. |
| 66 | **/ |
| 67 | static std::string getId(const std::string& version); |
Gunnar Mills | cebd102 | 2017-04-17 16:10:15 -0500 | [diff] [blame] | 68 | |
Saqib Khan | ba23988 | 2017-05-26 08:41:54 -0500 | [diff] [blame] | 69 | /** |
| 70 | * @brief Get the active bmc version identifier. |
| 71 | * |
| 72 | * @return The version identifier. |
| 73 | */ |
| 74 | static std::string getBMCVersion(); |
Leonel Gonzalez | e423368 | 2017-07-07 14:38:25 -0500 | [diff] [blame] | 75 | |
| 76 | /** |
| 77 | * @brief Delete the d-bus object and image. |
| 78 | */ |
| 79 | void delete_() override; |
| 80 | |
| 81 | |
| 82 | private: |
| 83 | /** |
| 84 | * @brief The parent's erase callback. |
| 85 | */ |
| 86 | eraseFunc eraseCallback; |
Gunnar Mills | 392f294 | 2017-04-12 11:04:37 -0500 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | } // namespace manager |
| 90 | } // namespace software |
| 91 | } // namespace phosphor |
| 92 | |