summaryrefslogtreecommitdiff
authorJulien Danjou <julien@danjou.info>2012-10-30 14:12:16 (GMT)
committer Richard Hughes <richard@hughsie.com>2012-10-30 20:03:54 (GMT)
commit2f03ad62b520fc5c02e3ff9eb5bffc4275eb88dc (patch) (side-by-side diff)
treeac3251d364ecee90a11e60d6fc36c676777efb1d
parentfd32f0be0f16b9420bdecd57d4a0cdcfc3882960 (diff)
downloadupower-2f03ad62b520fc5c02e3ff9eb5bffc4275eb88dc.zip
upower-2f03ad62b520fc5c02e3ff9eb5bffc4275eb88dc.tar.gz
Add luminosity property
This adds the luminosity property for devices able to recharge using light. Signed-off-by: Julien Danjou <julien@danjou.info> Signed-off-by: Richard Hughes <richard@hughsie.com>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libupower-glib/up-device.c27
-rw-r--r--src/org.freedesktop.UPower.Device.xml10
-rw-r--r--src/up-device.c16
3 files changed, 53 insertions, 0 deletions
diff --git a/libupower-glib/up-device.c b/libupower-glib/up-device.c
index ce826c6..bf9f758 100644
--- a/libupower-glib/up-device.c
+++ b/libupower-glib/up-device.c
@@ -81,6 +81,7 @@ struct _UpDevicePrivate
gdouble energy_full_design; /* Watt Hours */
gdouble energy_rate; /* Watts */
gdouble voltage; /* Volts */
+ gdouble luminosity; /* Lux */
gint64 time_to_empty; /* seconds */
gint64 time_to_full; /* seconds */
gdouble percentage; /* percent */
@@ -112,6 +113,7 @@ enum {
PROP_ENERGY_FULL_DESIGN,
PROP_ENERGY_RATE,
PROP_VOLTAGE,
+ PROP_LUMINOSITY,
PROP_TIME_TO_EMPTY,
PROP_TIME_TO_FULL,
PROP_PERCENTAGE,
@@ -195,6 +197,8 @@ up_device_collect_props_cb (const char *key, const GValue *value, UpDevice *devi
device->priv->energy_rate = g_value_get_double (value);
} else if (g_strcmp0 (key, "Voltage") == 0) {
device->priv->voltage = g_value_get_double (value);
+ } else if (g_strcmp0 (key, "Luminosity") == 0) {
+ device->priv->luminosity = g_value_get_double (value);
} else if (g_strcmp0 (key, "TimeToFull") == 0) {
device->priv->time_to_full = g_value_get_int64 (value);
} else if (g_strcmp0 (key, "TimeToEmpty") == 0) {
@@ -481,6 +485,10 @@ up_device_to_text (UpDevice *device)
if (device->priv->voltage > 0)
g_string_append_printf (string, " voltage: %g V\n", device->priv->voltage);
}
+ if (device->priv->kind == UP_DEVICE_KIND_KEYBOARD) {
+ if (device->priv->luminosity > 0)
+ g_string_append_printf (string, " luminosity: %g lx\n", device->priv->luminosity);
+ }
if (device->priv->kind == UP_DEVICE_KIND_BATTERY ||
device->priv->kind == UP_DEVICE_KIND_UPS) {
if (device->priv->time_to_full > 0) {
@@ -807,6 +815,9 @@ up_device_set_property (GObject *object, guint prop_id, const GValue *value, GPa
case PROP_VOLTAGE:
device->priv->voltage = g_value_get_double (value);
break;
+ case PROP_LUMINOSITY:
+ device->priv->luminosity = g_value_get_double (value);
+ break;
case PROP_TIME_TO_EMPTY:
device->priv->time_to_empty = g_value_get_int64 (value);
break;
@@ -908,6 +919,9 @@ up_device_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe
case PROP_VOLTAGE:
g_value_set_double (value, device->priv->voltage);
break;
+ case PROP_LUMINOSITY:
+ g_value_set_double (value, device->priv->luminosity);
+ break;
case PROP_TIME_TO_EMPTY:
g_value_set_int64 (value, device->priv->time_to_empty);
break;
@@ -1234,6 +1248,19 @@ up_device_class_init (UpDeviceClass *klass)
g_param_spec_double ("voltage", NULL, NULL,
0.0, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
+
+ /**
+ * UpDevice:luminosity:
+ *
+ * The current luminosity of the device.
+ *
+ * Since: 0.9.19
+ **/
+ g_object_class_install_property (object_class,
+ PROP_LUMINOSITY,
+ g_param_spec_double ("luminosity", NULL, NULL,
+ 0.0, G_MAXDOUBLE, 0.0,
+ G_PARAM_READWRITE));
/**
* UpDevice:time-to-empty:
*
diff --git a/src/org.freedesktop.UPower.Device.xml b/src/org.freedesktop.UPower.Device.xml
index 7c9a65b..04ea4da 100644
--- a/src/org.freedesktop.UPower.Device.xml
+++ b/src/org.freedesktop.UPower.Device.xml
@@ -482,6 +482,16 @@ method return sender=:1.386 -> dest=:1.477 reply_serial=2
</doc:doc>
</property>
+ <property name="Luminosity" type="d" access="read">
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ Luminosity being recorded by the meter.
+ </doc:para>
+ </doc:description>
+ </doc:doc>
+ </property>
+
<property name="TimeToEmpty" type="x" access="read">
<doc:doc>
<doc:description>
diff --git a/src/up-device.c b/src/up-device.c
index 3591125..efb8d72 100644
--- a/src/up-device.c
+++ b/src/up-device.c
@@ -73,6 +73,7 @@ struct UpDevicePrivate
gdouble energy_full_design; /* Watt Hours */
gdouble energy_rate; /* Watts */
gdouble voltage; /* Volts */
+ gdouble luminosity; /* Lux */
gint64 time_to_empty; /* seconds */
gint64 time_to_full; /* seconds */
gdouble percentage; /* percent */
@@ -105,6 +106,7 @@ enum {
PROP_ENERGY_FULL_DESIGN,
PROP_ENERGY_RATE,
PROP_VOLTAGE,
+ PROP_LUMINOSITY,
PROP_TIME_TO_EMPTY,
PROP_TIME_TO_FULL,
PROP_PERCENTAGE,
@@ -235,6 +237,9 @@ up_device_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe
case PROP_VOLTAGE:
g_value_set_double (value, device->priv->voltage);
break;
+ case PROP_LUMINOSITY:
+ g_value_set_double (value, device->priv->luminosity);
+ break;
case PROP_TIME_TO_EMPTY:
g_value_set_int64 (value, device->priv->time_to_empty);
break;
@@ -335,6 +340,9 @@ up_device_set_property (GObject *object, guint prop_id, const GValue *value, GPa
case PROP_VOLTAGE:
device->priv->voltage = g_value_get_double (value);
break;
+ case PROP_LUMINOSITY:
+ device->priv->luminosity = g_value_get_double (value);
+ break;
case PROP_TIME_TO_EMPTY:
device->priv->time_to_empty = g_value_get_int64 (value);
break;
@@ -1130,6 +1138,14 @@ up_device_class_init (UpDeviceClass *klass)
0.0, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
/**
+ * UpDevice:luminosity:
+ */
+ g_object_class_install_property (object_class,
+ PROP_LUMINOSITY,
+ g_param_spec_double ("luminosity", NULL, NULL,
+ 0.0, G_MAXDOUBLE, 0.0,
+ G_PARAM_READWRITE));
+ /**
* UpDevice:time-to-empty:
*/
g_object_class_install_property (object_class,