summaryrefslogtreecommitdiff
path: root/lib/test-agent.c
diff options
context:
space:
mode:
authorGustavo Padovan <gustavo.padovan@collabora.co.uk>2013-05-15 17:55:13 -0300
committerBastien Nocera <hadess@hadess.net>2013-05-30 14:17:43 +0200
commit1755d1bd2c35443792e157de3fc8d2972849e1ce (patch)
tree67059ab3fb52d8d8be994d5c46fbceadd3e4522e /lib/test-agent.c
parent0b0534924fb5ea781195e116a7dfbf956d16379c (diff)
downloadgnome-bluetooth-1755d1bd2c35443792e157de3fc8d2972849e1ce.tar.gz
agent: Port agent code to BlueZ 5
The biggest difference of the new Agent API is that BlueZ 5 doesn't register one agent per adapter anymore. There is now only one agent, to handle all adapters at the same time and most of changes in this commit are related to that. The new API also introduces a new Agent method, RequestAuthorization(), to give power to the user allow/deny JustWorks pairing(when both sides doesn't require user interaction), so now bluetooth_agent_set_authorize_func is related to that method and there is new bluetooth_agent_set_authorize_service_func which is sets the callback to the function to authorize services to trying to connect. https://bugzilla.gnome.org/show_bug.cgi?id=685717
Diffstat (limited to 'lib/test-agent.c')
-rw-r--r--lib/test-agent.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/lib/test-agent.c b/lib/test-agent.c
index 0a9c1c45..a57baacd 100644
--- a/lib/test-agent.c
+++ b/lib/test-agent.c
@@ -31,35 +31,20 @@
#include <signal.h>
#include "bluetooth-agent.h"
-#include "bluetooth-client-glue.h"
static gboolean
-agent_pincode (GDBusMethodInvocation *invocation,
+agent_confirm (GDBusMethodInvocation *invocation,
GDBusProxy *device,
- gpointer user_data)
+ guint passkey,
+ gpointer data)
{
- GVariant *value;
- GVariant *result;
- const char *alias, *address;
+ const char *path;
- result = g_dbus_proxy_call_sync (device, "GetProperties", NULL,
- G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL);
- if (result != NULL) {
- value = g_variant_lookup_value (result, "Address", G_VARIANT_TYPE_STRING);
- address = value ? g_variant_get_string (value, NULL) : "No address";
+ path = g_dbus_proxy_get_object_path(device);
- value = g_variant_lookup_value (result, "Name", G_VARIANT_TYPE_STRING);
- alias = value ? g_variant_get_string (value, NULL) : address;
+ g_print ("Confirming passkey %6.6d from %s\n", passkey, path);
- printf("address %s name %s\n", address, alias);
-
- g_variant_unref (result);
- } else {
- g_message ("Could not get address or name for '%s'",
- g_dbus_proxy_get_object_path (device));
- }
-
- g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", "1234"));
+ g_dbus_method_invocation_return_value (invocation, NULL);
return TRUE;
}
@@ -87,7 +72,7 @@ int main (int argc, char **argv)
agent = bluetooth_agent_new();
- bluetooth_agent_set_pincode_func(agent, agent_pincode, NULL);
+ bluetooth_agent_set_confirm_func(agent, agent_confirm, NULL);
bluetooth_agent_register(agent);