summaryrefslogtreecommitdiff
path: root/src/timedate/timedated.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-10-17 01:03:39 +0200
committerLennart Poettering <lennart@poettering.net>2013-10-17 01:03:39 +0200
commit03cc26dda4cb59207fea3dd4fd1fa4608746739c (patch)
tree668d68fb3f7803ed5c7ce4a04e227bdbff030b0b /src/timedate/timedated.c
parentaacf3b483b70b9a9ff16217f6376d143cbfe4636 (diff)
timedated: expose time and NTP sync flag via the bus
This way, timedatectl can be run over the network and determine all properties correctly from the server rather than the client.
Diffstat (limited to 'src/timedate/timedated.c')
-rw-r--r--src/timedate/timedated.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 16e24c1b8..48c6a132e 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -481,6 +481,42 @@ static int property_get_rtc_time(
return 1;
}
+static int property_get_time(
+ sd_bus *bus,
+ const char *path,
+ const char *interface,
+ const char *property,
+ sd_bus_message *reply,
+ sd_bus_error *error,
+ void *userdata) {
+
+ int r;
+
+ r = sd_bus_message_append(reply, "t", now(CLOCK_REALTIME));
+ if (r < 0)
+ return r;
+
+ return 1;
+}
+
+static int property_get_ntp_sync(
+ sd_bus *bus,
+ const char *path,
+ const char *interface,
+ const char *property,
+ sd_bus_message *reply,
+ sd_bus_error *error,
+ void *userdata) {
+
+ int r;
+
+ r = sd_bus_message_append(reply, "b", ntp_synced());
+ if (r < 0)
+ return r;
+
+ return 1;
+}
+
static int method_set_timezone(sd_bus *bus, sd_bus_message *m, void *userdata) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
Context *c = userdata;
@@ -735,6 +771,8 @@ static const sd_bus_vtable timedate_vtable[] = {
SD_BUS_PROPERTY("LocalRTC", "b", NULL, offsetof(Context, local_rtc), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("CanNTP", "b", bus_property_get_tristate, offsetof(Context, can_ntp), 0),
SD_BUS_PROPERTY("NTP", "b", bus_property_get_tristate, offsetof(Context, use_ntp), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
+ SD_BUS_PROPERTY("NTPSynchronized", "b", property_get_ntp_sync, 0, 0),
+ SD_BUS_PROPERTY("TimeUSec", "t", property_get_time, 0, 0),
SD_BUS_PROPERTY("RTCTimeUSec", "t", property_get_rtc_time, 0, 0),
SD_BUS_METHOD("SetTime", "xbb", NULL, method_set_time, 0),
SD_BUS_METHOD("SetTimezone", "sb", NULL, method_set_timezone, 0),