summaryrefslogtreecommitdiffstats
path: root/src/stk.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2011-05-31 23:31:41 -0500
committerDenis Kenzior <denkenz@gmail.com>2011-05-31 23:31:41 -0500
commitcdb98a70d0bf25e7f3b7bbbe364805dc9aa46e89 (patch)
tree5dbffb2049a02e5027d71027567feaba6c823758 /src/stk.c
parent4c2d8976142f52013b8edb1777a65b674d6d25b7 (diff)
downloadofono-cdb98a70d0bf25e7f3b7bbbe364805dc9aa46e89.tar.bz2
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.
Diffstat (limited to 'src/stk.c')
-rw-r--r--src/stk.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/stk.c b/src/stk.c
index 8214b659..9575f0e4 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -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);
}