Commit 5ddfe0db authored by Bastien Nocera's avatar Bastien Nocera

all: Use g_get_real_time() when possible

Instead of a call to g_get_current_time().
parent 8271045a
......@@ -68,14 +68,12 @@ static gboolean
up_backend_changed_time_cb (UpBackend *backend)
{
UpDevice *device;
GTimeVal timeval;
//FIXME!
device = NULL;
/* reset time */
g_get_current_time (&timeval);
g_object_set (device, "update-time", (guint64) timeval.tv_sec, NULL);
g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
return TRUE;
}
......
......@@ -382,7 +382,6 @@ static gboolean
up_device_supply_refresh (UpDevice *device)
{
GObject *object;
GTimeVal timeval;
UpDeviceKind type;
gboolean ret;
......@@ -400,10 +399,8 @@ up_device_supply_refresh (UpDevice *device)
break;
}
if (ret) {
g_get_current_time (&timeval);
g_object_set (device, "update-time", (guint64) timeval.tv_sec, NULL);
}
if (ret)
g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
return ret;
}
......
......@@ -219,7 +219,6 @@ static gboolean
up_device_csr_refresh (UpDevice *device)
{
gboolean ret = FALSE;
GTimeVal timeval;
UpDeviceCsr *csr = UP_DEVICE_CSR (device);
libusb_device_handle *handle = NULL;
guint8 buf[80];
......@@ -275,8 +274,7 @@ up_device_csr_refresh (UpDevice *device)
}
/* reset time */
g_get_current_time (&timeval);
g_object_set (device, "update-time", (guint64) timeval.tv_sec, NULL);
g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
/* success */
ret = TRUE;
......
......@@ -393,7 +393,6 @@ up_device_hid_refresh (UpDevice *device)
{
gboolean set = FALSE;
gboolean ret = FALSE;
GTimeVal timeval;
guint i;
struct hiddev_event ev[64];
int rd;
......@@ -428,8 +427,7 @@ up_device_hid_refresh (UpDevice *device)
up_device_hid_fixup_state (device);
/* reset time */
g_get_current_time (&timeval);
g_object_set (device, "update-time", (guint64) timeval.tv_sec, NULL);
g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
out:
return ret;
}
......
......@@ -153,7 +153,6 @@ out:
static gboolean
up_device_idevice_refresh (UpDevice *device)
{
GTimeVal timeval;
UpDeviceIdevice *idevice = UP_DEVICE_IDEVICE (device);
lockdownd_client_t client = NULL;
plist_t dict, node;
......@@ -201,8 +200,7 @@ up_device_idevice_refresh (UpDevice *device)
plist_free (dict);
/* reset time */
g_get_current_time (&timeval);
g_object_set (device, "update-time", (guint64) timeval.tv_sec, NULL);
g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
retval = TRUE;
......
......@@ -1088,7 +1088,6 @@ static gboolean
up_device_supply_refresh (UpDevice *device)
{
gboolean ret;
GTimeVal timeval;
UpDeviceSupply *supply = UP_DEVICE_SUPPLY (device);
UpDeviceKind type;
UpDeviceState state;
......@@ -1109,10 +1108,8 @@ up_device_supply_refresh (UpDevice *device)
}
/* reset time if we got new data */
if (ret) {
g_get_current_time (&timeval);
g_object_set (device, "update-time", (guint64) timeval.tv_sec, NULL);
}
if (ret)
g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
return ret;
}
......
......@@ -48,7 +48,6 @@ up_device_unifying_refresh (UpDevice *device)
{
gboolean ret;
GError *error = NULL;
GTimeVal timeval;
HidppRefreshFlags refresh_flags;
UpDeviceState state = UP_DEVICE_STATE_UNKNOWN;
UpDeviceUnifying *unifying = UP_DEVICE_UNIFYING (device);
......@@ -95,7 +94,6 @@ up_device_unifying_refresh (UpDevice *device)
state = UP_DEVICE_STATE_UNKNOWN;
}
g_get_current_time (&timeval);
lux = hidpp_device_get_luminosity (priv->hidpp_device);
if (lux >= 0) {
g_object_set (device, "luminosity", lux, NULL);
......@@ -105,7 +103,7 @@ up_device_unifying_refresh (UpDevice *device)
"is-present", hidpp_device_is_reachable (priv->hidpp_device),
"percentage", (gdouble) hidpp_device_get_batt_percentage (priv->hidpp_device),
"state", state,
"update-time", (guint64) timeval.tv_sec,
"update-time", (guint64) g_get_real_time (),
NULL);
out:
return TRUE;
......
......@@ -388,7 +388,6 @@ static gboolean
up_device_wup_refresh (UpDevice *device)
{
gboolean ret = FALSE;
GTimeVal timeval;
gchar *data = NULL;
UpDeviceWup *wup = UP_DEVICE_WUP (device);
......@@ -407,8 +406,7 @@ up_device_wup_refresh (UpDevice *device)
}
/* reset time */
g_get_current_time (&timeval);
g_object_set (device, "update-time", (guint64) timeval.tv_sec, NULL);
g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
out:
g_free (data);
......
......@@ -399,7 +399,6 @@ static gboolean
up_apm_device_refresh(UpDevice* device)
{
UpDeviceKind type;
GTimeVal timeval;
gboolean ret;
g_object_get (device, "type", &type, NULL);
......@@ -415,10 +414,8 @@ up_apm_device_refresh(UpDevice* device)
break;
}
if (ret) {
g_get_current_time (&timeval);
g_object_set (device, "update-time", (guint64) timeval.tv_sec, NULL);
}
if (ret)
g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
return ret;
}
......@@ -578,8 +575,8 @@ static void
up_backend_init (UpBackend *backend)
{
GError *err = NULL;
GTimeVal timeval;
UpDeviceClass *device_class;
gint64 current_time;
backend->priv = UP_BACKEND_GET_PRIVATE (backend);
backend->priv->is_laptop = up_native_is_laptop();
......@@ -604,7 +601,7 @@ up_backend_init (UpBackend *backend)
}
/* setup dummy */
g_get_current_time (&timeval);
current_time = g_get_real_time ();
g_object_set (backend->priv->battery,
"type", UP_DEVICE_KIND_BATTERY,
"power-supply", TRUE,
......@@ -614,13 +611,13 @@ up_backend_init (UpBackend *backend)
"state", UP_DEVICE_STATE_UNKNOWN,
"percentage", 0.0f,
"time-to-empty", (gint64) 0,
"update-time", (guint64) timeval.tv_sec,
"update-time", (guint64) current_time,
(void*) NULL);
g_object_set (backend->priv->ac,
"type", UP_DEVICE_KIND_LINE_POWER,
"online", TRUE,
"power-supply", TRUE,
"update-time", (guint64) timeval.tv_sec,
"update-time", (guint64) current_time,
(void*) NULL);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment