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/tach_detect.cpp b/presence/tach_detect.cpp
index 1636b9a..e374c12 100644
--- a/presence/tach_detect.cpp
+++ b/presence/tach_detect.cpp
@@ -14,13 +14,11 @@
* limitations under the License.
*/
#include "config.h"
-#if defined(PRESENCE_JSON_FILE) || \
- (defined(PRESENCE_JSON_DBUS_INTF) && defined(PRESENCE_JSON_DBUS_PROP))
+#ifdef PRESENCE_USE_JSON
#include "json_config.hpp"
#else
#include "generated.hpp"
#endif
-#include "sdbusplus.hpp"
#include <sdeventplus/event.hpp>
#include <functional>
#include <stdplus/signal.hpp>
@@ -34,32 +32,9 @@
auto event = sdeventplus::Event::get_default();
bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
-#ifdef PRESENCE_JSON_FILE
+#ifdef PRESENCE_USE_JSON
// Use json file for presence config
- presence::JsonConfig config(PRESENCE_JSON_FILE);
-#elif defined(PRESENCE_JSON_DBUS_INTF) && defined(PRESENCE_JSON_DBUS_PROP)
- // Use first object returned in the subtree
- // (There should really only be one object with the config interface)
- std::string jsonFile = "";
- auto objects = util::SDBusPlus::getSubTree(
- bus, "/", PRESENCE_JSON_DBUS_INTF, 0);
- auto itObj = objects.begin();
- if (itObj != objects.end())
- {
- auto itServ = itObj->second.begin();
- if (itServ != itObj->second.end())
- {
- // Retrieve json config file location from dbus
- jsonFile = util::SDBusPlus::getProperty<std::string>(
- bus, itServ->first, itObj->first,
- PRESENCE_JSON_DBUS_INTF, PRESENCE_JSON_DBUS_PROP);
- }
- }
- presence::JsonConfig config(jsonFile);
-#endif
-
-#if defined(PRESENCE_JSON_FILE) || \
- (defined(PRESENCE_JSON_DBUS_INTF) && defined(PRESENCE_JSON_DBUS_PROP))
+ presence::JsonConfig config(bus);
for (auto& p: presence::JsonConfig::get())
{
p->monitor();