Diff between c42078d2928af496062bbb1dacbce8848a42b8d1 and 80efa0ed859ce140d1d0cc556efa57a557618bba

Changed Files

File Additions Deletions Status
test/test-profile +12 -3 modified

Full Patch

diff --git a/test/test-profile b/test/test-profile
index 3e38f95..b78d00c 100755
--- a/test/test-profile
+++ b/test/test-profile
@@ -13,6 +13,8 @@ import dbus.mainloop.glib
 from optparse import OptionParser, make_option
 
 class Profile(dbus.service.Object):
+	fd = -1
+
 	@dbus.service.method("org.bluez.Profile1",
 					in_signature="", out_signature="")
 	def Release(self):
@@ -27,15 +29,22 @@ class Profile(dbus.service.Object):
 	@dbus.service.method("org.bluez.Profile1",
 				in_signature="oha{sv}", out_signature="")
 	def NewConnection(self, path, fd, properties):
-		fd = fd.take()
-		print("NewConnection(%s, %d)" % (path, fd))
+		self.fd = fd.take()
+		print("NewConnection(%s, %d)" % (path, self.fd))
 		for key in properties.keys():
 			if key == "Version" or key == "Features":
 				print("  %s = 0x%04x" % (key, properties[key]))
 			else:
 				print("  %s = %s" % (key, properties[key]))
 
-		os.close(fd)
+	@dbus.service.method("org.bluez.Profile1",
+				in_signature="o", out_signature="")
+	def RequestDisconnection(self, path):
+		print("RequestDisconnection(%s)" % (path))
+
+		if (self.fd > 0):
+			os.close(self.fd)
+			self.fd = -1
 
 if __name__ == '__main__':
 	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)