From: Philippe Nunes <philippe.nunes@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH v2 04/11] stk: Add support for the proactive command 'Close channel'
Date: Mon, 04 Jul 2011 18:06:35 +0200 [thread overview]
Message-ID: <1309795602-26046-5-git-send-email-philippe.nunes@linux.intel.com> (raw)
In-Reply-To: <1309795602-26046-1-git-send-email-philippe.nunes@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 3502 bytes --]
---
src/stk.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 73 insertions(+), 0 deletions(-)
diff --git a/src/stk.c b/src/stk.c
index 64ef91a..8d4f7c0 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -504,6 +504,37 @@ static void cancel_pending_dtmf(struct ofono_stk *stk)
__ofono_voicecall_tone_cancel(vc, stk->dtmf_id);
}
+static void ofono_stk_deactivate_context_cb(int error, void *data)
+{
+}
+
+static void stk_close_channel(struct ofono_stk *stk)
+{
+ int err;
+ struct ofono_modem *modem = __ofono_atom_get_modem(stk->atom);
+ struct ofono_atom *gprs_atom;
+
+ gprs_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_GPRS);
+ if (gprs_atom == NULL || !__ofono_atom_get_registered(gprs_atom))
+ goto out;
+
+ err = __ofono_gprs_private_context_deactivate(
+ __ofono_atom_get_data(gprs_atom),
+ ofono_stk_deactivate_context_cb,
+ stk);
+
+ if (err == 0)
+ return;
+
+out:
+ stk->bip.channel.id = 0;
+ stk->bip.channel.status = STK_CHANNEL_PACKET_DATA_SERVICE_NOT_ACTIVATED;
+
+ if (stk->pending_cmd && stk->pending_cmd->type ==
+ STK_COMMAND_TYPE_CLOSE_CHANNEL)
+ send_simple_response(stk, STK_RESULT_TYPE_NOT_CAPABLE);
+}
+
static void user_termination_cb(enum stk_agent_result result, void *user_data)
{
struct ofono_stk *stk = user_data;
@@ -518,6 +549,9 @@ static void user_termination_cb(enum stk_agent_result result, void *user_data)
}
send_simple_response(stk, STK_RESULT_TYPE_USER_TERMINATED);
+
+ if (stk->bip.channel.id)
+ stk_close_channel(stk);
}
static void stk_alpha_id_set(struct ofono_stk *stk,
@@ -662,6 +696,8 @@ out:
if (stk_respond(stk, &rsp, stk_command_cb))
stk_command_cb(&failure, stk);
+ if (rsp.result.type != STK_RESULT_TYPE_SUCCESS)
+ stk_close_channel(stk);
}
static int duration_to_msecs(const struct stk_duration *duration)
@@ -2827,6 +2863,38 @@ static gboolean handle_command_open_channel(const struct stk_command *cmd,
return FALSE;
}
+static gboolean handle_command_close_channel(const struct stk_command *cmd,
+ struct stk_response *rsp,
+ struct ofono_stk *stk)
+{
+ const struct stk_command_close_channel *cc = &cmd->close_channel;
+
+ /* Check if channel identifier is valid */
+ if (cmd->dst != (stk->bip.channel.id | 0x20)) {
+ unsigned char addnl_info[1];
+
+ addnl_info[1] = STK_RESULT_ADDNL_BIP_PB_CHANNEL_ID_NOT_VALID;
+ ADD_ERROR_RESULT(rsp->result, STK_RESULT_TYPE_BIP_ERROR,
+ addnl_info);
+ return TRUE;
+ }
+
+ /*
+ * Don't inform the user about the link closing phase if AID is
+ * a null data object or is not provided
+ */
+ if (cc->alpha_id && cc->alpha_id[0] != '\0')
+ stk_alpha_id_set(stk, cc->alpha_id, &cc->text_attr,
+ &cc->icon_id);
+
+ stk->respond_on_exit = TRUE;
+ stk->cancel_cmd = stk_request_cancel;
+
+ stk_close_channel(stk);
+
+ return FALSE;
+}
+
static gboolean handle_command_get_channel_status(const struct stk_command *cmd,
struct stk_response *rsp,
struct ofono_stk *stk)
@@ -3035,6 +3103,11 @@ void ofono_stk_proactive_command_notify(struct ofono_stk *stk,
&rsp, stk);
break;
+ case STK_COMMAND_TYPE_CLOSE_CHANNEL:
+ respond = handle_command_close_channel(stk->pending_cmd,
+ &rsp, stk);
+ break;
+
case STK_COMMAND_TYPE_GET_CHANNEL_STATUS:
respond = handle_command_get_channel_status(stk->pending_cmd,
&rsp, stk);
--
1.7.1
next prev parent reply other threads:[~2011-07-04 16:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-04 16:06 [PATCH v2 00/11] Add BIP commands support Philippe Nunes
2011-07-04 16:06 ` [PATCH v2 01/11] gprs: Add private APIs to activate/deactivate a private context for STK Philippe Nunes
2011-07-04 16:06 ` [PATCH v2 02/11] stk: Add support for the proactive command 'Open channel' Philippe Nunes
2011-07-04 16:06 ` [PATCH v2 03/11] stk: Add support for the proactive command 'Get channel status' Philippe Nunes
2011-07-04 16:06 ` Philippe Nunes [this message]
2011-07-04 16:06 ` [PATCH v2 05/11] stk: Add 'ofono_stk_activate_cb' definition Philippe Nunes
2011-07-04 16:06 ` [PATCH v2 06/11] stk: Add 'ofono_stk_deactivate_context_cb' definition Philippe Nunes
2011-07-04 16:06 ` [PATCH v2 07/11] stk: Add support for the proactive command 'Receive data' Philippe Nunes
2011-07-04 16:06 ` [PATCH v2 08/11] stk: Add support for the proactive command 'Send data' Philippe Nunes
2011-07-04 16:06 ` [PATCH v2 09/11] stk: Add support of the Setup event list proactive command Philippe Nunes
2011-07-04 16:06 ` [PATCH v2 10/11] stk: Add host route to route the traffic through the stk interface Philippe Nunes
2011-07-04 16:06 ` [PATCH v2 11/11] gprs: Add API to set a 'detach'notification callback Philippe Nunes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1309795602-26046-5-git-send-email-philippe.nunes@linux.intel.com \
--to=philippe.nunes@linux.intel.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox