summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2013-10-28 14:38:37 +0100
committerBastien Nocera <hadess@hadess.net>2013-10-28 15:15:02 +0100
commit03591e6e05e813e5cc8b1116dfaf6722ff942603 (patch)
treeebde7327990a7eb1e16145658ec36783b5943206
parentd1032c562a1c61d1478d3a000d9ddf3144472251 (diff)
linux: Switch non-battery devices to use the new daemon poll
Next up is doing this for batteries, which need to switch between a normal/slow poll to a faster one when the battery state is unknown.
-rw-r--r--src/linux/up-device-supply.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index efacc71..4a0c72d 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -1054,6 +1054,10 @@ up_device_supply_coldplug (UpDevice *device)
/* set the value */
g_object_set (device, "type", type, NULL);
+ if (type != UP_DEVICE_KIND_LINE_POWER &&
+ type != UP_DEVICE_KIND_BATTERY)
+ up_daemon_start_poll (G_OBJECT (device), (GSourceFunc) up_device_supply_poll_battery_normal);
+
/* coldplug values */
ret = up_device_supply_refresh (device);
out:
@@ -1136,9 +1140,7 @@ up_device_supply_refresh (UpDevice *device)
up_device_supply_setup_poll (device, state);
break;
default:
- up_device_supply_disable_poll (device);
ret = up_device_supply_refresh_device (supply, &state);
- up_device_supply_setup_poll (device, state);
break;
}
@@ -1174,6 +1176,23 @@ up_device_supply_init (UpDeviceSupply *supply)
}
/**
+ * up_device_supply_dispose:
+ **/
+static void
+up_device_supply_dispose (GObject *object)
+{
+ UpDeviceKind type;
+
+ /* Disable poll for non-batteries */
+ g_object_get (object, "type", &type, NULL);
+ if (type != UP_DEVICE_KIND_LINE_POWER &&
+ type != UP_DEVICE_KIND_BATTERY)
+ up_daemon_stop_poll (object);
+
+ G_OBJECT_CLASS (up_device_supply_parent_class)->dispose (object);
+}
+
+/**
* up_device_supply_finalize:
**/
static void
@@ -1205,6 +1224,7 @@ up_device_supply_class_init (UpDeviceSupplyClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
UpDeviceClass *device_class = UP_DEVICE_CLASS (klass);
+ object_class->dispose = up_device_supply_dispose;
object_class->finalize = up_device_supply_finalize;
device_class->get_on_battery = up_device_supply_get_on_battery;
device_class->get_online = up_device_supply_get_online;