Scan directories that store PSU images on start

When the service starts, scan the directories that store PSU images,
including the built-in images, and the saved images during PSU update.

When the scanned image is different than the running images, create
activation/version object;
When the scanned image is the same as the running images, update the
version object's path to indicate the PSU image path, so it could be
used for future update in case a PSU is replaced with a different
software.

Tested: On Witherspoon, fake create a dummy PSU image with a different
        version than running PSU, verify a new object is created on
        restart;
        fake creating a dummy PSU image with a same version as a running
        PSU, verify no new object is created, but the "Path" property is
        set to the PSU image directory.

Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: I860b978250a718eb82d948a1c88bd8f41bb2b2e3
diff --git a/src/item_updater.hpp b/src/item_updater.hpp
index 33db8bc..2cccf68 100644
--- a/src/item_updater.hpp
+++ b/src/item_updater.hpp
@@ -8,6 +8,7 @@
 #include "utils.hpp"
 #include "version.hpp"
 
+#include <filesystem>
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/server.hpp>
 #include <xyz/openbmc_project/Association/Definitions/server.hpp>
@@ -29,6 +30,8 @@
 
 namespace MatchRules = sdbusplus::bus::match::rules;
 
+namespace fs = std::filesystem;
+
 /** @class ItemUpdater
  *  @brief Manages the activation of the PSU version items.
  */
@@ -51,6 +54,7 @@
                                this, std::placeholders::_1))
     {
         processPSUImage();
+        processStoredImage();
     }
 
     /** @brief Deletes version
@@ -109,9 +113,7 @@
     /** @brief Create Activation object */
     std::unique_ptr<Activation> createActivationObject(
         const std::string& path, const std::string& versionId,
-        const std::string& extVersion,
-        sdbusplus::xyz::openbmc_project::Software::server::Activation::
-            Activations activationStatus,
+        const std::string& extVersion, Activation::Status activationStatus,
         const AssociationList& assocs, const std::string& filePath);
 
     /** @brief Create Version object */
@@ -142,6 +144,12 @@
      */
     void processPSUImage();
 
+    /** @brief Create PSU Version from stored images */
+    void processStoredImage();
+
+    /** @brief Scan a directory and create PSU Version from stored images */
+    void scanDirectory(const fs::path& p);
+
     /** @brief Persistent sdbusplus D-Bus bus connection. */
     sdbusplus::bus::bus& bus;