From 710d49be2fc33f22e8f4a7ed43774fd9293d083f Mon Sep 17 00:00:00 2001 From: Lei YU Date: Tue, 1 Aug 2017 17:10:17 +0800 Subject: Use new settings API The new time manager code was using the old settings daemon. Now it uses the new settings API. Change-Id: Id551d97c28a6cfbb81c87118b26292b1b5574e93 Signed-off-by: Lei YU --- manager.hpp | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'manager.hpp') diff --git a/manager.hpp b/manager.hpp index 9b135d9..dc0885e 100644 --- a/manager.hpp +++ b/manager.hpp @@ -2,6 +2,7 @@ #include "types.hpp" #include "property_change_listener.hpp" +#include "settings.hpp" #include #include @@ -30,6 +31,7 @@ class Manager Manager& operator=(const Manager&) = delete; Manager(Manager&&) = delete; Manager& operator=(Manager&&) = delete; + ~Manager() = default; /** @brief Add a listener that will be called * when property is changed @@ -41,14 +43,22 @@ class Manager sdbusplus::bus::bus& bus; /** @brief The match of settings property change */ + // TODO: This is to be removed when all properties are handled in + // new settings daemon sdbusplus::bus::match::match propertyChangeMatch; + /** @brief The match of settings property change */ + std::vector settingsMatches; + /** @brief The match of pgood change */ sdbusplus::bus::match::match pgoodChangeMatch; /** @brief The container to hold all the listeners */ std::set listeners; + /** @brief Settings objects of intereset */ + settings::Objects settings; + /** @brief The value to indicate if host is on */ bool hostOn = false; @@ -81,6 +91,18 @@ class Manager */ std::string getSettings(const char* setting) const; + /** @brief Get setting from settingsd service + * + * @param[in] path - The dbus object path + * @param[in] interface - The dbus interface + * @param[in] setting - The string of the setting + * + * @return The setting value in string + */ + std::string getSetting(const char* path, + const char* interface, + const char* setting) const; + /** @brief Set current time mode from the time mode string * * @param[in] mode - The string of time mode @@ -113,6 +135,14 @@ class Manager */ void onTimeOwnerChanged(); + /** @brief Callback to handle change in a setting + * + * @param[in] msg - sdbusplus dbusmessage + * + * @return 0 on success, < 0 on failure. + */ + int onSettingsChanged(sdbusplus::message::message& msg); + /** @brief Notified on settings property changed * * @param[in] key - The name of property that is changed @@ -182,10 +212,10 @@ class Manager sd_bus_error* retError); /** @brief The string of time mode property */ - static constexpr auto PROPERTY_TIME_MODE = "time_mode"; + static constexpr auto PROPERTY_TIME_MODE = "TimeSyncMethod"; /** @brief The string of time owner property */ - static constexpr auto PROPERTY_TIME_OWNER = "time_owner"; + static constexpr auto PROPERTY_TIME_OWNER = "TimeOwner"; /** @brief The string of use dhcp ntp property */ static constexpr auto PROPERTY_DHCP_NTP = "use_dhcp_ntp"; -- cgit v1.2.1