Commit graph

65 commits

Author SHA1 Message Date
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
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
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
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
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
Benjamin Berg
4b96535023 up-client: Document and handle NULL return when getting devices 2021-02-04 09:45:50 +00: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
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
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
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
Martin Pitt
29c5c85f6b lib: Remove hidden singleton instance
GObject _new constructors should always return a new pointer and not do
anything else than g_{object,initable}_new(). Drop the internal
up_client_object singleton instance.

This simplifies the code and makes the code robust with multiple threads.

Side issue in https://bugs.freedesktop.org/show_bug.cgi?id=95350
2016-05-18 14:59:12 +02:00
Martin Pitt
932a6a39e3 lib: Add proper error and cancellable handling to UpClient constructor
A GObject's _init() should never fail or block, but this is currently the case
as up_client_init() connects to upowerd on D-Bus. Convert this to the GInitable
interface and provide a new constructor up_client_new_full() which accepts a
GCancellable and GError, so that clients can do proper error handling
and reporting.

This changes up_client_new() to return NULL when connecting to upowerd fails.
This provides a more well-defined behaviour in this case as clients can check
for this and our methods stop segfaulting as they have checks like

   g_return_val_if_fail (UP_IS_CLIENT (client), ...)

Previously we returned a valid object, but trying to call any method on it
segfaulted due to the NULL D-Bus proxy, so client code had no chance to check
whether the UpClient object was really valid.

https://bugs.freedesktop.org/show_bug.cgi?id=95350
2016-05-18 14:58:28 +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
Bastien Nocera
fe37183fba lib: Fix memory leak in up_client_get_devices()
When up_client_get_devices() fails to contact the D-Bus daemon, don't
leak the newly created array.
2015-06-26 11:15:32 +02:00
Bastien Nocera
5ed25a7e5f all: Remove IsDocked property
Removes the deprecated (for not very long) property, before we do a 1.0
release.

https://bugs.freedesktop.org/show_bug.cgi?id=78380
2014-05-07 11:01:27 +02:00
Bastien Nocera
212b4397cc lib: Fix API doc for up_client_get_on_battery() 2014-05-07 09:46:49 +02:00
Bastien Nocera
54a030a38d lib: Hard-code the IsDocked value 2014-05-07 09:46:08 +02:00
Bastien Nocera
d650df8af8 lib: Fix typo in g-i annotation
Missing colon.
2014-04-23 15:48:48 +02:00
Martin Pitt
0d64bbddaa lib: Fix segfault on getting property when daemon is not running
This fixes "upower --version" when the daemon is not running, and thus the
client proxy is NULL.
2013-11-08 14:59:50 +01:00
Bastien Nocera
5f43bb78f7 lib: Remove up_client_enumerate_devices_sync()
And make device-removed send an object path, not a UpDevice.

This means that we don't keep all the remote devices as local
UpDevices object, getting woken up any time any of them have a
property changed, without anybody listening.

This should greatly cut down on the wakeups on the client side,
especially for applications that only use a small portion of the API
like the "on-battery" or "warning-level" properties.
2013-10-17 14:36:35 +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
c33528da7a lib: Simplify proxying glue properties in UpClient 2013-10-17 12:36:44 +02:00
Bastien Nocera
db31456921 all: Add GetCriticalAction daemon method
This allows desktop front-ends to get which action will
actually be taken when we hit critical battery.

This is not a property as availability of actions might
change over the course of the run of the system, and
we didn't want to make unnecessary D-Bus calls on startup.
2013-10-17 09:04:03 +02:00
Bastien Nocera
b2f72dd69a all: Remove WarningLevel from the daemon properties
The WarningLevel property just replicated the warning level
on the display device, or at least should have. So we fix the latter
to remove the former.
2013-10-17 00:57:27 +02:00
Bastien Nocera
45c4b37277 lib: Add up_client_get_display_device()
Add a helper to get to the display device.
2013-10-17 00:37:29 +02:00
Bastien Nocera
34951c91ff lib: Remove unneeded up_client_get_properties_sync()
It doesn't do anything, and we already broke the ABI by removing
some functions, so remove this as well.
2013-10-17 00:37:20 +02:00
Bastien Nocera
28438a7672 lib: Emit notify:: signals
In the UpClient object.

https://bugs.freedesktop.org/show_bug.cgi?id=43001
2013-10-14 11:06:53 +02:00
Bastien Nocera
858ab85f95 lib: Update for property removal and additions
Remove on-low-battery and add warning-level daemon properties.
2013-10-14 10:42:56 +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
65c84120f9 lib: Port UpClient to GDBus
Using the new proxy.
2013-10-14 10:42:55 +02:00
Bastien Nocera
030e2c9d36 lib: Remove deprecated features
All this is now handled by logind.
2013-10-14 10:42:55 +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
Bastien Nocera
fc5793e742 lib: Fix crasher calling _about_to_sleep_sync()
https://bugs.freedesktop.org/show_bug.cgi?id=54976
2013-10-13 00:49:24 +02:00
Bastien Nocera
e4858d9434 up-client: Really don't overwrite retval with prop values
db89e5a32b was incomplete and
"ret" was being used instead of prop_val to set some of those
properties. It's likely your laptop would have been seen as
docked for example.
2013-10-10 18:32:41 +02:00
Martin Pitt
03c4abbfb5 libupower-glib: Fix error handling
In up_client_get_properties_sync(), don't set the passed GError** to NULL,
instead set the actual pointed-to GError* to NULL by default.

Fixes proper error reporting back to the client if something does fail.
2013-10-08 17:02:57 +02:00
Bastien Nocera
ecc4e379cc up-client: Don't error out gathering deprecated properties
We would error out when trying to get properties that are
disabled by default (deprecated). Ignore those properties
when building without the deprecations.

This is still broken if the library is built with the deprecations
enabled, but not the daemon isn't, but that's an edge case.

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

Signed-off-by: Martin Pitt <martinpitt@gnome.org>
2013-10-08 16:47:30 +02:00
Bastien Nocera
db89e5a32b up-client: Don't overwrite retval with property values
If one of the properties is FALSE, we'll end up return FALSE
without setting an error (and making the caller crash if they
expect an error being filled in).

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

Signed-off-by: Martin Pitt <martinpitt@gnome.org>
2013-10-08 16:46:41 +02:00