summaryrefslogtreecommitdiff
path: root/src/linux/up-device-unifying.c
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-08-19 11:35:33 +0200
committerMartin Pitt <martinpitt@gnome.org>2013-09-03 08:31:27 +0200
commita8028628213cca67adf556f1fedf86233b4111ad (patch)
treebc294da2b3785bda9359cbe1515611eab85d5799 /src/linux/up-device-unifying.c
parent88398cf75b0f98427aa35cca4c6e0aa43e3e7e1a (diff)
downloadupower-a8028628213cca67adf556f1fedf86233b4111ad.tar.gz
hidpp: fix properties for unreachable devices (v2)
This includes "is-present" and "state" (which will be marked "unknown"). "percentage" is not touched since it is still an indication of the battery level, changing it to zero is not helpful. Previously, properties were never updated because the refresh would fail when the battery refresh request failed. - v2: fix invalid return value when an invalid parameter is passed to hidpp_device_is_reachable. Signed-off-by: Peter Wu <lekensteyn@gmail.com>
Diffstat (limited to 'src/linux/up-device-unifying.c')
-rw-r--r--src/linux/up-device-unifying.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/linux/up-device-unifying.c b/src/linux/up-device-unifying.c
index 005a132..989ac48 100644
--- a/src/linux/up-device-unifying.c
+++ b/src/linux/up-device-unifying.c
@@ -73,11 +73,9 @@ up_device_unifying_refresh (UpDevice *device)
refresh_flags,
&error);
if (!ret) {
- if (error) {
- g_warning ("failed to coldplug unifying device: %s",
- error->message);
- g_error_free (error);
- }
+ g_warning ("failed to coldplug unifying device: %s",
+ error->message);
+ g_error_free (error);
goto out;
}
switch (hidpp_device_get_batt_status (priv->hidpp_device)) {
@@ -93,9 +91,15 @@ up_device_unifying_refresh (UpDevice *device)
default:
break;
}
+
+ /* if a device is unreachable, some known values do not make sense */
+ if (!hidpp_device_is_reachable (priv->hidpp_device)) {
+ state = UP_DEVICE_STATE_UNKNOWN;
+ }
+
g_get_current_time (&timeval);
g_object_set (device,
- "is-present", hidpp_device_get_version (priv->hidpp_device) > 0,
+ "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,
@@ -245,11 +249,9 @@ up_device_unifying_coldplug (UpDevice *device)
HIDPP_REFRESH_FLAGS_MODEL,
&error);
if (!ret) {
- if (error) {
- g_warning ("failed to coldplug unifying device: %s",
- error->message);
- g_error_free (error);
- }
+ g_warning ("failed to coldplug unifying device: %s",
+ error->message);
+ g_error_free (error);
goto out;
}