Commit graph

129 commits

Author SHA1 Message Date
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
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
b9aaa05bc6 docs: Better documentation for the BatteryLevel prop
https://bugs.freedesktop.org/show_bug.cgi?id=103361
2017-10-31 17:45:18 +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
eb6b1b62a2 lib: Simplify string checks
We don't need to protect against NULL values, we already do at the start
of the function.

Created with:
:%s,g_strcmp0\(.*\) == 0,g_str_equal \1,

Mentioned in:
https://bugs.freedesktop.org/show_bug.cgi?id=100359#c14
2017-04-10 10:37:32 +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
4f9230900b lib: Add more members to UpDeviceLevel struct
Those levels will not be used to cover warning levels, but approximate
battery levels that devices can use, exported by the kernel as
POWER_SUPPLY_CAPACITY_LEVEL_* values.

See linux/power_supply.h

https://bugs.freedesktop.org/show_bug.cgi?id=100359
2017-04-06 14:18:10 +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
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
Kalev Lember
0825c162d3 Support g_autoptr() for all libupower-glib object types
This allows using e.g. g_autoptr(UpDevice) in other programs, but does
not make upower itself use g_autoptr, or require a new enough glib to
support it.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2015-09-15 12:33:44 +01: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
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
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
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
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
595d72f6b6 lib: Proxy notify changes from UpDevice glue 2013-10-17 12:37:29 +02:00
Bastien Nocera
c33528da7a lib: Simplify proxying glue properties in UpClient 2013-10-17 12:36:44 +02:00