]> git.ozlabs.org Git - petitboot/blobdiff - ui/common/discover-client.c
Add list insert routines
[petitboot] / ui / common / discover-client.c
index 47c57cb11bc69d49e69467cbe0b259e8c07069c5..8672ae019d54f3e2121742cdfb125908e5be3059 100644 (file)
@@ -10,7 +10,7 @@
 #include <asm/byteorder.h>
 
 #include <talloc/talloc.h>
-#include <log.h>
+#include <log/log.h>
 
 #include "ui/common/discover-client.h"
 #include "pb-protocol/pb-protocol.h"
@@ -107,10 +107,6 @@ static void remove_device(struct discover_client *client, const char *id)
        if (!device)
                return;
 
-       client->ops.remove_device(device, client->ops.cb_arg);
-
-       talloc_free(device);
-
        /* remove the device from the client's device array */
        client->n_devices--;
        memmove(&client->devices[i], &client->devices[i+1],
@@ -118,6 +114,10 @@ static void remove_device(struct discover_client *client, const char *id)
        client->devices = talloc_realloc(client, client->devices,
                        struct device *, client->n_devices);
 
+       /* notify the UI */
+       client->ops.remove_device(device, client->ops.cb_arg);
+
+       talloc_free(device);
 }
 
 int discover_client_process(struct discover_client *client)
@@ -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];
+}