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 adapter_added(path):
      9 	print "Adapter with path %s added" % (path)
     10 
     11 def adapter_removed(path):
     12 	print "Adapter with path %s removed" % (path)
     13 
     14 def default_changed(path):
     15 	print "Default adapter is now at path %s" % (path)
     16 
     17 if __name__ == "__main__":
     18 	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
     19 
     20 	bus = dbus.SystemBus()
     21 
     22 	manager = dbus.Interface(bus.get_object('org.bluez', '/'),
     23 							'org.bluez.Manager')
     24 
     25 	manager.connect_to_signal("AdapterAdded", adapter_added)
     26 
     27 	manager.connect_to_signal("AdapterRemoved", adapter_removed)
     28 
     29 	manager.connect_to_signal("DefaultAdapterChanged", default_changed)
     30 
     31 	try:
     32 		path = manager.DefaultAdapter()
     33 		default_changed(path)
     34 	except:
     35 		pass
     36 
     37 	mainloop = gobject.MainLoop()
     38 	mainloop.run()
     39