Use a single dbus connection object

Starting with sdbusplus 8ca6025, calling bus_new_default multiple times
doesn't seem to work - making calls that generate dbus traffic on one
of the objects results in something like:

  sd_bus_call: System.Error.ENOTCONN: Transport endpoint is not connected

This wasn't ideal anyway - move to a single object, shared
application-wide.

Tested: Booted a witherspoon QEMU image and there were no coredumps
Change-Id: I804a1b1438b22f48e45b26d395135e401ca98a06
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/manager.cpp b/manager.cpp
index f9de91d..69639e4 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -30,7 +30,7 @@
 const std::set<std::string> Manager::managedProperties = {PROPERTY_TIME_MODE,
                                                           PROPERTY_TIME_OWNER};
 
-Manager::Manager(sdbusplus::bus::bus& bus) : bus(bus)
+Manager::Manager(sdbusplus::bus::bus& bus) : bus(bus), settings(bus)
 {
     using namespace sdbusplus::bus::match::rules;
     hostStateChangeMatch =
diff --git a/settings.cpp b/settings.cpp
index aeefe64..9add59d 100644
--- a/settings.cpp
+++ b/settings.cpp
@@ -15,9 +15,8 @@
 constexpr auto mapperPath = "/xyz/openbmc_project/object_mapper";
 constexpr auto mapperIntf = "xyz.openbmc_project.ObjectMapper";
 
-Objects::Objects()
+Objects::Objects(sdbusplus::bus::bus& bus) : bus(bus)
 {
-    auto bus = sdbusplus::bus::new_default();
     std::vector<std::string> settingsIntfs = {timeOwnerIntf, timeSyncIntf,
                                               hostStateIntf};
     auto depth = 0;
@@ -71,7 +70,6 @@
 
 Service Objects::service(const Path& path, const Interface& interface) const
 {
-    auto bus = sdbusplus::bus::new_default();
     using Interfaces = std::vector<Interface>;
     auto mapperCall =
         bus.new_method_call(mapperService, mapperPath, mapperIntf, "GetObject");
diff --git a/settings.hpp b/settings.hpp
index 8a89e74..b4893cb 100644
--- a/settings.hpp
+++ b/settings.hpp
@@ -25,9 +25,10 @@
      *
      * @param[in] bus - The D-bus bus object
      */
-    Objects();
-    Objects(const Objects&) = default;
-    Objects& operator=(const Objects&) = default;
+    Objects() = delete;
+    explicit Objects(sdbusplus::bus::bus&);
+    Objects(const Objects&) = delete;
+    Objects& operator=(const Objects&) = delete;
     Objects(Objects&&) = default;
     Objects& operator=(Objects&&) = default;
     ~Objects() = default;
@@ -51,6 +52,9 @@
 
     /** @brief host state object */
     Path hostState;
+
+  private:
+    sdbusplus::bus::bus& bus;
 };
 
 } // namespace settings