transport: dbus: Implement close
Change-Id: I9f261b56fe66e56d71c069d63f5caba5394cbe12
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/transport_dbus.c b/transport_dbus.c
index 7443975..435176f 100644
--- a/transport_dbus.c
+++ b/transport_dbus.c
@@ -274,6 +274,40 @@
return transport_dbus_create_window(context, false, m, ret_error);
}
+static int transport_dbus_close_window(sd_bus_message *m, void *userdata,
+ sd_bus_error *ret_error)
+{
+ struct mbox_context *context = userdata;
+ struct protocol_close io;
+ sd_bus_message *n;
+ int rc;
+
+ if (!context) {
+ MSG_ERR("DBUS Internal Error\n");
+ return -EINVAL;
+ }
+
+ rc = sd_bus_message_read(m, "y", &io.req.flags);
+ if (rc < 0) {
+ MSG_ERR("DBUS error reading message: %s\n", strerror(-rc));
+ return rc;
+ }
+
+ rc = context->protocol->close(context, &io);
+ if (rc < 0) {
+ return rc;
+ }
+
+ rc = sd_bus_message_new_method_return(m, &n);
+ if (rc < 0) {
+ MSG_ERR("sd_bus_message_new_method_return failed: %d\n", rc);
+ return rc;
+ }
+
+ return sd_bus_send(NULL, n, NULL);
+
+}
+
static int transport_dbus_ack(sd_bus_message *m, void *userdata,
sd_bus_error *ret_error)
{
@@ -359,6 +393,8 @@
SD_BUS_METHOD("CreateWriteWindow", "qq", "qqq",
&transport_dbus_create_write_window,
SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD("CloseWindow", "y", NULL, &transport_dbus_close_window,
+ SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_METHOD("Ack", "y", NULL, &transport_dbus_ack,
SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_PROPERTY("FlashControlLost", "b", transport_dbus_get_property,