bios: Use DBusHandler functions to avoid duplicate
Use the DBusHandler functions to avoid duplicate
Signed-off-by: John Wang <wangzqbj@inspur.com>
Change-Id: I1def4701c4ef773f3bccf5dce9c7510fa3901210
diff --git a/libpldmresponder/bios_parser.cpp b/libpldmresponder/bios_parser.cpp
index 30fee04..0c39acb 100644
--- a/libpldmresponder/bios_parser.cpp
+++ b/libpldmresponder/bios_parser.cpp
@@ -228,15 +228,11 @@
}
const auto& dbusValToValMap = internal::dbusValToValMaps.at(attrName);
- auto bus = sdbusplus::bus::new_default();
- auto service = pldm::responder::getService(bus, dBusMap.value().objectPath,
- dBusMap.value().interface);
- auto method =
- bus.new_method_call(service.c_str(), dBusMap.value().objectPath.c_str(),
- "org.freedesktop.DBus.Properties", "Get");
- method.append(dBusMap->interface, dBusMap->propertyName);
- auto reply = bus.call(method);
- reply.read(propValue);
+ propValue =
+ pldm::responder::DBusHandler()
+ .getDbusPropertyVariant<internal::PropertyValue>(
+ dBusMap->objectPath.c_str(), dBusMap->propertyName.c_str(),
+ dBusMap->interface.c_str());
auto iter = dbusValToValMap.find(propValue);
if (iter != dbusValToValMap.end())
@@ -345,17 +341,9 @@
return std::get<DefaultStr>(valueEntry);
}
- auto bus = sdbusplus::bus::new_default();
- auto service = pldm::responder::getService(bus, dBusMap->objectPath,
- dBusMap->interface);
- auto method =
- bus.new_method_call(service.c_str(), dBusMap->objectPath.c_str(),
- "org.freedesktop.DBus.Properties", "Get");
- method.append(dBusMap->interface, dBusMap->propertyName);
- auto reply = bus.call(method);
- reply.read(propValue);
-
- return std::get<std::string>(propValue);
+ return pldm::responder::DBusHandler().getDbusProperty<std::string>(
+ dBusMap->objectPath.c_str(), dBusMap->propertyName.c_str(),
+ dBusMap->interface.c_str());
}
} // namespace bios_string