}
}
- if (new_state == CONNMAN_SERVICE_STATE_ONLINE)
- __connman_timeserver_sync(service);
-
if (new_state == CONNMAN_SERVICE_STATE_IDLE) {
connman_bool_t reconnect;
dns_changed(service);
domain_changed(service);
- __connman_timeserver_stop();
-
__connman_notifier_disconnect(service->type);
/*
NULL);
}
-int __connman_timeserver_sync(struct connman_service *service)
+int __connman_timeserver_sync(struct connman_service *default_service)
{
- char **nameservers = NULL;
+ struct connman_service *service;
+ char **nameservers;
int i;
+ if (default_service != NULL)
+ service = default_service;
+ else
+ service = __connman_service_get_default();
+
+ if (service == NULL)
+ return -EINVAL;
+
DBG("service %p", service);
i = __connman_service_get_index(service);
return servers;
}
+static void default_changed(struct connman_service *default_service)
+{
+ DBG("");
+
+ if (default_service != NULL)
+ __connman_timeserver_sync(default_service);
+ else
+ __connman_timeserver_stop();
+}
+
+static struct connman_notifier timeserver_notifier = {
+ .name = "timeserver",
+ .default_changed = default_changed,
+};
+
int __connman_timeserver_init(void)
{
DBG("");
+ connman_notifier_register(×erver_notifier);
+
return 0;
}
void __connman_timeserver_cleanup(void)
{
DBG("");
+
+ connman_notifier_unregister(×erver_notifier);
}