summaryrefslogtreecommitdiff
path: root/src/clock.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2011-04-18 13:08:41 -0700
committerMarcel Holtmann <marcel@holtmann.org>2011-04-18 13:08:41 -0700
commitc797594a2bf5720a40261530255d5e403ccbb4a9 (patch)
treea1be28b07786f95f18df61187091190d5c076d33 /src/clock.c
parente8797320e8cf680e9c84b5462f0ba9c58a05b46e (diff)
downloadconnman-c797594a2bf5720a40261530255d5e403ccbb4a9.tar.gz
connman-c797594a2bf5720a40261530255d5e403ccbb4a9.tar.bz2
connman-c797594a2bf5720a40261530255d5e403ccbb4a9.zip
clock: Add support for retrieving time and timezone properties
Diffstat (limited to 'src/clock.c')
-rw-r--r--src/clock.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/clock.c b/src/clock.c
index 9cad0299..36440f38 100644
--- a/src/clock.c
+++ b/src/clock.c
@@ -23,6 +23,8 @@
#include <config.h>
#endif
+#include <sys/time.h>
+
#include <gdbus.h>
#include "connman.h"
@@ -42,6 +44,7 @@ enum timezone_updates {
static enum time_updates time_updates_config = TIME_UPDATES_AUTO;
static enum timezone_updates timezone_updates_config = TIMEZONE_UPDATES_AUTO;
+static char *timezone_config = NULL;
static char **timeservers_config = NULL;
static const char *time_updates2string(enum time_updates value)
@@ -110,6 +113,7 @@ static DBusMessage *get_properties(DBusConnection *conn,
{
DBusMessage *reply;
DBusMessageIter array, dict;
+ struct timeval tv;
const char *str;
DBG("conn %p", conn);
@@ -122,11 +126,22 @@ static DBusMessage *get_properties(DBusConnection *conn,
connman_dbus_dict_open(&array, &dict);
+ if (gettimeofday(&tv, NULL) == 0) {
+ dbus_uint64_t val = tv.tv_sec;
+
+ connman_dbus_dict_append_basic(&dict, "Time",
+ DBUS_TYPE_UINT64, &val);
+ }
+
str = time_updates2string(time_updates_config);
if (str != NULL)
connman_dbus_dict_append_basic(&dict, "TimeUpdates",
DBUS_TYPE_STRING, &str);
+ if (timezone_config != NULL)
+ connman_dbus_dict_append_basic(&dict, "Timezone",
+ DBUS_TYPE_STRING, &timezone_config);
+
str = timezone_updates2string(timezone_updates_config);
if (str != NULL)
connman_dbus_dict_append_basic(&dict, "TimezoneUpdates",
@@ -264,6 +279,8 @@ int __connman_clock_init(void)
if (connection == NULL)
return -1;
+ timezone_config = __connman_timezone_lookup();
+
g_dbus_register_interface(connection, CONNMAN_MANAGER_PATH,
CONNMAN_CLOCK_INTERFACE,
clock_methods, clock_signals,
@@ -284,5 +301,6 @@ void __connman_clock_cleanup(void)
dbus_connection_unref(connection);
+ g_free(timezone_config);
g_strfreev(timeservers_config);
}