blob: 3d17213f88f76935ede4c50f81b3eb24375d0351 [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"
Gunnar Millsef4781f2017-04-19 11:28:24 -05005#include "xyz/openbmc_project/Common/FilePath/server.hpp"
Leonel Gonzaleze4233682017-07-07 14:38:25 -05006#include <functional>
Gunnar Mills392f2942017-04-12 11:04:37 -05007
8namespace phosphor
9{
10namespace software
11{
12namespace manager
13{
14
Leonel Gonzaleze4233682017-07-07 14:38:25 -050015typedef std::function<void(std::string)> eraseFunc;
16
Gunnar Mills392f2942017-04-12 11:04:37 -050017using VersionInherit = sdbusplus::server::object::object<
Gunnar Millsef4781f2017-04-19 11:28:24 -050018 sdbusplus::xyz::openbmc_project::Software::server::Version,
19 sdbusplus::xyz::openbmc_project::Common::server::FilePath>;
Gunnar Mills392f2942017-04-12 11:04:37 -050020
21/** @class Version
22 * @brief OpenBMC version software management implementation.
23 * @details A concrete implementation for xyz.openbmc_project.Software.Version
24 * DBus API.
25 */
26class Version : public VersionInherit
27{
28 public:
29 /** @brief Constructs Version Software Manager
30 *
Gunnar Millscebd1022017-04-17 16:10:15 -050031 * @param[in] bus - The Dbus bus object
32 * @param[in] objPath - The Dbus object path
33 * @param[in] versionId - The version identifier
34 * @param[in] versionPurpose - The version purpose
Gunnar Millsef4781f2017-04-19 11:28:24 -050035 * @param[in] filePath - The image filesystem path
Gunnar Mills392f2942017-04-12 11:04:37 -050036 */
37 Version(sdbusplus::bus::bus& bus,
38 const std::string& objPath,
Gunnar Millscebd1022017-04-17 16:10:15 -050039 const std::string& versionId,
Gunnar Millsef4781f2017-04-19 11:28:24 -050040 VersionPurpose versionPurpose,
Eddie James9440f492017-08-30 11:34:16 -050041 const std::string& filePath) : VersionInherit(
Gunnar Mills392f2942017-04-12 11:04:37 -050042 bus, (objPath).c_str(), true)
43 {
44 // Set properties.
Gunnar Millscebd1022017-04-17 16:10:15 -050045 purpose(versionPurpose);
Gunnar Mills392f2942017-04-12 11:04:37 -050046 version(versionId);
Gunnar Millsef4781f2017-04-19 11:28:24 -050047 path(filePath);
Gunnar Mills392f2942017-04-12 11:04:37 -050048 // Emit deferred signal.
49 emit_object_added();
50 }
51
52 /**
Gunnar Millscebd1022017-04-17 16:10:15 -050053 * @brief Read the manifest file to get the value of the key.
Gunnar Mills392f2942017-04-12 11:04:37 -050054 *
Gunnar Millscebd1022017-04-17 16:10:15 -050055 * @return The value of the key.
Gunnar Mills392f2942017-04-12 11:04:37 -050056 **/
Gunnar Millscebd1022017-04-17 16:10:15 -050057 static std::string getValue(const std::string& manifestFilePath,
58 std::string key);
Gunnar Mills392f2942017-04-12 11:04:37 -050059
60 /**
Gunnar Millscebd1022017-04-17 16:10:15 -050061 * @brief Get the Version id.
Gunnar Mills392f2942017-04-12 11:04:37 -050062 *
63 * @return The id.
64 **/
65 static std::string getId(const std::string& version);
Gunnar Millscebd1022017-04-17 16:10:15 -050066
Saqib Khanba239882017-05-26 08:41:54 -050067 /**
68 * @brief Get the active bmc version identifier.
69 *
Saqib Khan1eef62d2017-08-10 15:29:34 -050070 * @param[in] releaseFilePath - The Path to file which contains
71 * the release version.
72 *
Saqib Khanba239882017-05-26 08:41:54 -050073 * @return The version identifier.
74 */
Saqib Khan1eef62d2017-08-10 15:29:34 -050075 static std::string getBMCVersion(const std::string& releaseFilePath);
Gunnar Mills392f2942017-04-12 11:04:37 -050076};
77
78} // namespace manager
79} // namespace software
80} // namespace phosphor