control: Add interfacesAdded signal support
Subscribe to and handle interfacesAdded signals to trigger event
actions.
Change-Id: I9d42a4341cb2880cf839b626786c569bdbf19a7c
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json/triggers/handlers.hpp b/control/json/triggers/handlers.hpp
index 2a52757..102a214 100644
--- a/control/json/triggers/handlers.hpp
+++ b/control/json/triggers/handlers.hpp
@@ -50,6 +50,47 @@
std::get<Prop>(obj), itProp->second);
return true;
}
+
+ /**
+ * @brief Processes an interfaces added signal and adds the interface
+ * (including property & property value) to the manager's object cache
+ *
+ * @param[in] msg - The sdbusplus signal message
+ * @param[in] obj - Object data associated with the signal
+ * @param[in] mgr - Manager that stores the object cache
+ */
+ static bool interfacesAdded(message& msg, const SignalObject& obj,
+ Manager& mgr)
+ {
+ sdbusplus::message::object_path op;
+ msg.read(op);
+ if (static_cast<const std::string&>(op) != std::get<Path>(obj))
+ {
+ // Path name does not match object's path
+ return false;
+ }
+
+ std::map<std::string, std::map<std::string, PropertyVariantType>>
+ intfProps;
+ msg.read(intfProps);
+ auto itIntf = intfProps.find(std::get<Intf>(obj));
+ if (itIntf == intfProps.cend())
+ {
+ // Object's interface not in dictionary of interfaces added
+ return false;
+ }
+
+ auto itProp = itIntf->second.find(std::get<Prop>(obj));
+ if (itProp == itIntf->second.cend())
+ {
+ // Object's property not in dictionary of properties of interface
+ return false;
+ }
+
+ mgr.setProperty(std::get<Path>(obj), std::get<Intf>(obj),
+ std::get<Prop>(obj), itProp->second);
+ return true;
+ }
};
} // namespace phosphor::fan::control::json::trigger::signal