Use shared getProperty function in control manager

When the manager checks a getProperty condition for fan control, it
should use the shared getProperty function that now returns a
DbusMethodError to better exit/restart the fan control application.

Tested:
    Condition check functions the same

Change-Id: I37f83ef4273343bd527ac149ac5eee213d0ad63d
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/manager.cpp b/control/manager.cpp
index d5f97d7..a322c10 100644
--- a/control/manager.cpp
+++ b/control/manager.cpp
@@ -21,6 +21,7 @@
 #include <unistd.h>
 #include "manager.hpp"
 #include "utility.hpp"
+#include "sdbusplus.hpp"
 
 namespace phosphor
 {
@@ -36,50 +37,6 @@
 constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager";
 constexpr auto FAN_CONTROL_READY_TARGET = "obmc-fan-control-ready@0.target";
 
-constexpr auto PROPERTY_INTERFACE = "org.freedesktop.DBus.Properties";
-constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
-constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper";
-constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper";
-
-
-/**
- * Get the current value of the D-Bus property under the specified path
- * and interface.
- *
- * @param[in] bus          - The D-Bus bus object
- * @param[in] path         - The D-Bus path
- * @param[in] interface    - The D-Bus interface
- * @param[in] propertyName - The D-Bus property
- * @param[out] value       - The D-Bus property's value
- */
-template <typename T>
-void getProperty(sdbusplus::bus::bus& bus,
-                 const std::string& path,
-                 const std::string& interface,
-                 const std::string& propertyName,
-                 T& value)
-{
-    sdbusplus::message::variant<T> property;
-    std::string service = phosphor::fan::util::getService(path, interface, bus);
-
-    auto method = bus.new_method_call(service.c_str(),
-                                      path.c_str(),
-                                      PROPERTY_INTERFACE,
-                                      "Get");
-
-    method.append(interface, propertyName);
-    auto reply = bus.call(method);
-
-    if (reply.is_method_error())
-    {
-        log<level::ERR>("Error in call response for retrieving property");
-        elog<InternalFailure>();
-    }
-    reply.read(property);
-    value = sdbusplus::message::variant_ns::get<T>(property);
-}
-
-
 /**
  * Check if a condition is true. Conditions are used to determine
  * which fan zone to use.
@@ -95,17 +52,16 @@
 
     for (auto& p : properties)
     {
-        bool value = std::get<propertyValuePos>(p);
-        bool propertyValue;
+        auto value = std::get<propertyValuePos>(p);
 
         // TODO openbmc/openbmc#1769: Support more types than just getProperty.
         if (type.compare("getProperty") == 0)
         {
-            getProperty(bus,
-                        std::get<propertyPathPos>(p),
-                        std::get<propertyInterfacePos>(p),
-                        std::get<propertyNamePos>(p),
-                        propertyValue);
+            auto propertyValue = util::SDBusPlus::getProperty<decltype(value)>(
+                    bus,
+                    std::get<propertyPathPos>(p),
+                    std::get<propertyInterfacePos>(p),
+                    std::get<propertyNamePos>(p));
 
             if (value != propertyValue)
             {