Reducing the dbus string constants
There are a large number of dbus constants scattered throughout the
code that could/should be obtained from phosphor-dbus-interface values.
Some of the minor refactoring is done in this commit to reduce the
dbus string constants.
Change-Id: I2a8441e9ab275e8f2a72c3c79a6ed80e6e444f46
Signed-off-by: Pavithra Barithaya <pavithra.b@ibm.com>
diff --git a/oem/ibm/libpldmresponder/platform_oem_ibm.cpp b/oem/ibm/libpldmresponder/platform_oem_ibm.cpp
index 432bfd4..5d9eea5 100644
--- a/oem/ibm/libpldmresponder/platform_oem_ibm.cpp
+++ b/oem/ibm/libpldmresponder/platform_oem_ibm.cpp
@@ -7,6 +7,7 @@
#include <phosphor-logging/lg2.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <xyz/openbmc_project/State/Boot/Progress/client.hpp>
#include <iostream>
@@ -23,22 +24,26 @@
const std::vector<uint16_t>& handles,
pldm::requester::Handler<pldm::requester::Request>* handler)
{
+ using BootProgress =
+ sdbusplus::client::xyz::openbmc_project::state::boot::Progress<>;
+
constexpr auto hostStatePath = "/xyz/openbmc_project/state/host0";
- constexpr auto hostStateInterface =
- "xyz.openbmc_project.State.Boot.Progress";
constexpr auto hostStateProperty = "BootProgress";
try
{
auto propVal = pldm::utils::DBusHandler().getDbusPropertyVariant(
- hostStatePath, hostStateProperty, hostStateInterface);
+ hostStatePath, hostStateProperty, BootProgress::interface);
const auto& currHostState = std::get<std::string>(propVal);
- if ((currHostState != "xyz.openbmc_project.State.Boot.Progress."
- "ProgressStages.SystemInitComplete") &&
- (currHostState != "xyz.openbmc_project.State.Boot.Progress."
- "ProgressStages.OSRunning") &&
- (currHostState != "xyz.openbmc_project.State.Boot.Progress."
- "ProgressStages.SystemSetup"))
+ if ((sdbusplus::message::convert_from_string<
+ BootProgress::ProgressStages>(currHostState) !=
+ BootProgress::ProgressStages::SystemInitComplete) &&
+ (sdbusplus::message::convert_from_string<
+ BootProgress::ProgressStages>(currHostState) !=
+ BootProgress::ProgressStages::OSRunning) &&
+ (sdbusplus::message::convert_from_string<
+ BootProgress::ProgressStages>(currHostState) !=
+ BootProgress::ProgressStages::SystemSetup))
{
return PLDM_SUCCESS;
}