Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | #include "common/utils.hpp" |
| 3 | #include "pldmd/handler.hpp" |
| 4 | |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 5 | namespace pldm |
| 6 | { |
| 7 | namespace responder |
| 8 | { |
| 9 | |
| 10 | namespace platform_config |
| 11 | { |
| 12 | using namespace pldm::utils; |
| 13 | |
| 14 | static constexpr auto compatibleInterface = |
| 15 | "xyz.openbmc_project.Inventory.Decorator.Compatible"; |
| 16 | static constexpr auto namesProperty = "Names"; |
| 17 | |
Archana Kakani | 46f352e | 2024-03-17 08:21:08 -0500 | [diff] [blame] | 18 | using SystemTypeCallback = std::function<void(const std::string&, bool)>; |
Archana Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 19 | |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 20 | class Handler : public CmdHandler |
| 21 | { |
| 22 | public: |
Kamalkumar Patel | 0a42269 | 2024-06-03 00:42:56 -0500 | [diff] [blame] | 23 | Handler(const fs::path sysDirPath = {}) : sysDirPath(sysDirPath) |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 24 | { |
| 25 | systemCompatibleMatchCallBack = |
Patrick Williams | 157f5d0 | 2024-02-13 02:36:55 -0600 | [diff] [blame] | 26 | std::make_unique<sdbusplus::bus::match_t>( |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 27 | 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 Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 33 | sysTypeCallback = nullptr; |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 34 | } |
| 35 | |
Archana Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 36 | /** @brief Interface to get the system type information using Dbus query |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 37 | * |
| 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 Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 45 | /** @brief Registers the callback from other objects */ |
| 46 | void registerSystemTypeCallback(SystemTypeCallback callback); |
| 47 | |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 48 | private: |
Kamalkumar Patel | 0a42269 | 2024-06-03 00:42:56 -0500 | [diff] [blame] | 49 | /** @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 | */ |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 56 | std::optional<std::string> getSysSpecificJsonDir( |
| 57 | const fs::path& dirPath, const std::vector<std::string>& dirNames); |
Kamalkumar Patel | 0a42269 | 2024-06-03 00:42:56 -0500 | [diff] [blame] | 58 | |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 59 | /** @brief system type/model */ |
| 60 | std::string systemType; |
| 61 | |
| 62 | /** @brief D-Bus Interface added signal match for Entity Manager */ |
| 63 | std::unique_ptr<sdbusplus::bus::match_t> systemCompatibleMatchCallBack; |
Archana Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 64 | |
| 65 | /** @brief Registered Callback */ |
| 66 | SystemTypeCallback sysTypeCallback; |
Kamalkumar Patel | 0a42269 | 2024-06-03 00:42:56 -0500 | [diff] [blame] | 67 | |
| 68 | /** @brief system specific json file directory path */ |
| 69 | fs::path sysDirPath; |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | } // namespace platform_config |
| 73 | |
| 74 | } // namespace responder |
| 75 | |
| 76 | } // namespace pldm |