summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2012-10-18 11:40:08 -0500
committerDenis Kenzior <denkenz@gmail.com>2012-10-18 11:40:08 -0500
commit74d0b74cfed8c2c3eeedae694832301be7b72068 (patch)
tree5391043aebfa5f9f5c59a335a4d8146ffc43221d /tools
parent4769c59957eea9b9038f625a6f98070462bb7eb0 (diff)
downloadofono-74d0b74cfed8c2c3eeedae694832301be7b72068.tar.bz2
stktest: Add RequestInput and RequestDigits
Diffstat (limited to 'tools')
-rw-r--r--tools/stktest.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/tools/stktest.c b/tools/stktest.c
index c6629b22..3f031c66 100644
--- a/tools/stktest.c
+++ b/tools/stktest.c
@@ -67,6 +67,12 @@ typedef DBusMessage *(*display_text_cb_t)(DBusMessage *msg, const char *text,
gboolean urgent);
typedef DBusMessage *(*get_inkey_cb_t)(DBusMessage *msg, const char *alpha,
unsigned char icon_id);
+typedef DBusMessage *(*get_input_cb_t)(DBusMessage *msg, const char *alpha,
+ unsigned char icon_id,
+ const char *def_input,
+ unsigned char min_chars,
+ unsigned char max_chars,
+ gboolean hide_typing);
typedef void (*terminal_response_func)(const unsigned char *pdu,
unsigned int len);
@@ -297,6 +303,59 @@ GET_INKEY_TEMPLATE(agent_request_key, "RequestKey")
GET_INKEY_TEMPLATE(agent_request_digit, "RequestDigit")
GET_INKEY_TEMPLATE(agent_request_confirmation, "RequestConfirmation")
+#define GET_INPUT_TEMPLATE(func, method_name) \
+static DBusMessage *func(DBusConnection *conn, DBusMessage *msg, \
+ void *data) \
+{ \
+ const char *alpha; \
+ const char *def_input; \
+ unsigned char icon_id; \
+ unsigned char min_chars; \
+ unsigned char max_chars; \
+ gboolean hide_typing; \
+ struct test *test; \
+ get_input_cb_t func; \
+ DBusMessage *reply; \
+ \
+ if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &alpha, \
+ DBUS_TYPE_BYTE, &icon_id, \
+ DBUS_TYPE_STRING, &def_input, \
+ DBUS_TYPE_BYTE, &min_chars, \
+ DBUS_TYPE_BYTE, &max_chars, \
+ DBUS_TYPE_BOOLEAN, \
+ &hide_typing, \
+ 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, method_name)) { \
+ g_printerr("Wrong method called!\n"); \
+ __stktest_test_finish(FALSE); \
+ return stktest_error_failed(msg); \
+ } \
+ \
+ if (func == NULL) { \
+ g_printerr(method_name " not expected to be called"); \
+ __stktest_test_finish(FALSE); \
+ return stktest_error_failed(msg); \
+ } \
+ \
+ reply = func(msg, alpha, icon_id, def_input, \
+ min_chars, max_chars, hide_typing); \
+ if (reply == NULL) \
+ pending = dbus_message_ref(msg); \
+ \
+ return reply; \
+} \
+
+GET_INPUT_TEMPLATE(agent_request_input, "RequestInput")
+GET_INPUT_TEMPLATE(agent_request_digits, "RequestDigits")
+
static void server_debug(const char *str, void *data)
{
g_print("%s: %s\n", (char *) data, str);
@@ -927,6 +986,16 @@ static const GDBusMethodTable agent_methods[] = {
GDBUS_ARGS({ "alpha", "s" }, { "icon_id", "y" }),
GDBUS_ARGS({ "confirmation", "b" }),
agent_request_confirmation) },
+ { GDBUS_ASYNC_METHOD("RequestInput",
+ GDBUS_ARGS({ "alpha", "s" }, { "icon_id", "y" },
+ { "default", "s" }, { "min_chars", "y" },
+ { "max_chars", "y" }, { "hide_typing", "b" }),
+ GDBUS_ARGS({ "input", "s" }), agent_request_input) },
+ { GDBUS_ASYNC_METHOD("RequestDigits",
+ GDBUS_ARGS({ "alpha", "s" }, { "icon_id", "y" },
+ { "default", "s" }, { "min_chars", "y" },
+ { "max_chars", "y" }, { "hide_typing", "b" }),
+ GDBUS_ARGS({ "digits", "s" }), agent_request_digits) },
{ GDBUS_NOREPLY_METHOD("Cancel", NULL, NULL, agent_cancel) },
{ },
};