From 53980c98d8316166985fad8e7880cdf08171506e Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Mon, 1 May 2017 10:23:51 -0700 Subject: [PATCH] client: WSC 'start-pin' command --- client/wsc.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/client/wsc.c b/client/wsc.c index 751aaf04..4a63627c 100644 --- a/client/wsc.c +++ b/client/wsc.c @@ -41,6 +41,28 @@ static void check_errors_method_callback(struct l_dbus_message *message, dbus_message_has_error(message); } +static void generate_pin_callback(struct l_dbus_message *message, + void *user_data) +{ + const struct proxy_interface *proxy = user_data; + const char *pin; + + if (dbus_message_has_error(message)) + return; + + if (!l_dbus_message_get_arguments(message, "s", &pin)) { + l_error("Failed to parse 'generate pin' callback message"); + + return; + } + + if (!pin) + return; + + proxy_interface_method_call(proxy, "StartPin", "s", + check_errors_method_callback, pin); +} + static enum cmd_status cmd_push_button(const char *device_name, char *args) { const struct proxy_interface *proxy = device_wsc_get(device_name); @@ -75,7 +97,18 @@ static enum cmd_status cmd_start_user_pin(const char *device_name, char *args) static enum cmd_status cmd_start_pin(const char *device_name, char *args) { - return CMD_STATUS_UNSUPPORTED; + const struct proxy_interface *proxy = device_wsc_get(device_name); + + if (!proxy) { + display("Invalid device name '%s'\n", device_name); + + return CMD_STATUS_INVALID_VALUE; + } + + proxy_interface_method_call(proxy, "GeneratePin", "", + generate_pin_callback); + + return CMD_STATUS_OK; } static enum cmd_status cmd_cancel(const char *device_name, char *args)