BMC: Call emit_interfaces signal for temporary interfaces

When an interface is removed, all the interfaces on that dbus
object are removed because the object class calls object_removed.
The code will be enhanced to handle the removal of interfaces with
openbmc/openbmc#1975 .

In the mean time, for interfaces that are temporary and removed
in the course of the code update flow, do not call emit_object_added
and call emit_interfaces_added and removed when they are created
and destroyed.

Resolves openbmc/openbmc#2096

Change-Id: I2d022e77015b84e2900b2392d4ac97da02478cdf
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
diff --git a/activation.hpp b/activation.hpp
index b3ec44b..69f52b7 100644
--- a/activation.hpp
+++ b/activation.hpp
@@ -49,12 +49,20 @@
                                    uint8_t value) :
                                    RedundancyPriorityInherit(bus,
                                    path.c_str(), true),
-                                   parent(parent)
+                                   parent(parent),
+                                   bus(bus),
+                                   path(path)
         {
             // Set Property
             priority(value);
-            // Emit deferred signal.
-            emit_object_added();
+            std::vector<std::string> interfaces({interface});
+            bus.emit_interfaces_added(path.c_str(), interfaces);
+        }
+
+        ~RedundancyPriority()
+        {
+            std::vector<std::string> interfaces({interface});
+            bus.emit_interfaces_removed(path.c_str(), interfaces);
         }
 
         /** @brief Overloaded Priority property set function
@@ -73,6 +81,13 @@
 
         /** @brief Parent Object. */
         Activation& parent;
+
+    private:
+        // TODO Remove once openbmc/openbmc#1975 is resolved
+        static constexpr auto interface =
+                "xyz.openbmc_project.Software.RedundancyPriority";
+        sdbusplus::bus::bus& bus;
+        std::string path;
 };
 
 /** @class ActivationBlocksTransition
@@ -90,7 +105,26 @@
          */
          ActivationBlocksTransition(sdbusplus::bus::bus& bus,
                                    const std::string& path) :
-                   ActivationBlocksTransitionInherit(bus, path.c_str()) {}
+                   ActivationBlocksTransitionInherit(bus, path.c_str(), true),
+                   bus(bus),
+                   path(path)
+        {
+            std::vector<std::string> interfaces({interface});
+            bus.emit_interfaces_added(path.c_str(), interfaces);
+        }
+
+        ~ActivationBlocksTransition()
+        {
+            std::vector<std::string> interfaces({interface});
+            bus.emit_interfaces_removed(path.c_str(), interfaces);
+        }
+
+    private:
+        // TODO Remove once openbmc/openbmc#1975 is resolved
+        static constexpr auto interface =
+                "xyz.openbmc_project.Software.ActivationBlocksTransition";
+        sdbusplus::bus::bus& bus;
+        std::string path;
 };
 
 class ActivationProgress : public ActivationProgressInherit
@@ -103,11 +137,27 @@
           */
         ActivationProgress(sdbusplus::bus::bus& bus,
                            const std::string& path) :
-                ActivationProgressInherit(bus, path.c_str(), true)
+                ActivationProgressInherit(bus, path.c_str(), true),
+                bus(bus),
+                path(path)
         {
             progress(0);
-            emit_object_added();
+            std::vector<std::string> interfaces({interface});
+            bus.emit_interfaces_added(path.c_str(), interfaces);
         }
+
+        ~ActivationProgress()
+        {
+            std::vector<std::string> interfaces({interface});
+            bus.emit_interfaces_removed(path.c_str(), interfaces);
+        }
+
+    private:
+        // TODO Remove once openbmc/openbmc#1975 is resolved
+        static constexpr auto interface =
+                "xyz.openbmc_project.Software.ActivationProgress";
+        sdbusplus::bus::bus& bus;
+        std::string path;
 };
 
 /** @class Activation