All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Gu <yang.gu@intel.com>
To: ofono@ofono.org
Subject: [PATCH 2/7] stkutil: Use struct to represent frame id
Date: Tue, 27 Apr 2010 17:47:07 +0800	[thread overview]
Message-ID: <1272361632-21352-2-git-send-email-yang.gu@intel.com> (raw)
In-Reply-To: <1272361632-21352-1-git-send-email-yang.gu@intel.com>

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

Use a field has_id to indicate if we have frame id or not. Originally we use
0xFF to indicate we don't have frame id. But in that way, we have to initialize
each test case of proactive command when it doesn't have this comprehension
tlv to be 0xFF. To use has_id will save this effort, and keep consistency with
other implementations.
---
 src/stkutil.c |   13 +++----------
 src/stkutil.h |   12 +++++++++---
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/src/stkutil.c b/src/stkutil.c
index 3323550..ed48db4 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -1635,7 +1635,7 @@ static gboolean parse_dataobj_frames_info(struct comprehension_tlv_iter *iter,
 static gboolean parse_dataobj_frame_id(struct comprehension_tlv_iter *iter,
 					void *user)
 {
-	unsigned char *frame_id = user;
+	struct stk_frame_id *fi = user;
 	const unsigned char *data;
 
 	if (comprehension_tlv_iter_get_length(iter) != 1)
@@ -1646,7 +1646,8 @@ static gboolean parse_dataobj_frame_id(struct comprehension_tlv_iter *iter,
 	if (data[0] >= 0x10)
 		return FALSE;
 
-	*frame_id = data[0];
+	fi->has_id = TRUE;
+	fi->id = data[0];
 
 	return TRUE;
 }
@@ -2084,8 +2085,6 @@ static gboolean parse_display_text(struct stk_command *command,
 	if (command->dst != STK_DEVICE_IDENTITY_TYPE_DISPLAY)
 		return FALSE;
 
-	obj->frame_id = 0xFF;
-
 	ret = parse_dataobj(iter, STK_DATA_OBJECT_TYPE_TEXT,
 				DATAOBJ_FLAG_MANDATORY | DATAOBJ_FLAG_MINIMUM,
 				&obj->text,
@@ -2126,8 +2125,6 @@ static gboolean parse_get_inkey(struct stk_command *command,
 	if (command->dst != STK_DEVICE_IDENTITY_TYPE_TERMINAL)
 		return FALSE;
 
-	obj->frame_id = 0xFF;
-
 	ret = parse_dataobj(iter, STK_DATA_OBJECT_TYPE_TEXT,
 				DATAOBJ_FLAG_MANDATORY | DATAOBJ_FLAG_MINIMUM,
 				&obj->text,
@@ -2162,8 +2159,6 @@ static gboolean parse_get_input(struct stk_command *command,
 	struct stk_command_get_input *obj = &command->get_input;
 	gboolean ret;
 
-	obj->frame_id = 0xFF;
-
 	if (command->src != STK_DEVICE_IDENTITY_TYPE_UICC)
 		return FALSE;
 
@@ -2207,8 +2202,6 @@ static gboolean parse_send_sms(struct stk_command *command,
 	struct gsm_sms_tpdu tpdu;
 	gboolean ret;
 
-	obj->frame_id = 0xFF;
-
 	if (command->src != STK_DEVICE_IDENTITY_TYPE_UICC)
 		return FALSE;
 
diff --git a/src/stkutil.h b/src/stkutil.h
index 5d2a818..cbb6442 100644
--- a/src/stkutil.h
+++ b/src/stkutil.h
@@ -728,6 +728,12 @@ struct stk_frames_info {
 	unsigned int len;
 };
 
+/* Defined in TS 102.223 Section 8.80 */
+struct stk_frame_id {
+	ofono_bool_t has_id;
+	unsigned char id;
+};
+
 /*
  * According to 102.223 Section 8.82 the length of CTLV is 1 byte. This means
  * that the maximum size is 127 according to the rules of CTLVs.
@@ -789,7 +795,7 @@ struct stk_command_display_text {
 	ofono_bool_t immediate_response;
 	struct stk_duration duration;
 	struct stk_text_attribute text_attribute;
-	unsigned char frame_id; /* Values 0x10 to 0xFF reserved */
+	struct stk_frame_id frame_id;
 };
 
 struct stk_command_get_input {
@@ -798,7 +804,7 @@ struct stk_command_get_input {
 	char *default_text;
 	struct stk_icon_id icon_id;
 	struct stk_text_attribute text_attribute;
-	unsigned char frame_id; /* Values 0x10 to 0xFF reserved */
+	struct stk_frame_id frame_id;
 };
 
 struct stk_command_send_sms {
@@ -807,7 +813,7 @@ struct stk_command_send_sms {
 	struct sms gsm_sms;
 	struct stk_icon_id icon_id;
 	struct stk_text_attribute text_attribute;
-	unsigned char frame_id; /* Values 0x10 to 0xFF reserved */
+	struct stk_frame_id frame_id;
 };
 
 struct stk_command {
-- 
1.7.0.4


  reply	other threads:[~2010-04-27  9:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-27  9:47 [PATCH 1/7] stkutil: Move advance of ctlv to parse_dataobj Yang Gu
2010-04-27  9:47 ` Yang Gu [this message]
2010-04-27  9:47 ` [PATCH 3/7] test-stkutil: Refactor the implementation to test display text Yang Gu
2010-04-27  9:47 ` [PATCH 4/7] stkutil: Add parser for more time proactive commands Yang Gu
2010-04-27  9:47 ` [PATCH 5/7] test-stkutil: Add unit test for more time parser Yang Gu
2010-04-27  9:47 ` [PATCH 6/7] stkutil: Change some dataobj parser to use char * instead of char ** Yang Gu
2010-04-27  9:47 ` [PATCH 7/7] stkutil: Make get inkey parser use its own struct Yang Gu
2010-04-27 14:36 ` [PATCH 1/7] stkutil: Move advance of ctlv to parse_dataobj 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=1272361632-21352-2-git-send-email-yang.gu@intel.com \
    --to=yang.gu@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 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.