blob: 01448736aa695661bd5925bf1a001b43f26946b7 [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"
Gunnar Mills392f2942017-04-12 11:04:37 -05006
7namespace phosphor
8{
9namespace software
10{
11namespace manager
12{
13
14using VersionInherit = sdbusplus::server::object::object<
Gunnar Millsef4781f2017-04-19 11:28:24 -050015 sdbusplus::xyz::openbmc_project::Software::server::Version,
16 sdbusplus::xyz::openbmc_project::Common::server::FilePath>;
Gunnar Mills392f2942017-04-12 11:04:37 -050017
18/** @class Version
19 * @brief OpenBMC version software management implementation.
20 * @details A concrete implementation for xyz.openbmc_project.Software.Version
21 * DBus API.
22 */
23class Version : public VersionInherit
24{
25 public:
26 /** @brief Constructs Version Software Manager
27 *
Gunnar Millscebd1022017-04-17 16:10:15 -050028 * @param[in] bus - The Dbus bus object
29 * @param[in] objPath - The Dbus object path
30 * @param[in] versionId - The version identifier
31 * @param[in] versionPurpose - The version purpose
Gunnar Millsef4781f2017-04-19 11:28:24 -050032 * @param[in] filePath - The image filesystem path
Gunnar Mills392f2942017-04-12 11:04:37 -050033 */
34 Version(sdbusplus::bus::bus& bus,
35 const std::string& objPath,
Gunnar Millscebd1022017-04-17 16:10:15 -050036 const std::string& versionId,
Gunnar Millsef4781f2017-04-19 11:28:24 -050037 VersionPurpose versionPurpose,
38 const std::string& filePath) : VersionInherit(
Gunnar Mills392f2942017-04-12 11:04:37 -050039 bus, (objPath).c_str(), true)
40 {
41 // Set properties.
Gunnar Millscebd1022017-04-17 16:10:15 -050042 purpose(versionPurpose);
Gunnar Mills392f2942017-04-12 11:04:37 -050043 version(versionId);
Gunnar Millsef4781f2017-04-19 11:28:24 -050044 path(filePath);
Gunnar Mills392f2942017-04-12 11:04:37 -050045 // Emit deferred signal.
46 emit_object_added();
47 }
48
49 /**
Gunnar Millscebd1022017-04-17 16:10:15 -050050 * @brief Read the manifest file to get the value of the key.
Gunnar Mills392f2942017-04-12 11:04:37 -050051 *
Gunnar Millscebd1022017-04-17 16:10:15 -050052 * @return The value of the key.
Gunnar Mills392f2942017-04-12 11:04:37 -050053 **/
Gunnar Millscebd1022017-04-17 16:10:15 -050054 static std::string getValue(const std::string& manifestFilePath,
55 std::string key);
Gunnar Mills392f2942017-04-12 11:04:37 -050056
57 /**
Gunnar Millscebd1022017-04-17 16:10:15 -050058 * @brief Get the Version id.
Gunnar Mills392f2942017-04-12 11:04:37 -050059 *
60 * @return The id.
61 **/
62 static std::string getId(const std::string& version);
Gunnar Millscebd1022017-04-17 16:10:15 -050063
Saqib Khanba239882017-05-26 08:41:54 -050064 /**
65 * @brief Get the active bmc version identifier.
66 *
67 * @return The version identifier.
68 */
69 static std::string getBMCVersion();
Gunnar Mills392f2942017-04-12 11:04:37 -050070};
71
72} // namespace manager
73} // namespace software
74} // namespace phosphor
75