linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Convert CreateDevice on test-device script to an asynchronous call
@ 2010-12-09 19:32 Claudio Takahasi
  2010-12-09 19:42 ` Claudio Takahasi
  0 siblings, 1 reply; 3+ messages in thread
From: Claudio Takahasi @ 2010-12-09 19:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

Change required to test the scenario when the sender of a CreateDevice
or CreatePairedDevice request disconnects from the system bus.
---
 test/test-device |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/test/test-device b/test/test-device
index a04ff35..828349c 100755
--- a/test/test-device
+++ b/test/test-device
@@ -1,11 +1,16 @@
 #!/usr/bin/python
 
+import gobject
+
 import sys
 import dbus
+import dbus.mainloop.glib
 import re
 from optparse import OptionParser, make_option
 
+dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
 bus = dbus.SystemBus()
+mainloop = gobject.MainLoop()
 
 manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.bluez.Manager")
 
@@ -48,13 +53,24 @@ if (args[0] == "list"):
 
 	sys.exit(0)
 
+def create_device_reply(device):
+	print "New device (%s)" % device
+	mainloop.quit()
+	sys.exit(0)
+
+def create_device_error(error):
+	print "Creating device failed: %s" % error
+	mainloop.quit()
+	sys.exit(1)
+
 if (args[0] == "create"):
 	if (len(args) < 2):
 		print "Need address parameter"
 	else:
-		device = adapter.CreateDevice(args[1])
-		print device
-	sys.exit(0)
+		adapter.CreateDevice(args[1],
+				reply_handler=create_device_reply,
+				error_handler=create_device_error)
+	mainloop.run()
 
 if (args[0] == "remove"):
 	if (len(args) < 2):
-- 
1.7.3.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] Convert CreateDevice on test-device script to an asynchronous call
  2010-12-09 19:32 [PATCH] Convert CreateDevice on test-device script to an asynchronous call Claudio Takahasi
@ 2010-12-09 19:42 ` Claudio Takahasi
  2010-12-09 20:09   ` Johan Hedberg
  0 siblings, 1 reply; 3+ messages in thread
From: Claudio Takahasi @ 2010-12-09 19:42 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

Change required to test the scenario when the sender of a CreateDevice
request disconnects from the system bus. Current implementation is
blocking and it doesn't allow the user to cancel a request.
---
 test/test-device |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/test/test-device b/test/test-device
index a04ff35..828349c 100755
--- a/test/test-device
+++ b/test/test-device
@@ -1,11 +1,16 @@
 #!/usr/bin/python
 
+import gobject
+
 import sys
 import dbus
+import dbus.mainloop.glib
 import re
 from optparse import OptionParser, make_option
 
+dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
 bus = dbus.SystemBus()
+mainloop = gobject.MainLoop()
 
 manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.bluez.Manager")
 
@@ -48,13 +53,24 @@ if (args[0] == "list"):
 
 	sys.exit(0)
 
+def create_device_reply(device):
+	print "New device (%s)" % device
+	mainloop.quit()
+	sys.exit(0)
+
+def create_device_error(error):
+	print "Creating device failed: %s" % error
+	mainloop.quit()
+	sys.exit(1)
+
 if (args[0] == "create"):
 	if (len(args) < 2):
 		print "Need address parameter"
 	else:
-		device = adapter.CreateDevice(args[1])
-		print device
-	sys.exit(0)
+		adapter.CreateDevice(args[1],
+				reply_handler=create_device_reply,
+				error_handler=create_device_error)
+	mainloop.run()
 
 if (args[0] == "remove"):
 	if (len(args) < 2):
-- 
1.7.3.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Convert CreateDevice on test-device script to an asynchronous call
  2010-12-09 19:42 ` Claudio Takahasi
@ 2010-12-09 20:09   ` Johan Hedberg
  0 siblings, 0 replies; 3+ messages in thread
From: Johan Hedberg @ 2010-12-09 20:09 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: linux-bluetooth

Hi Claudio,

On Thu, Dec 09, 2010, Claudio Takahasi wrote:
> Change required to test the scenario when the sender of a CreateDevice
> request disconnects from the system bus. Current implementation is
> blocking and it doesn't allow the user to cancel a request.
> ---
>  test/test-device |   22 +++++++++++++++++++---
>  1 files changed, 19 insertions(+), 3 deletions(-)

Pushed upstream. Thanks.

Johan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-12-09 20:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-09 19:32 [PATCH] Convert CreateDevice on test-device script to an asynchronous call Claudio Takahasi
2010-12-09 19:42 ` Claudio Takahasi
2010-12-09 20:09   ` Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).