summaryrefslogtreecommitdiffstats
path: root/src/sim.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2012-06-16 20:52:18 -0700
committerMarcel Holtmann <marcel@holtmann.org>2012-06-16 20:52:18 -0700
commitc3124b66d903a43ce639e3de8e838ef39419fc4f (patch)
tree2462fa0cef618ce2e3de8e32a4753bff9de9b767 /src/sim.c
parent1960dbbc79e43f33f23886c2a12e508a0350aad1 (diff)
downloadofono-c3124b66d903a43ce639e3de8e838ef39419fc4f.tar.bz2
sim: Add special callback for reading MSISDN value
Diffstat (limited to 'src/sim.c')
-rw-r--r--src/sim.c85
1 files changed, 55 insertions, 30 deletions
diff --git a/src/sim.c b/src/sim.c
index f02acedc..3d4eece4 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -1126,37 +1126,8 @@ static gboolean numbers_list_equal(GSList *a, GSList *b)
return TRUE;
}
-static void sim_msisdn_read_cb(int ok, int length, int record,
- const unsigned char *data,
- int record_length, void *userdata)
+static void sim_own_numbers_update_done(struct ofono_sim *sim)
{
- struct ofono_sim *sim = userdata;
- int total;
- struct ofono_phone_number ph;
-
- if (!ok)
- goto check;
-
- if (record_length < 14 || length < record_length)
- return;
-
- total = length / record_length;
-
- sim->efmsisdn_length = record_length;
- sim->efmsisdn_records = total;
-
- if (sim_adn_parse(data, record_length, &ph, NULL) == TRUE) {
- struct ofono_phone_number *own;
-
- own = g_new(struct ofono_phone_number, 1);
- memcpy(own, &ph, sizeof(struct ofono_phone_number));
- sim->new_numbers = g_slist_prepend(sim->new_numbers, own);
- }
-
- if (record != total)
- return;
-
-check:
/* All records retrieved */
if (sim->new_numbers)
sim->new_numbers = g_slist_reverse(sim->new_numbers);
@@ -1186,6 +1157,60 @@ check:
sim->new_numbers = NULL;
}
+static void sim_msisdn_cb(const struct ofono_error *error,
+ const struct ofono_phone_number *ph, void *userdata)
+{
+ struct ofono_sim *sim = userdata;
+
+ if (error->type == OFONO_ERROR_TYPE_NO_ERROR) {
+ struct ofono_phone_number *own;
+
+ own = g_new(struct ofono_phone_number, 1);
+ memcpy(own, ph, sizeof(struct ofono_phone_number));
+ sim->new_numbers = g_slist_prepend(sim->new_numbers, own);
+ }
+
+ sim_own_numbers_update_done(sim);
+}
+
+static void sim_msisdn_read_cb(int ok, int length, int record,
+ const unsigned char *data,
+ int record_length, void *userdata)
+{
+ struct ofono_sim *sim = userdata;
+ int total;
+ struct ofono_phone_number ph;
+
+ if (!ok) {
+ if (sim->driver->read_msisdn)
+ sim->driver->read_msisdn(sim, sim_msisdn_cb, sim);
+ else
+ sim_own_numbers_update_done(sim);
+ return;
+ }
+
+ if (record_length < 14 || length < record_length)
+ return;
+
+ total = length / record_length;
+
+ sim->efmsisdn_length = record_length;
+ sim->efmsisdn_records = total;
+
+ if (sim_adn_parse(data, record_length, &ph, NULL) == TRUE) {
+ struct ofono_phone_number *own;
+
+ own = g_new(struct ofono_phone_number, 1);
+ memcpy(own, &ph, sizeof(struct ofono_phone_number));
+ sim->new_numbers = g_slist_prepend(sim->new_numbers, own);
+ }
+
+ if (record != total)
+ return;
+
+ sim_own_numbers_update_done(sim);
+}
+
static gint service_number_compare(gconstpointer a, gconstpointer b)
{
const struct service_number *sdn = a;