use new sdbusplus match constructors
Change-Id: I774a8f9e7ce62e4a3663d12b3d561e5850f37a37
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/item_updater.cpp b/item_updater.cpp
index 9c26b9d..d33ac6d 100755
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -19,27 +19,20 @@
constexpr auto squashFSImage = "pnor.xz.squashfs";
-int ItemUpdater::createActivation(sd_bus_message* msg,
- void* userData,
- sd_bus_error* retErr)
+void ItemUpdater::createActivation(sdbusplus::message::message&)
{
- auto* updater = static_cast<ItemUpdater*>(userData);
- auto mapper = updater->busItem.new_method_call(
- MAPPER_BUSNAME,
- MAPPER_PATH,
- MAPPER_INTERFACE,
- "GetSubTreePaths");
- mapper.append(SOFTWARE_OBJPATH,
- 1, // Depth
+ auto mapper = busItem.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
+ MAPPER_INTERFACE, "GetSubTreePaths");
+ mapper.append(SOFTWARE_OBJPATH, /* Depth */ 1,
std::vector<std::string>({VERSION_IFACE}));
- auto mapperResponseMsg = updater->busItem.call(mapper);
+ auto mapperResponseMsg = busItem.call(mapper);
if (mapperResponseMsg.is_method_error())
{
log<level::ERR>("Error in mapper call",
entry("PATH=%s", SOFTWARE_OBJPATH),
entry("INTERFACE=%s", VERSION_IFACE));
- return -1;
+ return;
}
std::vector<std::string> mapperResponse;
@@ -49,7 +42,7 @@
log<level::ERR>("Error reading mapper response",
entry("PATH=%s", SOFTWARE_OBJPATH),
entry("INTERFACE=%s", VERSION_IFACE));
- return -1;
+ return;
}
auto extendedVersion = ItemUpdater::getExtendedVersion(MANIFEST_FILE);
@@ -61,12 +54,12 @@
{
log<level::ERR>("No version id found in object path",
entry("OBJPATH=%s", resp));
- return -1;
+ return;
}
auto versionId = resp.substr(pos + 1);
- if (updater->activations.find(versionId) == updater->activations.end())
+ if (activations.find(versionId) == activations.end())
{
// Determine the Activation state by processing the given image dir.
auto activationState = server::Activation::Activations::Invalid;
@@ -78,31 +71,29 @@
// activated when requested.
// This is done since the image on the BMC can be removed.
constexpr auto squashfsMountService =
- "obmc-flash-bios-squashfsmount@";
+ "obmc-flash-bios-squashfsmount@";
auto squashfsMountServiceFile =
- std::string(squashfsMountService) +
- versionId +
- ".service";
- auto method = updater->busItem.new_method_call(
- SYSTEMD_BUSNAME,
- SYSTEMD_PATH,
- SYSTEMD_INTERFACE,
- "StartUnit");
+ std::string(squashfsMountService) +
+ versionId + ".service";
+ auto method = busItem.new_method_call(SYSTEMD_BUSNAME,
+ SYSTEMD_PATH,
+ SYSTEMD_INTERFACE,
+ "StartUnit");
method.append(squashfsMountServiceFile, "replace");
- updater->busItem.call_noreply(method);
+ busItem.call_noreply(method);
}
- updater->activations.insert(std::make_pair(
+ activations.insert(std::make_pair(
versionId,
std::make_unique<Activation>(
- updater->busItem,
+ busItem,
resp,
versionId,
extendedVersion,
activationState)));
}
}
- return 0;
+ return;
}
std::string ItemUpdater::getExtendedVersion(const std::string& manifestFilePath)
diff --git a/item_updater.hpp b/item_updater.hpp
index 0e8558a..216b1d7 100755
--- a/item_updater.hpp
+++ b/item_updater.hpp
@@ -13,6 +13,7 @@
using ItemUpdaterInherit = sdbusplus::server::object::object<
sdbusplus::xyz::openbmc_project::Common::server::FactoryReset>;
+namespace MatchRules = sdbusplus::bus::match::rules;
/** @class ItemUpdater
* @brief Manages the activation of the version items.
@@ -30,12 +31,12 @@
busItem(bus),
versionMatch(
bus,
- "type='signal',"
- "member='InterfacesAdded',"
- "path='/xyz/openbmc_project/software',"
- "interface='org.freedesktop.DBus.ObjectManager'",
- createActivation,
- this)
+ MatchRules::interfacesAdded() +
+ MatchRules::path("/xyz/openbmc_project/software"),
+ std::bind(
+ std::mem_fn(&ItemUpdater::createActivation),
+ this,
+ std::placeholders::_1))
{
}
@@ -44,12 +45,8 @@
* @details Creates an Activation dbus object.
*
* @param[in] msg - Data associated with subscribed signal
- * @param[in] userData - Pointer to this object instance
- * @param[out] retError - Required param
*/
- static int createActivation(sd_bus_message* msg,
- void* userData,
- sd_bus_error* retError);
+ void createActivation(sdbusplus::message::message& msg);
/**
* @brief Get the extended version from the specified file.
@@ -77,7 +74,7 @@
std::map<std::string, std::unique_ptr<Activation>> activations;
/** @brief sdbusplus signal match for Software.Version */
- sdbusplus::server::match::match versionMatch;
+ sdbusplus::bus::match_t versionMatch;
/** @brief Host factory reset - clears PNOR partitions for each
* Activation dbus object */