From 5b123e1a3d3c7c27707eadd95756c38a671fc17c Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 13 Sep 2016 21:42:30 -0500 Subject: [PATCH] test: report InterfacesAdded & InterfacesRemoved --- test/monitor-iwd | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/monitor-iwd b/test/monitor-iwd index 1f27bb5a..8753878a 100755 --- a/test/monitor-iwd +++ b/test/monitor-iwd @@ -56,6 +56,28 @@ def property_changed(name, value, path, interface): iface = interface[interface.rfind(".") + 1:] print("{%s} [%s] %s = %s" % (iface, path, name, pretty(value))) +relevant_ifaces = [ "net.connman.iwd.Device", + "net.connman.iwd.Adapter", + "net.connman.iwd.WiFiSimpleConfiguration", + "net.connman.iwd.Network" ] + +def interfaces_added(path, interfaces): + for iface, props in interfaces.items(): + if not(iface in relevant_ifaces): + continue + + print("{Added %s} [%s]" % (iface, path)) + + for name, value in props.items(): + print(" %s = %s" % (name, pretty(value))) + +def interfaces_removed(path, interfaces): + for iface in interfaces: + if not(iface in relevant_ifaces): + continue + + print("{Removed %s} [%s]" % (iface, path)) + if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) @@ -67,5 +89,13 @@ if __name__ == '__main__': path_keyword="path", interface_keyword="interface") + bus.add_signal_receiver(interfaces_added, bus_name="net.connman.iwd", + dbus_interface="org.freedesktop.DBus.ObjectManager", + signal_name="InterfacesAdded") + + bus.add_signal_receiver(interfaces_removed, bus_name="net.connman.iwd", + dbus_interface="org.freedesktop.DBus.ObjectManager", + signal_name="InterfacesRemoved") + mainloop = GLib.MainLoop() mainloop.run()