Home | History | Annotate | Download | only in test
      1 #!/usr/bin/python
      2 
      3 import gobject
      4 
      5 import dbus
      6 import dbus.mainloop.glib
      7 
      8 def property_changed(name, value, path, interface):
      9 	iface = interface[interface.rfind(".") + 1:]
     10 	val = str(value)
     11 	print "{%s.PropertyChanged} [%s] %s = %s" % (iface, path, name, val)
     12 
     13 def object_signal(value, path, interface, member):
     14 	iface = interface[interface.rfind(".") + 1:]
     15 	val = str(value)
     16 	print "{%s.%s} [%s] Path = %s" % (iface, member, path, val)
     17 
     18 if __name__ == '__main__':
     19 	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
     20 
     21 	bus = dbus.SystemBus()
     22 
     23 	bus.add_signal_receiver(property_changed, bus_name="org.bluez",
     24 					signal_name = "PropertyChanged",
     25 						path_keyword="path",
     26 						interface_keyword="interface")
     27 
     28 	bus.add_signal_receiver(object_signal, bus_name="org.bluez",
     29 					signal_name = "AdapterAdded",
     30 						path_keyword="path",
     31 						member_keyword="member",
     32 						interface_keyword="interface")
     33 	bus.add_signal_receiver(object_signal, bus_name="org.bluez",
     34 					signal_name = "AdapterRemoved",
     35 						path_keyword="path",
     36 						member_keyword="member",
     37 						interface_keyword="interface")
     38 	bus.add_signal_receiver(object_signal, bus_name="org.bluez",
     39 					signal_name = "DefaultAdapterChanged",
     40 						path_keyword="path",
     41 						member_keyword="member",
     42 						interface_keyword="interface")
     43 
     44 	bus.add_signal_receiver(object_signal, bus_name="org.bluez",
     45 					signal_name = "DeviceCreated",
     46 						path_keyword="path",
     47 						member_keyword="member",
     48 						interface_keyword="interface")
     49 	bus.add_signal_receiver(object_signal, bus_name="org.bluez",
     50 					signal_name = "DeviceRemoved",
     51 						path_keyword="path",
     52 						member_keyword="member",
     53 						interface_keyword="interface")
     54 
     55 	mainloop = gobject.MainLoop()
     56 	mainloop.run()
     57