diff options
author | Philippe Nunes <philippe.nunes@linux.intel.com> | 2011-03-30 12:27:43 +0200 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2011-03-30 12:07:49 -0500 |
commit | 70ae73d78baf88cdd54078d9c6e2626ad15a7cd2 (patch) | |
tree | 4a2b49af6a9372f9b3420697699912b9713e0dfb /src/stkagent.c | |
parent | 90cb42e3f9a539637427650954bbf203f2fa88be (diff) | |
download | ofono-70ae73d78baf88cdd54078d9c6e2626ad15a7cd2.tar.bz2 |
stkagent: Add stk_agent_display_action method
Diffstat (limited to 'src/stkagent.c')
-rw-r--r-- | src/stkagent.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/stkagent.c b/src/stkagent.c index 23951826..15ad4fab 100644 --- a/src/stkagent.c +++ b/src/stkagent.c @@ -1081,3 +1081,64 @@ int stk_agent_confirm_launch_browser(struct stk_agent *agent, const char *text, return 0; } + +static void display_action_cb(DBusPendingCall *call, void *data) +{ + struct stk_agent *agent = data; + stk_agent_user_termination_cb cb = agent->user_cb; + DBusMessage *reply = dbus_pending_call_steal_reply(call); + enum stk_agent_result result; + gboolean remove_agent; + + if (check_error(agent, reply, + ALLOWED_ERROR_TERMINATE, &result) == -EINVAL) { + remove_agent = TRUE; + goto error; + } + + if (dbus_message_get_args(reply, NULL, DBUS_TYPE_INVALID) == FALSE) { + ofono_error("Can't parse the reply to DisplayAction()"); + remove_agent = TRUE; + goto error; + } + + cb(result, agent->user_data); + goto done; + + CALLBACK_END(); +} + +int stk_agent_display_action(struct stk_agent *agent, + const char *text, + const struct stk_icon_id *icon, + stk_agent_user_termination_cb cb, + void *user_data, + ofono_destroy_func destroy) +{ + DBusConnection *conn = ofono_dbus_get_connection(); + + agent->msg = dbus_message_new_method_call(agent->bus, agent->path, + OFONO_SIM_APP_INTERFACE, + "DisplayAction"); + if (agent->msg == NULL) + return -ENOMEM; + + dbus_message_append_args(agent->msg, + DBUS_TYPE_STRING, &text, + DBUS_TYPE_BYTE, &icon->id, + DBUS_TYPE_INVALID); + + if (dbus_connection_send_with_reply(conn, agent->msg, &agent->call, + 0) == FALSE || + agent->call == NULL) + return -EIO; + + agent->user_cb = cb; + agent->user_data = user_data; + agent->user_destroy = destroy; + + dbus_pending_call_set_notify(agent->call, display_action_cb, + agent, NULL); + + return 0; +} |