#include <stdlib.h>
#include <glib.h>
#include <glib-unix.h>
+#include <vconf.h>
#include "ttd-log.h"
#include "ttd-cloud-conn-state.h"
GMainLoop *mainloop;
GThreadPool *thread_pool;
worker_interface_h worker_itf_h;
+ bool is_time_set;
} ttd_data;
static gboolean __daemon_job_handler(gpointer data);
return func;
}
+
static gboolean __daemon_job_handler(gpointer data)
{
ttd_data *d_data = data;
return FALSE;
}
+static void __time_changed(keynode_t *node, void *data)
+{
+ ttd_data *d_data = data;
+ long long current_time;
+ _D("System time is changed");
+
+ current_time = common_get_epoch_time();
+
+ if ((current_time * 1000000) > EPOCH_TIME_REF && !d_data->is_time_set) {
+ /* Do something need correct time after here */
+ _D("We assume that system time is correct, because current[%lld] is bigger than 2018-05-17", current_time * 1000000);
+ d_data->is_time_set = true;
+ g_idle_add(__do_device_register, d_data);
+ }
+}
+
int main(int argc, char* argv[])
{
ttd_data *d_data = NULL;
g_unix_signal_add(SIGINT, _handle_sigint, d_data);
g_unix_signal_add(SIGTERM, _handle_sigterm, d_data);
+ if (vconf_notify_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED, __time_changed, d_data) < 0) {
+ _E("Failed to set vconf key changed");
+ }
+
ttd_queue_init();
ttd_conn_mgr_init();
ttd_http_init();
_D("[delay] start-to-ready - %.3lf(ms)",
(double)(_get_monotonic_time() - start)/1000);
- g_idle_add(__do_device_register, d_data);
-
g_main_loop_run(d_data->mainloop);
g_main_loop_unref(d_data->mainloop);