Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <sdbusplus/server.hpp> |
| 4 | #include "activation.hpp" |
| 5 | |
| 6 | namespace openpower |
| 7 | { |
| 8 | namespace software |
| 9 | { |
Adriana Kobylak | befe5ce | 2017-04-05 15:57:44 -0500 | [diff] [blame] | 10 | namespace updater |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 11 | { |
| 12 | |
| 13 | /** @class ItemUpdater |
| 14 | * @brief Manages the activation of the version items. |
| 15 | */ |
| 16 | class ItemUpdater |
| 17 | { |
| 18 | public: |
| 19 | ItemUpdater() = delete; |
| 20 | ~ItemUpdater() = default; |
| 21 | ItemUpdater(const ItemUpdater&) = delete; |
| 22 | ItemUpdater& operator=(const ItemUpdater&) = delete; |
| 23 | ItemUpdater(ItemUpdater&&) = delete; |
| 24 | ItemUpdater& operator=(ItemUpdater&&) = delete; |
| 25 | |
| 26 | /** @brief Constructs ItemUpdater |
| 27 | * |
| 28 | * @param[in] bus - The Dbus bus object |
| 29 | */ |
| 30 | ItemUpdater(sdbusplus::bus::bus& bus) : |
| 31 | busItem(bus), |
| 32 | versionMatch( |
| 33 | bus, |
| 34 | "type='signal'," |
| 35 | "member='InterfacesAdded'," |
| 36 | "path='/xyz/openbmc_project/software'," |
| 37 | "interface='org.freedesktop.DBus.ObjectManager'", |
| 38 | createActivation, |
| 39 | this) |
| 40 | { |
| 41 | } |
| 42 | |
| 43 | private: |
| 44 | /** @brief Callback function for Software.Version match. |
| 45 | * @details Creates an Activation dbus object. |
| 46 | * |
| 47 | * @param[in] msg - Data associated with subscribed signal |
| 48 | * @param[in] userData - Pointer to this object instance |
| 49 | * @param[out] retError - Required param |
| 50 | */ |
| 51 | static int createActivation(sd_bus_message* msg, |
| 52 | void* userData, |
| 53 | sd_bus_error* retError); |
| 54 | |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 55 | /** |
| 56 | * @brief Get the extended version from the specified file. |
| 57 | * |
| 58 | * @param[in] manifestFilePath - File to read. |
| 59 | * |
| 60 | * @return The extended version. |
| 61 | */ |
| 62 | static std::string getExtendedVersion(const std::string& |
| 63 | manifestFilePath); |
Saqib Khan | a8ade7e | 2017-04-12 10:27:56 -0500 | [diff] [blame^] | 64 | /** |
| 65 | * @brief Validates the presence of SquashFS iamge in the image dir. |
| 66 | * |
| 67 | * @param[in] versionId - The software version ID. |
| 68 | * @param[out] result - 0 --> if validation was successful |
| 69 | * - -1--> Otherwise |
| 70 | */ |
| 71 | static int validateSquashFSImage(const std::string& versionId); |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 72 | |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 73 | /** @brief Persistent sdbusplus DBus bus connection. */ |
| 74 | sdbusplus::bus::bus& busItem; |
| 75 | |
| 76 | /** @brief Persistent map of Activation dbus objects and their |
| 77 | * version id */ |
Adriana Kobylak | 268616b | 2017-04-05 15:23:30 -0500 | [diff] [blame] | 78 | std::map<std::string, std::unique_ptr<Activation>> activations; |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 79 | |
| 80 | /** @brief sdbusplus signal match for Software.Version */ |
| 81 | sdbusplus::server::match::match versionMatch; |
| 82 | }; |
| 83 | |
Adriana Kobylak | befe5ce | 2017-04-05 15:57:44 -0500 | [diff] [blame] | 84 | } // namespace updater |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 85 | } // namespace software |
| 86 | } // namespace openpower |
| 87 | |