blob: 578751b486f3eff7a5215a1bba5018c5f5ea596e [file] [log] [blame]
Kamalkumar Patel3c50c822024-01-30 07:14:40 -06001#pragma once
2#include "common/utils.hpp"
3#include "pldmd/handler.hpp"
4
Kamalkumar Patel3c50c822024-01-30 07:14:40 -06005namespace pldm
6{
7namespace responder
8{
9
10namespace platform_config
11{
12using namespace pldm::utils;
13
14static constexpr auto compatibleInterface =
15 "xyz.openbmc_project.Inventory.Decorator.Compatible";
16static constexpr auto namesProperty = "Names";
17
Archana Kakani46f352e2024-03-17 08:21:08 -050018using SystemTypeCallback = std::function<void(const std::string&, bool)>;
Archana Kakani62dd8ff2024-02-12 10:00:40 -060019
Kamalkumar Patel3c50c822024-01-30 07:14:40 -060020class Handler : public CmdHandler
21{
22 public:
Kamalkumar Patel0a422692024-06-03 00:42:56 -050023 Handler(const fs::path sysDirPath = {}) : sysDirPath(sysDirPath)
Kamalkumar Patel3c50c822024-01-30 07:14:40 -060024 {
25 systemCompatibleMatchCallBack =
Patrick Williams157f5d02024-02-13 02:36:55 -060026 std::make_unique<sdbusplus::bus::match_t>(
Kamalkumar Patel3c50c822024-01-30 07:14:40 -060027 pldm::utils::DBusHandler::getBus(),
28 sdbusplus::bus::match::rules::interfacesAdded() +
29 sdbusplus::bus::match::rules::sender(
30 "xyz.openbmc_project.EntityManager"),
31 std::bind(&Handler::systemCompatibleCallback, this,
32 std::placeholders::_1));
Archana Kakani62dd8ff2024-02-12 10:00:40 -060033 sysTypeCallback = nullptr;
Kamalkumar Patel3c50c822024-01-30 07:14:40 -060034 }
35
Archana Kakani62dd8ff2024-02-12 10:00:40 -060036 /** @brief Interface to get the system type information using Dbus query
Kamalkumar Patel3c50c822024-01-30 07:14:40 -060037 *
38 * @return - the system type information
39 */
40 virtual std::optional<std::filesystem::path> getPlatformName();
41
42 /** @brief D-Bus Interface added signal match for Entity Manager */
43 void systemCompatibleCallback(sdbusplus::message_t& msg);
44
Archana Kakani62dd8ff2024-02-12 10:00:40 -060045 /** @brief Registers the callback from other objects */
46 void registerSystemTypeCallback(SystemTypeCallback callback);
47
Kamalkumar Patel3c50c822024-01-30 07:14:40 -060048 private:
Kamalkumar Patel0a422692024-06-03 00:42:56 -050049 /** @brief Interface to get the first available directory
50 * from the received list
51 *
52 * @param[in] dirPath - Directory path to search system specific directory
53 * @param[in] dirNames - System names retrieved from remote application
54 * @return - The system type information
55 */
56 std::optional<std::string>
57 getSysSpecificJsonDir(const fs::path& dirPath,
58 const std::vector<std::string>& dirNames);
59
Kamalkumar Patel3c50c822024-01-30 07:14:40 -060060 /** @brief system type/model */
61 std::string systemType;
62
63 /** @brief D-Bus Interface added signal match for Entity Manager */
64 std::unique_ptr<sdbusplus::bus::match_t> systemCompatibleMatchCallBack;
Archana Kakani62dd8ff2024-02-12 10:00:40 -060065
66 /** @brief Registered Callback */
67 SystemTypeCallback sysTypeCallback;
Kamalkumar Patel0a422692024-06-03 00:42:56 -050068
69 /** @brief system specific json file directory path */
70 fs::path sysDirPath;
Kamalkumar Patel3c50c822024-01-30 07:14:40 -060071};
72
73} // namespace platform_config
74
75} // namespace responder
76
77} // namespace pldm