transport: Switch transports as required on GET_MBOX_INFO

Also flush the event state out via the new transport. This must be done
after the command has completed for the mbox transport.

Change-Id: I251fb949ae67a477288d0d57a1a6afe5b2af5f8f
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/transport_dbus.c b/transport_dbus.c
index 0444284..1d3f0cd 100644
--- a/transport_dbus.c
+++ b/transport_dbus.c
@@ -9,6 +9,18 @@
 #include "dbus.h"
 #include "mboxd.h"
 #include "protocol.h"
+#include "transport.h"
+
+int transport_dbus_flush_events(struct mbox_context *context)
+{
+	/* FIXME ! */
+	MSG_ERR("%s is unimplemented!\n", __func__);
+	return 0;
+}
+
+static const struct transport_ops transport_dbus_ops = {
+	.flush_events = transport_dbus_flush_events,
+};
 
 static int transport_dbus_get_info(sd_bus_message *m, void *userdata,
 					sd_bus_error *ret_error)
@@ -34,6 +46,10 @@
 		return rc;
 	}
 
+	/* Switch transport to DBus. This is fine as DBus signals are async */
+	context->transport = &transport_dbus_ops;
+	context->transport->flush_events(context);
+
 	rc = sd_bus_message_new_method_return(m, &n);
 	if (rc < 0) {
 		MSG_ERR("sd_bus_message_new_method_return failed: %d\n", rc);