All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/2] Add null text/alpha identifier and icon specific handling
@ 2010-12-29 13:16 Jeevaka Badrappan
  2010-12-29 13:16 ` [RFC 1/2] stkutil: Allocate for empty string in text dataobj Jeevaka Badrappan
  2010-12-29 13:16 ` [RFC 2/2] stk: add missing text and icon case handling Jeevaka Badrappan
  0 siblings, 2 replies; 4+ messages in thread
From: Jeevaka Badrappan @ 2010-12-29 13:16 UTC (permalink / raw)
  To: ofono

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

Hi,

Following patch adds the missing "text/alpha identifier and icon" one
particular case handling.

As per the ETSI TS 102 223 section 6.5.4, "If the terminal receives an
icon, and either an empty or no alpha identifier/text string is given
by the UICC, than the terminal shall reject the command with general"
result "Command data not understood by terminal"."

As per the ETSI 102 223 section 6.8, Text string is only required in
response to a GetInkey or GetInput proactive command. So, there is no
need to add any specific handling for null or empty strings cases.

Regards,
Jeevaka

Jeevaka Badrappan (2):
  stkutil: Allocate for empty string in text dataobj
  stk: add missing text and icon case handling

 src/stk.c     |  114 +++++++++++++++++++++++++++++++++++++++-----------------
 src/stkutil.c |    2 +-
 2 files changed, 80 insertions(+), 36 deletions(-)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RFC 1/2] stkutil: Allocate for empty string in text dataobj
  2010-12-29 13:16 [RFC 0/2] Add null text/alpha identifier and icon specific handling Jeevaka Badrappan
@ 2010-12-29 13:16 ` Jeevaka Badrappan
  2010-12-29 13:16 ` [RFC 2/2] stk: add missing text and icon case handling Jeevaka Badrappan
  1 sibling, 0 replies; 4+ messages in thread
From: Jeevaka Badrappan @ 2010-12-29 13:16 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/src/stkutil.c b/src/stkutil.c
index d7493f1..a463a99 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -565,7 +565,7 @@ static gboolean parse_dataobj_text(struct comprehension_tlv_iter *iter,
 	const unsigned char *data;
 	char *utf8;
 
-	if (len == 0) {
+	if (len == 0 || len == 1) {
 		*text = g_try_malloc0(1);
 		return TRUE;
 	}
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [RFC 2/2] stk: add missing text and icon case handling
  2010-12-29 13:16 [RFC 0/2] Add null text/alpha identifier and icon specific handling Jeevaka Badrappan
  2010-12-29 13:16 ` [RFC 1/2] stkutil: Allocate for empty string in text dataobj Jeevaka Badrappan
@ 2010-12-29 13:16 ` Jeevaka Badrappan
  2010-12-30 17:10   ` Denis Kenzior
  1 sibling, 1 reply; 4+ messages in thread
From: Jeevaka Badrappan @ 2010-12-29 13:16 UTC (permalink / raw)
  To: ofono

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

As per the ETSI TS 102 223 section 6.5.4,
If the terminal receives an icon, and either
an empty or no alpha identifier/text string
is given by the UICC, than the terminal shall
reject the command with general result
"Command data not understood by terminal".
---
 src/stk.c |  114 ++++++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 79 insertions(+), 35 deletions(-)

diff --git a/src/stk.c b/src/stk.c
index bec46ea..e3236c1 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -316,6 +316,20 @@ static char *dbus_apply_text_attributes(const char *text,
 	return stk_text_to_html(text, buf, attr->len / 4);
 }
 
+static gboolean check_text( const char *in, const unsigned char icon_id,
+				const struct stk_text_attribute *attr,
+				char **out)
+{
+	if ((in == NULL || strlen(in) < 1) && icon_id != 0)
+		return FALSE;
+
+	*out = dbus_apply_text_attributes(in ? in : "", attr);
+	if (*out == NULL)
+		return FALSE;
+
+	return TRUE;
+}
+
 static struct stk_menu *stk_menu_create(const char *title,
 		const struct stk_text_attribute *title_attr,
 		const struct stk_icon_id *icon, GSList *items,
@@ -341,10 +355,8 @@ static struct stk_menu *stk_menu_create(const char *title,
 	if (ret == NULL)
 		return NULL;
 
-	ret->title = dbus_apply_text_attributes(title ? title : "",
-						title_attr);
-	if (ret->title == NULL)
-		ret->title = g_strdup(title ? title : "");
+	if (check_text(title, icon->id, title_attr, &ret->title) == FALSE)
+		return NULL;
 
 	memcpy(&ret->icon, icon, sizeof(ret->icon));
 	ret->items = g_new0(struct stk_menu_item, len + 1);
@@ -841,6 +853,15 @@ static gboolean handle_command_send_sms(const struct stk_command *cmd,
 	struct ofono_sms *sms;
 	GSList msg_list;
 	struct ofono_uuid uuid;
+	char *text;
+
+	if (check_text(cmd->send_sms.alpha_id, cmd->send_sms.icon_id.id,
+			&cmd->send_sms.text_attr, &text) == FALSE) {
+		rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
+		return TRUE;
+	}
+
+	g_free(text);
 
 	sms_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SMS);
 
@@ -880,11 +901,10 @@ static gboolean handle_command_set_idle_text(const struct stk_command *cmd,
 	const char *path = __ofono_atom_get_path(stk->atom);
 	char *idle_mode_text;
 
-	idle_mode_text = dbus_apply_text_attributes(
-					cmd->setup_idle_mode_text.text,
-					&cmd->setup_idle_mode_text.text_attr);
-
-	if (idle_mode_text == NULL) {
+	if (check_text(cmd->setup_idle_mode_text.text,
+			cmd->setup_idle_mode_text.icon_id.id,
+			&cmd->setup_idle_mode_text.text_attr,
+			&idle_mode_text) == FALSE) {
 		rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
 		return TRUE;
 	}
@@ -1280,10 +1300,11 @@ static gboolean handle_command_display_text(const struct stk_command *cmd,
 	struct stk_command_display_text *dt = &stk->pending_cmd->display_text;
 	uint8_t qualifier = stk->pending_cmd->qualifier;
 	ofono_bool_t priority = (qualifier & (1 << 0)) != 0;
-	char *text = dbus_apply_text_attributes(dt->text, &dt->text_attr);
+	char *text;
 	int err;
 
-	if (text == NULL) {
+	if (check_text(dt->text, dt->icon_id.id, &dt->text_attr,
+			&text) == FALSE) {
 		rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
 		return TRUE;
 	}
@@ -1436,7 +1457,7 @@ static gboolean handle_command_get_inkey(const struct stk_command *cmd,
 {
 	int timeout = stk->timeout * 1000;
 	const struct stk_command_get_inkey *gi = &cmd->get_inkey;
-	char *text = dbus_apply_text_attributes(gi->text, &gi->text_attr);
+	char *text;
 	uint8_t qualifier = stk->pending_cmd->qualifier;
 	gboolean alphabet = (qualifier & (1 << 0)) != 0;
 	gboolean ucs2 = (qualifier & (1 << 1)) != 0;
@@ -1447,7 +1468,8 @@ static gboolean handle_command_get_inkey(const struct stk_command *cmd,
 	 */
 	int err;
 
-	if (text == NULL) {
+	if (check_text(gi->text, gi->icon_id.id, &gi->text_attr,
+			&text) == FALSE) {
 		rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
 		return TRUE;
 	}
@@ -1534,14 +1556,15 @@ static gboolean handle_command_get_input(const struct stk_command *cmd,
 {
 	int timeout = stk->timeout * 1000;
 	const struct stk_command_get_input *gi = &cmd->get_input;
-	char *text = dbus_apply_text_attributes(gi->text, &gi->text_attr);
+	char *text;
 	uint8_t qualifier = stk->pending_cmd->qualifier;
 	gboolean alphabet = (qualifier & (1 << 0)) != 0;
 	gboolean ucs2 = (qualifier & (1 << 1)) != 0;
 	gboolean hidden = (qualifier & (1 << 2)) != 0;
 	int err;
 
-	if (text == NULL) {
+	if (check_text(gi->text, gi->icon_id.id, &gi->text_attr,
+			&text) == FALSE) {
 		rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
 		return TRUE;
 	}
@@ -1664,14 +1687,10 @@ static void confirm_call_cb(enum stk_agent_result result, gboolean confirm,
 		return;
 	}
 
-	if (sc->alpha_id_call_setup) {
-		alpha_id = dbus_apply_text_attributes(sc->alpha_id_call_setup,
-						&sc->text_attr_call_setup);
-		if (alpha_id == NULL) {
-			send_simple_response(stk,
-					STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD);
-			return;
-		}
+	if (check_text(sc->alpha_id_call_setup, sc->icon_id_call_setup.id,
+			&sc->text_attr_call_setup, &alpha_id) == FALSE) {
+		send_simple_response(stk, STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD);
+		return;
 	}
 
 	err = __ofono_voicecall_dial(vc, sc->addr.number, sc->addr.ton_npi,
@@ -1722,7 +1741,8 @@ static gboolean handle_command_set_up_call(const struct stk_command *cmd,
 	const struct stk_command_setup_call *sc = &cmd->setup_call;
 	uint8_t qualifier = cmd->qualifier;
 	static unsigned char busy_on_call_result[] = { 0x02 };
-	char *alpha_id = NULL;
+	char *alpha_id_usr_cfm;
+	char *alpha_id_cs;
 	struct ofono_voicecall *vc = NULL;
 	struct ofono_atom *vc_atom;
 	int err;
@@ -1758,18 +1778,25 @@ static gboolean handle_command_set_up_call(const struct stk_command *cmd,
 		return TRUE;
 	}
 
-	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) {
+	if (check_text(sc->alpha_id_call_setup, sc->icon_id_call_setup.id,
+			&sc->text_attr_call_setup, &alpha_id_cs) == FALSE) {
 		rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
 		return TRUE;
 	}
 
-	err = stk_agent_confirm_call(stk->current_agent, alpha_id,
-					&sc->icon_id_usr_cfm, confirm_call_cb,
-					stk, NULL, stk->timeout * 1000);
-	g_free(alpha_id);
+	g_free(alpha_id_cs);
+
+	if (check_text(sc->alpha_id_usr_cfm, sc->icon_id_usr_cfm.id,
+			&sc->text_attr_usr_cfm, &alpha_id_usr_cfm) == FALSE) {
+		rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
+		return TRUE;
+	}
+
+	err = stk_agent_confirm_call(stk->current_agent, alpha_id_usr_cfm,
+			&sc->icon_id_usr_cfm, confirm_call_cb,
+			stk, NULL, stk->timeout * 1000);
+
+	g_free(alpha_id_usr_cfm);
 
 	if (err < 0) {
 		/*
@@ -1956,9 +1983,18 @@ static gboolean handle_command_refresh(const struct stk_command *cmd,
 					struct ofono_stk *stk)
 {
 	GSList *l;
+	char *alpha_id;
 
 	DBG("");
 
+	if (check_text(cmd->refresh.alpha_id, cmd->refresh.icon_id.id,
+			&cmd->refresh.text_attr, &alpha_id) == FALSE) {
+		rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
+		return TRUE;
+	}
+
+	g_free(alpha_id);
+
 	switch (cmd->qualifier) {
 	case 0:
 		DBG("NAA Initialization and "
@@ -2144,6 +2180,15 @@ static gboolean handle_command_send_dtmf(const struct stk_command *cmd,
 	char *dtmf_from = "01234567890abcABC";
 	char *dtmf_to = "01234567890*#p*#p";
 	int err, pos;
+	char *alpha_id;
+
+	if (check_text(cmd->send_dtmf.alpha_id, cmd->send_dtmf.icon_id.id,
+			&cmd->send_dtmf.text_attr, &alpha_id) == FALSE) {
+		rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
+		return TRUE;
+	}
+
+	g_free(alpha_id);
 
 	vc_atom = __ofono_modem_find_atom(__ofono_atom_get_modem(stk->atom),
 						OFONO_ATOM_TYPE_VOICECALL);
@@ -2299,9 +2344,8 @@ static gboolean handle_command_play_tone(const struct stk_command *cmd,
 		return TRUE;
 	}
 
-	text = dbus_apply_text_attributes(pt->alpha_id ? pt->alpha_id : "",
-						&pt->text_attr);
-	if (text == NULL) {
+	if (check_text(pt->alpha_id, pt->icon_id.id, &pt->text_attr,
+			&text) == FALSE) {
 		rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
 
 		return TRUE;
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC 2/2] stk: add missing text and icon case handling
  2010-12-29 13:16 ` [RFC 2/2] stk: add missing text and icon case handling Jeevaka Badrappan
@ 2010-12-30 17:10   ` Denis Kenzior
  0 siblings, 0 replies; 4+ messages in thread
From: Denis Kenzior @ 2010-12-30 17:10 UTC (permalink / raw)
  To: ofono

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

Hi Jeevaka,

On 12/29/2010 07:16 AM, Jeevaka Badrappan wrote:
> As per the ETSI TS 102 223 section 6.5.4,
> If the terminal receives an icon, and either
> an empty or no alpha identifier/text string
> is given by the UICC, than the terminal shall
> reject the command with general result
> "Command data not understood by terminal".
> ---
>  src/stk.c |  114 ++++++++++++++++++++++++++++++++++++++++++-------------------
>  1 files changed, 79 insertions(+), 35 deletions(-)
> 

I thought the agreement was to do such checking in stkutil.c?

Regards,
-Denis

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-12-30 17:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-29 13:16 [RFC 0/2] Add null text/alpha identifier and icon specific handling Jeevaka Badrappan
2010-12-29 13:16 ` [RFC 1/2] stkutil: Allocate for empty string in text dataobj Jeevaka Badrappan
2010-12-29 13:16 ` [RFC 2/2] stk: add missing text and icon case handling Jeevaka Badrappan
2010-12-30 17:10   ` 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.