diff options
author | Alex Deymo <deymo@chromium.org> | 2013-03-21 15:04:55 -0700 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2013-03-25 12:57:03 +0200 |
commit | 4b3005226554596d0d515b5f8cb196848ab6f819 (patch) | |
tree | 4300b9a2a825f51fb7506d0d0087ba3b35283f1d /client/agent.c | |
parent | d52e8994b51631a7d10abea30924e3124e2de462 (diff) |
client: Agent's DisplayPasskey implementation
Implements the DisplayPasskey(object device, uint32 passkey, uint16 entered)
method.
Diffstat (limited to 'client/agent.c')
-rw-r--r-- | client/agent.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/client/agent.c b/client/agent.c index 71454cc7d..498f49771 100644 --- a/client/agent.c +++ b/client/agent.c @@ -189,6 +189,31 @@ static DBusMessage *display_pincode(DBusConnection *conn, return dbus_message_new_method_return(msg); } +static DBusMessage *display_passkey(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + const char *device; + dbus_uint32_t passkey; + dbus_uint16_t entered; + char passkey_full[7]; + + dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &device, + DBUS_TYPE_UINT32, &passkey, DBUS_TYPE_UINT16, &entered, + DBUS_TYPE_INVALID); + + snprintf(passkey_full, sizeof(passkey_full), "%.6u", passkey); + passkey_full[6] = '\0'; + + if (entered > strlen(passkey_full)) + entered = strlen(passkey_full); + + rl_printf(AGENT_PROMPT "Passkey: " + COLOR_BOLDGRAY "%.*s" COLOR_BOLDWHITE "%s\n" COLOR_OFF, + entered, passkey_full, passkey_full + entered); + + return dbus_message_new_method_return(msg); +} + static DBusMessage *request_confirmation(DBusConnection *conn, DBusMessage *msg, void *user_data) { @@ -267,6 +292,10 @@ static const GDBusMethodTable methods[] = { { GDBUS_METHOD("DisplayPinCode", GDBUS_ARGS({ "device", "o" }, { "pincode", "s" }), NULL, display_pincode) }, + { GDBUS_METHOD("DisplayPasskey", + GDBUS_ARGS({ "device", "o" }, { "passkey", "u" }, + { "entered", "q" }), + NULL, display_passkey) }, { GDBUS_ASYNC_METHOD("RequestConfirmation", GDBUS_ARGS({ "device", "o" }, { "passkey", "u" }), NULL, request_confirmation) }, |