stkutil: Use struct to represent frame id

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.
This commit is contained in:
Yang Gu 2010-04-27 17:47:07 +08:00 committed by Denis Kenzior
parent def5c38094
commit 3ae32b6e51
2 changed files with 12 additions and 13 deletions

View File

@ -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;

View File

@ -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 {