| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <boost/asio/io_context.hpp> |
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 4 | #include <nlohmann/json.hpp> |
| 5 | #include <sdbusplus/asio/connection.hpp> |
| 6 | |
| Ed Tanous | dbf95b2 | 2025-10-13 11:38:35 -0700 | [diff] [blame] | 7 | #include <flat_map> |
| 8 | |
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 9 | using DBusValueVariant = |
| 10 | std::variant<std::string, int64_t, uint64_t, double, int32_t, uint32_t, |
| 11 | int16_t, uint16_t, uint8_t, bool, std::vector<uint8_t>>; |
| Ed Tanous | dbf95b2 | 2025-10-13 11:38:35 -0700 | [diff] [blame] | 12 | using DBusInterface = std::flat_map<std::string, DBusValueVariant, std::less<>>; |
| 13 | using DBusObject = std::flat_map<std::string, DBusInterface, std::less<>>; |
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 14 | |
| 15 | constexpr const char* configurationOutDir = "/var/configuration/"; |
| 16 | constexpr const char* versionHashFile = "/var/configuration/version"; |
| 17 | constexpr const char* versionFile = "/etc/os-release"; |
| 18 | |
| 19 | namespace em_utils |
| 20 | { |
| 21 | |
| 22 | namespace properties |
| 23 | { |
| 24 | constexpr const char* interface = "org.freedesktop.DBus.Properties"; |
| 25 | constexpr const char* get = "Get"; |
| 26 | } // namespace properties |
| 27 | |
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 28 | bool fwVersionIsSame(); |
| 29 | |
| Chau Ly | 7962944 | 2025-08-20 10:27:20 +0000 | [diff] [blame] | 30 | void handleLeftOverTemplateVars(nlohmann::json::iterator& keyPair); |
| 31 | |
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 32 | std::optional<std::string> templateCharReplace( |
| 33 | nlohmann::json::iterator& keyPair, const DBusObject& object, size_t index, |
| Chau Ly | 8ee4369 | 2025-10-09 07:22:08 +0000 | [diff] [blame] | 34 | const std::optional<std::string>& replaceStr = std::nullopt, |
| 35 | bool handleLeftOver = true); |
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 36 | |
| 37 | std::optional<std::string> templateCharReplace( |
| 38 | nlohmann::json::iterator& keyPair, const DBusInterface& interface, |
| 39 | size_t index, const std::optional<std::string>& replaceStr = std::nullopt); |
| 40 | |
| Christopher Meis | 811160e | 2025-08-08 08:48:37 +0200 | [diff] [blame] | 41 | std::string buildInventorySystemPath(std::string& boardName, |
| 42 | const std::string& boardType); |
| 43 | |
| Christopher Meis | 59ef1e7 | 2025-04-16 08:53:25 +0200 | [diff] [blame] | 44 | } // namespace em_utils |