From f5192075ca25e91ae72f12c89cab0c9c66eb6606 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Sun, 1 Feb 2009 16:22:03 +1100 Subject: [PATCH] [discover client] Add device accessors Allow the UIs to query the current device set. Signed-off-by: Jeremy Kerr --- ui/common/discover-client.c | 15 +++++++++++++++ ui/common/discover-client.h | 17 +++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/ui/common/discover-client.c b/ui/common/discover-client.c index 47c57cb..7c2e27d 100644 --- a/ui/common/discover-client.c +++ b/ui/common/discover-client.c @@ -156,3 +156,18 @@ int discover_client_process(struct discover_client *client) return 0; } + +/* accessors for discovered devices */ +int discover_client_device_count(struct discover_client *client) +{ + return client->n_devices; +} + +struct device *discover_client_get_device(struct discover_client *client, + int index) +{ + if (index < 0 || index >= client->n_devices) + return NULL; + + return client->devices[index]; +} diff --git a/ui/common/discover-client.h b/ui/common/discover-client.h index 6fc964d..719f72a 100644 --- a/ui/common/discover-client.h +++ b/ui/common/discover-client.h @@ -34,4 +34,21 @@ void discover_client_destroy(struct discover_client *client); */ int discover_client_process(struct discover_client *client); +/** + * Get the number of devices that the discover client has stored. This + * is the set of devices that have been added and not removed + * + * @param client The discover client + * @return The number of devices that have been added. + */ +int discover_client_device_count(struct discover_client *client); + +/** + * Get the device at a specific index. + * @param client A pointer to the discover client + * @param index The index of the device to retrieve + * @return The device at the specified index, or NULL if none exists + */ +struct device *discover_client_get_device(struct discover_client *client, + int index); #endif -- 2.39.2