Attaching an updated patch.

2009/8/20 Andrzej Zaborowski <[email protected]>:
> 2009/8/20 Gu, Yang <[email protected]>:
>> Several minor comments on this patch:
>> 1. How about unify all the mnc_length to be unsigned char?
>> 2. For this piece of code:
>>>+              value = new_mnc_length;
>>>+              ofono_dbus_signal_property_changed(conn, modem->path,
>>>+                                              SIM_MANAGER_INTERFACE,
>>>+                                              "MNCLength", DBUS_TYPE_BYTE,
>>>+                                              &value);
>> Is it necessary to use temporary variable value? Why not use 
>> &sim->mnc_length instead of &value?
>
> Necessary no, we can use unsigned char for sim->mnc_length --
> ofono_dbus_signal_property_changed requires unsigned char * -- it's
> just proper to use ints for integers.  I changed it as you suggest
> nevertheless.
>
>>
>> 3. In function sim_ad_read_cb(), variable "ph" is defined by not used.
>
> Thanks for noticing, removed in the attachment.

Regards
From a7743edeb4b0644a19076238e2de329e3a3d9cdb Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <[email protected]>
Date: Wed, 26 Aug 2009 02:36:45 +0200
Subject: [PATCH] Read EFad and expose MNC length in IMSI as a SimManager property.

Alternatively we could expose the MNC as a separate property.
---
 src/sim.c     |   44 ++++++++++++++++++++++++++++++++++++++++++++
 src/simutil.h |    1 +
 2 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/src/sim.c b/src/sim.c
index 3309c98..f76d4ed 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -76,6 +76,7 @@ struct sim_file_op {
 
 struct ofono_sim {
 	char *imsi;
+	unsigned char mnc_length;
 	GSList *own_numbers;
 	GSList *new_numbers;
 	gboolean ready;
@@ -154,6 +155,10 @@ static DBusMessage *sim_get_properties(DBusConnection *conn,
 		ofono_dbus_dict_append(&dict, "SubscriberIdentity",
 					DBUS_TYPE_STRING, &sim->imsi);
 
+	if (sim->mnc_length)
+		ofono_dbus_dict_append(&dict, "MNCLength",
+					DBUS_TYPE_BYTE, &sim->mnc_length);
+
 	own_numbers = get_own_numbers(sim->own_numbers);
 
 	ofono_dbus_dict_append_array(&dict, "SubscriberNumbers",
@@ -406,17 +411,56 @@ check:
 	sim->new_numbers = NULL;
 }
 
+static void sim_ad_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;
+	DBusConnection *conn = ofono_dbus_get_connection();
+	const char *path = __ofono_atom_get_path(sim->atom);
+	int new_mnc_length;
+
+	if (!ok)
+		return;
+
+	if (structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT)
+		return;
+
+	if (length < 4)
+		return;
+
+	new_mnc_length = data[3] & 0xf;
+
+	if (sim->mnc_length != new_mnc_length) {
+		sim->mnc_length = new_mnc_length;
+
+		ofono_dbus_signal_property_changed(conn, path,
+						SIM_MANAGER_INTERFACE,
+						"MNCLength", DBUS_TYPE_BYTE,
+						&sim->mnc_length);
+	}
+}
+
 static void sim_own_numbers_update(struct ofono_sim *sim)
 {
 	ofono_sim_read(sim, SIM_EFMSISDN_FILEID,
 			sim_msisdn_read_cb, sim);
 }
 
+static void sim_mnc_length_update(struct ofono_sim *sim)
+{
+	ofono_sim_read(sim, SIM_EFAD_FILEID,
+			sim_ad_read_cb, sim);
+}
+
 static void sim_ready(void *user)
 {
 	struct ofono_sim *sim = user;
 
 	sim_own_numbers_update(sim);
+	sim_mnc_length_update(sim);
 }
 
 static void sim_imsi_cb(const struct ofono_error *error, const char *imsi,
diff --git a/src/simutil.h b/src/simutil.h
index c0d3d52..9bb5323 100644
--- a/src/simutil.h
+++ b/src/simutil.h
@@ -22,6 +22,7 @@
 enum sim_fileid {
 	SIM_EFMSISDN_FILEID = 0x6f40,
 	SIM_EFSPN_FILEID = 0x6f46,
+	SIM_EFAD_FILEID = 0x6fad,
 	SIM_EFPNN_FILEID = 0x6fc5,
 	SIM_EFOPL_FILEID = 0x6fc6,
 	SIM_EFMBDN_FILEID = 0x6fc7,
-- 
1.6.1

_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to