Commit graph

60 commits

Author SHA1 Message Date
Kate Hsuan
0f57b6bf73 Drop the incorrect "since version" and mark the capacity_level property as deprecated
Fix: 09ada72 (dbus: org.freedesktop.UPower.Device: deprecate CapacityLevel property)
2025-12-17 16:19:55 +08:00
Kate Hsuan
09ada726f7 dbus: org.freedesktop.UPower.Device: deprecate CapacityLevel property
This property is duplicated from BatteryLevel and confuses the user.
2025-11-25 14:33:55 +08:00
Sicelo A. Mhlongo
240fa30ab5 lib: up-device: Expose CapacityLevel, VoltageMinDesign, and VoltageMaxDesign
For supplies that report the voltage_min_design, voltage_max_design, and
capacity_level attributes on sysfs, expose them via libupower for possible
use by clients.

Related: #301

Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
2025-04-16 15:08:39 +08:00
Kate Hsuan
bab81e5e44 Fix spelling issues with codespell 2025-01-08 14:01:34 +08:00
Jelle van der Waa
faa6d8a6b3 dbus: show charge-threshold-* status as yes/no
Previously shown as a boolean integer and not properly aligned.
2024-10-11 16:40:13 +02:00
Jelle van der Waa
3df2599629 dbus: Define ChargeThresholdEnabled and ChargeThresholdSupported properties
ChargeThresholdSupported property is used to show if the battery supports
Charging threshold feature. ChargeThresholdEnabled is used to show the
configuration (enabled/disabled) status of the feature.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
2024-08-02 13:58:48 +08:00
Jelle van der Waa
a12f7d7eef dbus: Define ChargeStartThreshold and ChargeEndThreshold properties
Define dbus interface for ChargeStartThreshold and ChargeEndThreshold.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
2024-08-02 13:58:48 +08:00
Bastien Nocera
a0c7b16aff lib: Avoid possible crash on daemon restart
#0  0x00007f40eb3e43a6 g_type_check_class_is_a (libgobject-2.0.so.0 + 0x3b3a6)
 #1  0x00007f40eb3c5253 g_object_class_find_property (libgobject-2.0.so.0 + 0x1c253)
 #2  0x00007f40bffcc668 up_device_changed_cb (libupower-glib.so.3 + 0xc668)
 #3  0x00007f40eb3bd4ea g_closure_invoke (libgobject-2.0.so.0 + 0x144ea)
 #4  0x00007f40eb3ebe16 signal_emit_unlocked_R.isra.0 (libgobject-2.0.so.0 + 0x42e16)
 #5  0x00007f40eb3dccbd g_signal_emit_valist (libgobject-2.0.so.0 + 0x33cbd)
 #6  0x00007f40eb3dcf33 g_signal_emit (libgobject-2.0.so.0 + 0x33f33)
 #7  0x00007f40eb3c86b4 g_object_dispatch_properties_changed.lto_priv.0 (libgobject-2.0.so.0 + 0x1f6b4)
 #8  0x00007f40eb3cef1f g_object_notify (libgobject-2.0.so.0 + 0x25f1f)
 #9  0x00007f40bffd5f1c up_exported_device_proxy_g_properties_changed (libupower-glib.so.3 + 0x15f1c)
 #10 0x00007f40eb3bd4ea g_closure_invoke (libgobject-2.0.so.0 + 0x144ea)
 #11 0x00007f40eb3ec315 signal_emit_unlocked_R.isra.0 (libgobject-2.0.so.0 + 0x43315)
 #12 0x00007f40eb3dccbd g_signal_emit_valist (libgobject-2.0.so.0 + 0x33cbd)
 #13 0x00007f40eb3dcf33 g_signal_emit (libgobject-2.0.so.0 + 0x33f33)
 #14 0x00007f40eb526fff process_get_all_reply (libgio-2.0.so.0 + 0x11dfff)
 #15 0x00007f40eb52a749 on_name_owner_changed_get_all_cb (libgio-2.0.so.0 + 0x121749)
2023-07-03 17:21:17 +02:00
Bastien Nocera
d0ebbe32bb device: Only handle Refresh() method if in debug mode
The Refresh D-Bus method could be used by clients to force re-reading
the state of batteries in the upower backends. This is not needed as
all the backends should be sending events when their states changes,
removing the need for an explicit refresh.

This is also a potential security problem if applications keep on
refreshing their data.

We now only allow access to the Refresh() method if the daemon was
started in debugging mode. This should make it clearer that it is a
debug tool.

Also remove a mention of the never implemented refresh-power-source
polkit authorisation.
2022-04-19 15:27:36 +02:00
Bastien Nocera
20aceb0e8c lib: Add API to access ChargeCyles D-Bus property 2021-09-13 12:55:36 +02:00
Marijn Suijten
d86c637f31 lib: Invert percentage conditional in device_to_text
Almost every device kind except line power and invalid (>= last) carry a
valid percentage property. By inverting this conditional not every new
device needs to be added explicitly to this already long and lacking
chain (PDA and MONITOR were already missing).
2021-02-02 18:15:47 +01:00
Bastien Nocera
67eefa17dd lib: Add "Touchpad" device type 2020-12-16 13:09:04 +01:00
Bastien Nocera
72b85b8c13 lib: Add "Pen" device type
So we can track the battery information for powered tablet pens, rather
than labelling them as tablets.
2019-10-24 12:50:26 +02:00
Christian Kellner
9b7ce3dea3 Replace use of G_TYPE_INSTANCE_GET_PRIVATE
G_TYPE_INSTANCE_GET_PRIVATE has been deprecated since glib version
2.58 and should be replaced with the xxx_get_instance_private (obj)
which is generated by G_ADD_PRIVATE.
2019-02-21 12:09:06 +01:00
Christian Kellner
8da188b303 Replace use of deprecated g_type_class_add_private
Use G_DEFINE_TYPE_WITH_CODE (..., G_PRIVATE_ADD (...)) instead of
the (deprecated since glib 2.58) function g_type_class_add_private
to add a private structure for a type.
Bump the minimal required version of glib to 2.38.0, the version
where G_PRIVATE_ADD was added.
2019-02-21 12:07:59 +01:00
Guido Günther
409b2ccc89 lib: Use @see_also instead of "See also"
This ensures consistent rendering.

See https://developer.gnome.org/gtk-doc-manual/stable/documenting_sections.html.en
2018-09-30 19:19:02 +02:00
Bastien Nocera
0e6cc20ca9 lib: Mention that battery level is preferred when present
And print "should be ignored" next to the percentage.

https://bugs.freedesktop.org/show_bug.cgi?id=97484
2018-04-19 03:40:40 +02:00
Bastien Nocera
a3c58db735 lib: Simplify resource destruction
Use g_clear_pointer() and g_clear_object() when possible.
2018-04-18 12:45:51 +02:00
Bastien Nocera
41bce28447 lib: Fix warnings when D-Bus related properties change
When UPower would appear, or disappear, we'd get warnings like:
g_object_notify: object class 'UpDevice' has no property named 'g-name-owner'
or:
g_object_notify: object class 'UpClient' has no property named 'g-name-owner'

This was caused by the property proxying added in 7531dbd and 28438a7
being too lax about which properties it tried to proxy, which included
ones that didn't apply to the object types in question.

See https://bugs.freedesktop.org/show_bug.cgi?id=43001

https://bugs.freedesktop.org/show_bug.cgi?id=102350
2018-03-02 17:47:14 +01:00
Bastien Nocera
4753a8bc5a lib: Fix API docs for *-level properties
One was referencing a non-existent enum member, the other was
missing a link altogether.
2017-09-08 06:55:54 +02:00
Bastien Nocera
5ccd4fe959 lib: Add UP_DEVICE_KIND_GAMING_INPUT for gaming devices
Joypads, joysticks, dance mats, paddles, Wiimotes, steering wheels,
tractor cabin simulators, pedals, yokes, breathing controllers, and,
hmm, etc.

https://bugs.freedesktop.org/show_bug.cgi?id=102493
2017-08-31 16:21:18 +02:00
Bastien Nocera
499d05b837 all: Add BatteryLevel property
Export approximate battery levels that devices can use, exported by
the kernel as POWER_SUPPLY_CAPACITY_LEVEL_* values.

This avoids bizarrely accurate values showing up in UIs when we only
have ok/warning levels of accuracy in some cases.

https://bugs.freedesktop.org/show_bug.cgi?id=100359
2017-04-06 16:33:38 +02:00
Bastien Nocera
4b03777c54 build: Fix -Wformat-y2k compilation errors
The strings are user visible strings, so this isn't a y2k problem.
2016-06-08 14:14:24 +02:00
Cosimo Cecchi
c108a8e8a4 Share generated code between daemon and library
Since we use the same GDBus code in libupower-glib and the daemon,
auto-generate a private library that can be used by both.
2015-07-29 13:38:13 +01:00
Vlad Orlov
2510148b16 lib: Fix crash on uninitialized variant
Initialize the GVariant* pointers, so that they aren't uninitialized when
jumping to "out:" and unref'ing them.

https://bugs.freedesktop.org/show_bug.cgi?id=89476
https://bugs.debian.org/774546
https://bugs.launchpad.net/ubuntu-mate/+bug/1428337
2015-03-13 13:17:31 +01:00
Richard Hughes
969c97426a Do not print a critical warning when misusing up_device_set_object_path_sync() 2014-05-20 13:25:17 +01:00
Bastien Nocera
aa62f6a15c lib: Fix possible warning when type changes
UpDevice on the daemon side has a "type" property, but the
libupower-glib object has a "kind" type instead. Translate that.
2013-10-17 23:20:22 +02:00
Bastien Nocera
3063bdaf44 lib: Fix compile-time warning 2013-10-17 14:51:07 +02:00
Bastien Nocera
0010e93251 all: Remove *changed signals
Now that we send out PropertiesChanged signals (on the daemon side)
and "notify" signals (on the client side), there's no need for the
all encompassing DeviceChanged and Changed signals.

They would have woken up any client, even if they were not interested
in receiving the signals.
2013-10-17 14:25:25 +02:00
Bastien Nocera
595d72f6b6 lib: Proxy notify changes from UpDevice glue 2013-10-17 12:37:29 +02:00
Bastien Nocera
a76eaeddb9 lib: Trim properties when printing the display device 2013-10-17 00:45:26 +02:00
Bastien Nocera
85ce906bf2 lib: Fix compilation 2013-10-15 16:04:21 +02:00
Bastien Nocera
677f2f4da7 lib: Use slices to allocate cached properties
Saves on memory fragmentation.
2013-10-15 15:51:55 +02:00
Bastien Nocera
4079ba8272 lib: Print property name when cached property doesn't exist 2013-10-15 15:51:00 +02:00
Bastien Nocera
d7d215a4b6 lib: Cache property values correctly
This is cleaner.
2013-10-15 15:50:31 +02:00
Bastien Nocera
d2484d4ec1 lib: Add support for the IconName property 2013-10-14 11:06:53 +02:00
Bastien Nocera
e0fb5078bd lib: up_device_to_text() won't work for fake devices
For now, up_device_to_text() won't work for devices that aren't
backed by a UPower device.
2013-10-14 10:42:56 +02:00
Bastien Nocera
869050d699 lib: Make it possible to create local UpDevices
gnome-settings-daemon creates a composite UpDevice that's not
backed by any real D-Bus object in UPower, so we shouldn't
try and poke the inexistant proxy in this case.

We'll cache the properties that the caller sets in this case,
but will not support sending back default/unset values.
2013-10-14 10:42:56 +02:00
Bastien Nocera
9c27c42a99 lib: Fix alignment of "online" in device dump 2013-10-14 10:42:56 +02:00
Bastien Nocera
493c2192a2 lib: Add warning-level device property 2013-10-14 10:42:56 +02:00
Bastien Nocera
b989cad776 lib: Port UpDevice to GDBus
Using the new proxy.
2013-10-14 10:42:55 +02:00
Bastien Nocera
c590354d0a lib: No need to set private members to NULL
GObject already makes sure of that for us.
2013-10-14 10:42:55 +02:00
Bastien Nocera
c842f1a53e Remove obsolete battery recall properties
The recalls for that broken batch of Sony batteries dates back from
2006. All the batteries that could have been recalled have now
been recalled, and somebody particularly interested in supporting
them can match the batteries using the old rules file, in a
user session or a separate daemon.
2013-10-14 10:42:55 +02:00
Bastien Nocera
ad7e809d4d lib: Simplify _new() functions
No need to use a temporary variable.
2013-10-14 10:37:03 +02:00
Bastien Nocera
66da41ceac lib: Add missing "element-type" introspection metadata
https://bugs.freedesktop.org/show_bug.cgi?id=55419
2013-10-14 09:58:22 +02:00
Martin Pitt
2b10e20262 Make GetHistory() array order consistent
When requesting fewer history elements than we actually have, fix the
interpolation loop to not reverse the returned elements; this already does not
happen if we request more elements than available, which led to the returned
list order depending on the history size.

Now the first array element is always the most recent one. Update documentation
accordingly.

Add test case to reproduce the problem. We now add three sample points to be
able to request a subset and still assert its correct order, and make the
charge values be further apart to ensure correct interpolation.

https://bugs.freedesktop.org/show_bug.cgi?id=68384
2013-08-29 10:44:26 +02:00
Seth Forshee
eaf86482a9 Add temperature property for batteries
Linux's power_supply class supports a temperature attribute, which is
supported by many battery drivers. Add a new property to export this
information and support this property in Linux.

https://bugs.freedesktop.org/show_bug.cgi?id=68338

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Martin Pitt <martinpitt@gnome.org>
2013-08-23 08:45:57 +02:00
Julien Danjou
2f03ad62b5 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>
2012-10-30 20:03:54 +00:00
Martin Pitt
2b216e7db3 Selectively disable warnings for deprecated GValueArray
GLib 2.33 and further deprecates GValueArray. However, we still need it as long
as we are using dbus-glib, so selectively disable the deprecation warnings for
the three functions that use GValueArray. This allows us to continue to build
with -Werror.
2012-06-14 12:52:11 +02:00
Richard Hughes
ed34986e08 libupower-glib: Reject invalid object paths to avoid asserting libdbus 2010-11-01 09:52:07 +00:00