digitalmars.D.learn - Connecting to D-Bus signals
- Olivier Pisano (35/35) Oct 04 2022 Hi,
Hi, I am currently trying to connect to a signal on UDisks2 to be notified whenever the user plugs a USB drive on the system, but my method never gets called. Here is my code : import ddbus; import ddbus.c_lib; import std.stdio; final class UsbDevice { void onInterfacesAdded(ObjectPath path, Variant!DBusAny[string][string] params) { writeln("Interfaces added"); } } void main() { auto conn = connectToBus(DBusBusType.DBUS_BUS_SYSTEM); auto router = new MessageRouter(); auto dev = new UsbDevice(); MessagePattern ifaceAdded = MessagePattern( ObjectPath("/org/freedesktop/UDisks2"), interfaceName("org.freedesktop.DBus.ObjectManager"), "InterfacesAdded", true); router.setHandler(ifaceAdded, &dev.onInterfacesAdded); registerRouter(conn, router); simpleMainLoop(conn); } What am I doing wrong ? Thanks in advance, Ol
Oct 04 2022