summaryrefslogtreecommitdiffstats
path: root/src/stkutil.c
diff options
context:
space:
mode:
authorAndrzej Zaborowski <andrew.zaborowski@intel.com>2010-06-07 12:08:38 +0200
committerDenis Kenzior <denkenz@gmail.com>2010-06-09 19:29:15 -0500
commitb95ef22f61357f70d36449af3636f7554b0130f5 (patch)
treec9172732fee9a2d259f2b392f7b5cc1530b58216 /src/stkutil.c
parent08c689ca7c2129aa05324d1bac93693202645be5 (diff)
downloadofono-b95ef22f61357f70d36449af3636f7554b0130f5.tar.bz2
stkutil: Refactor stk_location_info
In some cases an empty stk_location_info means that no object should be emitted (e.g. it is optional) and in other cases an empty object should be emitted. This is context specific to the terminal response / envelope and thus we break this up into two separate functions.
Diffstat (limited to 'src/stkutil.c')
-rw-r--r--src/stkutil.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/stkutil.c b/src/stkutil.c
index dda9db57..8ac1dba4 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -3492,14 +3492,8 @@ static gboolean build_dataobj_location_info(struct stk_tlv_builder *tlv,
unsigned char tag = STK_DATA_OBJECT_TYPE_LOCATION_INFO;
guint8 mccmnc[3];
- if (li->mcc[0] == 0)
- /*
- * "If no location information is available for an access
- * technology, the respective data object shall have
- * length zero."
- */
- return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
- stk_tlv_builder_close_container(tlv);
+ if (li->mcc[0] == '\0')
+ return TRUE;
sim_encode_mcc_mnc(mccmnc, li->mcc, li->mnc);
@@ -3532,6 +3526,15 @@ static gboolean build_dataobj_location_info(struct stk_tlv_builder *tlv,
return stk_tlv_builder_close_container(tlv);
}
+static gboolean build_empty_dataobj_location_info(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ unsigned char tag = STK_DATA_OBJECT_TYPE_LOCATION_INFO;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
/* Described in TS 102.223 Section 8.20
*
* See format note in parse_dataobj_imei.
@@ -4036,12 +4039,22 @@ static gboolean build_local_info(struct stk_tlv_builder *builder,
NULL) != TRUE)
return FALSE;
- for (i = 0; i < info->location_infos.access_techs.length; i++)
+ for (i = 0; i < info->location_infos.access_techs.length; i++) {
+ dataobj_writer location = build_dataobj_location_info;
+ /*
+ * "If no location information is available for an
+ * access technology, the respective data object
+ * shall have length zero."
+ */
+ if (info->location_infos.locations[i].mcc[0] == '\0')
+ location = build_empty_dataobj_location_info;
+
if (build_dataobj(builder,
- build_dataobj_location_info,
+ location,
0, &info->location_infos.locations[i],
NULL) != TRUE)
return FALSE;
+ }
return TRUE;