Tom Joseph | 4d8d577 | 2021-08-17 07:35:05 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Tom Joseph | 4d8d577 | 2021-08-17 07:35:05 -0700 | [diff] [blame] | 3 | #include <sdbusplus/bus.hpp> |
| 4 | #include <xyz/openbmc_project/Object/Delete/server.hpp> |
| 5 | #include <xyz/openbmc_project/Software/Activation/server.hpp> |
| 6 | #include <xyz/openbmc_project/Software/ActivationProgress/server.hpp> |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | namespace pldm |
| 11 | { |
| 12 | |
| 13 | namespace fw_update |
| 14 | { |
| 15 | |
Andrew Jeffery | f106a2c | 2024-07-25 21:45:41 +0930 | [diff] [blame] | 16 | class UpdateManager; |
| 17 | |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 18 | using ActivationIntf = sdbusplus::server::object_t< |
Tom Joseph | 4d8d577 | 2021-08-17 07:35:05 -0700 | [diff] [blame] | 19 | sdbusplus::xyz::openbmc_project::Software::server::Activation>; |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 20 | using ActivationProgressIntf = sdbusplus::server::object_t< |
Tom Joseph | 4d8d577 | 2021-08-17 07:35:05 -0700 | [diff] [blame] | 21 | sdbusplus::xyz::openbmc_project::Software::server::ActivationProgress>; |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 22 | using DeleteIntf = sdbusplus::server::object_t< |
Tom Joseph | 4d8d577 | 2021-08-17 07:35:05 -0700 | [diff] [blame] | 23 | sdbusplus::xyz::openbmc_project::Object::server::Delete>; |
| 24 | |
| 25 | /** @class ActivationProgress |
| 26 | * |
| 27 | * Concrete implementation of xyz.openbmc_project.Software.ActivationProgress |
| 28 | * D-Bus interface |
| 29 | */ |
| 30 | class ActivationProgress : public ActivationProgressIntf |
| 31 | { |
| 32 | public: |
| 33 | /** @brief Constructor |
| 34 | * |
| 35 | * @param[in] bus - Bus to attach to |
| 36 | * @param[in] objPath - D-Bus object path |
| 37 | */ |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 38 | ActivationProgress(sdbusplus::bus_t& bus, const std::string& objPath) : |
Tom Joseph | 4d8d577 | 2021-08-17 07:35:05 -0700 | [diff] [blame] | 39 | ActivationProgressIntf(bus, objPath.c_str(), |
| 40 | action::emit_interface_added) |
| 41 | { |
| 42 | progress(0); |
| 43 | } |
| 44 | }; |
| 45 | |
| 46 | /** @class Delete |
| 47 | * |
| 48 | * Concrete implementation of xyz.openbmc_project.Object.Delete D-Bus interface |
| 49 | */ |
| 50 | class Delete : public DeleteIntf |
| 51 | { |
| 52 | public: |
| 53 | /** @brief Constructor |
| 54 | * |
| 55 | * @param[in] bus - Bus to attach to |
| 56 | * @param[in] objPath - D-Bus object path |
| 57 | * @param[in] updateManager - Reference to FW update manager |
| 58 | */ |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 59 | Delete(sdbusplus::bus_t& bus, const std::string& objPath, |
Tom Joseph | 4d8d577 | 2021-08-17 07:35:05 -0700 | [diff] [blame] | 60 | UpdateManager* updateManager) : |
| 61 | DeleteIntf(bus, objPath.c_str(), action::emit_interface_added), |
| 62 | updateManager(updateManager) |
| 63 | {} |
| 64 | |
| 65 | /** @brief Delete the Activation D-Bus object for the FW update package */ |
Andrew Jeffery | f106a2c | 2024-07-25 21:45:41 +0930 | [diff] [blame] | 66 | void delete_() override; |
Tom Joseph | 4d8d577 | 2021-08-17 07:35:05 -0700 | [diff] [blame] | 67 | |
| 68 | private: |
| 69 | UpdateManager* updateManager; |
| 70 | }; |
| 71 | |
| 72 | /** @class Activation |
| 73 | * |
| 74 | * Concrete implementation of xyz.openbmc_project.Object.Activation D-Bus |
| 75 | * interface |
| 76 | */ |
| 77 | class Activation : public ActivationIntf |
| 78 | { |
| 79 | public: |
| 80 | /** @brief Constructor |
| 81 | * |
| 82 | * @param[in] bus - Bus to attach to |
| 83 | * @param[in] objPath - D-Bus object path |
| 84 | * @param[in] updateManager - Reference to FW update manager |
| 85 | */ |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 86 | Activation(sdbusplus::bus_t& bus, std::string objPath, |
Tom Joseph | 4d8d577 | 2021-08-17 07:35:05 -0700 | [diff] [blame] | 87 | Activations activationStatus, UpdateManager* updateManager) : |
Patrick Williams | 357b72d | 2022-04-13 09:01:35 -0500 | [diff] [blame] | 88 | ActivationIntf(bus, objPath.c_str(), |
| 89 | ActivationIntf::action::defer_emit), |
Tom Joseph | 4d8d577 | 2021-08-17 07:35:05 -0700 | [diff] [blame] | 90 | bus(bus), objPath(objPath), updateManager(updateManager) |
| 91 | { |
| 92 | activation(activationStatus); |
| 93 | deleteImpl = std::make_unique<Delete>(bus, objPath, updateManager); |
| 94 | emit_object_added(); |
| 95 | } |
| 96 | |
| 97 | using sdbusplus::xyz::openbmc_project::Software::server::Activation:: |
| 98 | activation; |
| 99 | using sdbusplus::xyz::openbmc_project::Software::server::Activation:: |
| 100 | requestedActivation; |
| 101 | |
| 102 | /** @brief Overriding Activation property setter function |
| 103 | */ |
Andrew Jeffery | f106a2c | 2024-07-25 21:45:41 +0930 | [diff] [blame] | 104 | Activations activation(Activations value) override; |
Tom Joseph | 4d8d577 | 2021-08-17 07:35:05 -0700 | [diff] [blame] | 105 | |
| 106 | /** @brief Overriding RequestedActivations property setter function |
| 107 | */ |
| 108 | RequestedActivations |
| 109 | requestedActivation(RequestedActivations value) override |
| 110 | { |
| 111 | if ((value == RequestedActivations::Active) && |
| 112 | (requestedActivation() != RequestedActivations::Active)) |
| 113 | { |
| 114 | if ((ActivationIntf::activation() == Activations::Ready)) |
| 115 | { |
| 116 | activation(Activations::Activating); |
| 117 | } |
| 118 | } |
| 119 | return ActivationIntf::requestedActivation(value); |
| 120 | } |
| 121 | |
| 122 | private: |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 123 | sdbusplus::bus_t& bus; |
Tom Joseph | 4d8d577 | 2021-08-17 07:35:05 -0700 | [diff] [blame] | 124 | const std::string objPath; |
| 125 | UpdateManager* updateManager; |
| 126 | std::unique_ptr<Delete> deleteImpl; |
| 127 | }; |
| 128 | |
| 129 | } // namespace fw_update |
| 130 | |
| 131 | } // namespace pldm |