[Pkg-bluetooth-commits] r847 - in /packages/bluez/trunk/debian: changelog patches/002_test_agent_newapi.patch
filippo at users.alioth.debian.org
filippo at users.alioth.debian.org
Sun Jun 21 08:32:40 UTC 2009
Author: filippo
Date: Sun Jun 21 08:32:38 2009
New Revision: 847
URL: http://svn.debian.org/wsvn/pkg-bluetooth/?sc=1&rev=847
Log:
debian/patches/002_test_agent_newapi.patch port bluetooth-agent to new
D-Bus API
Added:
packages/bluez/trunk/debian/patches/002_test_agent_newapi.patch
Modified:
packages/bluez/trunk/debian/changelog
Modified: packages/bluez/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-bluetooth/packages/bluez/trunk/debian/changelog?rev=847&op=diff
==============================================================================
--- packages/bluez/trunk/debian/changelog (original)
+++ packages/bluez/trunk/debian/changelog Sun Jun 21 08:32:38 2009
@@ -7,8 +7,10 @@
* Switch to group bluetooth from netdev for authorized users
* Mention pand/hidd/dund move to bluez-compat in init script and default
(Closes: #532622)
-
- -- Filippo Giunchedi <filippo at debian.org> Fri, 19 Jun 2009 18:48:51 +0200
+ * debian/patches/002_test_agent_newapi.patch port bluetooth-agent to new
+ D-Bus API
+
+ -- Filippo Giunchedi <filippo at debian.org> Sun, 21 Jun 2009 10:31:40 +0200
bluez (4.40-2) unstable; urgency=low
Added: packages/bluez/trunk/debian/patches/002_test_agent_newapi.patch
URL: http://svn.debian.org/wsvn/pkg-bluetooth/packages/bluez/trunk/debian/patches/002_test_agent_newapi.patch?rev=847&op=file
==============================================================================
--- packages/bluez/trunk/debian/patches/002_test_agent_newapi.patch (added)
+++ packages/bluez/trunk/debian/patches/002_test_agent_newapi.patch Sun Jun 21 08:32:38 2009
@@ -1,0 +1,181 @@
+From: Filippo Giunchedi <filippo at esaurito.net>
+Subject: [PATCH] test/agent.c new API
+
+This patch updates test/agent.c to new D-Bus API
+
+---
+ test/agent.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
+ 1 files changed, 97 insertions(+), 14 deletions(-)
+
+diff --git a/test/agent.c b/test/agent.c
+index b256f52..93c2fe8 100644
+--- a/test/agent.c
++++ b/test/agent.c
+@@ -70,20 +70,18 @@ static DBusHandlerResult agent_filter(DBusConnection *conn,
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
+-static DBusHandlerResult request_message(DBusConnection *conn,
++static DBusHandlerResult request_pincode_message(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+ {
+ DBusMessage *reply;
+- const char *path, *address;
+- dbus_bool_t numeric;
++ const char *path;
+
+ if (!passkey)
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+ if (!dbus_message_get_args(msg, NULL,
+- DBUS_TYPE_STRING, &path, DBUS_TYPE_STRING, &address,
+- DBUS_TYPE_BOOLEAN, &numeric, DBUS_TYPE_INVALID)) {
+- fprintf(stderr, "Invalid arguments for passkey Request method");
++ DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID)) {
++ fprintf(stderr, "Invalid arguments for RequestPinCode method");
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
+@@ -99,7 +97,7 @@ static DBusHandlerResult request_message(DBusConnection *conn,
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+ }
+
+- printf("Passkey request for device %s\n", address);
++ printf("Pincode request for device %s\n", path);
+
+ dbus_message_append_args(reply, DBUS_TYPE_STRING, &passkey,
+ DBUS_TYPE_INVALID);
+@@ -114,20 +112,63 @@ send:
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+-static DBusHandlerResult cancel_message(DBusConnection *conn,
++static DBusHandlerResult request_passkey_message(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+ {
+ DBusMessage *reply;
+- const char *path, *address;
++ const char *path;
++ unsigned int int_passkey;
++
++ if (!passkey)
++ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
++
+
+ if (!dbus_message_get_args(msg, NULL,
+- DBUS_TYPE_STRING, &path, DBUS_TYPE_STRING, &address,
+- DBUS_TYPE_INVALID)) {
++ DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID)) {
++ fprintf(stderr, "Invalid arguments for RequestPasskey method");
++ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
++ }
++
++ if (do_reject) {
++ reply = dbus_message_new_error(msg,
++ "org.bluez.Error.Rejected", "");
++ goto send;
++ }
++
++ reply = dbus_message_new_method_return(msg);
++ if (!reply) {
++ fprintf(stderr, "Can't create reply message\n");
++ return DBUS_HANDLER_RESULT_NEED_MEMORY;
++ }
++
++ printf("Passkey request for device %s\n", path);
++
++ int_passkey = strtoul(passkey, NULL, 10);
++
++ dbus_message_append_args(reply, DBUS_TYPE_UINT32, &int_passkey,
++ DBUS_TYPE_INVALID);
++
++send:
++ dbus_connection_send(conn, reply, NULL);
++
++ dbus_connection_flush(conn);
++
++ dbus_message_unref(reply);
++
++ return DBUS_HANDLER_RESULT_HANDLED;
++}
++
++static DBusHandlerResult cancel_message(DBusConnection *conn,
++ DBusMessage *msg, void *data)
++{
++ DBusMessage *reply;
++
++ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_INVALID)) {
+ fprintf(stderr, "Invalid arguments for passkey Confirm method");
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
+- printf("Request canceled for device %s\n", address);
++ printf("Request canceled\n");
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply) {
+@@ -174,11 +215,50 @@ static DBusHandlerResult release_message(DBusConnection *conn,
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
++static DBusHandlerResult authorize_message(DBusConnection *conn,
++ DBusMessage *msg, void *data)
++{
++ DBusMessage *reply;
++ const char *path, *uuid;
++
++ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
++ DBUS_TYPE_STRING, &uuid, DBUS_TYPE_INVALID)) {
++ fprintf(stderr, "Invalid arguments for Authorize method");
++ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
++ }
++
++ if (do_reject) {
++ reply = dbus_message_new_error(msg,
++ "org.bluez.Error.Rejected", "");
++ goto send;
++ }
++
++ reply = dbus_message_new_method_return(msg);
++ if (!reply) {
++ fprintf(stderr, "Can't create reply message\n");
++ return DBUS_HANDLER_RESULT_NEED_MEMORY;
++ }
++
++ printf("Authorizing request for %s\n", path);
++
++send:
++ dbus_connection_send(conn, reply, NULL);
++
++ dbus_connection_flush(conn);
++
++ dbus_message_unref(reply);
++
++ return DBUS_HANDLER_RESULT_HANDLED;
++}
++
+ static DBusHandlerResult agent_message(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+ {
+- if (dbus_message_is_method_call(msg, "org.bluez.Agent", "Request"))
+- return request_message(conn, msg, data);
++ if (dbus_message_is_method_call(msg, "org.bluez.Agent", "RequestPinCode"))
++ return request_pincode_message(conn, msg, data);
++
++ if (dbus_message_is_method_call(msg, "org.bluez.Agent", "RequestPasskey"))
++ return request_passkey_message(conn, msg, data);
+
+ if (dbus_message_is_method_call(msg, "org.bluez.Agent", "Cancel"))
+ return cancel_message(conn, msg, data);
+@@ -186,6 +266,9 @@ static DBusHandlerResult agent_message(DBusConnection *conn,
+ if (dbus_message_is_method_call(msg, "org.bluez.Agent", "Release"))
+ return release_message(conn, msg, data);
+
++ if (dbus_message_is_method_call(msg, "org.bluez.Agent", "Authorize"))
++ return authorize_message(conn, msg, data);
++
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
+--
+tg: (8fdf676..) t/upstream/agent_newapi (depends on: master)
More information about the Pkg-bluetooth-commits
mailing list