blob: fcd57eb4139b84fde9243e45f2f51f470d2eaa0a [file] [log] [blame]
Gunnar Mills392f2942017-04-12 11:04:37 -05001#pragma once
2
3#include <sdbusplus/bus.hpp>
4#include "xyz/openbmc_project/Software/Version/server.hpp"
Leonel Gonzaleze4233682017-07-07 14:38:25 -05005#include "xyz/openbmc_project/Object/Delete/server.hpp"
Gunnar Millsef4781f2017-04-19 11:28:24 -05006#include "xyz/openbmc_project/Common/FilePath/server.hpp"
Leonel Gonzaleze4233682017-07-07 14:38:25 -05007#include <functional>
Gunnar Mills392f2942017-04-12 11:04:37 -05008
9namespace phosphor
10{
11namespace software
12{
13namespace manager
14{
15
Leonel Gonzaleze4233682017-07-07 14:38:25 -050016typedef std::function<void(std::string)> eraseFunc;
17
Gunnar Mills392f2942017-04-12 11:04:37 -050018using VersionInherit = sdbusplus::server::object::object<
Gunnar Millsef4781f2017-04-19 11:28:24 -050019 sdbusplus::xyz::openbmc_project::Software::server::Version,
Leonel Gonzaleze4233682017-07-07 14:38:25 -050020 sdbusplus::xyz::openbmc_project::Object::server::Delete,
Gunnar Millsef4781f2017-04-19 11:28:24 -050021 sdbusplus::xyz::openbmc_project::Common::server::FilePath>;
Gunnar Mills392f2942017-04-12 11:04:37 -050022
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 */
28class Version : public VersionInherit
29{
30 public:
31 /** @brief Constructs Version Software Manager
32 *
Gunnar Millscebd1022017-04-17 16:10:15 -050033 * @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 Millsef4781f2017-04-19 11:28:24 -050037 * @param[in] filePath - The image filesystem path
Gunnar Mills392f2942017-04-12 11:04:37 -050038 */
39 Version(sdbusplus::bus::bus& bus,
40 const std::string& objPath,
Gunnar Millscebd1022017-04-17 16:10:15 -050041 const std::string& versionId,
Gunnar Millsef4781f2017-04-19 11:28:24 -050042 VersionPurpose versionPurpose,
43 const std::string& filePath) : VersionInherit(
Gunnar Mills392f2942017-04-12 11:04:37 -050044 bus, (objPath).c_str(), true)
45 {
46 // Set properties.
Gunnar Millscebd1022017-04-17 16:10:15 -050047 purpose(versionPurpose);
Gunnar Mills392f2942017-04-12 11:04:37 -050048 version(versionId);
Gunnar Millsef4781f2017-04-19 11:28:24 -050049 path(filePath);
Gunnar Mills392f2942017-04-12 11:04:37 -050050 // Emit deferred signal.
51 emit_object_added();
52 }
53
54 /**
Gunnar Millscebd1022017-04-17 16:10:15 -050055 * @brief Read the manifest file to get the value of the key.
Gunnar Mills392f2942017-04-12 11:04:37 -050056 *
Gunnar Millscebd1022017-04-17 16:10:15 -050057 * @return The value of the key.
Gunnar Mills392f2942017-04-12 11:04:37 -050058 **/
Gunnar Millscebd1022017-04-17 16:10:15 -050059 static std::string getValue(const std::string& manifestFilePath,
60 std::string key);
Gunnar Mills392f2942017-04-12 11:04:37 -050061
62 /**
Gunnar Millscebd1022017-04-17 16:10:15 -050063 * @brief Get the Version id.
Gunnar Mills392f2942017-04-12 11:04:37 -050064 *
65 * @return The id.
66 **/
67 static std::string getId(const std::string& version);
Gunnar Millscebd1022017-04-17 16:10:15 -050068
Saqib Khanba239882017-05-26 08:41:54 -050069 /**
70 * @brief Get the active bmc version identifier.
71 *
72 * @return The version identifier.
73 */
74 static std::string getBMCVersion();
Leonel Gonzaleze4233682017-07-07 14:38:25 -050075
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 Mills392f2942017-04-12 11:04:37 -050087};
88
89} // namespace manager
90} // namespace software
91} // namespace phosphor
92