control: Support group service names in name owner triggers
If a group provides a service name, which is required to be the service
name for all group members and their interfaces, use that service name
when subscribing to nameOwnerChanged signals or calling the nameHasOwner
method. This can be used so that the service name does not have to be
looked up for each group member(and interface) or where the service for
a group(and interface) may not be on dbus when subscribing.
Change-Id: Ic52aef519eef61103478742c7a32e1f268809d38
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json/triggers/init.cpp b/control/json/triggers/init.cpp
index 1ce272c..2a9ce9e 100644
--- a/control/json/triggers/init.cpp
+++ b/control/json/triggers/init.cpp
@@ -73,7 +73,11 @@
auto intf = group.getInterface();
try
{
- servName = mgr->getService(member, intf);
+ servName = group.getService();
+ if (servName.empty())
+ {
+ servName = mgr->getService(member, intf);
+ }
if (!servName.empty() && lastName != servName)
{
// Member not provided by same service as last group member
diff --git a/control/json/triggers/signal.cpp b/control/json/triggers/signal.cpp
index 19d7f19..7a2dce0 100644
--- a/control/json/triggers/signal.cpp
+++ b/control/json/triggers/signal.cpp
@@ -172,7 +172,11 @@
// will do nothing since signals require a group
for (const auto& member : group.getMembers())
{
- auto serv = Manager::getService(member, group.getInterface());
+ auto serv = group.getService();
+ if (serv.empty())
+ {
+ serv = Manager::getService(member, group.getInterface());
+ }
if (!serv.empty())
{
// No need to re-subscribe to the same service's nameOwnerChanged