]> git.ozlabs.org Git - petitboot/commitdiff
discover: Add discover_server_notify_boot_status
authorJeremy Kerr <jk@ozlabs.org>
Wed, 1 May 2013 01:29:51 +0000 (09:29 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Mon, 6 May 2013 01:02:12 +0000 (09:02 +0800)
Add a function to the server to notify clients of boot status updates.

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

index 198793204ef0cd30a68bb7da80858fd3a7791cdd..3f08152601a05640b1b72996cc5575d549518e89 100644 (file)
@@ -145,6 +145,24 @@ static int write_device_remove_message(struct discover_server *server,
        return client_write_message(server, client, message);
 }
 
        return client_write_message(server, client, message);
 }
 
+static int write_boot_status_message(struct discover_server *server,
+               struct client *client, const struct boot_status *status)
+{
+       struct pb_protocol_message *message;
+       int len;
+
+       len = pb_protocol_boot_status_len(status);
+
+       message = pb_protocol_create_message(client,
+                       PB_PROTOCOL_ACTION_STATUS, len);
+       if (!message)
+               return -1;
+
+       pb_protocol_serialise_boot_status(status, message->payload, len);
+
+       return client_write_message(server, client, message);
+}
+
 static int discover_server_process_message(void *arg)
 {
        struct pb_protocol_message *message;
 static int discover_server_process_message(void *arg)
 {
        struct pb_protocol_message *message;
@@ -247,6 +265,15 @@ void discover_server_notify_device_remove(struct discover_server *server,
 
 }
 
 
 }
 
+void discover_server_notify_boot_status(struct discover_server *server,
+               struct boot_status *status)
+{
+       struct client *client;
+
+       list_for_each_entry(&server->clients, client, list)
+               write_boot_status_message(server, client, status);
+}
+
 void discover_server_set_device_source(struct discover_server *server,
                struct device_handler *handler)
 {
 void discover_server_set_device_source(struct discover_server *server,
                struct device_handler *handler)
 {
index e47cf5f67237125ef641b9ec4311261575edfdad..541afaf776b4bbf718953ec9787b3b17ebcea845 100644 (file)
@@ -6,6 +6,7 @@
 struct discover_server;
 struct device_handler;
 struct boot_option;
 struct discover_server;
 struct device_handler;
 struct boot_option;
+struct boot_status;
 struct device;
 
 struct discover_server *discover_server_init(struct waitset *waitset);
 struct device;
 
 struct discover_server *discover_server_init(struct waitset *waitset);
@@ -21,4 +22,6 @@ void discover_server_notify_boot_option_add(struct discover_server *server,
                struct boot_option *option);
 void discover_server_notify_device_remove(struct discover_server *server,
                struct device *device);
                struct boot_option *option);
 void discover_server_notify_device_remove(struct discover_server *server,
                struct device *device);
+void discover_server_notify_boot_status(struct discover_server *server,
+               struct boot_status *status);
 #endif /* _DISCOVER_SERVER_H */
 #endif /* _DISCOVER_SERVER_H */