summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-06-12 06:19:37 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2008-06-12 06:19:37 +0000
commitcaab6d5c5ecd6e093429ecaa46efc7b3754ac8c6 (patch)
treeacb51b4d87cef73032a7c4d3b4306ba1d5d86da0
parent807834685aed273794a99cf1111d18825e04488d (diff)
Wait for CreatePairedDevice to complete before exiting (i.e. don't exit when Release is called in that case)
-rwxr-xr-xhcid/simple-agent15
1 files changed, 11 insertions, 4 deletions
diff --git a/hcid/simple-agent b/hcid/simple-agent
index 23ff131b..0d3dc1f7 100755
--- a/hcid/simple-agent
+++ b/hcid/simple-agent
@@ -11,11 +11,17 @@ class Rejected(dbus.DBusException):
_dbus_error_name = "org.bluez.Error.Rejected"
class Agent(dbus.service.Object):
+ exit_on_release = True
+
+ def set_exit_on_release(self, exit_on_release):
+ self.exit_on_release = exit_on_release
+
@dbus.service.method("org.bluez.Agent",
in_signature="", out_signature="")
def Release(self):
print "Release"
- mainloop.quit()
+ if self.exit_on_release:
+ mainloop.quit()
@dbus.service.method("org.bluez.Agent",
in_signature="os", out_signature="")
@@ -61,11 +67,11 @@ class Agent(dbus.service.Object):
def create_device_reply(device):
print "New device (%s)" % (device)
- sys.exit(0)
+ mainloop.quit()
def create_device_error(error):
print "Creating device failed: %s" % (error)
- sys.exit(0)
+ mainloop.quit()
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
@@ -83,7 +89,7 @@ if __name__ == '__main__':
"org.bluez.Adapter")
path = "/test/agent"
- object = Agent(bus, path)
+ agent = Agent(bus, path)
mainloop = gobject.MainLoop()
@@ -92,6 +98,7 @@ if __name__ == '__main__':
device = adapter.FindDevice(sys.argv[2])
adapter.RemoveDevice(device)
+ agent.set_exit_on_release(False)
adapter.CreatePairedDevice(sys.argv[2], path, "DisplayYesNo",
reply_handler=create_device_reply,
error_handler=create_device_error)