control: Add nameOwnerChanged signal support
Subscribe to and handle nameOwnerChanged signals to trigger event
actions.
Change-Id: I7d5a472d31a2af5297581c18d84ef4ac897ff3ea
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json/triggers/handlers.hpp b/control/json/triggers/handlers.hpp
index d33d00d..f3b1a23 100644
--- a/control/json/triggers/handlers.hpp
+++ b/control/json/triggers/handlers.hpp
@@ -124,6 +124,36 @@
mgr.removeInterface(std::get<Path>(obj), std::get<Intf>(obj));
return true;
}
+
+ /**
+ * @brief Processes a name owner changed signal and updates the service's
+ * owner state
+ *
+ * @param[in] msg - The sdbusplus signal message
+ * @param[in] obj - Object data associated with the signal
+ * @param[in] mgr - Manager that stores the service's owner state
+ */
+ static bool nameOwnerChanged(message& msg, const SignalObject& obj,
+ Manager& mgr)
+ {
+ bool hasOwner = false;
+
+ std::string serv;
+ msg.read(serv);
+
+ std::string oldOwner;
+ msg.read(oldOwner);
+
+ std::string newOwner;
+ msg.read(newOwner);
+ if (!newOwner.empty())
+ {
+ hasOwner = true;
+ }
+
+ mgr.setOwner(std::get<Path>(obj), std::get<Intf>(obj), serv, hasOwner);
+ return true;
+ }
};
} // namespace phosphor::fan::control::json::trigger::signal