]> git.ozlabs.org Git - petitboot/commitdiff
ui: Receive boot status messages
authorJeremy Kerr <jk@ozlabs.org>
Wed, 1 May 2013 01:09:39 +0000 (09:09 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Mon, 6 May 2013 01:02:12 +0000 (09:02 +0800)
Add support in the discover client code to handle boot status messages,
and pass them to the UI thorugh a new callback ("update_status") in the
client_ops.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
ui/common/discover-client.c
ui/common/discover-client.h

index 42aa9de9a950a3877a7b3dad8c96b96d47305373..a40bfdafe0ce669b1d832f5d95d90f50267eadc8 100644 (file)
@@ -110,10 +110,19 @@ static void device_remove(struct discover_client *client, const char *id)
        talloc_free(device);
 }
 
        talloc_free(device);
 }
 
+static void update_status(struct discover_client *client,
+               struct boot_status *status)
+{
+       if (client->ops.update_status)
+               client->ops.update_status(status, client->ops.cb_arg);
+       talloc_free(status);
+}
+
 static int discover_client_process(void *arg)
 {
        struct discover_client *client = arg;
        struct pb_protocol_message *message;
 static int discover_client_process(void *arg)
 {
        struct discover_client *client = arg;
        struct pb_protocol_message *message;
+       struct boot_status *status;
        struct boot_option *opt;
        struct device *dev;
        char *dev_id;
        struct boot_option *opt;
        struct device *dev;
        char *dev_id;
@@ -156,6 +165,16 @@ static int discover_client_process(void *arg)
                }
                device_remove(client, dev_id);
                break;
                }
                device_remove(client, dev_id);
                break;
+       case PB_PROTOCOL_ACTION_STATUS:
+               status = talloc_zero(client, struct boot_status);
+
+               rc = pb_protocol_deserialise_boot_status(status, message);
+               if (rc) {
+                       pb_log("%s: invalid status message?\n", __func__);
+                       return 0;
+               }
+               update_status(client, status);
+               break;
        default:
                pb_log("%s: unknown action %d\n", __func__, message->action);
        }
        default:
                pb_log("%s: unknown action %d\n", __func__, message->action);
        }
index 5317b446f5407e50682b91a523d1889bfeaa4bc3..2245a65141330883383af48f9e448fa4e4a0e256 100644 (file)
@@ -24,6 +24,7 @@ struct discover_client_ops {
        int (*boot_option_add)(struct device *dev, struct boot_option *option,
                        void *arg);
        void (*device_remove)(struct device *device, void *arg);
        int (*boot_option_add)(struct device *dev, struct boot_option *option,
                        void *arg);
        void (*device_remove)(struct device *device, void *arg);
+       void (*update_status)(struct boot_status *status, void *arg);
        void *cb_arg;
 };
 
        void *cb_arg;
 };