1 #include "settings.hpp"
2 
3 #include "xyz/openbmc_project/Common/error.hpp"
4 
5 #include <phosphor-logging/elog-errors.hpp>
6 #include <phosphor-logging/lg2.hpp>
7 
8 namespace settings
9 {
10 
11 using namespace phosphor::logging;
12 using namespace sdbusplus::xyz::openbmc_project::Common::Error;
13 
14 constexpr auto mapperService = "xyz.openbmc_project.ObjectMapper";
15 constexpr auto mapperPath = "/xyz/openbmc_project/object_mapper";
16 constexpr auto mapperIntf = "xyz.openbmc_project.ObjectMapper";
17 
18 Objects::Objects(sdbusplus::bus_t& bus) : bus(bus)
19 {
20     Interfaces settingsIntfs = {timeSyncIntf};
21     MapperResponse result;
22 
23     try
24     {
25         result = getSubTree(bus, root, settingsIntfs, 0);
26     }
27     catch (const sdbusplus::exception_t& ex)
28     {
29         lg2::error("Failed to invoke GetSubTree method: {ERROR}", "ERROR", ex);
30     }
31 
32     if (result.empty())
33     {
34         lg2::error("Invalid response from mapper");
35     }
36 
37     for (const auto& iter : result)
38     {
39         const Path& path = iter.first;
40         for (const auto& service_iter : iter.second)
41         {
42             for (const Interface& interface : service_iter.second)
43             {
44                 if (timeSyncIntf == interface)
45                 {
46                     timeSyncMethod = path;
47                 }
48             }
49         }
50     }
51 }
52 
53 } // namespace settings
54