DBUS_TYPE_INVALID);
}
+static void passkey_response(DBusConnection *conn, const char *input)
+{
+ dbus_uint32_t passkey;
+ if (sscanf(input, "%u", &passkey) == 1)
+ g_dbus_send_reply(conn, pending_message, DBUS_TYPE_UINT32,
+ &passkey, DBUS_TYPE_INVALID);
+ else if (!strcmp(input, "no"))
+ g_dbus_send_error(conn, pending_message,
+ "org.bluez.Error.Rejected", NULL);
+ else
+ g_dbus_send_error(conn, pending_message,
+ "org.bluez.Error.Canceled", NULL);
+}
+
static void confirm_response(DBusConnection *conn, const char *input)
{
if (!strcmp(input, "yes"))
if (!strcmp(member, "RequestPinCode"))
pincode_response(conn, input);
+ else if (!strcmp(member, "RequestPasskey"))
+ passkey_response(conn, input);
else if (!strcmp(member, "RequestConfirmation"))
confirm_response(conn, input);
else if (!strcmp(member, "RequestAuthorization"))
return dbus_message_new_method_return(msg);
}
+static DBusMessage *request_passkey(DBusConnection *conn,
+ DBusMessage *msg, void *user_data)
+{
+ const char *device;
+
+ rl_printf("Request passkey\n");
+
+ dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &device,
+ DBUS_TYPE_INVALID);
+
+ agent_prompt("Enter passkey (number in 0-999999): ");
+
+ pending_message = dbus_message_ref(msg);
+
+ return NULL;
+}
+
static DBusMessage *display_passkey(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
{ GDBUS_METHOD("DisplayPinCode",
GDBUS_ARGS({ "device", "o" }, { "pincode", "s" }),
NULL, display_pincode) },
+ { GDBUS_ASYNC_METHOD("RequestPasskey",
+ GDBUS_ARGS({ "device", "o" }),
+ GDBUS_ARGS({ "passkey", "u" }), request_passkey) },
{ GDBUS_METHOD("DisplayPasskey",
GDBUS_ARGS({ "device", "o" }, { "passkey", "u" },
{ "entered", "q" }),