All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] Present list of preferred languages on SimManager interface.
  2009-09-14 16:37 [PATCH] Present list of preferred languages on SimManager interface Andrzej Zaborowski
@ 2009-09-14 16:06 ` Denis Kenzior
  2009-09-14 17:33   ` Andrzej Zaborowski
  0 siblings, 1 reply; 12+ messages in thread
From: Denis Kenzior @ 2009-09-14 16:06 UTC (permalink / raw)
  To: ofono

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

Hi Andrew,

> It does not look like the list can be used directly for filtering CBs
> because for that, the ME should choose one language, if there is one
> that is supported by the UI (aka MMI).

It actually can, since the preferred language list for cell broadcasts can be 
of any length...

And now for some nitpicks:

> +static int parse_language_list(char **out_list, const unsigned char
> *sim_list, +				int length)
> +{
> +	unsigned char code[3];
> +	int count, i;
> +	long written;
> +
> +	count = 0;
> +	length--;
> +
> +	for (i = 0; i < length; i += 2) {
> +		code[0] = sim_list[i + 0];
> +		code[1] = sim_list[i + 1];
> +		code[2] = 0;
> +
> +		if (code[0] == 0xff || code[1] == 0xff)
> +			continue;
> +
> +		out_list[count] = convert_gsm_to_utf8(code, 2,
> +							NULL, &written, 0);

Lets skip the gsm conversion.  The ISO639 standard only uses latin characters 
which are guaranteed to be the same between utf8 / gsm.

> +static void sim_efpl_read_cb(int ok,
> +				enum ofono_sim_file_structure structure,
> +				int length, int record,
> +				const unsigned char *data,
> +				int record_length, void *userdata)
> +{
> +	struct ofono_sim *sim = userdata;
> +	unsigned char *efli = sim->efli;
> +	const unsigned char *efpl = data;
> +	int efli_length = sim->efli_length;
> +	int efpl_length = length;
> +	int count;
> +	const char *path = __ofono_atom_get_path(sim->atom);
> +	DBusConnection *conn = ofono_dbus_get_connection();
> +
> +	if (!ok || structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT)
> +		efpl = NULL;
> +
> +	if (length < 2)
> +		efpl = NULL;
> +
> +	sim->language_prefs = g_malloc(((efli_length + efpl_length) / 2 + 1) *
> +			sizeof(char *));
> +
> +	count = 0;
> +
> +	/* Make a list of languages in both files in order of preferences
> +	 * following 31.102.
> +	 */
> +
> +	if (efli && efpl && efli[0] == 0xff && efli[1] == 0xff) {
> +		count += parse_language_list(sim->language_prefs + count,
> +						efpl, efpl_length);
> +		efpl = NULL;
> +	}
> +
> +	if (efli) {
> +		count += parse_language_list(sim->language_prefs + count,
> +						efli, efli_length);
> +		g_free(efli);
> +		sim->efli = NULL;
> +	}
> +
> +	if (efpl)
> +		count += parse_language_list(sim->language_prefs + count,
> +						efpl, efpl_length);

If we're going down the path of preserving both EFli and EFpl, then you should 
make sure no duplicates exist. Alternatively we can assume that oFono/UI will 
support all languages and simply not read EFpl if there is useable information 
in EFli.

> +static void sim_retrieve_efli(struct ofono_sim *sim)
> +{
> +	/* According to 31.102 the EFli is read first and EFpl is then
> +	 * only read if none of the EFli languages are supported by user
> +	 * interface.  51.011 mandates the exact opposite, making EFpl/EFelp
> +	 * preferred over EFlp (same ID as EFli, different format).
> +	 * However we don't depend on the user interface and so
> +	 * need to read both files now.
> +	 */
> +	ofono_sim_read(sim, SIM_EFLI_FILEID, sim_efli_read_cb, sim);
> +	ofono_sim_read(sim, SIM_EFPL_FILEID, sim_efpl_read_cb, sim);

Strictly speaking 31.101 & 31.102 supersede 51.011.

Regards,
-Denis

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

* [PATCH] Present list of preferred languages on SimManager interface.
@ 2009-09-14 16:37 Andrzej Zaborowski
  2009-09-14 16:06 ` Denis Kenzior
  0 siblings, 1 reply; 12+ messages in thread
From: Andrzej Zaborowski @ 2009-09-14 16:37 UTC (permalink / raw)
  To: ofono

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

It does not look like the list can be used directly for filtering CBs
because for that, the ME should choose one language, if there is one
that is supported by the UI (aka MMI).

Patch made on top of [PATCH] Do the PIN check in SIMManager.
---
 src/sim.c     |  128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/simutil.h |    2 +
 2 files changed, 130 insertions(+), 0 deletions(-)

diff --git a/src/sim.c b/src/sim.c
index 3886485..3ebb9e8 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -80,10 +80,13 @@ struct ofono_sim {
 	gboolean ready;
 	gboolean pin_ready;
 	int pin_type;
+	char **language_prefs;
 	GQueue *simop_q;
 	gint simop_source;
 	unsigned char efmsisdn_length;
 	unsigned char efmsisdn_records;
+	unsigned char *efli;
+	unsigned char efli_length;
 	unsigned int next_ready_watch_id;
 	GSList *ready_watches;
 	const struct ofono_sim_driver *driver;
@@ -224,6 +227,11 @@ static DBusMessage *sim_get_properties(DBusConnection *conn,
 					(void *) &pin_name);
 	}
 
+	if (sim->language_prefs)
+		ofono_dbus_dict_append_array(&dict, "PreferredLanguages",
+						DBUS_TYPE_STRING,
+						&sim->language_prefs);
+
 	dbus_message_iter_close_container(&iter, &dict);
 
 	return reply;
@@ -746,6 +754,120 @@ static void sim_pin_check(struct ofono_sim *sim)
 	sim->driver->query_passwd_state(sim, sim_pin_query_cb, sim);
 }
 
+static void sim_efli_read_cb(int ok,
+				enum ofono_sim_file_structure structure,
+				int length, int record,
+				const unsigned char *data,
+				int record_length, void *userdata)
+{
+	struct ofono_sim *sim = userdata;
+
+	if (!ok || structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT)
+		return;
+
+	if (length < 2)
+		return;
+
+	sim->efli = g_memdup(data, length);
+	sim->efli_length = length;
+}
+
+static int parse_language_list(char **out_list, const unsigned char *sim_list,
+				int length)
+{
+	unsigned char code[3];
+	int count, i;
+	long written;
+
+	count = 0;
+	length--;
+
+	for (i = 0; i < length; i += 2) {
+		code[0] = sim_list[i + 0];
+		code[1] = sim_list[i + 1];
+		code[2] = 0;
+
+		if (code[0] == 0xff || code[1] == 0xff)
+			continue;
+
+		out_list[count] = convert_gsm_to_utf8(code, 2,
+							NULL, &written, 0);
+		if (out_list[count] && written == 2)
+			count++;
+	}
+
+	return count;
+}
+
+static void sim_efpl_read_cb(int ok,
+				enum ofono_sim_file_structure structure,
+				int length, int record,
+				const unsigned char *data,
+				int record_length, void *userdata)
+{
+	struct ofono_sim *sim = userdata;
+	unsigned char *efli = sim->efli;
+	const unsigned char *efpl = data;
+	int efli_length = sim->efli_length;
+	int efpl_length = length;
+	int count;
+	const char *path = __ofono_atom_get_path(sim->atom);
+	DBusConnection *conn = ofono_dbus_get_connection();
+
+	if (!ok || structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT)
+		efpl = NULL;
+
+	if (length < 2)
+		efpl = NULL;
+
+	sim->language_prefs = g_malloc(((efli_length + efpl_length) / 2 + 1) *
+			sizeof(char *));
+
+	count = 0;
+
+	/* Make a list of languages in both files in order of preferences
+	 * following 31.102.
+	 */
+
+	if (efli && efpl && efli[0] == 0xff && efli[1] == 0xff) {
+		count += parse_language_list(sim->language_prefs + count,
+						efpl, efpl_length);
+		efpl = NULL;
+	}
+
+	if (efli) {
+		count += parse_language_list(sim->language_prefs + count,
+						efli, efli_length);
+		g_free(efli);
+		sim->efli = NULL;
+	}
+
+	if (efpl)
+		count += parse_language_list(sim->language_prefs + count,
+						efpl, efpl_length);
+
+	sim->language_prefs[count] = NULL;
+
+	ofono_dbus_signal_array_property_changed(conn, path,
+							SIM_MANAGER_INTERFACE,
+							"PreferredLanguages",
+							DBUS_TYPE_STRING,
+							&sim->language_prefs);
+}
+
+static void sim_retrieve_efli(struct ofono_sim *sim)
+{
+	/* According to 31.102 the EFli is read first and EFpl is then
+	 * only read if none of the EFli languages are supported by user
+	 * interface.  51.011 mandates the exact opposite, making EFpl/EFelp
+	 * preferred over EFlp (same ID as EFli, different format).
+	 * However we don't depend on the user interface and so
+	 * need to read both files now.
+	 */
+	ofono_sim_read(sim, SIM_EFLI_FILEID, sim_efli_read_cb, sim);
+	ofono_sim_read(sim, SIM_EFPL_FILEID, sim_efpl_read_cb, sim);
+}
+
 static void sim_op_error(struct ofono_sim *sim)
 {
 	struct sim_file_op *op = g_queue_pop_head(sim->simop_q);
@@ -1357,6 +1479,11 @@ static void sim_remove(struct ofono_atom *atom)
 		sim->service_numbers = NULL;
 	}
 
+	if (sim->language_prefs) {
+		g_strfreev(sim->language_prefs);
+		sim->language_prefs = NULL;
+	}
+
 	if (sim->simop_source) {
 		g_source_remove(sim->simop_source);
 		sim->simop_source = 0;
@@ -1446,6 +1573,7 @@ void ofono_sim_register(struct ofono_sim *sim)
 	 * arbitrary files to be written or read, assuming their presence
 	 * in the EFust
 	 */
+	sim_retrieve_efli(sim);
 	sim_pin_check(sim);
 }
 
diff --git a/src/simutil.h b/src/simutil.h
index fc4f063..d1517ed 100644
--- a/src/simutil.h
+++ b/src/simutil.h
@@ -20,6 +20,8 @@
  */
 
 enum sim_fileid {
+	SIM_EFPL_FILEID = 0x2f05,
+	SIM_EFLI_FILEID = 0x6f05,
 	SIM_EFMSISDN_FILEID = 0x6f40,
 	SIM_EFSPN_FILEID = 0x6f46,
 	SIM_EFSDN_FILEID = 0x6f49,
-- 
1.6.1


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

* Re: [PATCH] Present list of preferred languages on SimManager interface.
  2009-09-14 16:06 ` Denis Kenzior
@ 2009-09-14 17:33   ` Andrzej Zaborowski
  2009-09-16 12:54     ` Andrzej Zaborowski
  0 siblings, 1 reply; 12+ messages in thread
From: Andrzej Zaborowski @ 2009-09-14 17:33 UTC (permalink / raw)
  To: ofono

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

Hi Denis,

2009/9/14 Denis Kenzior <denkenz@gmail.com>:
>> +static int parse_language_list(char **out_list, const unsigned char
>> *sim_list, +                          int length)
>> +{
>> +     unsigned char code[3];
>> +     int count, i;
>> +     long written;
>> +
>> +     count = 0;
>> +     length--;
>> +
>> +     for (i = 0; i < length; i += 2) {
>> +             code[0] = sim_list[i + 0];
>> +             code[1] = sim_list[i + 1];
>> +             code[2] = 0;
>> +
>> +             if (code[0] == 0xff || code[1] == 0xff)
>> +                     continue;
>> +
>> +             out_list[count] = convert_gsm_to_utf8(code, 2,
>> +                                                     NULL, &written, 0);
>
> Lets skip the gsm conversion.  The ISO639 standard only uses latin characters
> which are guaranteed to be the same between utf8 / gsm.

Ok, I was considering doing that but decided there wasn't any gain
from not doing the conversion.

>
>> +static void sim_efpl_read_cb(int ok,
>> +                             enum ofono_sim_file_structure structure,
>> +                             int length, int record,
>> +                             const unsigned char *data,
>> +                             int record_length, void *userdata)
>> +{
>> +     struct ofono_sim *sim = userdata;
>> +     unsigned char *efli = sim->efli;
>> +     const unsigned char *efpl = data;
>> +     int efli_length = sim->efli_length;
>> +     int efpl_length = length;
>> +     int count;
>> +     const char *path = __ofono_atom_get_path(sim->atom);
>> +     DBusConnection *conn = ofono_dbus_get_connection();
>> +
>> +     if (!ok || structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT)
>> +             efpl = NULL;
>> +
>> +     if (length < 2)
>> +             efpl = NULL;
>> +
>> +     sim->language_prefs = g_malloc(((efli_length + efpl_length) / 2 + 1) *
>> +                     sizeof(char *));
>> +
>> +     count = 0;
>> +
>> +     /* Make a list of languages in both files in order of preferences
>> +      * following 31.102.
>> +      */
>> +
>> +     if (efli && efpl && efli[0] == 0xff && efli[1] == 0xff) {
>> +             count += parse_language_list(sim->language_prefs + count,
>> +                                             efpl, efpl_length);
>> +             efpl = NULL;
>> +     }
>> +
>> +     if (efli) {
>> +             count += parse_language_list(sim->language_prefs + count,
>> +                                             efli, efli_length);
>> +             g_free(efli);
>> +             sim->efli = NULL;
>> +     }
>> +
>> +     if (efpl)
>> +             count += parse_language_list(sim->language_prefs + count,
>> +                                             efpl, efpl_length);
>
> If we're going down the path of preserving both EFli and EFpl, then you should
> make sure no duplicates exist. Alternatively we can assume that oFono/UI will
> support all languages and simply not read EFpl if there is useable information
> in EFli.

Let's present the full list, I added checking for duplicates.

>
>> +static void sim_retrieve_efli(struct ofono_sim *sim)
>> +{
>> +     /* According to 31.102 the EFli is read first and EFpl is then
>> +      * only read if none of the EFli languages are supported by user
>> +      * interface.  51.011 mandates the exact opposite, making EFpl/EFelp
>> +      * preferred over EFlp (same ID as EFli, different format).
>> +      * However we don't depend on the user interface and so
>> +      * need to read both files now.
>> +      */
>> +     ofono_sim_read(sim, SIM_EFLI_FILEID, sim_efli_read_cb, sim);
>> +     ofono_sim_read(sim, SIM_EFPL_FILEID, sim_efpl_read_cb, sim);
>
> Strictly speaking 31.101 & 31.102 supersede 51.011.

I think that was the plan but apparently they don't have all contents
51.011 has, and 31.102 even explicitely refers to 51.011 for the EFpl
format (which 51.011 only says is defined by ETSI).

Also the card I tested has a 5 byte EFli / EFlp, filled with 0xff
bytes, which means it must be in the 51.011 format so the document is
not obsolete.

Regards

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Present-list-of-preferred-languages-on-SimManager-in.patch --]
[-- Type: text/x-patch, Size: 5268 bytes --]

From 763a0b12a6636d7f1ec5be99d8fe24c5925c6678 Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <andrew.zaborowski@intel.com>
Date: Mon, 14 Sep 2009 21:25:05 +0200
Subject: [PATCH] Present list of preferred languages on SimManager interface.

Patch made on top of [PATCH] Do the PIN check in SIMManager.
---
 src/sim.c     |  124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/simutil.h |    2 +
 2 files changed, 126 insertions(+), 0 deletions(-)

diff --git a/src/sim.c b/src/sim.c
index 3886485..7a42ee7 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -80,10 +80,13 @@ struct ofono_sim {
 	gboolean ready;
 	gboolean pin_ready;
 	int pin_type;
+	char **language_prefs;
 	GQueue *simop_q;
 	gint simop_source;
 	unsigned char efmsisdn_length;
 	unsigned char efmsisdn_records;
+	unsigned char *efli;
+	unsigned char efli_length;
 	unsigned int next_ready_watch_id;
 	GSList *ready_watches;
 	const struct ofono_sim_driver *driver;
@@ -224,6 +227,11 @@ static DBusMessage *sim_get_properties(DBusConnection *conn,
 					(void *) &pin_name);
 	}
 
+	if (sim->language_prefs)
+		ofono_dbus_dict_append_array(&dict, "PreferredLanguages",
+						DBUS_TYPE_STRING,
+						&sim->language_prefs);
+
 	dbus_message_iter_close_container(&iter, &dict);
 
 	return reply;
@@ -746,6 +754,116 @@ static void sim_pin_check(struct ofono_sim *sim)
 	sim->driver->query_passwd_state(sim, sim_pin_query_cb, sim);
 }
 
+static void sim_efli_read_cb(int ok,
+				enum ofono_sim_file_structure structure,
+				int length, int record,
+				const unsigned char *data,
+				int record_length, void *userdata)
+{
+	struct ofono_sim *sim = userdata;
+
+	if (!ok || structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT)
+		return;
+
+	if (length < 2)
+		return;
+
+	sim->efli = g_memdup(data, length);
+	sim->efli_length = length;
+}
+
+static void parse_language_list(char **out_list, int *count,
+				const unsigned char *sim_list, int length)
+{
+	int i, j;
+
+	length--;
+
+	for (i = 0; i < length; i += 2) {
+		if (sim_list[i] == 0xff || sim_list[i + 1] == 0xff)
+			continue;
+
+		for (j = 0; j < *count; j++)
+			if (!memcmp(out_list[j], sim_list + i, 2))
+				break;
+		if (j < *count)
+			continue;
+
+		/* ISO 639 codes contain only characters that are coded
+		 * identically in SMS 7 bit charset, ASCII or UTF8 so
+		 * no conversion.
+		 */
+		out_list[(*count)++] = g_strndup((char *) sim_list + i, 2);
+	}
+}
+
+static void sim_efpl_read_cb(int ok,
+				enum ofono_sim_file_structure structure,
+				int length, int record,
+				const unsigned char *data,
+				int record_length, void *userdata)
+{
+	struct ofono_sim *sim = userdata;
+	unsigned char *efli = sim->efli;
+	const unsigned char *efpl = data;
+	int efli_length = sim->efli_length;
+	int efpl_length = length;
+	int count;
+	const char *path = __ofono_atom_get_path(sim->atom);
+	DBusConnection *conn = ofono_dbus_get_connection();
+
+	if (!ok || structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT)
+		efpl = NULL;
+
+	if (length < 2)
+		efpl = NULL;
+
+	sim->language_prefs = g_new0(char *,
+					(efli_length + efpl_length) / 2 + 1);
+
+	count = 0;
+
+	/* Make a list of languages in both files in order of preferences
+	 * following 31.102.
+	 */
+
+	if (efli && efpl && efli[0] == 0xff && efli[1] == 0xff) {
+		parse_language_list(sim->language_prefs, &count,
+					efpl, efpl_length);
+		efpl = NULL;
+	}
+
+	if (efli) {
+		parse_language_list(sim->language_prefs, &count,
+					efli, efli_length);
+		g_free(efli);
+		sim->efli = NULL;
+	}
+
+	if (efpl)
+		parse_language_list(sim->language_prefs, &count,
+					efpl, efpl_length);
+
+	ofono_dbus_signal_array_property_changed(conn, path,
+							SIM_MANAGER_INTERFACE,
+							"PreferredLanguages",
+							DBUS_TYPE_STRING,
+							&sim->language_prefs);
+}
+
+static void sim_retrieve_efli(struct ofono_sim *sim)
+{
+	/* According to 31.102 the EFli is read first and EFpl is then
+	 * only read if none of the EFli languages are supported by user
+	 * interface.  51.011 mandates the exact opposite, making EFpl/EFelp
+	 * preferred over EFlp (same ID as EFli, different format).
+	 * However we don't depend on the user interface and so
+	 * need to read both files now.
+	 */
+	ofono_sim_read(sim, SIM_EFLI_FILEID, sim_efli_read_cb, sim);
+	ofono_sim_read(sim, SIM_EFPL_FILEID, sim_efpl_read_cb, sim);
+}
+
 static void sim_op_error(struct ofono_sim *sim)
 {
 	struct sim_file_op *op = g_queue_pop_head(sim->simop_q);
@@ -1357,6 +1475,11 @@ static void sim_remove(struct ofono_atom *atom)
 		sim->service_numbers = NULL;
 	}
 
+	if (sim->language_prefs) {
+		g_strfreev(sim->language_prefs);
+		sim->language_prefs = NULL;
+	}
+
 	if (sim->simop_source) {
 		g_source_remove(sim->simop_source);
 		sim->simop_source = 0;
@@ -1446,6 +1569,7 @@ void ofono_sim_register(struct ofono_sim *sim)
 	 * arbitrary files to be written or read, assuming their presence
 	 * in the EFust
 	 */
+	sim_retrieve_efli(sim);
 	sim_pin_check(sim);
 }
 
diff --git a/src/simutil.h b/src/simutil.h
index fc4f063..d1517ed 100644
--- a/src/simutil.h
+++ b/src/simutil.h
@@ -20,6 +20,8 @@
  */
 
 enum sim_fileid {
+	SIM_EFPL_FILEID = 0x2f05,
+	SIM_EFLI_FILEID = 0x6f05,
 	SIM_EFMSISDN_FILEID = 0x6f40,
 	SIM_EFSPN_FILEID = 0x6f46,
 	SIM_EFSDN_FILEID = 0x6f49,
-- 
1.6.1


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

* Re: [PATCH] Present list of preferred languages on SimManager interface.
  2009-09-14 17:33   ` Andrzej Zaborowski
@ 2009-09-16 12:54     ` Andrzej Zaborowski
  2009-09-17 18:49       ` Andrzej Zaborowski
  0 siblings, 1 reply; 12+ messages in thread
From: Andrzej Zaborowski @ 2009-09-16 12:54 UTC (permalink / raw)
  To: ofono

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

2009/9/14 Andrzej Zaborowski <andrew.zaborowski@intel.com>:
> 2009/9/14 Denis Kenzior <denkenz@gmail.com>:
>>> +     /* According to 31.102 the EFli is read first and EFpl is then
>>> +      * only read if none of the EFli languages are supported by user
>>> +      * interface.  51.011 mandates the exact opposite, making EFpl/EFelp
>>> +      * preferred over EFlp (same ID as EFli, different format).
>>> +      * However we don't depend on the user interface and so
>>> +      * need to read both files now.
>>> +      */
>>> +     ofono_sim_read(sim, SIM_EFLI_FILEID, sim_efli_read_cb, sim);
>>> +     ofono_sim_read(sim, SIM_EFPL_FILEID, sim_efpl_read_cb, sim);
>>
>> Strictly speaking 31.101 & 31.102 supersede 51.011.
>
> I think that was the plan but apparently they don't have all contents
> 51.011 has, and 31.102 even explicitely refers to 51.011 for the EFpl
> format (which 51.011 only says is defined by ETSI).
>
> Also the card I tested has a 5 byte EFli / EFlp, filled with 0xff
> bytes, which means it must be in the 51.011 format so the document is
> not obsolete.

So here's another version generated on top of HEAD and with an attempt
to detect when the card uses EFlp format instead of EFli.

Regards

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Present-list-of-preferred-languages-on-SimManager-in.patch --]
[-- Type: text/x-patch, Size: 5268 bytes --]

From 763a0b12a6636d7f1ec5be99d8fe24c5925c6678 Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <andrew.zaborowski@intel.com>
Date: Mon, 14 Sep 2009 21:25:05 +0200
Subject: [PATCH] Present list of preferred languages on SimManager interface.

Patch made on top of [PATCH] Do the PIN check in SIMManager.
---
 src/sim.c     |  124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/simutil.h |    2 +
 2 files changed, 126 insertions(+), 0 deletions(-)

diff --git a/src/sim.c b/src/sim.c
index 3886485..7a42ee7 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -80,10 +80,13 @@ struct ofono_sim {
 	gboolean ready;
 	gboolean pin_ready;
 	int pin_type;
+	char **language_prefs;
 	GQueue *simop_q;
 	gint simop_source;
 	unsigned char efmsisdn_length;
 	unsigned char efmsisdn_records;
+	unsigned char *efli;
+	unsigned char efli_length;
 	unsigned int next_ready_watch_id;
 	GSList *ready_watches;
 	const struct ofono_sim_driver *driver;
@@ -224,6 +227,11 @@ static DBusMessage *sim_get_properties(DBusConnection *conn,
 					(void *) &pin_name);
 	}
 
+	if (sim->language_prefs)
+		ofono_dbus_dict_append_array(&dict, "PreferredLanguages",
+						DBUS_TYPE_STRING,
+						&sim->language_prefs);
+
 	dbus_message_iter_close_container(&iter, &dict);
 
 	return reply;
@@ -746,6 +754,116 @@ static void sim_pin_check(struct ofono_sim *sim)
 	sim->driver->query_passwd_state(sim, sim_pin_query_cb, sim);
 }
 
+static void sim_efli_read_cb(int ok,
+				enum ofono_sim_file_structure structure,
+				int length, int record,
+				const unsigned char *data,
+				int record_length, void *userdata)
+{
+	struct ofono_sim *sim = userdata;
+
+	if (!ok || structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT)
+		return;
+
+	if (length < 2)
+		return;
+
+	sim->efli = g_memdup(data, length);
+	sim->efli_length = length;
+}
+
+static void parse_language_list(char **out_list, int *count,
+				const unsigned char *sim_list, int length)
+{
+	int i, j;
+
+	length--;
+
+	for (i = 0; i < length; i += 2) {
+		if (sim_list[i] == 0xff || sim_list[i + 1] == 0xff)
+			continue;
+
+		for (j = 0; j < *count; j++)
+			if (!memcmp(out_list[j], sim_list + i, 2))
+				break;
+		if (j < *count)
+			continue;
+
+		/* ISO 639 codes contain only characters that are coded
+		 * identically in SMS 7 bit charset, ASCII or UTF8 so
+		 * no conversion.
+		 */
+		out_list[(*count)++] = g_strndup((char *) sim_list + i, 2);
+	}
+}
+
+static void sim_efpl_read_cb(int ok,
+				enum ofono_sim_file_structure structure,
+				int length, int record,
+				const unsigned char *data,
+				int record_length, void *userdata)
+{
+	struct ofono_sim *sim = userdata;
+	unsigned char *efli = sim->efli;
+	const unsigned char *efpl = data;
+	int efli_length = sim->efli_length;
+	int efpl_length = length;
+	int count;
+	const char *path = __ofono_atom_get_path(sim->atom);
+	DBusConnection *conn = ofono_dbus_get_connection();
+
+	if (!ok || structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT)
+		efpl = NULL;
+
+	if (length < 2)
+		efpl = NULL;
+
+	sim->language_prefs = g_new0(char *,
+					(efli_length + efpl_length) / 2 + 1);
+
+	count = 0;
+
+	/* Make a list of languages in both files in order of preferences
+	 * following 31.102.
+	 */
+
+	if (efli && efpl && efli[0] == 0xff && efli[1] == 0xff) {
+		parse_language_list(sim->language_prefs, &count,
+					efpl, efpl_length);
+		efpl = NULL;
+	}
+
+	if (efli) {
+		parse_language_list(sim->language_prefs, &count,
+					efli, efli_length);
+		g_free(efli);
+		sim->efli = NULL;
+	}
+
+	if (efpl)
+		parse_language_list(sim->language_prefs, &count,
+					efpl, efpl_length);
+
+	ofono_dbus_signal_array_property_changed(conn, path,
+							SIM_MANAGER_INTERFACE,
+							"PreferredLanguages",
+							DBUS_TYPE_STRING,
+							&sim->language_prefs);
+}
+
+static void sim_retrieve_efli(struct ofono_sim *sim)
+{
+	/* According to 31.102 the EFli is read first and EFpl is then
+	 * only read if none of the EFli languages are supported by user
+	 * interface.  51.011 mandates the exact opposite, making EFpl/EFelp
+	 * preferred over EFlp (same ID as EFli, different format).
+	 * However we don't depend on the user interface and so
+	 * need to read both files now.
+	 */
+	ofono_sim_read(sim, SIM_EFLI_FILEID, sim_efli_read_cb, sim);
+	ofono_sim_read(sim, SIM_EFPL_FILEID, sim_efpl_read_cb, sim);
+}
+
 static void sim_op_error(struct ofono_sim *sim)
 {
 	struct sim_file_op *op = g_queue_pop_head(sim->simop_q);
@@ -1357,6 +1475,11 @@ static void sim_remove(struct ofono_atom *atom)
 		sim->service_numbers = NULL;
 	}
 
+	if (sim->language_prefs) {
+		g_strfreev(sim->language_prefs);
+		sim->language_prefs = NULL;
+	}
+
 	if (sim->simop_source) {
 		g_source_remove(sim->simop_source);
 		sim->simop_source = 0;
@@ -1446,6 +1569,7 @@ void ofono_sim_register(struct ofono_sim *sim)
 	 * arbitrary files to be written or read, assuming their presence
 	 * in the EFust
 	 */
+	sim_retrieve_efli(sim);
 	sim_pin_check(sim);
 }
 
diff --git a/src/simutil.h b/src/simutil.h
index fc4f063..d1517ed 100644
--- a/src/simutil.h
+++ b/src/simutil.h
@@ -20,6 +20,8 @@
  */
 
 enum sim_fileid {
+	SIM_EFPL_FILEID = 0x2f05,
+	SIM_EFLI_FILEID = 0x6f05,
 	SIM_EFMSISDN_FILEID = 0x6f40,
 	SIM_EFSPN_FILEID = 0x6f46,
 	SIM_EFSDN_FILEID = 0x6f49,
-- 
1.6.1


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

* Re: [PATCH] Present list of preferred languages on SimManager interface.
  2009-09-16 12:54     ` Andrzej Zaborowski
@ 2009-09-17 18:49       ` Andrzej Zaborowski
  2009-09-17 19:50         ` Denis Kenzior
  0 siblings, 1 reply; 12+ messages in thread
From: Andrzej Zaborowski @ 2009-09-17 18:49 UTC (permalink / raw)
  To: ofono

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

2009/9/16 Andrzej Zaborowski <andrew.zaborowski@intel.com>:
> So here's another version generated on top of HEAD and with an attempt
> to detect when the card uses EFlp format instead of EFli.

Sorry, I sent the wrong file, here's the *actual* new version.

Regards

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Present-list-of-preferred-languages-on-SimManager-in.patch --]
[-- Type: text/x-patch, Size: 7484 bytes --]

From c652820f5faf01288ac1a7caf340aefe2cba37dd Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <andrew.zaborowski@intel.com>
Date: Thu, 17 Sep 2009 15:58:29 +0200
Subject: [PATCH 1/2] Present list of preferred languages on SimManager interfce.

We try to detect the old (2G / 2G+, 51.011) EFlp format and deal
with the file contents accordingly.
---
 src/sim.c     |  216 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/simutil.h |    2 +
 2 files changed, 218 insertions(+), 0 deletions(-)

diff --git a/src/sim.c b/src/sim.c
index 46cac40..3f26678 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -77,10 +77,14 @@ struct ofono_sim {
 	GSList *service_numbers;
 	gboolean sdn_ready;
 	gboolean ready;
+	char **language_prefs;
 	GQueue *simop_q;
 	gint simop_source;
 	unsigned char efmsisdn_length;
 	unsigned char efmsisdn_records;
+	unsigned char *efli;
+	unsigned char efli_length;
+	unsigned int next_ready_watch_id;
 	struct ofono_watchlist *ready_watches;
 	const struct ofono_sim_driver *driver;
 	void *driver_data;
@@ -197,6 +201,11 @@ static DBusMessage *sim_get_properties(DBusConnection *conn,
 		g_strfreev(service_numbers);
 	}
 
+	if (sim->language_prefs)
+		ofono_dbus_dict_append_array(&dict, "PreferredLanguages",
+		                                DBUS_TYPE_STRING,
+		                                &sim->language_prefs);
+
 	dbus_message_iter_close_container(&iter, &dict);
 
 	return reply;
@@ -604,6 +613,207 @@ static void sim_retrieve_imsi(struct ofono_sim *sim)
 	sim->driver->read_imsi(sim, sim_imsi_cb, sim);
 }
 
+static void sim_efli_read_cb(int ok,
+		                enum ofono_sim_file_structure structure,
+		                int length, int record,
+		                const unsigned char *data,
+		                int record_length, void *userdata)
+{
+	struct ofono_sim *sim = userdata;
+
+	if (!ok || structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT)
+		return;
+
+	sim->efli = g_memdup(data, length);
+	sim->efli_length = length;
+}
+
+/* Detect whether the file is in EFli format, as opposed to 51.011 EFlp */
+static gboolean sim_efli_format(const unsigned char *ef, int length)
+{
+	if (length & 1)
+		return FALSE;
+
+	while (length) {
+		if (ef[0] != ef[1] && (ef[0] == 0xff || ef[1] == 0xff))
+			return FALSE;
+
+		/* ISO 639 country codes are each two lower-case SMS 7-bit
+		 * characters while CB DCS language codes are in ranges
+		 * (0 - 15) or (32 - 47), so the ranges don't overlap
+		 */
+		if (ef[0] != 0xff && (ef[0] < 'a' || ef[0] > 'z'))
+			return FALSE;
+		if (ef[1] != 0xff && (ef[1] < 'a' || ef[1] > 'z'))
+			return FALSE;
+
+		ef += 2;
+		length -= 2;
+	}
+
+	return TRUE;
+}
+
+static void parse_language_list(char **out_list, int *count,
+				const unsigned char *ef, int length)
+{
+	int i, j;
+
+	length--;
+
+	for (i = 0; i < length; i += 2) {
+		if (ef[i] == 0xff || ef[i + 1] == 0xff)
+			continue;
+
+		for (j = 0; j < *count; j++)
+			if (!memcmp(out_list[j], ef + i, 2))
+				break;
+		if (j < *count)
+			continue;
+
+		/* ISO 639 codes contain only characters that are coded
+		 * identically in SMS 7 bit charset, ASCII or UTF8 so
+		 * no conversion.
+		 */
+		out_list[(*count)++] = g_strndup((char *) ef + i, 2);
+	}
+}
+
+static const char* const dcs_lang_to_iso[0x30] = {
+	[0x00] = "de",
+	[0x01] = "en",
+	[0x02] = "it",
+	[0x03] = "fr",
+	[0x04] = "es",
+	[0x05] = "nl",
+	[0x06] = "sv",
+	[0x07] = "da",
+	[0x08] = "pt",
+	[0x09] = "fi",
+	[0x0a] = "no",
+	[0x0b] = "el",
+	[0x0c] = "tr",
+	[0x0d] = "hu",
+	[0x0e] = "pl",
+	[0x20] = "cs",
+	[0x21] = "ar",
+	[0x22] = "he",
+	[0x23] = "ar",
+	[0x24] = "ru",
+	[0x25] = "is",
+};
+
+static void parse_eflp(char **out_list, int *count,
+			const unsigned char *eflp, int length)
+{
+	int i, j;
+	const char *code;
+
+	for (i = 0; i < length; i++) {
+		if (eflp[i] >= 0x30)
+			continue;
+
+		code = dcs_lang_to_iso[eflp[i]];
+		if (!code)
+			continue;
+
+		for (j = 0; j < *count; j ++)
+			if (!memcmp(out_list[j], code, 2))
+				break;
+		if (j < *count)
+			continue;
+
+		out_list[*count++] = g_strdup(code);
+	}
+}
+
+static void sim_efpl_read_cb(int ok,
+				enum ofono_sim_file_structure structure,
+				int length, int record,
+				const unsigned char *data,
+				int record_length, void *userdata)
+{
+	struct ofono_sim *sim = userdata;
+	unsigned char *efli = sim->efli;
+	const unsigned char *efpl = data;
+	int efli_length = sim->efli_length;
+	int efpl_length = length;
+	int count;
+	int maxcount;
+	const char *path = __ofono_atom_get_path(sim->atom);
+	DBusConnection *conn = ofono_dbus_get_connection();
+
+	if (!ok || structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT ||
+			length < 2) {
+		efpl = NULL;
+		efpl_length = 0;
+	}
+
+	if (!efli || sim_efli_format(efli, efli_length)) {
+		maxcount = (efli_length + efpl_length) / 2;
+		sim->language_prefs = g_new0(char *, maxcount + 1);
+
+		count = 0;
+
+		/* Make a list of languages in both files in order of
+		 * preference following TS 31.102.
+		 */
+
+		if (efli && efpl && efli[0] == 0xff && efli[1] == 0xff) {
+			parse_language_list(sim->language_prefs, &count,
+						efpl, efpl_length);
+			efpl = NULL;
+		}
+
+		if (efli) {
+			parse_language_list(sim->language_prefs, &count,
+						efli, efli_length);
+			g_free(efli);
+			sim->efli = NULL;
+		}
+
+		if (efpl)
+			parse_language_list(sim->language_prefs, &count,
+						efpl, efpl_length);
+	} else {
+		maxcount = efpl_length / 2 + efli_length;
+		sim->language_prefs = g_new0(char *, maxcount + 1);
+
+		count = 0;
+
+		/* Make a list of languages in both files in order of
+		 * preference following TS 51.011.
+		 */
+
+		if (efpl)
+			parse_language_list(sim->language_prefs, &count,
+						efpl, efpl_length);
+
+		parse_eflp(sim->language_prefs, &count, efli, efli_length);
+		g_free(efli);
+		sim->efli = NULL;
+	}
+
+	ofono_dbus_signal_array_property_changed(conn, path,
+							SIM_MANAGER_INTERFACE,
+							"PreferredLanguages",
+							DBUS_TYPE_STRING,
+							&sim->language_prefs);
+}
+
+static void sim_retrieve_efli(struct ofono_sim *sim)
+{
+	/* According to 31.102 the EFli is read first and EFpl is then
+	 * only read if none of the EFli languages are supported by user
+	 * interface.  51.011 mandates the exact opposite, making EFpl/EFelp
+	 * preferred over EFlp (same EFid as EFli, different format).
+	 * However we don't depend on the user interface and so
+	 * need to read both files now.
+	 */
+	ofono_sim_read(sim, SIM_EFLI_FILEID, sim_efli_read_cb, sim);
+	ofono_sim_read(sim, SIM_EFPL_FILEID, sim_efpl_read_cb, sim);
+}
+
 static void sim_op_error(struct ofono_sim *sim)
 {
 	struct sim_file_op *op = g_queue_pop_head(sim->simop_q);
@@ -1163,6 +1373,11 @@ static void sim_remove(struct ofono_atom *atom)
 		sim->service_numbers = NULL;
 	}
 
+	if (sim->language_prefs) {
+		g_strfreev(sim->language_prefs);
+		sim->language_prefs = NULL;
+	}
+
 	if (sim->simop_source) {
 		g_source_remove(sim->simop_source);
 		sim->simop_source = 0;
@@ -1253,6 +1468,7 @@ void ofono_sim_register(struct ofono_sim *sim)
 	 * arbitrary files to be written or read, assuming their presence
 	 * in the EFust
 	 */
+	sim_retrieve_efli(sim);
 	sim_retrieve_imsi(sim);
 }
 
diff --git a/src/simutil.h b/src/simutil.h
index 90fc37b..2cd3b73 100644
--- a/src/simutil.h
+++ b/src/simutil.h
@@ -20,6 +20,8 @@
  */
 
 enum sim_fileid {
+	SIM_EFPL_FILEID = 0x2f05,
+	SIM_EFLI_FILEID = 0x6f05,
 	SIM_EFMSISDN_FILEID = 0x6f40,
 	SIM_EFSPN_FILEID = 0x6f46,
 	SIM_EFSDN_FILEID = 0x6f49,
-- 
1.6.1


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

* Re: [PATCH] Present list of preferred languages on SimManager interface.
  2009-09-17 18:49       ` Andrzej Zaborowski
@ 2009-09-17 19:50         ` Denis Kenzior
  2009-09-23 20:52           ` andrzej zaborowski
  0 siblings, 1 reply; 12+ messages in thread
From: Denis Kenzior @ 2009-09-17 19:50 UTC (permalink / raw)
  To: ofono

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

Hi,

> 2009/9/16 Andrzej Zaborowski <andrew.zaborowski@intel.com>:
> > So here's another version generated on top of HEAD and with an attempt
> > to detect when the card uses EFlp format instead of EFli.
>
> Sorry, I sent the wrong file, here's the *actual* new version.

Patch has been applied.  I cleaned it up a little afterward.  Let me know if I 
broke anything.

Regards,
-Denis

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

* Re: [PATCH] Present list of preferred languages on SimManager interface.
  2009-09-23 20:52           ` andrzej zaborowski
@ 2009-09-23 20:05             ` Denis Kenzior
  2009-09-23 22:01               ` andrzej zaborowski
  0 siblings, 1 reply; 12+ messages in thread
From: Denis Kenzior @ 2009-09-23 20:05 UTC (permalink / raw)
  To: ofono

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

Hi Andrew,

> The only corner case where order is now different is when the first

Sorry, I'm not following, can you elaborate?  If sim_efli_format encounters an 
empty entry it simply continues on...

> item in EFli is empty and other items aren't.  Attached a cosmetic
> patch.

Patch has been applied, thanks.

Regards,
-Denis

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

* Re: [PATCH] Present list of preferred languages on SimManager interface.
  2009-09-17 19:50         ` Denis Kenzior
@ 2009-09-23 20:52           ` andrzej zaborowski
  2009-09-23 20:05             ` Denis Kenzior
  0 siblings, 1 reply; 12+ messages in thread
From: andrzej zaborowski @ 2009-09-23 20:52 UTC (permalink / raw)
  To: ofono

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

2009/9/17 Denis Kenzior <denkenz@gmail.com>:
>> 2009/9/16 Andrzej Zaborowski <andrew.zaborowski@intel.com>:
>> > So here's another version generated on top of HEAD and with an attempt
>> > to detect when the card uses EFlp format instead of EFli.
>>
>> Sorry, I sent the wrong file, here's the *actual* new version.
>
> Patch has been applied.  I cleaned it up a little afterward.  Let me know if I
> broke anything.

The only corner case where order is now different is when the first
item in EFli is empty and other items aren't.  Attached a cosmetic
patch.

Regards

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-Rename-eflp_format-to-efli_format-the-opposite.patch --]
[-- Type: text/x-patch, Size: 1454 bytes --]

From b0323a75872138ffd883d843b4d0bc816c367a2d Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <andrew.zaborowski@intel.com>
Date: Wed, 23 Sep 2009 23:23:43 +0200
Subject: [PATCH] Rename eflp_format to efli_format, semantically opposite.

---
 src/sim.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/sim.c b/src/sim.c
index 1a4edc4..ec003ee 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -1065,7 +1065,7 @@ static void sim_efpl_read_cb(int ok,
 	struct ofono_sim *sim = userdata;
 	const char *path = __ofono_atom_get_path(sim->atom);
 	DBusConnection *conn = ofono_dbus_get_connection();
-	gboolean eflp_format = TRUE;
+	gboolean efli_format = TRUE;
 	GSList *efli = NULL;
 	GSList *efpl = NULL;
 
@@ -1077,9 +1077,9 @@ static void sim_efpl_read_cb(int ok,
 
 skip_efpl:
 	if (sim->efli && sim->efli_length > 0) {
-		eflp_format = sim_efli_format(sim->efli, sim->efli_length);
+		efli_format = sim_efli_format(sim->efli, sim->efli_length);
 
-		if (eflp_format)
+		if (efli_format)
 			efli = parse_language_list(sim->efli, sim->efli_length);
 		else
 			efli = parse_eflp(sim->efli, sim->efli_length);
@@ -1096,7 +1096,7 @@ skip_efpl:
 	 * preference to the EFPL at the MF unless...
 	 * Otherwise in order of preference according to TS 51.011
 	 */
-	if (eflp_format)
+	if (efli_format)
 		sim->language_prefs = concat_lang_prefs(efli, efpl);
 	else
 		sim->language_prefs = concat_lang_prefs(efpl, efli);
-- 
1.6.1


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

* Re: [PATCH] Present list of preferred languages on SimManager interface.
  2009-09-23 20:05             ` Denis Kenzior
@ 2009-09-23 22:01               ` andrzej zaborowski
  2009-09-23 22:30                 ` Denis Kenzior
  0 siblings, 1 reply; 12+ messages in thread
From: andrzej zaborowski @ 2009-09-23 22:01 UTC (permalink / raw)
  To: ofono

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

2009/9/23 Denis Kenzior <denkenz@gmail.com>:
> Hi Andrew,
>
>> The only corner case where order is now different is when the first
>
> Sorry, I'm not following, can you elaborate?  If sim_efli_format encounters an
> empty entry it simply continues on...

In 5.1.1.2 of 31.102, EFpl also takes precedence before EFli if FFFF
is in the first entry of EFli, you may interpret this case as EFpl
comes first then EFli, or EFli is discarded altogether.

Regards

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

* Re: [PATCH] Present list of preferred languages on SimManager interface.
  2009-09-23 22:01               ` andrzej zaborowski
@ 2009-09-23 22:30                 ` Denis Kenzior
  2009-09-25 18:56                   ` andrzej zaborowski
  0 siblings, 1 reply; 12+ messages in thread
From: Denis Kenzior @ 2009-09-23 22:30 UTC (permalink / raw)
  To: ofono

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

Hi Andrew,

> 2009/9/23 Denis Kenzior <denkenz@gmail.com>:
> > Hi Andrew,
> >
> >> The only corner case where order is now different is when the first
> >
> > Sorry, I'm not following, can you elaborate?  If sim_efli_format
> > encounters an empty entry it simply continues on...
>
> In 5.1.1.2 of 31.102, EFpl also takes precedence before EFli if FFFF
> is in the first entry of EFli, you may interpret this case as EFpl
> comes first then EFli, or EFli is discarded altogether.

Ah yes, you're correct.  I pushed a patch to simply ignore EFli if the first 
entry is 0xffff

Regards,
-Denis

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

* Re: [PATCH] Present list of preferred languages on SimManager interface.
  2009-09-23 22:30                 ` Denis Kenzior
@ 2009-09-25 18:56                   ` andrzej zaborowski
  2009-09-28 18:29                     ` Denis Kenzior
  0 siblings, 1 reply; 12+ messages in thread
From: andrzej zaborowski @ 2009-09-25 18:56 UTC (permalink / raw)
  To: ofono

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

Hi Denis,

2009/9/24 Denis Kenzior <denkenz@gmail.com>:
> I pushed a patch to simply ignore EFli if the first
> entry is 0xffff

I moved the check a little up because at that point the raw EFli would
have been freed already (see attached).

Regards

[-- Attachment #2: 0001-Check-the-first-EFli-record-before-EFli-is-freed.patch --]
[-- Type: application/octet-stream, Size: 1550 bytes --]

From 123a426eba39841d8aabf3f21d1013c7aa1b3a10 Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <andrew.zaborowski@intel.com>
Date: Fri, 25 Sep 2009 03:28:52 +0200
Subject: [PATCH] Check the first EFli record before EFli is freed.

---
 src/sim.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/sim.c b/src/sim.c
index c722754..72aeabb 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -1166,9 +1166,15 @@ skip_efpl:
 	if (sim->efli && sim->efli_length > 0) {
 		efli_format = sim_efli_format(sim->efli, sim->efli_length);
 
-		if (efli_format)
-			efli = parse_language_list(sim->efli, sim->efli_length);
-		else
+		if (efli_format) {
+			/* Discard if FFFF in highest priority position */
+			if (sim->efli_length >= 2 && sim->efli[0] == 0xff &&
+					sim->efli[1] == 0xff)
+				efli = NULL;
+			else
+				efli = parse_language_list(sim->efli,
+							sim->efli_length);
+		} else
 			efli = parse_eflp(sim->efli, sim->efli_length);
 
 		g_free(sim->efli);
@@ -1186,13 +1192,9 @@ skip_efpl:
 	 *   preference in the EFPL at the MF level
 	 * Otherwise in order of preference according to TS 51.011
 	 */
-	if (efli_format) {
-		if (sim->efli_length >= 2 && sim->efli[0] == 0xff &&
-				sim->efli[1] == 0xff)
-			sim->language_prefs = concat_lang_prefs(NULL, efpl);
-		else
-			sim->language_prefs = concat_lang_prefs(efli, efpl);
-	} else
+	if (efli_format)
+		sim->language_prefs = concat_lang_prefs(efli, efpl);
+	else
 		sim->language_prefs = concat_lang_prefs(efpl, efli);
 
 	if (efli) {
-- 
1.6.1


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

* Re: [PATCH] Present list of preferred languages on SimManager interface.
  2009-09-25 18:56                   ` andrzej zaborowski
@ 2009-09-28 18:29                     ` Denis Kenzior
  0 siblings, 0 replies; 12+ messages in thread
From: Denis Kenzior @ 2009-09-28 18:29 UTC (permalink / raw)
  To: ofono

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

Hi Andrew,

> Hi Denis,
>
> 2009/9/24 Denis Kenzior <denkenz@gmail.com>:
> > I pushed a patch to simply ignore EFli if the first
> > entry is 0xffff
>
> I moved the check a little up because at that point the raw EFli would
> have been freed already (see attached).

Good catch, I fixed it slightly differently upstream.

Regards,
-Denis

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

end of thread, other threads:[~2009-09-28 18:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-14 16:37 [PATCH] Present list of preferred languages on SimManager interface Andrzej Zaborowski
2009-09-14 16:06 ` Denis Kenzior
2009-09-14 17:33   ` Andrzej Zaborowski
2009-09-16 12:54     ` Andrzej Zaborowski
2009-09-17 18:49       ` Andrzej Zaborowski
2009-09-17 19:50         ` Denis Kenzior
2009-09-23 20:52           ` andrzej zaborowski
2009-09-23 20:05             ` Denis Kenzior
2009-09-23 22:01               ` andrzej zaborowski
2009-09-23 22:30                 ` Denis Kenzior
2009-09-25 18:56                   ` andrzej zaborowski
2009-09-28 18:29                     ` 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.