Open Source Telephony
 help / color / mirror / Atom feed
From: Jeevaka Badrappan <jeevaka.badrappan@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH 3/4] stk: Handle set up call in handled_notify
Date: Wed, 06 Jul 2011 03:06:12 -0700	[thread overview]
Message-ID: <1309946773-7747-4-git-send-email-jeevaka.badrappan@linux.intel.com> (raw)
In-Reply-To: <1309946773-7747-1-git-send-email-jeevaka.badrappan@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 4004 bytes --]

---
 src/stk.c |  108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 106 insertions(+), 2 deletions(-)

diff --git a/src/stk.c b/src/stk.c
index 9575f0e..26faa11 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -77,6 +77,8 @@ struct ofono_stk {
 	struct timeval get_inkey_start_ts;
 	int dtmf_id;
 
+	gboolean modem_handled_cmd;
+
 	__ofono_sms_sim_download_cb_t sms_pp_cb;
 	void *sms_pp_userdata;
 };
@@ -1785,6 +1787,44 @@ static void confirm_call_cb(enum stk_agent_result result, gboolean confirm,
 		stk_command_cb(&error, stk);
 }
 
+static void confirm_handled_call_cb(enum stk_agent_result result,
+					gboolean confirm, void *user_data)
+{
+	struct ofono_stk *stk = user_data;
+	const struct stk_command_setup_call *sc =
+					&stk->pending_cmd->setup_call;
+	struct ofono_voicecall *vc = NULL;
+	struct ofono_atom *vc_atom;
+
+	if (stk->driver->user_confirmation == NULL)
+		goto out;
+
+	if (result != STK_AGENT_RESULT_OK) {
+		stk->driver->user_confirmation(stk, FALSE);
+		goto out;
+	}
+
+	stk->driver->user_confirmation(stk, confirm);
+
+	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 == NULL)
+		goto out;
+
+	__ofono_voicecall_set_alpha_and_icon_id(vc, sc->alpha_id_call_setup,
+						sc->icon_id_call_setup.id);
+
+	stk->modem_handled_cmd = TRUE;
+
+	return;
+out:
+	stk_command_free(stk->pending_cmd);
+	stk->pending_cmd = NULL;
+}
+
 static gboolean handle_command_set_up_call(const struct stk_command *cmd,
 						struct stk_response *rsp,
 						struct ofono_stk *stk)
@@ -2601,6 +2641,40 @@ static gboolean handle_command_launch_browser(const struct stk_command *cmd,
 	return FALSE;
 }
 
+static void handle_setup_call_confirmation_req(struct stk_command *cmd,
+						struct ofono_stk *stk)
+{
+	const struct stk_command_setup_call *sc = &cmd->setup_call;
+	int err;
+	char *alpha_id = dbus_apply_text_attributes(
+					sc->alpha_id_usr_cfm ?
+					sc->alpha_id_usr_cfm : "",
+					&sc->text_attr_usr_cfm);
+	if (alpha_id == NULL)
+		goto out;
+
+	err = stk_agent_confirm_call(stk->current_agent, alpha_id,
+					&sc->icon_id_usr_cfm,
+					confirm_handled_call_cb,
+					stk, NULL,
+					stk->timeout * 1000);
+	g_free(alpha_id);
+
+	if (err < 0)
+		goto out;
+
+	stk->pending_cmd = cmd;
+	stk->cancel_cmd = stk_request_cancel;
+
+	return;
+
+out:
+	if (stk->driver->user_confirmation)
+		stk->driver->user_confirmation(stk, FALSE);
+
+	stk_command_free(cmd);
+}
+
 static void stk_proactive_command_cancel(struct ofono_stk *stk)
 {
 	if (stk->immediate_response)
@@ -2615,8 +2689,38 @@ static void stk_proactive_command_cancel(struct ofono_stk *stk)
 	}
 }
 
+static void proactive_session_end_handled_cmd(struct ofono_stk *stk)
+{
+	stk->modem_handled_cmd = FALSE;
+
+	switch(stk->pending_cmd->type) {
+	case STK_COMMAND_TYPE_SETUP_CALL:
+	{
+		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 != NULL)
+			__ofono_voicecall_clear_alpha_and_icon_id(vc);
+
+		break;
+	}
+
+	default:
+		break;
+	}
+}
+
 void ofono_stk_proactive_session_end_notify(struct ofono_stk *stk)
 {
+	if (stk->modem_handled_cmd == TRUE)
+		proactive_session_end_handled_cmd(stk);
+
 	/* Wait until we receive the next command */
 	if (stk->immediate_response)
 		return;
@@ -2858,8 +2962,8 @@ void ofono_stk_proactive_command_handled_notify(struct ofono_stk *stk,
 		break;
 
 	case STK_COMMAND_TYPE_SETUP_CALL:
-		/* TODO */
-		break;
+		handle_setup_call_confirmation_req(cmd, stk);
+		return;
 
 	case STK_COMMAND_TYPE_SEND_USSD:
 		stk_alpha_id_set(stk, cmd->send_ussd.alpha_id,
-- 
1.7.4.1


  parent reply	other threads:[~2011-07-06 10:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-06 10:06 [PATCH 0/4] Add support for modem handled setup call proactive command Jeevaka Badrappan
2011-07-06 10:06 ` [PATCH 1/4] include: Add driver api for user confirmation Jeevaka Badrappan
2011-07-06  6:28   ` Denis Kenzior
2011-07-06 10:06 ` [PATCH 2/4] voicecall: api for set/clear alpha and icon id Jeevaka Badrappan
2011-07-06  6:38   ` Denis Kenzior
2011-07-06 10:06 ` Jeevaka Badrappan [this message]
2011-07-06  6:43   ` [PATCH 3/4] stk: Handle set up call in handled_notify Denis Kenzior
2011-07-06 16:51   ` Andrzej Zaborowski
2011-07-06 10:06 ` [PATCH 4/4] ifxmodem: add support for user_confirmation in stk Jeevaka Badrappan
  -- strict thread matches above, loose matches on Subject: below --
2011-07-15 12:42 [PATCH 0/4] Add support for modem handled setup call proactive command Jeevaka Badrappan
2011-07-15 12:42 ` [PATCH 3/4] stk: Handle set up call in handled_notify Jeevaka Badrappan
2011-07-15 12:46   ` jeevaka.badrappan
2011-07-15 16:11     ` Denis Kenzior
2011-07-15 16:34   ` Denis Kenzior
2011-07-15 16:45     ` jeevaka.badrappan
2011-07-15 16:59       ` Denis Kenzior

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=1309946773-7747-4-git-send-email-jeevaka.badrappan@linux.intel.com \
    --to=jeevaka.badrappan@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