blob: 5afb96dd7cd57a9b8e0b72b30fc5a75a4ec51268 [file] [log] [blame]
Adriana Kobylak2d8fa222017-03-15 12:34:32 -05001#pragma once
2
3#include <sdbusplus/server.hpp>
4#include "activation.hpp"
5
6namespace openpower
7{
8namespace software
9{
Adriana Kobylakbefe5ce2017-04-05 15:57:44 -050010namespace updater
Adriana Kobylak2d8fa222017-03-15 12:34:32 -050011{
12
13/** @class ItemUpdater
14 * @brief Manages the activation of the version items.
15 */
16class 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 Khan7254f0e2017-04-10 21:45:37 -050055 /**
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);
64
Adriana Kobylak2d8fa222017-03-15 12:34:32 -050065 /** @brief Persistent sdbusplus DBus bus connection. */
66 sdbusplus::bus::bus& busItem;
67
68 /** @brief Persistent map of Activation dbus objects and their
69 * version id */
Adriana Kobylak268616b2017-04-05 15:23:30 -050070 std::map<std::string, std::unique_ptr<Activation>> activations;
Adriana Kobylak2d8fa222017-03-15 12:34:32 -050071
72 /** @brief sdbusplus signal match for Software.Version */
73 sdbusplus::server::match::match versionMatch;
74};
75
Adriana Kobylakbefe5ce2017-04-05 15:57:44 -050076} // namespace updater
Adriana Kobylak2d8fa222017-03-15 12:34:32 -050077} // namespace software
78} // namespace openpower
79