* [PATCH v4 0/2] Add support for modem handled setup call proactive command
@ 2011-07-25 18:15 Jeevaka Badrappan
2011-07-25 18:15 ` [PATCH v4 1/2] voicecall: api for set/clear alpha and icon id Jeevaka Badrappan
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jeevaka Badrappan @ 2011-07-25 18:15 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 948 bytes --]
Hi,
This patch set fixes the review comments.
If the modem is able to setup the call, then the alpha id will be freed when the
initiated call ends.
If the modem is not able to setup the call due to some reason, then the memory
allocated for alpha id and dial request are freed when the command end/session
end is received.
Also, noticed there is a break missing in the ofono_stk_proactive_command_handled_notify
for STK_COMMAND_TYPE_SEND_SS case. Fix for that will be provided as a separate patch.
Note: This version of the patch is not tested.
Thanks and Regards,
Jeevaka
Jeevaka Badrappan (2):
voicecall: api for set/clear alpha and icon id
stk: Handle set up call in handled_notify
src/ofono.h | 6 ++
src/stk.c | 166 ++++++++++++++++++++++++++++++++++++++++++++++---------
src/voicecall.c | 65 +++++++++++++++++++++
3 files changed, 211 insertions(+), 26 deletions(-)
--
1.7.4.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v4 1/2] voicecall: api for set/clear alpha and icon id
2011-07-25 18:15 [PATCH v4 0/2] Add support for modem handled setup call proactive command Jeevaka Badrappan
@ 2011-07-25 18:15 ` Jeevaka Badrappan
2011-07-25 18:15 ` [PATCH v4 2/2] stk: Handle set up call in handled_notify Jeevaka Badrappan
2011-07-26 4:00 ` [PATCH v4 0/2] Add support for modem handled setup call proactive command Denis Kenzior
2 siblings, 0 replies; 4+ messages in thread
From: Jeevaka Badrappan @ 2011-07-25 18:15 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3364 bytes --]
---
src/ofono.h | 6 +++++
src/voicecall.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 71 insertions(+), 0 deletions(-)
diff --git a/src/ofono.h b/src/ofono.h
index 6524806..808a8f1 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -266,6 +266,12 @@ int __ofono_voicecall_dial(struct ofono_voicecall *vc,
ofono_voicecall_dial_cb_t cb, void *user_data);
void __ofono_voicecall_dial_cancel(struct ofono_voicecall *vc);
+void __ofono_voicecall_set_alpha_and_icon_id(struct ofono_voicecall *vc,
+ const char *addr, int addr_type,
+ const char *message,
+ unsigned char icon_id);
+void __ofono_voicecall_clear_alpha_and_icon_id(struct ofono_voicecall *vc);
+
int __ofono_voicecall_tone_send(struct ofono_voicecall *vc,
const char *tone_str,
ofono_voicecall_tone_cb_t cb, void *user_data);
diff --git a/src/voicecall.c b/src/voicecall.c
index f4c2358..14b5d22 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -42,6 +42,7 @@
#define MAX_VOICE_CALLS 16
#define VOICECALL_FLAG_SIM_ECC_READY 0x1
+#define VOICECALL_FLAG_STK_MODEM_CALLSETUP 0x2
#define SETTINGS_STORE "voicecall"
#define SETTINGS_GROUP "Settings"
@@ -2223,6 +2224,39 @@ void ofono_voicecall_notify(struct ofono_voicecall *vc,
goto error;
}
+ if (vc->flags & VOICECALL_FLAG_STK_MODEM_CALLSETUP) {
+ struct dial_request *req = vc->dial_req;
+ const char *number = phone_number_to_string(&req->ph);
+
+ if (!strcmp(number, "112")) {
+ struct ofono_modem *modem =
+ __ofono_atom_get_modem(vc->atom);
+
+ __ofono_modem_inc_emergency_mode(modem);
+ }
+
+ if (v->call->clip_validity == CLIP_VALIDITY_NOT_AVAILABLE) {
+ v->call->phone_number.type = req->ph.type;
+ strncpy(v->call->phone_number.number, req->ph.number,
+ 20);
+ v->call->clip_validity = CLIP_VALIDITY_VALID;
+ }
+
+ v->message = req->message;
+ v->icon_id = req->icon_id;
+
+ req->message = NULL;
+ req->call = v;
+
+ /*
+ * TS 102 223 Section 6.4.13: The terminal shall not store
+ * in the UICC the call set-up details (called party number
+ * and associated parameters)
+ */
+ v->untracked = TRUE;
+ vc->flags &= ~VOICECALL_FLAG_STK_MODEM_CALLSETUP;
+ }
+
v->detect_time = time(NULL);
if (!voicecall_dbus_register(v)) {
@@ -3682,6 +3716,37 @@ void __ofono_voicecall_tone_cancel(struct ofono_voicecall *vc, int id)
}
}
+void __ofono_voicecall_set_alpha_and_icon_id(struct ofono_voicecall *vc,
+ const char *addr, int addr_type,
+ const char *message,
+ unsigned char icon_id)
+{
+ struct dial_request *req;
+
+ req = g_new0(struct dial_request, 1);
+
+ req->message = g_strdup(message);
+ req->icon_id = icon_id;
+
+ req->ph.type = addr_type;
+ strncpy(req->ph.number, addr, 20);
+
+ vc->dial_req = req;
+
+ vc->flags |= VOICECALL_FLAG_STK_MODEM_CALLSETUP;
+}
+
+void __ofono_voicecall_clear_alpha_and_icon_id(struct ofono_voicecall *vc)
+{
+ g_free(vc->dial_req->message);
+ vc->dial_req->message = NULL;
+
+ g_free(vc->dial_req);
+ vc->dial_req = NULL;
+
+ vc->flags &= ~VOICECALL_FLAG_STK_MODEM_CALLSETUP;
+}
+
static void ssn_mt_forwarded_notify(struct ofono_voicecall *vc,
unsigned int id, int code,
const struct ofono_phone_number *ph)
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v4 2/2] stk: Handle set up call in handled_notify
2011-07-25 18:15 [PATCH v4 0/2] Add support for modem handled setup call proactive command Jeevaka Badrappan
2011-07-25 18:15 ` [PATCH v4 1/2] voicecall: api for set/clear alpha and icon id Jeevaka Badrappan
@ 2011-07-25 18:15 ` Jeevaka Badrappan
2011-07-26 4:00 ` [PATCH v4 0/2] Add support for modem handled setup call proactive command Denis Kenzior
2 siblings, 0 replies; 4+ messages in thread
From: Jeevaka Badrappan @ 2011-07-25 18:15 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 6717 bytes --]
---
src/stk.c | 166 +++++++++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 140 insertions(+), 26 deletions(-)
diff --git a/src/stk.c b/src/stk.c
index e8ffb42..e85e595 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -1790,6 +1790,45 @@ 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->addr.number,
+ sc->addr.ton_npi,
+ sc->alpha_id_call_setup,
+ sc->icon_id_call_setup.id);
+
+ 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)
@@ -2606,6 +2645,77 @@ static gboolean handle_command_launch_browser(const struct stk_command *cmd,
return FALSE;
}
+static void proactive_command_handled_end(struct ofono_stk *stk)
+{
+ if (stk->pending_cmd == NULL)
+ return;
+
+ 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;
+ }
+ case STK_COMMAND_TYPE_SEND_SMS:
+ case STK_COMMAND_TYPE_SEND_USSD:
+ case STK_COMMAND_TYPE_SEND_SS:
+ case STK_COMMAND_TYPE_SEND_DTMF:
+ stk_alpha_id_unset(stk);
+ break;
+
+ default:
+ break;
+ }
+
+ stk_command_free(stk->pending_cmd);
+ stk->pending_cmd = NULL;
+ stk->cancel_cmd = NULL;
+}
+
+static gboolean 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->cancel_cmd = proactive_command_handled_end;
+
+ return TRUE;
+
+out:
+ if (stk->driver->user_confirmation)
+ stk->driver->user_confirmation(stk, FALSE);
+
+ return FALSE;
+}
+
static void stk_proactive_command_cancel(struct ofono_stk *stk)
{
if (stk->immediate_response)
@@ -2816,8 +2926,8 @@ void ofono_stk_proactive_command_handled_notify(struct ofono_stk *stk,
int length,
const unsigned char *pdu)
{
- struct stk_command *cmd;
struct stk_response dummyrsp;
+ gboolean ok = TRUE;
/*
* Modems send us the proactive command details and terminal responses
@@ -2826,69 +2936,73 @@ void ofono_stk_proactive_command_handled_notify(struct ofono_stk *stk,
* responses here
*/
if (length > 0 && pdu[0] == 0x81) {
- stk_alpha_id_unset(stk);
+ proactive_command_handled_end(stk);
return;
}
stk_proactive_command_cancel(stk);
- cmd = stk_command_new_from_pdu(pdu, length);
+ stk->pending_cmd = stk_command_new_from_pdu(pdu, length);
- if (cmd == NULL || cmd->status != STK_PARSE_RESULT_OK) {
+ if (stk->pending_cmd == NULL ||
+ stk->pending_cmd->status != STK_PARSE_RESULT_OK) {
ofono_error("Can't parse proactive command");
- if (cmd)
- stk_command_free(cmd);
- return;
+ ok = FALSE;
+ goto out;
}
- DBG("type: %d", cmd->type);
+ DBG("type: %d", stk->pending_cmd->type);
- switch (cmd->type) {
+ switch (stk->pending_cmd->type) {
case STK_COMMAND_TYPE_MORE_TIME:
break;
case STK_COMMAND_TYPE_SEND_SMS:
- stk_alpha_id_set(stk, cmd->send_sms.alpha_id,
- &cmd->send_sms.text_attr,
- &cmd->send_sms.icon_id);
+ stk_alpha_id_set(stk, stk->pending_cmd->send_sms.alpha_id,
+ &stk->pending_cmd->send_sms.text_attr,
+ &stk->pending_cmd->send_sms.icon_id);
break;
case STK_COMMAND_TYPE_SETUP_IDLE_MODE_TEXT:
- handle_command_set_idle_text(cmd, &dummyrsp, stk);
+ handle_command_set_idle_text(stk->pending_cmd, &dummyrsp, stk);
break;
case STK_COMMAND_TYPE_SETUP_MENU:
- handle_command_set_up_menu(cmd, &dummyrsp, stk);
+ handle_command_set_up_menu(stk->pending_cmd, &dummyrsp, stk);
break;
case STK_COMMAND_TYPE_SETUP_CALL:
- /* TODO */
+ ok = handle_setup_call_confirmation_req(stk->pending_cmd, stk);
break;
case STK_COMMAND_TYPE_SEND_USSD:
- stk_alpha_id_set(stk, cmd->send_ussd.alpha_id,
- &cmd->send_ussd.text_attr,
- &cmd->send_ussd.icon_id);
+ stk_alpha_id_set(stk, stk->pending_cmd->send_ussd.alpha_id,
+ &stk->pending_cmd->send_ussd.text_attr,
+ &stk->pending_cmd->send_ussd.icon_id);
break;
case STK_COMMAND_TYPE_SEND_SS:
- stk_alpha_id_set(stk, cmd->send_ss.alpha_id,
- &cmd->send_ss.text_attr,
- &cmd->send_ss.icon_id);
+ stk_alpha_id_set(stk, stk->pending_cmd->send_ss.alpha_id,
+ &stk->pending_cmd->send_ss.text_attr,
+ &stk->pending_cmd->send_ss.icon_id);
case STK_COMMAND_TYPE_SEND_DTMF:
- stk_alpha_id_set(stk, cmd->send_dtmf.alpha_id,
- &cmd->send_dtmf.text_attr,
- &cmd->send_dtmf.icon_id);
+ stk_alpha_id_set(stk, stk->pending_cmd->send_dtmf.alpha_id,
+ &stk->pending_cmd->send_dtmf.text_attr,
+ &stk->pending_cmd->send_dtmf.icon_id);
break;
case STK_COMMAND_TYPE_REFRESH:
- handle_command_refresh(cmd, NULL, stk);
+ handle_command_refresh(stk->pending_cmd, NULL, stk);
break;
}
- stk_command_free(cmd);
+out:
+ if (ok == FALSE) {
+ stk_command_free(stk->pending_cmd);
+ stk->pending_cmd = NULL;
+ }
}
int ofono_stk_driver_register(const struct ofono_stk_driver *d)
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v4 0/2] Add support for modem handled setup call proactive command
2011-07-25 18:15 [PATCH v4 0/2] Add support for modem handled setup call proactive command Jeevaka Badrappan
2011-07-25 18:15 ` [PATCH v4 1/2] voicecall: api for set/clear alpha and icon id Jeevaka Badrappan
2011-07-25 18:15 ` [PATCH v4 2/2] stk: Handle set up call in handled_notify Jeevaka Badrappan
@ 2011-07-26 4:00 ` Denis Kenzior
2 siblings, 0 replies; 4+ messages in thread
From: Denis Kenzior @ 2011-07-26 4:00 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 919 bytes --]
Hi Jeevaka,
On 07/25/2011 01:15 PM, Jeevaka Badrappan wrote:
> Hi,
>
> This patch set fixes the review comments.
>
> If the modem is able to setup the call, then the alpha id will be freed when the
> initiated call ends.
>
> If the modem is not able to setup the call due to some reason, then the memory
> allocated for alpha id and dial request are freed when the command end/session
> end is received.
>
I went ahead and applied both of these patches. I did do some minor
refactoring afterwards, please test and let me know whether I broke
something.
> Also, noticed there is a break missing in the ofono_stk_proactive_command_handled_notify
> for STK_COMMAND_TYPE_SEND_SS case. Fix for that will be provided as a separate patch.
I went ahead and fixed this as well.
>
> Note: This version of the patch is not tested.
>
> Thanks and Regards,
> Jeevaka
>
Regards,
-Denis
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-07-26 4:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-25 18:15 [PATCH v4 0/2] Add support for modem handled setup call proactive command Jeevaka Badrappan
2011-07-25 18:15 ` [PATCH v4 1/2] voicecall: api for set/clear alpha and icon id Jeevaka Badrappan
2011-07-25 18:15 ` [PATCH v4 2/2] stk: Handle set up call in handled_notify Jeevaka Badrappan
2011-07-26 4:00 ` [PATCH v4 0/2] Add support for modem handled setup call proactive command Denis Kenzior
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.