[RFC 2/3] test/obex: Add AuthorizeGet on Agent2 interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Expose method for authroizing opp GET request.
---
 test/simple-obex-agent | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/test/simple-obex-agent b/test/simple-obex-agent
index 05ec4ed..41cd386 100755
--- a/test/simple-obex-agent
+++ b/test/simple-obex-agent
@@ -15,6 +15,7 @@ BUS_NAME = 'org.bluez.obex'
 PATH = '/org/bluez/obex'
 AGENT_MANAGER_INTERFACE = 'org.bluez.obex.AgentManager1'
 AGENT_INTERFACE = 'org.bluez.obex.Agent1'
+AGENT_INTERFACE_2 = 'org.bluez.obex.Agent2'
 TRANSFER_INTERFACE = 'org.bluez.obex.Transfer1'
 
 def ask(prompt):
@@ -55,6 +56,32 @@ class Agent(dbus.service.Object):
 		print("Authorization Canceled")
 		self.pending_auth = False
 
+	@dbus.service.method(AGENT_INTERFACE_2, in_signature="",
+							out_signature="s")
+	def AuthorizeGet(self):
+		self.pending_auth = True
+		auth = ask("Authorize (Y/n):")
+
+		if auth == "n" or auth == "N":
+			self.pending_auth = False
+			raise dbus.DBusException(
+					"org.bluez.obex.Error.Rejected: "
+					"Not Authorized")
+
+		self.pending_auth = False
+		path = ask("Filename location:")
+
+		if path == "":
+			path = "vcard.vcf"
+
+		return path
+
+	@dbus.service.method(AGENT_INTERFACE_2, in_signature="",
+							out_signature="")
+	def Cancel(self):
+		print("Authorization Canceled")
+		self.pending_auth = False
+
 if __name__ == '__main__':
 	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux