From: Kristen Carlson Accardi <kristen@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH 3/6] sim: read EFimg
Date: Wed, 18 Aug 2010 04:25:20 -0700 [thread overview]
Message-ID: <1282130723-10488-4-git-send-email-kristen@linux.intel.com> (raw)
In-Reply-To: <1282130723-10488-1-git-send-email-kristen@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 2421 bytes --]
Read EFimg when the sim is ready, and store it in memory.
---
src/sim.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/src/sim.c b/src/sim.c
index d2ed780..6d723bb 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -88,6 +88,8 @@ struct ofono_sim {
unsigned char efmsisdn_records;
unsigned char *efli;
unsigned char efli_length;
+ unsigned char *efimg;
+ int efimg_length;
enum ofono_sim_cphs_phase cphs_phase;
unsigned char cphs_service_table[2];
struct ofono_watchlist *state_watches;
@@ -1001,6 +1003,44 @@ static void sim_own_numbers_update(struct ofono_sim *sim)
sim_msisdn_read_cb, sim);
}
+static void sim_efimg_read_cb(int ok, int length, int record,
+ const unsigned char *data,
+ int record_length, void *userdata)
+{
+ struct ofono_sim *sim = userdata;
+ unsigned char *efimg;
+ int num_records = length / record_length;
+
+ if (!ok)
+ return;
+
+ /*
+ * EFimg descriptors are 9 bytes long.
+ * Byte 1 of the record is the number of descriptors per record.
+ */
+ if (record_length < 10)
+ return;
+
+ if (sim->efimg == NULL) {
+ sim->efimg = g_try_malloc0(num_records * 9);
+
+ if (sim->efimg == NULL)
+ return;
+
+ sim->efimg_length = num_records * 9;
+ }
+
+ /*
+ * TBD - if we have more than one descriptor per record,
+ * pick the nicest one. For now we use the first one.
+ */
+
+ /* copy descriptor into slot for this record */
+ efimg = &sim->efimg[(record - 1) * 9];
+
+ memcpy(efimg, &data[1], 9);
+}
+
static void sim_ready(void *user, enum ofono_sim_state new_state)
{
struct ofono_sim *sim = user;
@@ -1015,6 +1055,8 @@ static void sim_ready(void *user, enum ofono_sim_state new_state)
sim_ad_read_cb, sim);
ofono_sim_read(sim, SIM_EFSDN_FILEID, OFONO_SIM_FILE_STRUCTURE_FIXED,
sim_sdn_read_cb, sim);
+ ofono_sim_read(sim, SIM_EFIMG_FILEID, OFONO_SIM_FILE_STRUCTURE_FIXED,
+ sim_efimg_read_cb, sim);
}
static void sim_cphs_information_read_cb(int ok, int length, int record,
@@ -1934,6 +1976,11 @@ static void sim_free_state(struct ofono_sim *sim)
g_strfreev(sim->language_prefs);
sim->language_prefs = NULL;
}
+
+ if (sim->efimg) {
+ g_free(sim->efimg);
+ sim->efimg = NULL;
+ }
}
void ofono_sim_inserted_notify(struct ofono_sim *sim, ofono_bool_t inserted)
--
1.7.2.1
next prev parent reply other threads:[~2010-08-18 11:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-18 11:25 [PATCH v2 0/6] Icon support Kristen Carlson Accardi
2010-08-18 11:25 ` [PATCH 1/6] simutil: add fileid for EFimg Kristen Carlson Accardi
2010-08-18 11:25 ` [PATCH 2/6] stkutil: change uint32_t to guint32 Kristen Carlson Accardi
2010-08-18 11:25 ` Kristen Carlson Accardi [this message]
2010-08-25 18:03 ` [PATCH 3/6] sim: read EFimg Denis Kenzior
2010-08-18 11:25 ` [PATCH 4/6] sim: read EFiidf Kristen Carlson Accardi
2010-08-18 11:25 ` [PATCH 5/6] sim: implement GetIcon Kristen Carlson Accardi
2010-08-18 11:25 ` [PATCH 6/6] test: add get-icon script Kristen Carlson Accardi
-- strict thread matches above, loose matches on Subject: below --
2010-08-25 11:00 [PATCH v2 0/6] icon support patches Kristen Carlson Accardi
2010-08-25 11:00 ` [PATCH 3/6] sim: read EFimg Kristen Carlson Accardi
2010-08-25 18:52 ` 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=1282130723-10488-4-git-send-email-kristen@linux.intel.com \
--to=kristen@linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox