Modify D-Bus to using asio server
DBus updates are now using the asio server way.
Tested:
Tested with unit tests and locally on a machine.
Signed-off-by: Kasun Athukorala <kasunath@google.com>
Change-Id: I77553bcc3baae70e5d684a62f2c19592ff844665
Signed-off-by: Brandon Kim <brandonkim@google.com>
diff --git a/include/dbus/file_notifier.hpp b/include/dbus/file_notifier.hpp
index da37158..1e72a6b 100644
--- a/include/dbus/file_notifier.hpp
+++ b/include/dbus/file_notifier.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include <sdbusplus/server.hpp>
+#include <sdbusplus/asio/object_server.hpp>
#include <xyz/openbmc_project/Common/FilePath/server.hpp>
#include <format>
@@ -9,36 +9,46 @@
namespace bios_bmc_smm_error_logger
{
-using FileNotifierInterface = sdbusplus::server::object_t<
- sdbusplus::xyz::openbmc_project::Common::server::FilePath>;
-
/**
* @brief A class for notifying file paths of CPER logs.
*/
-class CperFileNotifier : public FileNotifierInterface
+class CperFileNotifier
{
public:
/**
* @brief Constructor for the CperFileNotifier class.
*
- * @param bus - bus to attach to.
+ * @param server - sdbusplus asio object server.
* @param filePath - full path of the CPER log JSON file.
* @param entry - index of the DBus file path object.
*/
- CperFileNotifier(sdbusplus::bus_t& bus, const std::string& filePath,
- uint64_t entry) :
- FileNotifierInterface(bus, generatePath(entry).c_str(),
- action::emit_no_signals)
+ CperFileNotifier(sdbusplus::asio::object_server& server,
+ const std::string& filePath, uint64_t entry) :
+ server(server)
{
- // We only need the interface added signal for the fault monitor. So
- // stop emitting properties changed signal.
- path(filePath, /*skipSignal=*/true);
+ pathIface = server.add_interface(generatePath(entry).c_str(),
+ "xyz.openbmc_project.Common.FilePath");
+ pathIface->register_property("Path", filePath);
+ pathIface->initialize();
}
+ ~CperFileNotifier()
+ {
+ server.remove_interface(pathIface);
+ }
+
+ CperFileNotifier& operator=(const CperFileNotifier&) = delete;
+ CperFileNotifier& operator=(CperFileNotifier&&) = delete;
+ CperFileNotifier(const CperFileNotifier&) = delete;
+ CperFileNotifier(CperFileNotifier&&) = default;
+
static constexpr const char* cperBasePath =
"/xyz/openbmc_project/external_storer/bios_bmc_smm_error_logger/CPER";
private:
+ sdbusplus::asio::object_server& server;
+ std::shared_ptr<sdbusplus::asio::dbus_interface> pathIface;
+
/**
* @brief Generate a path for the CperFileNotifier DBus object.
*