1 #pragma once 2 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 16 class UpdateManager; 17 18 using ActivationIntf = sdbusplus::server::object_t< 19 sdbusplus::xyz::openbmc_project::Software::server::Activation>; 20 using ActivationProgressIntf = sdbusplus::server::object_t< 21 sdbusplus::xyz::openbmc_project::Software::server::ActivationProgress>; 22 using DeleteIntf = sdbusplus::server::object_t< 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 */ 38 ActivationProgress(sdbusplus::bus_t& bus, const std::string& objPath) : 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 */ 59 Delete(sdbusplus::bus_t& bus, const std::string& objPath, 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 */ 66 void delete_() override; 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 */ 86 Activation(sdbusplus::bus_t& bus, std::string objPath, 87 Activations activationStatus, UpdateManager* updateManager) : 88 ActivationIntf(bus, objPath.c_str(), 89 ActivationIntf::action::defer_emit), 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 */ 104 Activations activation(Activations value) override; 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: 123 sdbusplus::bus_t& bus; 124 const std::string objPath; 125 UpdateManager* updateManager; 126 std::unique_ptr<Delete> deleteImpl; 127 }; 128 129 } // namespace fw_update 130 131 } // namespace pldm 132