RE: [RFC 2/4] stk: Handle Launch Browser proactive command
Hi, So a question about this. Why are we checking the netreg atom? Shouldn't we be checking the gprs atom's attached property? But this brings up an even more interesting question, do we even need to assume that we have to be attached to the cellular network to perform these operations? We could in theory go over wifi. I agree that the modem online property is unrelated to this. Also the card may in theory specify a URL that designates a local file or something on a local network, not the internet. Agree. It can be anything not only cellular network. Do we need to check the bearer parameters in that case or can I just remove the current check code? Regards, Jeevaka ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [RFC 2/4] stk: Handle Launch Browser proactive command
Hi Jeevaka, On 01/13/2011 08:56 AM, jeevaka.badrap...@elektrobit.com wrote: Hi, So a question about this. Why are we checking the netreg atom? Shouldn't we be checking the gprs atom's attached property? But this brings up an even more interesting question, do we even need to assume that we have to be attached to the cellular network to perform these operations? We could in theory go over wifi. I agree that the modem online property is unrelated to this. Also the card may in theory specify a URL that designates a local file or something on a local network, not the internet. Agree. It can be anything not only cellular network. Do we need to check the bearer parameters in that case or can I just remove the current check code? Good point on the bearer parameters. My take is that we should either ignore the bearer parameters or return not-capable if they're set. Otherwise removing the current checks in the code seems reasonable to me. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [RFC 2/4] stk: Handle Launch Browser proactive command
Hi Jeevaka, +static gboolean handle_command_launch_browser(const struct stk_command *cmd, + struct stk_response *rsp, + struct ofono_stk *stk) +{ + const struct stk_command_launch_browser *lb = cmd-launch_browser; + struct ofono_modem *modem = __ofono_atom_get_modem(stk-atom); + static unsigned char no_cause[] = { 0x00 }; + static unsigned char no_service[] = { 0x04 }; + struct ofono_atom *netreg_atom; + struct ofono_netreg *netreg; + int qualifier = cmd-qualifier; + char *alpha_id; + int err; + int status; + + if (qualifier 3 || qualifier == 1) { + rsp-result.type = STK_RESULT_TYPE_COMMAND_NOT_UNDERSTOOD; + return TRUE; + } + + if ( lb-browser_id 4) { + rsp-result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD; + return TRUE; + } + + if (ofono_modem_get_online(modem) == FALSE) { + ADD_ERROR_RESULT(rsp-result, STK_RESULT_TYPE_TERMINAL_BUSY, + no_service); + return TRUE; + } + + netreg_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_NETREG); + if (netreg_atom == NULL) { + rsp-result.type = STK_RESULT_TYPE_NOT_CAPABLE; + return TRUE; + } + + netreg = __ofono_atom_get_data(netreg_atom); + status = __ofono_netreg_registration_status(netreg); + + if (status != NETWORK_REGISTRATION_STATUS_REGISTERED + status != NETWORK_REGISTRATION_STATUS_ROAMING) { + ADD_ERROR_RESULT(rsp-result, STK_RESULT_TYPE_TERMINAL_BUSY, + no_service); + return TRUE; + } + So a question about this. Why are we checking the netreg atom? Shouldn't we be checking the gprs atom's attached property? But this brings up an even more interesting question, do we even need to assume that we have to be attached to the cellular network to perform these operations? We could in theory go over wifi. Thoughts? + alpha_id = dbus_apply_text_attributes(lb-alpha_id ? lb-alpha_id : , + lb-text_attr); + if (alpha_id == NULL) { + rsp-result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD; + return TRUE; + } + + err = stk_agent_launch_browser(stk-current_agent, alpha_id, + lb-icon_id.id, lb-url, + confirm_launch_browser_cb, + stk, NULL, stk-timeout * 1000); + g_free(alpha_id); + + if (err 0) { + /* + * We most likely got an out of memory error, tell SIM + * to retry + */ + ADD_ERROR_RESULT(rsp-result, STK_RESULT_TYPE_TERMINAL_BUSY, + no_cause); + return TRUE; + } + + stk-respond_on_exit = TRUE; + stk-cancel_cmd = stk_request_cancel; + + return FALSE; +} + Rest seems reasonable to me. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [RFC 2/4] stk: Handle Launch Browser proactive command
Hi, On 12 January 2011 23:31, Denis Kenzior denk...@gmail.com wrote: +static gboolean handle_command_launch_browser(const struct stk_command *cmd, + struct stk_response *rsp, + struct ofono_stk *stk) +{ + const struct stk_command_launch_browser *lb = cmd-launch_browser; + struct ofono_modem *modem = __ofono_atom_get_modem(stk-atom); + static unsigned char no_cause[] = { 0x00 }; + static unsigned char no_service[] = { 0x04 }; + struct ofono_atom *netreg_atom; + struct ofono_netreg *netreg; + int qualifier = cmd-qualifier; + char *alpha_id; + int err; + int status; + + if (qualifier 3 || qualifier == 1) { + rsp-result.type = STK_RESULT_TYPE_COMMAND_NOT_UNDERSTOOD; + return TRUE; + } + + if ( lb-browser_id 4) { + rsp-result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD; + return TRUE; + } + + if (ofono_modem_get_online(modem) == FALSE) { + ADD_ERROR_RESULT(rsp-result, STK_RESULT_TYPE_TERMINAL_BUSY, + no_service); + return TRUE; + } + + netreg_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_NETREG); + if (netreg_atom == NULL) { + rsp-result.type = STK_RESULT_TYPE_NOT_CAPABLE; + return TRUE; + } + + netreg = __ofono_atom_get_data(netreg_atom); + status = __ofono_netreg_registration_status(netreg); + + if (status != NETWORK_REGISTRATION_STATUS_REGISTERED + status != NETWORK_REGISTRATION_STATUS_ROAMING) { + ADD_ERROR_RESULT(rsp-result, STK_RESULT_TYPE_TERMINAL_BUSY, + no_service); + return TRUE; + } + So a question about this. Why are we checking the netreg atom? Shouldn't we be checking the gprs atom's attached property? But this brings up an even more interesting question, do we even need to assume that we have to be attached to the cellular network to perform these operations? We could in theory go over wifi. I agree that the modem online property is unrelated to this. Also the card may in theory specify a URL that designates a local file or something on a local network, not the internet. Best regards ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[RFC 2/4] stk: Handle Launch Browser proactive command
--- src/stk.c | 122 src/stkagent.c | 67 +++ src/stkagent.h |5 ++ 3 files changed, 194 insertions(+), 0 deletions(-) diff --git a/src/stk.c b/src/stk.c index 932e49a..0511b68 100644 --- a/src/stk.c +++ b/src/stk.c @@ -99,6 +99,11 @@ struct extern_req { static void envelope_queue_run(struct ofono_stk *stk); static void timers_update(struct ofono_stk *stk); +#define ADD_ERROR_RESULT(result, error, addn_info) \ + result.type = error;\ + result.additional_len = sizeof(addn_info); \ + result.additional = addn_info; \ + static int stk_respond(struct ofono_stk *stk, struct stk_response *rsp, ofono_stk_generic_cb_t cb) { @@ -2338,6 +2343,118 @@ static gboolean handle_command_play_tone(const struct stk_command *cmd, return FALSE; } +static void confirm_launch_browser_cb(enum stk_agent_result result, + gboolean confirm, + void *user_data) +{ + struct ofono_stk *stk = user_data; + unsigned char no_cause[] = { 0x00 }; + struct ofono_error failure = { .type = OFONO_ERROR_TYPE_FAILURE }; + struct stk_response rsp; + + stk-respond_on_exit = FALSE; + + switch (result) { + case STK_AGENT_RESULT_TIMEOUT: + confirm = FALSE; + /* Fall through */ + + case STK_AGENT_RESULT_OK: + if (confirm) + break; + + send_simple_response(stk, STK_RESULT_TYPE_USER_REJECT); + return; + default: + memset(rsp, 0, sizeof(rsp)); + ADD_ERROR_RESULT(rsp.result, STK_RESULT_TYPE_TERMINAL_BUSY, + no_cause); + + if (stk_respond(stk, rsp, stk_command_cb)) + stk_command_cb(failure, stk); + + return; + } + + send_simple_response(stk, STK_RESULT_TYPE_SUCCESS); +} + +static gboolean handle_command_launch_browser(const struct stk_command *cmd, + struct stk_response *rsp, + struct ofono_stk *stk) +{ + const struct stk_command_launch_browser *lb = cmd-launch_browser; + struct ofono_modem *modem = __ofono_atom_get_modem(stk-atom); + static unsigned char no_cause[] = { 0x00 }; + static unsigned char no_service[] = { 0x04 }; + struct ofono_atom *netreg_atom; + struct ofono_netreg *netreg; + int qualifier = cmd-qualifier; + char *alpha_id; + int err; + int status; + + if (qualifier 3 || qualifier == 1) { + rsp-result.type = STK_RESULT_TYPE_COMMAND_NOT_UNDERSTOOD; + return TRUE; + } + + if ( lb-browser_id 4) { + rsp-result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD; + return TRUE; + } + + if (ofono_modem_get_online(modem) == FALSE) { + ADD_ERROR_RESULT(rsp-result, STK_RESULT_TYPE_TERMINAL_BUSY, + no_service); + return TRUE; + } + + netreg_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_NETREG); + if (netreg_atom == NULL) { + rsp-result.type = STK_RESULT_TYPE_NOT_CAPABLE; + return TRUE; + } + + netreg = __ofono_atom_get_data(netreg_atom); + status = __ofono_netreg_registration_status(netreg); + + if (status != NETWORK_REGISTRATION_STATUS_REGISTERED + status != NETWORK_REGISTRATION_STATUS_ROAMING) { + ADD_ERROR_RESULT(rsp-result, STK_RESULT_TYPE_TERMINAL_BUSY, + no_service); + return TRUE; + } + + alpha_id = dbus_apply_text_attributes(lb-alpha_id ? lb-alpha_id : , + lb-text_attr); + if (alpha_id == NULL) { + rsp-result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD; + return TRUE; + } + + err = stk_agent_launch_browser(stk-current_agent, alpha_id, + lb-icon_id.id, lb-url, + confirm_launch_browser_cb, + stk, NULL, stk-timeout * 1000); + g_free(alpha_id); + + if (err 0) { + /* +* We most likely got an out of memory error, tell SIM +* to retry +*/ + ADD_ERROR_RESULT(rsp-result, STK_RESULT_TYPE_TERMINAL_BUSY, + no_cause); + return TRUE; + } + + stk-respond_on_exit = TRUE; + stk-cancel_cmd = stk_request_cancel; + + return FALSE; +} + static