associations: explicitly pass deferSignal
Explicitly pass the deferSignal parameter to the dbus bindings to enable
creating associations without emitting signals.
The patch does not introduce any functional change - only future
capability; the dbus binding argument is defaulted to emit a signal
(deferSignal = false) and that logic is preserved - moved from the
binding call site to higher up the call stack (createAssociations).
Change-Id: I6d55237d43c994442d10b899e725ea36c46dc834
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/association_manager.cpp b/association_manager.cpp
index 946bd74..91956ba 100644
--- a/association_manager.cpp
+++ b/association_manager.cpp
@@ -79,7 +79,8 @@
}
}
-void Manager::createAssociations(const std::string& objectPath)
+void Manager::createAssociations(const std::string& objectPath,
+ bool deferSignal)
{
auto endpoints = _associations.find(objectPath);
if (endpoints == _associations.end())
@@ -106,7 +107,7 @@
const auto& reverseType = std::get<reverseTypePos>(types);
createAssociation(objectPath, forwardType, endpointPath,
- reverseType);
+ reverseType, deferSignal);
}
}
}
@@ -114,7 +115,8 @@
void Manager::createAssociation(const std::string& forwardPath,
const std::string& forwardType,
const std::string& reversePath,
- const std::string& reverseType)
+ const std::string& reverseType,
+ bool deferSignal)
{
auto object = _associationIfaces.find(forwardPath);
if (object == _associationIfaces.end())
@@ -128,7 +130,10 @@
prop.emplace_back(forwardType, reverseType, reversePath);
a->associations(std::move(prop));
- a->emit_object_added();
+ if (!deferSignal)
+ {
+ a->emit_object_added();
+ }
_associationIfaces.emplace(forwardPath, std::move(a));
}
else
@@ -136,7 +141,7 @@
// Interface exists, just update the property
auto prop = object->second->associations();
prop.emplace_back(forwardType, reverseType, reversePath);
- object->second->associations(std::move(prop));
+ object->second->associations(std::move(prop), deferSignal);
}
}
} // namespace associations
diff --git a/association_manager.hpp b/association_manager.hpp
index e38fff1..2be0058 100644
--- a/association_manager.hpp
+++ b/association_manager.hpp
@@ -79,8 +79,10 @@
* Called after PIM creates a new inventory D-Bus interface on objectPath.
*
* @param[in] objectPath - the D-Bus object path to check for associations
+ * @param[in] deferSignal - whether or not to send a Properties or
+ * ObjectManager signal
*/
- void createAssociations(const std::string& objectPath);
+ void createAssociations(const std::string& objectPath, bool deferSignal);
/**
* @brief Returned the association configuration.
@@ -109,11 +111,13 @@
* @param[in] forwardType - the type of the forward association
* @param[in] reversePath - the path of the reverse association
* @param[in] reverseType - the type of the reverse association
+ * @param[in] deferSignal - whether or not to send a Properties or
+ * ObjectManager signal
*/
void createAssociation(const std::string& forwardPath,
const std::string& forwardType,
const std::string& reversePath,
- const std::string& reverseType);
+ const std::string& reverseType, bool deferSignal);
/**
* @brief The map of association data that is loaded from its
diff --git a/manager.cpp b/manager.cpp
index e78265c..20cdb05 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -243,7 +243,7 @@
#ifdef CREATE_ASSOCIATIONS
if (newObj)
{
- _associations.createAssociations(absPath);
+ _associations.createAssociations(absPath, false);
}
#endif
++objit;