Support multi power buttons with multi behaviors

For supporting more-than-one power buttons behaviors,
add new matches and instances by following json config.

This change is for multiple slots integrated on one chassis,
and each slot has button to control power status.

For example:
/xyz/openbmc_project/Chassis/Buttons/Power01 for button on slot1
/xyz/openbmc_project/Chassis/Buttons/Power02 for button on slot2

Moreover, support multi-level power control by json config,
chassis now can do action by corresponding pressing duration.

Tested:
Press buttons and check corresponding behaviors.

Change-Id: I7789f0367d5e846dd9e68f966ba0755fc916217a
Signed-off-by: Rush Chen <rush.chen.wiwynn@gmail.com>
diff --git a/inc/button_handler.hpp b/inc/button_handler.hpp
index 1332a0f..ff8850b 100644
--- a/inc/button_handler.hpp
+++ b/inc/button_handler.hpp
@@ -1,10 +1,16 @@
 #pragma once
 
+#include "config.hpp"
 #include "power_button_profile.hpp"
 
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/bus/match.hpp>
 
+#include <algorithm>
+#include <numeric>
+#include <sstream>
+#include <string>
+
 namespace phosphor
 {
 namespace button
@@ -16,6 +22,19 @@
     powerReleased,
     resetReleased
 };
+
+enum class PwrCtl
+{
+    chassisOn,
+    chassisOff,
+    chassisCycle,
+};
+
+inline static size_t numberOfChassis()
+{
+    return instances.size();
+}
+
 /**
  * @class Handler
  *
@@ -129,6 +148,7 @@
      * @return void
      */
     void handlePowerEvent(PowerEvent powerEventType,
+                          const std::string& objectPath,
                           std::chrono::microseconds duration);
 
     /**
@@ -147,6 +167,12 @@
     std::unique_ptr<sdbusplus::bus::match_t> powerButtonLongPressed;
 
     /**
+     * @brief Matches on the multi power button released signal
+     */
+    std::vector<std::unique_ptr<sdbusplus::bus::match_t>>
+        multiPowerButtonReleased;
+
+    /**
      * @brief Matches on the ID button released signal
      */
     std::unique_ptr<sdbusplus::bus::match_t> idButtonReleased;
@@ -165,6 +191,17 @@
      * @brief The custom power handler profile object.
      */
     std::unique_ptr<PowerButtonProfile> powerButtonProfile;
+
+    /**
+     * @brief Flag to indicate multi power button mode(false) or host select
+     * button mode(true)
+     */
+    bool hostSelectButtonMode = false;
+
+    /**
+     * @brief Flag to indicate if the button supports multi action
+     */
+    bool isButtonMultiActionSupport = true;
 };
 
 } // namespace button