stktest: Add RequestInput and RequestDigits

This commit is contained in:
Denis Kenzior 2012-10-18 11:40:08 -05:00
parent 4769c59957
commit 74d0b74cfe
1 changed files with 69 additions and 0 deletions

View File

@ -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) },
{ },
};