@@ -31,6 +31,86 @@ NotifyService::NotifyService(sdbusplus::async::context& ctx,
3131 ctx.spawn (init (ctx, notifyFilePath));
3232}
3333
34+ sdbusplus::async::task<std::string>
35+ // NOLINTNEXTLINE
36+ NotifyService::getDbusObjectPath (sdbusplus::async::context& ctx,
37+ const std::string& service,
38+ const std::string& interface)
39+ {
40+ std::string objectPath{};
41+
42+ constexpr auto objMapper =
43+ sdbusplus::async::proxy ()
44+ .service (" xyz.openbmc_project.ObjectMapper" )
45+ .path (" /xyz/openbmc_project/object_mapper" )
46+ .interface (" xyz.openbmc_project.ObjectMapper" );
47+
48+ using services = std::map<std::string, std::vector<std::string>>;
49+ using paths = std::map<std::string, services>;
50+ paths subTreesInfo = co_await objMapper.call <paths>(
51+ ctx, " GetSubTree" , " /" , 0 , std::vector<std::string>{interface});
52+
53+ // TODO : Change the logic with std::views
54+ bool objPathFound{false };
55+ for (const auto & [objPath, serviceInterfaceMap] : subTreesInfo)
56+ {
57+ for (const auto & [serviceName, interfaces] : serviceInterfaceMap)
58+ {
59+ if (serviceName == service)
60+ {
61+ objectPath = objPath;
62+ objPathFound = true ;
63+ break ;
64+ }
65+ }
66+ if (objPathFound)
67+ {
68+ break ;
69+ }
70+ }
71+ if (!objPathFound)
72+ {
73+ lg2::error (
74+ " Unable to find the object path which hosts the interface[{INTERFACE}],"
75+ " of the service {SERVICE}" ,
76+ " INTERFACE" , interface, " SERVICE" , service);
77+ throw std::runtime_error (" Unable to find the DBus object path" );
78+ }
79+
80+ co_return objectPath;
81+ }
82+
83+ // NOLINTNEXTLINE
84+ sdbusplus::async::task<> NotifyService::invokeNotifyDBusMethod (
85+ [[maybe_unused]] sdbusplus::async::context& ctx,
86+ [[maybe_unused]] const std::string& service,
87+ [[maybe_unused]] const fs::path& modifiedDataPath)
88+ {
89+ // TODO : Complete DBus notification method once INTERFACE and method name
90+ // finalized
91+ // Step 1 : Invoke getDbusObjectPath()
92+ // Step 2 : Using the object path,interface and service, frame the DBus
93+ // :method call
94+ lg2::warning (" DBus notification support is not available currently" );
95+
96+ co_return ;
97+ }
98+
99+ sdbusplus::async::task<>
100+ // NOLINTNEXTLINE
101+ NotifyService::sendDBusNotification (sdbusplus::async::context& ctx,
102+ std::vector<std::string> services,
103+ fs::path modifiedDataPath)
104+ {
105+ for (const auto & service : services)
106+ {
107+ // NOLINTNEXTLINE
108+ co_await invokeNotifyDBusMethod (ctx, service, modifiedDataPath);
109+ }
110+
111+ co_return ;
112+ }
113+
34114sdbusplus::async::task<>
35115 // NOLINTNEXTLINE
36116 NotifyService::sendSystemDNotification (sdbusplus::async::context& ctx,
@@ -80,7 +160,13 @@ sdbusplus::async::task<> NotifyService::init(sdbusplus::async::context& ctx,
80160 file_operations::readfromFile (notifyFilePath);
81161 if (notifyfileData[" NotifyInfo" ][" Mode" ] == " DBus" )
82162 {
83- // TODO : Send DBUS notification
163+ // Send DBUS notification
164+ // NOLINTNEXTLINE
165+ co_await sendDBusNotification (
166+ ctx,
167+ notifyfileData[" NotifyInfo" ][" NotifyServices" ]
168+ .get <std::vector<std::string>>(),
169+ notifyfileData[" ModifiedDataPath" ]);
84170 }
85171 else if ((notifyfileData[" NotifyInfo" ][" Mode" ] == " Systemd" ))
86172 {
0 commit comments