diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2007-06-22 22:50:08 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2007-06-22 22:50:08 +0000 |
commit | 6d738f7aebecbbfb9412c4f190c63e06080d1799 (patch) | |
tree | f42a95b2e70d4feb9ab9ec10d5aa3b806a41dbc8 | |
parent | 3e4bc988db4efbc53148d75fbfca3b5e8b1fed8f (diff) |
Add example for manager signals
-rw-r--r-- | daemon/Makefile.am | 3 | ||||
-rwxr-xr-x | daemon/test-manager | 29 |
2 files changed, 31 insertions, 1 deletions
diff --git a/daemon/Makefile.am b/daemon/Makefile.am index e3fd75fe..6ef20b7e 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -50,6 +50,7 @@ AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@ INCLUDES = -I$(top_srcdir)/common -I$(top_srcdir)/sdpd -EXTRA_DIST = bluetooth.conf echo.service test-database hal-namespace.txt +EXTRA_DIST = bluetooth.conf echo.service \ + test-manager test-database hal-namespace.txt MAINTAINERCLEANFILES = Makefile.in diff --git a/daemon/test-manager b/daemon/test-manager new file mode 100755 index 00000000..7db46a1b --- /dev/null +++ b/daemon/test-manager @@ -0,0 +1,29 @@ +#!/usr/bin/python + +import gobject + +import dbus +import dbus.mainloop.glib + +def adapter_added(path): + print "Adapter with path %s added" % (path) + +def adapter_removed(path): + print "Adapter with path %s removed" % (path) + +if __name__ == "__main__": + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + + bus = dbus.SystemBus() + + manager = dbus.Interface(bus.get_object('org.bluez', '/org/bluez'), + 'org.bluez.Manager') + + manager.connect_to_signal("AdapterAdded", adapter_added, + dbus_interface="org.bluez.Manager") + + manager.connect_to_signal("AdapterRemoved", adapter_removed, + dbus_interface="org.bluez.Manager") + + mainloop = gobject.MainLoop() + mainloop.run() |