Use time mode owner enums in dbus interface

Dbus interface defines time mode owners in xyz::openbmc_project::Time.
Use the enums from the interface instead of repo defined enums and use
the generated code to do convertions between strings and enums.

Update unit tests accordingly.

Change-Id: Ic304aa3b4137375d208bb1702e0f64df512fc5a0
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/bmc_epoch.cpp b/bmc_epoch.cpp
index 7bc6c22..4c8bf60 100644
--- a/bmc_epoch.cpp
+++ b/bmc_epoch.cpp
@@ -110,7 +110,7 @@
         // TODO: throw NotAllowed exception
         return 0;
     }
-    if (timeOwner == Owner::HOST)
+    if (timeOwner == Owner::Host)
     {
         log<level::ERR>("Setting BmcTime with HOST owner is not allowed");
         // TODO: throw NotAllowed exception
diff --git a/epoch_base.hpp b/epoch_base.hpp
index fedaeb6..778a5cd 100644
--- a/epoch_base.hpp
+++ b/epoch_base.hpp
@@ -38,10 +38,10 @@
         sdbusplus::bus::bus& bus;
 
         /** @brief The current time mode */
-        Mode timeMode = Mode::MANUAL;
+        Mode timeMode = Mode::Manual;
 
         /** @brief The current time owner */
-        Owner timeOwner = Owner::BOTH;
+        Owner timeOwner = Owner::Both;
 
         /** @brief Set current time to system
          *
diff --git a/host_epoch.cpp b/host_epoch.cpp
index 129d224..99cdf6d 100644
--- a/host_epoch.cpp
+++ b/host_epoch.cpp
@@ -25,7 +25,7 @@
 uint64_t HostEpoch::elapsed() const
 {
     auto ret = getTime();
-    if (timeOwner == Owner::SPLIT)
+    if (timeOwner == Owner::Split)
     {
         ret += offset;
     }
@@ -48,7 +48,7 @@
     */
     if (timeOwner == Owner::BMC ||
         (timeMode == Mode::NTP
-         && (timeOwner == Owner::HOST || timeOwner == Owner::BOTH)))
+         && (timeOwner == Owner::Host || timeOwner == Owner::Both)))
     {
         log<level::ERR>("Setting HostTime is not allowed");
         // TODO: throw NotAllowed exception
@@ -56,7 +56,7 @@
     }
 
     auto time = microseconds(value);
-    if (timeOwner == Owner::SPLIT)
+    if (timeOwner == Owner::Split)
     {
         // Calculate the offset between host and bmc time
         offset = time - getTime();
@@ -82,7 +82,7 @@
     // If timeOwner is changed to SPLIT, the offset shall be preserved
     // Otherwise it shall be cleared;
     timeOwner = owner;
-    if (timeOwner != Owner::SPLIT)
+    if (timeOwner != Owner::Split)
     {
         offset = microseconds(0);
         saveOffset();
@@ -99,7 +99,7 @@
 {
     // If owner is split and BMC time is changed,
     // the offset shall be adjusted
-    if (timeOwner == Owner::SPLIT)
+    if (timeOwner == Owner::Split)
     {
         auto steadyTime = duration_cast<microseconds>(
             steady_clock::now().time_since_epoch());
diff --git a/test/TestBmcEpoch.cpp b/test/TestBmcEpoch.cpp
index f182de4..e268b9f 100644
--- a/test/TestBmcEpoch.cpp
+++ b/test/TestBmcEpoch.cpp
@@ -68,8 +68,8 @@
 TEST_F(TestBmcEpoch, empty)
 {
     // Default mode/owner is MANUAL/BOTH
-    EXPECT_EQ(Mode::MANUAL, getTimeMode());
-    EXPECT_EQ(Owner::BOTH, getTimeOwner());
+    EXPECT_EQ(Mode::Manual, getTimeMode());
+    EXPECT_EQ(Owner::Both, getTimeOwner());
 }
 
 TEST_F(TestBmcEpoch, getElapsed)
@@ -90,8 +90,8 @@
     EXPECT_EQ(0, ret);
 
     // In Host owner, setting time is not allowed
-    setTimeMode(Mode::MANUAL);
-    setTimeOwner(Owner::HOST);
+    setTimeMode(Mode::Manual);
+    setTimeOwner(Owner::Host);
     ret = bmcEpoch->elapsed(epochNow);
     EXPECT_EQ(0, ret);
 }
diff --git a/test/TestEpochBase.cpp b/test/TestEpochBase.cpp
index e4a2b68..6c2ec88 100644
--- a/test/TestEpochBase.cpp
+++ b/test/TestEpochBase.cpp
@@ -37,8 +37,8 @@
     epochBase.onModeChanged(Mode::NTP);
     EXPECT_EQ(Mode::NTP, getMode());
 
-    epochBase.onModeChanged(Mode::MANUAL);
-    EXPECT_EQ(Mode::MANUAL, getMode());
+    epochBase.onModeChanged(Mode::Manual);
+    EXPECT_EQ(Mode::Manual, getMode());
 }
 
 TEST_F(TestEpochBase, onOwnerChange)
@@ -46,14 +46,14 @@
     epochBase.onOwnerChanged(Owner::BMC);
     EXPECT_EQ(Owner::BMC, getOwner());
 
-    epochBase.onOwnerChanged(Owner::HOST);
-    EXPECT_EQ(Owner::HOST, getOwner());
+    epochBase.onOwnerChanged(Owner::Host);
+    EXPECT_EQ(Owner::Host, getOwner());
 
-    epochBase.onOwnerChanged(Owner::SPLIT);
-    EXPECT_EQ(Owner::SPLIT, getOwner());
+    epochBase.onOwnerChanged(Owner::Split);
+    EXPECT_EQ(Owner::Split, getOwner());
 
-    epochBase.onOwnerChanged(Owner::BOTH);
-    EXPECT_EQ(Owner::BOTH, getOwner());
+    epochBase.onOwnerChanged(Owner::Both);
+    EXPECT_EQ(Owner::Both, getOwner());
 }
 
 }
diff --git a/test/TestHostEpoch.cpp b/test/TestHostEpoch.cpp
index 0e59745..a492b9a 100644
--- a/test/TestHostEpoch.cpp
+++ b/test/TestHostEpoch.cpp
@@ -138,8 +138,8 @@
 TEST_F(TestHostEpoch, empty)
 {
     // Default mode/owner is MANUAL/BOTH
-    EXPECT_EQ(Mode::MANUAL, getTimeMode());
-    EXPECT_EQ(Owner::BOTH, getTimeOwner());
+    EXPECT_EQ(Mode::Manual, getTimeMode());
+    EXPECT_EQ(Owner::Both, getTimeOwner());
 }
 
 TEST_F(TestHostEpoch, readDataFileNotExist)
@@ -176,7 +176,7 @@
 {
     // Set time in NTP/HOST is not allowed
     setTimeMode(Mode::NTP);
-    setTimeOwner(Owner::HOST);
+    setTimeOwner(Owner::Host);
     checkSettingTimeNotAllowed();
 }
 
@@ -184,7 +184,7 @@
 {
     // Set time in NTP/SPLIT, offset will be set
     setTimeMode(Mode::NTP);
-    setTimeOwner(Owner::SPLIT);
+    setTimeOwner(Owner::Split);
 
     checkSetSplitTimeInFuture();
 
@@ -197,14 +197,14 @@
 {
     // Set time in NTP/BOTH is not allowed
     setTimeMode(Mode::NTP);
-    setTimeOwner(Owner::BOTH);
+    setTimeOwner(Owner::Both);
     checkSettingTimeNotAllowed();
 }
 
 TEST_F(TestHostEpoch, setElapsedInManualBmc)
 {
     // Set time in MANUAL/BMC is not allowed
-    setTimeMode(Mode::MANUAL);
+    setTimeMode(Mode::Manual);
     setTimeOwner(Owner::BMC);
     checkSettingTimeNotAllowed();
 }
@@ -214,15 +214,15 @@
     // Set time in MANUAL/HOST, time will be set to BMC
     // However it requies gmock to test this case
     // TODO: when gmock is ready, test this case.
-    setTimeMode(Mode::MANUAL);
-    setTimeOwner(Owner::HOST);
+    setTimeMode(Mode::Manual);
+    setTimeOwner(Owner::Host);
 }
 
 TEST_F(TestHostEpoch, setElapsedInManualSplit)
 {
     // Set to SPLIT owner so that offset will be set
-    setTimeMode(Mode::MANUAL);
-    setTimeOwner(Owner::SPLIT);
+    setTimeMode(Mode::Manual);
+    setTimeOwner(Owner::Split);
 
     checkSetSplitTimeInFuture();
 
@@ -236,14 +236,14 @@
     // Set time in MANUAL/BOTH, time will be set to BMC
     // However it requies gmock to test this case
     // TODO: when gmock is ready, test this case.
-    setTimeMode(Mode::MANUAL);
-    setTimeOwner(Owner::BOTH);
+    setTimeMode(Mode::Manual);
+    setTimeOwner(Owner::Both);
 }
 
 TEST_F(TestHostEpoch, setElapsedInSplitAndBmcTimeIsChanged)
 {
     // Set to SPLIT owner so that offset will be set
-    setTimeOwner(Owner::SPLIT);
+    setTimeOwner(Owner::Split);
 
     // Get current time, and set future +1min time
     auto t1 = hostEpoch.elapsed();
@@ -277,13 +277,13 @@
 {
     EXPECT_EQ(USEC_ZERO, getOffset());
 
-    setTimeOwner(Owner::SPLIT);
+    setTimeOwner(Owner::Split);
     hostEpoch.onBmcTimeChanged(microseconds(hostEpoch.elapsed()) + 1min);
 
     // Now offset shall be non zero
     EXPECT_NE(USEC_ZERO, getOffset());
 
-    setTimeOwner(Owner::BOTH);
+    setTimeOwner(Owner::Both);
 
     // Now owner is BOTH, the offset shall be cleared
     EXPECT_EQ(USEC_ZERO, getOffset());
diff --git a/test/TestManager.cpp b/test/TestManager.cpp
index 5c9c8c3..d87ca39 100644
--- a/test/TestManager.cpp
+++ b/test/TestManager.cpp
@@ -69,8 +69,8 @@
     EXPECT_EQ("", getRequestedOwner());
 
     // Default mode/owner is MANUAL/BOTH
-    EXPECT_EQ(Mode::MANUAL, getTimeMode());
-    EXPECT_EQ(Owner::BOTH, getTimeOwner());
+    EXPECT_EQ(Mode::Manual, getTimeMode());
+    EXPECT_EQ(Owner::Both, getTimeOwner());
 }
 
 
@@ -88,13 +88,17 @@
     EXPECT_FALSE(hostOn());
 
     // Check mocked listeners shall receive notifications on property changed
-    EXPECT_CALL(listener1, onModeChanged(Mode::MANUAL)).Times(1);
-    EXPECT_CALL(listener1, onOwnerChanged(Owner::HOST)).Times(1);
-    EXPECT_CALL(listener2, onModeChanged(Mode::MANUAL)).Times(1);
-    EXPECT_CALL(listener2, onOwnerChanged(Owner::HOST)).Times(1);
+    EXPECT_CALL(listener1, onModeChanged(Mode::Manual)).Times(1);
+    EXPECT_CALL(listener1, onOwnerChanged(Owner::Host)).Times(1);
+    EXPECT_CALL(listener2, onModeChanged(Mode::Manual)).Times(1);
+    EXPECT_CALL(listener2, onOwnerChanged(Owner::Host)).Times(1);
 
-    notifyPropertyChanged("time_mode", "MANUAL");
-    notifyPropertyChanged("time_owner", "HOST");
+    notifyPropertyChanged(
+        "time_mode",
+        "xyz.openbmc_project.Time.Synchronization.Method.Manual");
+    notifyPropertyChanged(
+        "time_owner",
+        "xyz.openbmc_project.Time.Owner.Owners.Host");
 
     EXPECT_EQ("", getRequestedMode());
     EXPECT_EQ("", getRequestedOwner());
@@ -103,24 +107,30 @@
     notifyPgoodChanged(true);
 
     // Check mocked listeners shall not receive notifications
-    EXPECT_CALL(listener1, onModeChanged(Mode::MANUAL)).Times(0);
-    EXPECT_CALL(listener1, onOwnerChanged(Owner::HOST)).Times(0);
-    EXPECT_CALL(listener2, onModeChanged(Mode::MANUAL)).Times(0);
-    EXPECT_CALL(listener2, onOwnerChanged(Owner::HOST)).Times(0);
+    EXPECT_CALL(listener1, onModeChanged(Mode::Manual)).Times(0);
+    EXPECT_CALL(listener1, onOwnerChanged(Owner::Host)).Times(0);
+    EXPECT_CALL(listener2, onModeChanged(Mode::Manual)).Times(0);
+    EXPECT_CALL(listener2, onOwnerChanged(Owner::Host)).Times(0);
 
-    notifyPropertyChanged("time_mode", "NTP");
-    notifyPropertyChanged("time_owner", "SPLIT");
+    notifyPropertyChanged(
+        "time_mode",
+        "xyz.openbmc_project.Time.Synchronization.Method.NTP");
+    notifyPropertyChanged(
+        "time_owner",
+        "xyz.openbmc_project.Time.Owner.Owners.Split");
 
-    EXPECT_EQ("NTP", getRequestedMode());
-    EXPECT_EQ("SPLIT", getRequestedOwner());
+    EXPECT_EQ("xyz.openbmc_project.Time.Synchronization.Method.NTP",
+              getRequestedMode());
+    EXPECT_EQ("xyz.openbmc_project.Time.Owner.Owners.Split",
+              getRequestedOwner());
 
 
     // When host becomes off, the requested mode/owner shall be notified
     // to listners, and be cleared
     EXPECT_CALL(listener1, onModeChanged(Mode::NTP)).Times(1);
-    EXPECT_CALL(listener1, onOwnerChanged(Owner::SPLIT)).Times(1);
+    EXPECT_CALL(listener1, onOwnerChanged(Owner::Split)).Times(1);
     EXPECT_CALL(listener2, onModeChanged(Mode::NTP)).Times(1);
-    EXPECT_CALL(listener2, onOwnerChanged(Owner::SPLIT)).Times(1);
+    EXPECT_CALL(listener2, onOwnerChanged(Owner::Split)).Times(1);
 
     notifyPgoodChanged(false);
 
@@ -136,8 +146,12 @@
 TEST_F(TestManager, DISABLED_propertyChangedAndChangedbackWhenHostOn)
 {
     // Property is now MANUAL/HOST
-    notifyPropertyChanged("time_mode", "MANUAL");
-    notifyPropertyChanged("time_owner", "HOST");
+    notifyPropertyChanged(
+        "time_mode",
+        "xyz.openbmc_project.Time.Synchronization.Method.Manual");
+    notifyPropertyChanged(
+        "time_owner",
+        "xyz.openbmc_project.Time.Owner.Owners.Host");
 
     // Set host on
     notifyPgoodChanged(true);
@@ -148,20 +162,32 @@
     EXPECT_CALL(listener2, onModeChanged(_)).Times(0);
     EXPECT_CALL(listener2, onOwnerChanged(_)).Times(0);
 
-    notifyPropertyChanged("time_mode", "NTP");
-    notifyPropertyChanged("time_owner", "SPLIT");
+    notifyPropertyChanged(
+        "time_mode",
+        "xyz.openbmc_project.Time.Synchronization.Method.NTP");
+    notifyPropertyChanged(
+        "time_owner",
+        "xyz.openbmc_project.Time.Owner.Owners.Split");
 
     // Saved as requested mode/owner
-    EXPECT_EQ("NTP", getRequestedMode());
-    EXPECT_EQ("SPLIT", getRequestedOwner());
+    EXPECT_EQ("xyz.openbmc_project.Time.Synchronization.Method.NTP",
+              getRequestedMode());
+    EXPECT_EQ("xyz.openbmc_project.Time.Owner.Owners.Split",
+              getRequestedOwner());
 
     // Property changed back to MANUAL/HOST
-    notifyPropertyChanged("time_mode", "MANUAL");
-    notifyPropertyChanged("time_owner", "HOST");
+    notifyPropertyChanged(
+        "time_mode",
+        "xyz.openbmc_project.Time.Synchronization.Method.Manual");
+    notifyPropertyChanged(
+        "time_owner",
+        "xyz.openbmc_project.Time.Owner.Owners.Host");
 
     // Requested mode/owner shall be updated
-    EXPECT_EQ("MANUAL", getRequestedMode());
-    EXPECT_EQ("HOST", getRequestedOwner());
+    EXPECT_EQ("xyz.openbmc_project.Time.Synchronization.Method.Manual",
+              getRequestedMode());
+    EXPECT_EQ("xyz.openbmc_project.Time.Owner.Owners.Host",
+              getRequestedOwner());
 
     // Because the latest mode/owner is the same as when host is off,
     // The listeners shall not be notified, and requested mode/owner
diff --git a/test/TestUtils.cpp b/test/TestUtils.cpp
index 16ccd9c..483e82a 100644
--- a/test/TestUtils.cpp
+++ b/test/TestUtils.cpp
@@ -10,52 +10,67 @@
 namespace utils
 {
 
-using InvalidArgument =
-    sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument;
+using InvalidEnumString = sdbusplus::exception::InvalidEnumString;
 
 TEST(TestUtil, strToMode)
 {
-    EXPECT_EQ(Mode::NTP, strToMode("NTP"));
-    EXPECT_EQ(Mode::MANUAL, strToMode("MANUAL"));
+    EXPECT_EQ(
+        Mode::NTP,
+        strToMode("xyz.openbmc_project.Time.Synchronization.Method.NTP"));
+    EXPECT_EQ(
+        Mode::Manual,
+        strToMode("xyz.openbmc_project.Time.Synchronization.Method.Manual"));
 
-    // All unrecognized strings result in InvalidArgument exception
-    EXPECT_THROW(strToMode(""), InvalidArgument);
-    EXPECT_THROW(strToMode("Manual"), InvalidArgument);
-    EXPECT_THROW(strToMode("whatever"), InvalidArgument);
+    // All unrecognized strings result in InvalidEnumString exception
+    EXPECT_THROW(strToMode(""), InvalidEnumString);
+    EXPECT_THROW(
+        strToMode("xyz.openbmc_project.Time.Synchronization.Method.MANUAL"),
+        InvalidEnumString);
+    EXPECT_THROW(strToMode("whatever"), InvalidEnumString);
 }
 
 
 TEST(TestUtil, strToOwner)
 {
-    EXPECT_EQ(Owner::BMC, strToOwner("BMC"));
-    EXPECT_EQ(Owner::HOST, strToOwner("HOST"));
-    EXPECT_EQ(Owner::SPLIT, strToOwner("SPLIT"));
-    EXPECT_EQ(Owner::BOTH, strToOwner("BOTH"));
+    EXPECT_EQ(Owner::BMC,
+              strToOwner("xyz.openbmc_project.Time.Owner.Owners.BMC"));
+    EXPECT_EQ(Owner::Host,
+              strToOwner("xyz.openbmc_project.Time.Owner.Owners.Host"));
+    EXPECT_EQ(Owner::Split,
+              strToOwner("xyz.openbmc_project.Time.Owner.Owners.Split"));
+    EXPECT_EQ(Owner::Both,
+              strToOwner("xyz.openbmc_project.Time.Owner.Owners.Both"));
 
-    // All unrecognized strings result in InvalidArgument exception
-    EXPECT_THROW(strToOwner(""), InvalidArgument);
-    EXPECT_THROW(strToOwner("Split"), InvalidArgument);
-    EXPECT_THROW(strToOwner("xyz"), InvalidArgument);
+    // All unrecognized strings result in InvalidEnumString exception
+    EXPECT_THROW(strToOwner(""), InvalidEnumString);
+    EXPECT_THROW(strToOwner("Split"), InvalidEnumString);
+    EXPECT_THROW(strToOwner("xyz"), InvalidEnumString);
 }
 
 TEST(TestUtil, modeToStr)
 {
-    EXPECT_EQ("NTP", modeToStr(Mode::NTP));
-    EXPECT_EQ("MANUAL", modeToStr(Mode::MANUAL));
+    EXPECT_EQ("xyz.openbmc_project.Time.Synchronization.Method.NTP",
+              modeToStr(Mode::NTP));
+    EXPECT_EQ("xyz.openbmc_project.Time.Synchronization.Method.Manual",
+              modeToStr(Mode::Manual));
 
-    // All unrecognized strings result in InvalidArgument exception
-    EXPECT_THROW(modeToStr(static_cast<Mode>(100)), InvalidArgument);
+    // All unrecognized strings result in exception
+    EXPECT_ANY_THROW(modeToStr(static_cast<Mode>(100)));
 }
 
 TEST(TestUtil, ownerToStr)
 {
-    EXPECT_EQ("BMC", ownerToStr(Owner::BMC));
-    EXPECT_EQ("HOST", ownerToStr(Owner::HOST));
-    EXPECT_EQ("SPLIT", ownerToStr(Owner::SPLIT));
-    EXPECT_EQ("BOTH", ownerToStr(Owner::BOTH));
+    EXPECT_EQ("xyz.openbmc_project.Time.Owner.Owners.BMC",
+              ownerToStr(Owner::BMC));
+    EXPECT_EQ("xyz.openbmc_project.Time.Owner.Owners.Host",
+              ownerToStr(Owner::Host));
+    EXPECT_EQ("xyz.openbmc_project.Time.Owner.Owners.Split",
+              ownerToStr(Owner::Split));
+    EXPECT_EQ("xyz.openbmc_project.Time.Owner.Owners.Both",
+              ownerToStr(Owner::Both));
 
-    // All unrecognized strings result in InvalidArgument exception
-    EXPECT_THROW(ownerToStr(static_cast<Owner>(100)), InvalidArgument);
+    // All unrecognized strings result in exception
+    EXPECT_ANY_THROW(ownerToStr(static_cast<Owner>(100)));
 }
 
 } // namespace utils
diff --git a/types.hpp b/types.hpp
index 9b88965..e4c2888 100644
--- a/types.hpp
+++ b/types.hpp
@@ -1,49 +1,49 @@
 #pragma once
 
+#include <xyz/openbmc_project/Time/Owner/server.hpp>
+#include <xyz/openbmc_project/Time/Synchronization/server.hpp>
+
 namespace phosphor
 {
 namespace time
 {
-        /** @brief Supported time modes
-         *  NTP     Time sourced by Network Time Server
-         *  MANUAL  User of the system need to set the time
-         */
-        enum class Mode
-        {
-            NTP,
-            MANUAL,
-        };
+    /** @brief Alias to time sync mode class */
+    using ModeSetting =
+        sdbusplus::xyz::openbmc_project::Time::server::Synchronization;
 
-        /** @brief Supported time owners
-         *  BMC     Time source may be NTP or MANUAL but it has to be set natively
-         *          on the BMC. Meaning, host can not set the time. What it also
-         *          means is that when BMC gets IPMI_SET_SEL_TIME, then its ignored.
-         *          similarly, when BMC gets IPMI_GET_SEL_TIME, then the BMC's time
-         *          is returned.
-         *
-         *  HOST    Its only IPMI_SEL_SEL_TIME that will set the time on BMC.
-         *          Meaning, IPMI_GET_SEL_TIME and request to get BMC time will
-         *          result in same value.
-         *
-         *  SPLIT   Both BMC and HOST will maintain their individual clocks but then
-         *          the time information is stored in BMC. BMC can have either NTP
-         *          or MANUAL as it's source of time and will set the time directly
-         *          on the BMC. When IPMI_SET_SEL_TIME is received, then the delta
-         *          between that and BMC's time is calculated and is stored.
-         *          When BMC reads the time, the current time is returned.
-         *          When IPMI_GET_SEL_TIME is received, BMC's time is retrieved and
-         *          then the delta offset is factored in prior to returning.
-         *
-         *  BOTH:   BMC's time is set with whoever that sets the time. Similarly,
-         *          BMC's time is returned to whoever that asks the time.
-         */
-        enum class Owner
-        {
-            BMC,
-            HOST,
-            SPLIT,
-            BOTH,
-        };
+    /** @brief Alias to time owner class */
+    using OwnerSetting = sdbusplus::xyz::openbmc_project::Time::server::Owner;
+
+    /** @brief Supported time sync modes
+     *  NTP     Time sourced by Network Time Server
+     *  Manual  User of the system need to set the time
+     */
+    using Mode = ModeSetting::Method;
+
+    /** @brief Supported time owners
+     *  BMC     Time source may be NTP or Manual but it has to be set natively
+     *          on the BMC. Meaning, host can not set the time. What it also
+     *          means is that when BMC gets IPMI_SET_SEL_TIME, then its ignored.
+     *          similarly, when BMC gets IPMI_GET_SEL_TIME, then the BMC's time
+     *          is returned.
+     *
+     *  Host    Its only IPMI_SEL_SEL_TIME that will set the time on BMC.
+     *          Meaning, IPMI_GET_SEL_TIME and request to get BMC time will
+     *          result in same value.
+     *
+     *  Split   Both BMC and Host will maintain their individual clocks but then
+     *          the time information is stored in BMC. BMC can have either NTP
+     *          or Manual as it's source of time and will set the time directly
+     *          on the BMC. When IPMI_SET_SEL_TIME is received, then the delta
+     *          between that and BMC's time is calculated and is stored.
+     *          When BMC reads the time, the current time is returned.
+     *          When IPMI_GET_SEL_TIME is received, BMC's time is retrieved and
+     *          then the delta offset is factored in prior to returning.
+     *
+     *  Both:   BMC's time is set with whoever that sets the time. Similarly,
+     *          BMC's time is returned to whoever that asks the time.
+     */
+    using Owner = OwnerSetting::Owners;
 }
 }
 
diff --git a/utils.cpp b/utils.cpp
index 57c3b5f..25b8f8c 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -16,22 +16,6 @@
 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";
-
-/** @brief The map that maps the string to Mode */
-const std::map<std::string, Mode> modeMap =
-{
-    { "NTP", Mode::NTP },
-    { "MANUAL", Mode::MANUAL },
-};
-
-/** @brief The map that maps the string to Owner */
-const std::map<std::string, Owner> ownerMap =
-{
-    { "BMC", Owner::BMC },
-    { "HOST", Owner::HOST },
-    { "SPLIT", Owner::SPLIT },
-    { "BOTH", Owner::BOTH },
-};
 }
 
 namespace utils
@@ -79,78 +63,22 @@
 
 Mode strToMode(const std::string& mode)
 {
-    auto it = modeMap.find(mode);
-    if (it == modeMap.end())
-    {
-        using namespace xyz::openbmc_project::Common;
-        elog<InvalidArgumentError>(
-            InvalidArgument::ARGUMENT_NAME("TimeMode"),
-            InvalidArgument::ARGUMENT_VALUE(mode.c_str()));
-    }
-    return it->second;
+    return ModeSetting::convertMethodFromString(mode);
 }
 
 Owner strToOwner(const std::string& owner)
 {
-    auto it = ownerMap.find(owner);
-    if (it == ownerMap.end())
-    {
-        using namespace xyz::openbmc_project::Common;
-        elog<InvalidArgumentError>(
-            InvalidArgument::ARGUMENT_NAME("TimeOwner"),
-            InvalidArgument::ARGUMENT_VALUE(owner.c_str()));
-    }
-    return it->second;
+    return OwnerSetting::convertOwnersFromString(owner);
 }
 
-const char* modeToStr(Mode mode)
+std::string modeToStr(Mode mode)
 {
-    const char* ret{};
-    switch (mode)
-    {
-    case Mode::NTP:
-        ret = "NTP";
-        break;
-    case Mode::MANUAL:
-        ret = "MANUAL";
-        break;
-    default:
-        using namespace xyz::openbmc_project::Common;
-        elog<InvalidArgumentError>(
-            InvalidArgument::ARGUMENT_NAME("Mode"),
-            InvalidArgument::ARGUMENT_VALUE(
-                std::to_string(static_cast<int>(mode)).c_str()));
-        break;
-    }
-    return ret;
+    return sdbusplus::xyz::openbmc_project::Time::server::convertForMessage(mode);
 }
 
-const char* ownerToStr(Owner owner)
+std::string ownerToStr(Owner owner)
 {
-    const char* ret{};
-    switch (owner)
-    {
-    case Owner::BMC:
-        ret = "BMC";
-        break;
-    case Owner::HOST:
-        ret = "HOST";
-        break;
-    case Owner::SPLIT:
-        ret = "SPLIT";
-        break;
-    case Owner::BOTH:
-        ret = "BOTH";
-        break;
-    default:
-        using namespace xyz::openbmc_project::Common;
-        elog<InvalidArgumentError>(
-            InvalidArgument::ARGUMENT_NAME("Owner"),
-            InvalidArgument::ARGUMENT_VALUE(
-                std::to_string(static_cast<int>(owner)).c_str()));
-        break;
-    }
-    return ret;
+    return sdbusplus::xyz::openbmc_project::Time::server::convertForMessage(owner);
 }
 
 } // namespace utils
diff --git a/utils.hpp b/utils.hpp
index 87bc2bf..5d72155 100644
--- a/utils.hpp
+++ b/utils.hpp
@@ -108,7 +108,9 @@
 /** @brief Convert a string to enum Mode
  *
  * Convert the time mode string to enum.
- * Valid strings are "NTP", "MANUAL"
+ * Valid strings are
+ *   "xyz.openbmc_project.Time.Synchronization.Method.NTP"
+ *   "xyz.openbmc_project.Time.Synchronization.Method.Manual"
  * If it's not a valid time mode string, it means something
  * goes wrong so raise exception.
  *
@@ -121,7 +123,11 @@
 /** @brief Convert a string to enum Owner
  *
  * Convert the time owner string to enum.
- * Valid strings are "BMC", "HOST", "SPLIT", "BOTH"
+ * Valid strings are
+ *   "xyz.openbmc_project.Time.Owner.Owners.BMC"
+ *   "xyz.openbmc_project.Time.Owner.Owners.Host"
+ *   "xyz.openbmc_project.Time.Owner.Owners.Both"
+ *   "xyz.openbmc_project.Time.Owner.Owners.Split"
  * If it's not a valid time owner string, it means something
  * goes wrong so raise exception.
  *
@@ -137,7 +143,7 @@
  *
  * @return The string of the mode
  */
-const char* modeToStr(Mode mode);
+std::string modeToStr(Mode mode);
 
 /** @brief Convert a owner enum to owner string
  *
@@ -145,7 +151,7 @@
  *
  * @return The string of the owner
  */
-const char* ownerToStr(Owner owner);
+std::string ownerToStr(Owner owner);
 
 } // namespace utils
 } // namespace time