summaryrefslogtreecommitdiffstats
path: root/src/stk.c
diff options
context:
space:
mode:
authorAndrzej Zaborowski <andrew.zaborowski@intel.com>2011-02-15 08:58:59 +0100
committerDenis Kenzior <denkenz@gmail.com>2011-02-17 15:16:34 -0600
commitf7d4643cc551841815f621bfc86b7b1ece46be54 (patch)
tree3172a961749c7385db750597fb370b8c45497b38 /src/stk.c
parent7f43fc0f69606dfb248fe37d1c48ad73f5dbc744 (diff)
downloadofono-f7d4643cc551841815f621bfc86b7b1ece46be54.tar.bz2
stk: Partially handle Refresh command
Only the four "NAA initialisation" modes are handled at the moment.
Diffstat (limited to 'src/stk.c')
-rw-r--r--src/stk.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/stk.c b/src/stk.c
index 199e02b1..bc46b2ff 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -1973,10 +1973,22 @@ static gboolean handle_command_send_ussd(const struct stk_command *cmd,
return FALSE;
}
+static void free_idle_mode_text(struct ofono_stk *stk)
+{
+ g_free(stk->idle_mode_text);
+ stk->idle_mode_text = NULL;
+
+ memset(&stk->idle_mode_icon, 0, sizeof(stk->idle_mode_icon));
+}
+
static gboolean handle_command_refresh(const struct stk_command *cmd,
struct stk_response *rsp,
struct ofono_stk *stk)
{
+ struct ofono_error failure = { .type = OFONO_ERROR_TYPE_FAILURE };
+ struct ofono_sim *sim = NULL;
+ struct ofono_atom *sim_atom;
+ int err;
GSList *l;
DBG("");
@@ -2030,6 +2042,59 @@ static gboolean handle_command_refresh(const struct stk_command *cmd,
cmd->refresh.icon_id.qualifier);
DBG("Alpha ID: %s", cmd->refresh.alpha_id);
+ sim_atom = __ofono_modem_find_atom(__ofono_atom_get_modem(stk->atom),
+ OFONO_ATOM_TYPE_SIM);
+ if (sim_atom)
+ sim = __ofono_atom_get_data(sim_atom);
+
+ if (sim == NULL) {
+ rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+ return TRUE;
+ }
+
+ if (cmd->qualifier < 4) {
+ int qualifier = stk->pending_cmd->qualifier;
+ GSList *file_list = stk->pending_cmd->refresh.file_list;
+
+ /* Don't free the list yet */
+ stk->pending_cmd->refresh.file_list = NULL;
+
+ /*
+ * Queue the TERMINAL RESPONSE before triggering potential
+ * file accesses.
+ */
+ err = stk_respond(stk, rsp, stk_command_cb);
+ if (err)
+ stk_command_cb(&failure, stk);
+
+ /* TODO: use the alphaId / icon */
+ /* TODO: if AID is supplied, check its value */
+ /* TODO: possibly check if a D-bus call is pending or
+ * an STK session ongoing. */
+
+ /* TODO: free some elements of the atom state */
+
+ switch (qualifier) {
+ case 0:
+ free_idle_mode_text(stk);
+ __ofono_sim_refresh(sim, file_list, TRUE, TRUE);
+ break;
+ case 1:
+ __ofono_sim_refresh(sim, file_list, FALSE, FALSE);
+ break;
+ case 2:
+ case 3:
+ free_idle_mode_text(stk);
+ __ofono_sim_refresh(sim, file_list, FALSE, TRUE);
+ break;
+ }
+
+ g_slist_foreach(file_list, (GFunc) g_free, NULL);
+ g_slist_free(file_list);
+
+ return FALSE;
+ }
+
rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
return TRUE;
}