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.
This commit is contained in:
Jelle van der Waa 2023-11-13 16:58:13 +01:00
parent b21cec4c11
commit 18d550a555
3 changed files with 28 additions and 5 deletions

View file

@ -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;

View file

@ -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,

View file

@ -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;