diff options
author | Jelle van der Waa <jvanderwaa@redhat.com> | 2023-11-13 16:58:13 +0100 |
---|---|---|
committer | Jelle van der Waa <jvanderwaa@redhat.com> | 2024-01-26 10:20:50 +0100 |
commit | 18d550a5552376869b9c9490a7df3c19dd12c519 (patch) | |
tree | 70bfae204473efaf07b5d2403f7c0ec988e48564 | |
parent | b21cec4c112a1bc14d1cbb83bff16dde763d0300 (diff) |
Revert "lib: Remove deprecated up_client_get_devices()"
This reverts commit 67666029543f12d423619df4e8d1ad32faa928e9.
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.
-rw-r--r-- | libupower-glib/up-client.c | 26 | ||||
-rw-r--r-- | libupower-glib/up-client.h | 3 | ||||
-rw-r--r-- | tools/up-tool.c | 4 |
3 files changed, 28 insertions, 5 deletions
diff --git a/libupower-glib/up-client.c b/libupower-glib/up-client.c index 1137849..b005a2f 100644 --- a/libupower-glib/up-client.c +++ b/libupower-glib/up-client.c @@ -73,6 +73,28 @@ G_DEFINE_TYPE_WITH_CODE (UpClient, up_client, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(G_TYPE_INITABLE, up_client_initable_iface_init) G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, up_client_async_initable_iface_init)) +/** + * up_client_get_devices: + * @client: a #UpClient instance. + * + * Get a copy of the device objects. This function does not set the free + * function for the #GPtrArray so you need use g_object_unref on all + * elements when you are finished with the array. + * + * Return value: (element-type UpDevice) (transfer full): an array of #UpDevice objects or %NULL on error, free with g_ptr_array_unref() + * + * Since: 0.9.0 + * Deprecated: 0.99.8 + **/ +GPtrArray * +up_client_get_devices (UpClient *client) +{ + GPtrArray *array = up_client_get_devices2 (client); + if (array) + g_ptr_array_set_free_func (array, NULL); + return array; +} + static GPtrArray * up_client_get_devices_full (UpClient *client, GCancellable *cancellable, @@ -109,7 +131,7 @@ up_client_get_devices_full (UpClient *client, } /** - * up_client_get_devices: + * up_client_get_devices2: * @client: a #UpClient instance. * * Get a copy of the device objects. @@ -119,7 +141,7 @@ up_client_get_devices_full (UpClient *client, * Since: 0.99.8 **/ GPtrArray * -up_client_get_devices (UpClient *client) +up_client_get_devices2 (UpClient *client) { g_autoptr(GError) error = NULL; GPtrArray *ret = NULL; diff --git a/libupower-glib/up-client.h b/libupower-glib/up-client.h index 360ee0e..dfc4853 100644 --- a/libupower-glib/up-client.h +++ b/libupower-glib/up-client.h @@ -84,7 +84,8 @@ UpDevice * up_client_get_display_device (UpClient *client); char * up_client_get_critical_action (UpClient *client); /* accessors */ -GPtrArray *up_client_get_devices (UpClient *client); +GPtrArray *up_client_get_devices (UpClient *client) G_DEPRECATED_FOR(up_client_get_devices2); +GPtrArray *up_client_get_devices2 (UpClient *client); void up_client_get_devices_async (UpClient *client, GCancellable *cancellable, GAsyncReadyCallback callback, diff --git a/tools/up-tool.c b/tools/up-tool.c index ee4553d..e599d86 100644 --- a/tools/up-tool.c +++ b/tools/up-tool.c @@ -163,7 +163,7 @@ up_tool_do_monitor (UpClient *client) g_signal_connect (client, "device-removed", G_CALLBACK (up_tool_device_removed_cb), NULL); g_signal_connect (client, "notify", G_CALLBACK (up_tool_changed_cb), NULL); - devices = up_client_get_devices (client); + devices = up_client_get_devices2 (client); for (i=0; i < devices->len; i++) { UpDevice *device; device = g_ptr_array_index (devices, i); @@ -239,7 +239,7 @@ main (int argc, char **argv) if (opt_enumerate || opt_dump) { GPtrArray *devices; - devices = up_client_get_devices (client); + devices = up_client_get_devices2 (client); if (!devices) { g_print ("Failed to get device list\n"); goto out; |