presence: Hard code JSON config file locations

Instead of using locations provided at configure time to retrieve the
JSON config file, hard code the directory paths and the dbus
interface/property used. This simplifies what's required to be given at
configure time and eliminates complexities in the possible locations the
JSON config files could be stored in.

The expected value retrieved from dbus is a relative location to the
base path /usr/share/phosphor-fan-presence/presence/[DBUS_VALUE]

Tested:
    Config file is able to loaded from each location
    Dbus property value used relative to base path location

Change-Id: I831647f78887b3948ce35be4015fd7762748838d
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/presence/json_config.hpp b/presence/json_config.hpp
index 206b290..1e31939 100644
--- a/presence/json_config.hpp
+++ b/presence/json_config.hpp
@@ -6,6 +6,7 @@
 #include <nlohmann/json.hpp>
 #include <filesystem>
 #include <sdeventplus/source/signal.hpp>
+#include <sdbusplus/bus.hpp>
 
 #include "config.h"
 #include "rpolicy.hpp"
@@ -22,8 +23,11 @@
 namespace fs = std::filesystem;
 using json = nlohmann::json;
 
-constexpr auto jsonFileName = "config.json";
-constexpr auto jsonOverridePath = "/etc/phosphor-fan-presence/presence";
+constexpr auto confFileName = "config.json";
+constexpr auto confOverridePath = "/etc/phosphor-fan-presence/presence";
+constexpr auto confBasePath = "/usr/share/phosphor-fan-presence/presence";
+constexpr auto confDbusIntf = "xyz.openbmc_project.Configs.ThermalApps";
+constexpr auto confDbusProp = "FanPresence";
 
 using policies = std::vector<std::unique_ptr<RedundancyPolicy>>;
 
@@ -53,9 +57,9 @@
          * Constructor
          * Parses and populates the fan presence policies from a json file
          *
-         * @param[in] jsonConfigPath - json configuration path
+         * @param[in] bus - sdbusplus bus object
          */
-        explicit JsonConfig(const std::string& jsonConfigPath);
+        explicit JsonConfig(sdbusplus::bus::bus& bus);
 
         /**
          * @brief Get the json config based fan presence policies
@@ -79,8 +83,11 @@
         /* Fan presence policies */
         static policies _policies;
 
-        /* Default json configuration file */
-        const fs::path _defaultFile;
+        /* The sdbusplus bus object */
+        sdbusplus::bus::bus& _bus;
+
+        /* Config file to be used */
+        fs::path _confFile;
 
         /* List of Fan objects to have presence policies */
         std::vector<fanPolicy> _fans;
@@ -95,6 +102,17 @@
         static const std::map<std::string, rpolicyHandler> _rpolicies;
 
         /**
+         * Get the json configuration file. The first location found to contain
+         * the json config file is used from the following locations in order.
+         * 1.) confOverridePath ("/etc/phosphor-fan-presence/presence")
+         * 2.) confBasePath ("/usr/share/phosphor-fan-presence/presence")
+         * 3.) From first dbus object found hosting
+         *     interface = Interface set in confDbusIntf
+         *     property = Property set in confDbusProp
+         */
+        const fs::path getConfFile();
+
+        /**
          * @brief Load the json config file
          */
         void load();