stk: Cancel pending DTMF tones if session is ended

The Send DTMF command is special in its use of DisplayAction method of
STK agent.  This allows the user to send a 'User Terminated Session'
response to the SIM.  If the user performs this action, then any pending
DTMFs should also be canceled as soon as possible.
This commit is contained in:
Denis Kenzior 2011-05-31 23:31:41 -05:00
parent 4c2d897614
commit cdb98a70d0
1 changed files with 25 additions and 13 deletions

View File

@ -474,12 +474,34 @@ static void emit_menu_changed(struct ofono_stk *stk)
g_dbus_send_message(conn, signal);
}
static void cancel_pending_dtmf(struct ofono_stk *stk)
{
struct ofono_voicecall *vc = NULL;
struct ofono_atom *vc_atom;
vc_atom = __ofono_modem_find_atom(__ofono_atom_get_modem(stk->atom),
OFONO_ATOM_TYPE_VOICECALL);
if (vc_atom)
vc = __ofono_atom_get_data(vc_atom);
if (vc) /* Should be always true here */
__ofono_voicecall_tone_cancel(vc, stk->dtmf_id);
}
static void user_termination_cb(enum stk_agent_result result, void *user_data)
{
struct ofono_stk *stk = user_data;
if (result == STK_AGENT_RESULT_TERMINATE)
send_simple_response(stk, STK_RESULT_TYPE_USER_TERMINATED);
if (result != STK_AGENT_RESULT_TERMINATE)
return;
switch (stk->pending_cmd->type) {
case STK_COMMAND_TYPE_SEND_DTMF:
cancel_pending_dtmf(stk);
break;
}
send_simple_response(stk, STK_RESULT_TYPE_USER_TERMINATED);
}
static void stk_alpha_id_set(struct ofono_stk *stk,
@ -2265,17 +2287,7 @@ static gboolean handle_command_provide_local_info(const struct stk_command *cmd,
static void send_dtmf_cancel(struct ofono_stk *stk)
{
struct ofono_voicecall *vc = NULL;
struct ofono_atom *vc_atom;
vc_atom = __ofono_modem_find_atom(__ofono_atom_get_modem(stk->atom),
OFONO_ATOM_TYPE_VOICECALL);
if (vc_atom)
vc = __ofono_atom_get_data(vc_atom);
if (vc) /* Should be always true here */
__ofono_voicecall_tone_cancel(vc, stk->dtmf_id);
cancel_pending_dtmf(stk);
stk_alpha_id_unset(stk);
}