From 1a19f8f12dd633ca557f2d36963e327e33bddcf7 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 9 Oct 2012 00:17:08 -0500 Subject: [PATCH] stktest: Add support for RequestKey method --- tools/stktest.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tools/stktest.c b/tools/stktest.c index a2f3c8f..2a60dbf 100644 --- a/tools/stktest.c +++ b/tools/stktest.c @@ -67,6 +67,8 @@ typedef DBusMessage *(*display_text_cb_t)(DBusMessage *msg, const char *text, gboolean urgent); typedef DBusMessage *(*request_digit_cb_t)(DBusMessage *msg, const char *alpha, unsigned char icon_id); +typedef DBusMessage *(*request_key_cb_t)(DBusMessage *msg, const char *alpha, + unsigned char icon_id); typedef void (*terminal_response_func)(const unsigned char *pdu, unsigned int len); @@ -292,6 +294,45 @@ static DBusMessage *agent_request_digit(DBusConnection *conn, DBusMessage *msg, return reply; } +static DBusMessage *agent_request_key(DBusConnection *conn, DBusMessage *msg, + void *data) +{ + const char *alpha; + unsigned char icon_id; + struct test *test; + request_key_cb_t func; + DBusMessage *reply; + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &alpha, + DBUS_TYPE_BYTE, &icon_id, + DBUS_TYPE_INVALID) == FALSE) + return stktest_error_invalid_args(msg); + + if (cur_test == NULL) + return stktest_error_failed(msg); + + test = cur_test->data; + func = test->agent_func; + + if (strcmp(test->method, "RequestKey")) { + g_printerr("Wrong method called!\n"); + __stktest_test_finish(FALSE); + return stktest_error_failed(msg); + } + + if (func == NULL) { + g_printerr("RequestKey not expected to be called"); + __stktest_test_finish(FALSE); + return stktest_error_failed(msg); + } + + reply = func(msg, alpha, icon_id); + if (reply == NULL) + pending = dbus_message_ref(msg); + + return reply; +} + static void server_debug(const char *str, void *data) { g_print("%s: %s\n", (char *) data, str); @@ -914,6 +955,10 @@ static const GDBusMethodTable agent_methods[] = { GDBUS_ARGS({ "alpha", "s" }, { "icon_id", "y" }), GDBUS_ARGS({ "digit", "s" }), agent_request_digit) }, + { GDBUS_ASYNC_METHOD("RequestKey", + GDBUS_ARGS({ "alpha", "s" }, { "icon_id", "y" }), + GDBUS_ARGS({ "key", "s" }), + agent_request_key) }, { GDBUS_NOREPLY_METHOD("Cancel", NULL, NULL, agent_cancel) }, { }, }; -- 2.7.4