-static int status_property(const char *name, DBusMessageIter *iter, StatusInfo *i) {
- assert(name);
- assert(iter);
-
- switch (dbus_message_iter_get_arg_type(iter)) {
-
- case DBUS_TYPE_STRING: {
- const char *s;
-
- dbus_message_iter_get_basic(iter, &s);
- if (!isempty(s)) {
- if (streq(name, "Timezone"))
- i->timezone = s;
- }
- break;
- }
-
- case DBUS_TYPE_BOOLEAN: {
- dbus_bool_t b;
-
- dbus_message_iter_get_basic(iter, &b);
- if (streq(name, "LocalRTC"))
- i->local_rtc = b;
- else if (streq(name, "NTP"))
- i->ntp = b;
- }
- }
-
- return 0;
-}
-
-static int show_status(DBusConnection *bus, char **args, unsigned n) {
- _cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
- const char *interface = "";
+static int show_status(sd_bus *bus, char **args, unsigned n) {
+ StatusInfo info = {};
+ static const struct bus_properties_map map[] = {
+ { "Timezone", "s", NULL, offsetof(StatusInfo, timezone) },
+ { "LocalRTC", "b", NULL, offsetof(StatusInfo, rtc_local) },
+ { "NTP", "b", NULL, offsetof(StatusInfo, ntp_enabled) },
+ { "CanNTP", "b", NULL, offsetof(StatusInfo, ntp_capable) },
+ { "NTPSynchronized", "b", NULL, offsetof(StatusInfo, ntp_synced) },
+ { "TimeUSec", "t", NULL, offsetof(StatusInfo, time) },
+ { "RTCTimeUSec", "t", NULL, offsetof(StatusInfo, rtc_time) },
+ {}
+ };