Commit graph

156 commits

Author SHA1 Message Date
Sicelo A. Mhlongo
f6e63cfc40 upower: deprecate luminosity property
Since d2053eff ("linux: Remove user-space support for Logitech Unifying
devices"), the luminosity property is no longer in use and no code for it
exists except in the lib. Deprecate and eventually drop it.
2025-12-17 16:46:28 +08:00
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
Kate Hsuan
2678cb00d4 Fix trailing white space and end of file 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
Jelle van der Waa
1e58e8218a Stop using deprecated g_get_current_time
g_get_current_time was deprecated in 2.62 and can be directly replaced with
g_get_real_time.
2024-03-13 08:59:46 +01:00
Jelle van der Waa
17c14cc63f Revert "all: Remove Lid handling"
This reverts commit 07565ef6a1.

In the current systemd stable release 255 org.freedesktop.login1 does
not emit a LidisClosed event, this has added in systemd `main` and will
be availble in the next release.

As GNOME control panel still uses UPower's `LidIsclosed` property and
many other DE's such as Xfce/LXQt/Deepin as well revert this until the
systemd changes are available in all Distributions.

https://github.com/systemd/systemd/pull/30706

Resolve: https://gitlab.freedesktop.org/upower/upower/-/issues/260
2024-01-26 14:57:27 +00:00
Jelle van der Waa
18d550a555 Revert "lib: Remove deprecated up_client_get_devices()"
This reverts commit 6766602954.

Removing this and renaming up_client_get_devices2 to
up_client_get_devices means consumers have to support three cases to
support older UPower versions. So for example GNOME Control center now
uses up_client_get_devices2 and would have to now check if UPower
version > 0.92.
2024-01-26 10:20:50 +01:00
Bastien Nocera
6766602954 lib: Remove deprecated up_client_get_devices()
And rename up_client_get_devices2() to up_client_get_devices().
2023-07-06 11:15:02 +02:00
Bastien Nocera
07565ef6a1 all: Remove Lid handling
It is now handled solely in logind to take power management decisions,
and in the compositor for making decisions related to available
displays.

See:
https://www.freedesktop.org/software/systemd/man/org.freedesktop.login1.html
2023-07-06 11:09:42 +02: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
Benjamin Berg
9058d45685 Remove Wakeups API
The API relied on /proc/timer_stats which has been removed from the
kernel in 2017. Since then, the API has been non-functional (yet
incorrectly reporting support because the support test was buggy).

Just remove it completely. The debian codesearch does not uncover any
API users. Also, I doubt that any new API (based on tracing scheduler
events as perf would do) would map well to what exists now. i.e. if
something like this is re-implemented in UPower or elsewhere, then the
API should likely look different.

And, realistically, if this does need root privileges (i.e. can't be
moved to use BPF programs or so on user units), then we can also create
a new small daemon that is launched on-demand just for that.
2022-03-24 17:02:27 +01:00
Bastien Nocera
090e79ea54 lib: Fix UpClient reference leak
The task holds a reference to the UpClient and won't let it go until the
task is finalized.

See https://gitlab.gnome.org/GNOME/gnome-bluetooth/-/merge_requests/115
2022-02-16 12:23:55 +01:00
Jan Alexander Steffens (heftig)
1dc74629ff build: Fix version macros
The project version is a string. We need to split it into an array of
version components.
2022-02-05 02:34:28 +00:00
Bastien Nocera
07ad5a9b4c lib: Simplify loop using g_auto 2022-01-24 18:27:43 +01:00
Bastien Nocera
5e8b96ea24 lib: Prepare headers for internal g_auto* usage 2022-01-24 18:27:43 +01:00
Bastien Nocera
0d08f8feea lib: Remove unnecessary cast 2022-01-24 18:20:16 +01:00
Bastien Nocera
1fdc0824b6 lib: Implement up_client_get_devices_async() 2022-01-23 23:26:33 +01:00
Bastien Nocera
74aefb0fd7 lib: Add internal helper for up_client_get_devices2()
Making sure to pass GCancellable and GError arguments.
2022-01-23 23:04:26 +01:00
Bastien Nocera
c5282324d8 lib: Add up_client_new_async()
Closes: #121
2022-01-21 22:35:24 +01:00
Bastien Nocera
20aceb0e8c lib: Add API to access ChargeCyles D-Bus property 2021-09-13 12:55:36 +02:00
Bastien Nocera
3079262bc3 build: Remove unused variable assignment 2021-09-07 17:20:48 +02:00
Bastien Nocera
b68fe26fc9 build: Require GIR to be created to run tests 2021-09-07 17:15:52 +02:00
Bastien Nocera
9035db94fc build: Add missing GLib log domains
The daemon sources and libupower-glib were built without their historic
log domains which meant some debug messages did not appear when running
upowerd in verbose mode.

This fixes the test_no_poll_batteries test.
2021-09-07 17:15:52 +02:00
Bastien Nocera
9b93b6c402 build: Remove autotools 2021-09-06 14:06:40 +02:00
Bastien Nocera
6b9134c5d4 build: Clean up include_directories usage 2021-09-06 14:06:40 +02:00
Benjamin Berg
f2e702d4dc build: Support building upower with meson 2021-09-02 17:47:30 +02:00
Bastien Nocera
bd59723fb8 lib: Mark device refresh function as deprecated
As the daemon API will soon be removed.

See https://gitlab.freedesktop.org/upower/upower/-/merge_requests/66
2021-08-19 18:57:35 +02:00
Bastien Nocera
4e962fdc8d lib: Mark lid related functions and properties as deprecated
As we want to eventually remove them.

See https://gitlab.freedesktop.org/upower/upower/-/merge_requests/5
2021-08-19 18:57:30 +02:00
Bastien Nocera
2bddb64f68 lib: Add UP_DEVICE_KIND_BLUETOOTH_GENERIC type
This will be useful to show information about Bluetooth devices which
don't fit in with the existing types, and for which we don't want to
show an unknown kind.
2021-06-17 13:47:33 +02:00
Benjamin Berg
4b96535023 up-client: Document and handle NULL return when getting devices 2021-02-04 09:45:50 +00:00
Marijn Suijten
e294444496 lib: Add more device kinds for Bluetooth classes
This adds a variety of missing device kinds specific to the Bluetooth
classes supported in gnome-bluetooth [1].

In up_device_to_text these types have only been added to the
`percentage` class, which is currently the only property exposed by
org.bluez.Battery1, where these devices are coming from.

[1]: cf4a0ba59d/lib/bluetooth-utils.c (L165)
2021-02-02 18:22:25 +01: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
Bastien Nocera
7c17075ac0 build: Fix up-daemon-generated.h not being found on distcheck 2018-10-25 13:12:35 +02:00
Bastien Nocera
ca2174aa3f build: Fix out-of-tree build
The generated headers for the dbus service are in the build dir, not
the source dir.

../../libupower-glib/up-client.c:39:10: fatal error: up-daemon-generated.h: No such file or directory
 #include "up-daemon-generated.h"
          ^~~~~~~~~~~~~~~~~~~~~~~
2018-10-02 10:18:04 +02:00
Guido Günther
5ffcb1c269 lib: UpClient: up_client_get_display_device returns a UpDevice
It doesn't return a UpClient.
2018-09-30 19:19:02 +02:00
Guido Günther
afdf4f9919 lib: UpClient: Fix stray '%' 2018-09-30 19:19:02 +02: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
Guido Günther
0c180d044f lib: Work-around to fix gtk-doc's type detection
Without the braces on the same line gtk-doc adds function pointers as
functions to the documentation and fails to detect the types as
GObjects. This fixes object names in the index and cross refs.

See the examples in

https://developer.gnome.org/gtk-doc-manual/stable/documenting_symbols.html.en
2018-09-30 19:18:35 +02:00
Robert Ancell
cb1071b9ab lib: Add a new version of up_client_get_devices which unrefs contents
The existing function didn't set the free function on the GPtrArray.
This means a libupower user can easily make a mistake in the reference
counting of the array contents.
2018-05-31 09:42:56 +12: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