summaryrefslogtreecommitdiffstats
path: root/src/sim.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2009-07-13 18:30:17 -0500
committerDenis Kenzior <denkenz@gmail.com>2009-07-14 15:45:05 -0500
commit0fa689721347cc5b97b5b84c1f6495983a3bff61 (patch)
treef81c65a56c0e6ff3c1f247cf03b36e7dc2b58911 /src/sim.c
parent0fd50806304018485f64f27caf051444904a7ae0 (diff)
downloadofono-0fa689721347cc5b97b5b84c1f6495983a3bff61.tar.bz2
Refactor OPL code
Diffstat (limited to 'src/sim.c')
-rw-r--r--src/sim.c133
1 files changed, 0 insertions, 133 deletions
diff --git a/src/sim.c b/src/sim.c
index e22cac83..cd8d7386 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -245,139 +245,6 @@ check:
}
}
-struct opl_operator {
- struct sim_operator mcc_mnc;
- guint16 lac_tac_low;
- guint16 lac_tac_high;
- guint8 id;
-};
-
-static struct opl_operator *opl_operator_alloc(const guint8 *record)
-{
- struct opl_operator *oper = g_new0(struct opl_operator, 1);
-
- parse_mcc_mnc(&oper->mcc_mnc, record);
- record += 3;
-
- oper->lac_tac_low = (record[0] << 8) | record[1];
- record += 2;
- oper->lac_tac_high = (record[0] << 8) | record[1];
- record += 2;
-
- oper->id = record[0];
- if (!oper->id) {
- /* TODO: name to be taken from other sources, see TS 22.101 */
- }
-
- return oper;
-}
-
-static gint opl_operator_compare(gconstpointer a, gconstpointer b)
-{
- const struct opl_operator *opa = a;
- const struct sim_operator *opb = b;
- int i;
-
- for (i = 0; opb->mcc[i] | opa->mcc_mnc.mcc[i]; i ++)
- if (opb->mcc[i] != opa->mcc_mnc.mcc[i] &&
- !(opa->mcc_mnc.mcc[i] == '0' + 0xd &&
- opb->mcc[i]))
- return opa->mcc_mnc.mcc[i] - opb->mcc[i];
- for (i = 0; opb->mnc[i] | opa->mcc_mnc.mnc[i]; i ++)
- if (opb->mnc[i] != opa->mcc_mnc.mnc[i] &&
- !(opa->mcc_mnc.mnc[i] == '0' + 0xd &&
- opb->mnc[i]))
- return opa->mcc_mnc.mnc[i] - opb->mnc[i];
-
- if (opa->lac_tac_low > 0x0000 || opa->lac_tac_high < 0xfffe)
- return 1;
-
- return 0;
-}
-
-static void sim_opl_read_cb(const struct ofono_error *error,
- const unsigned char *sdata, int length, void *data)
-{
- struct ofono_modem *modem = data;
- struct sim_manager_data *sim = modem->sim_manager;
- struct opl_operator *oper;
-
- if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
- goto skip;
-
- if (length < sim->opl_size)
- goto skip;
-
- oper = opl_operator_alloc(sdata);
- if (oper->id > sim->pnn_num) {
- g_free(oper);
- goto skip;
- }
-
- sim->opl = g_slist_prepend(sim->opl, oper);
-
-skip:
- sim->opl_current ++;
- if (sim->opl_current < sim->opl_num)
- sim->ops->read_file_linear(modem, SIM_EFOPL_FILEID,
- sim->opl_current,
- sim->opl_size,
- sim_opl_read_cb, modem);
- else
- /* All records retrieved */
- if (sim->opl)
- sim->opl = g_slist_reverse(sim->opl);
-}
-
-static void sim_opl_info_cb(const struct ofono_error *error, int length,
- enum ofono_sim_file_structure structure,
- int record_length, void *data)
-{
- struct ofono_modem *modem = data;
- struct sim_manager_data *sim = modem->sim_manager;
-
- if (error->type != OFONO_ERROR_TYPE_NO_ERROR || length < 8 ||
- record_length < 8 ||
- structure != OFONO_SIM_FILE_STRUCTURE_FIXED)
- return;
-
- sim->opl_current = 0;
- sim->opl_size = record_length;
- sim->opl_num = length / record_length;
- sim->ops->read_file_linear(modem, SIM_EFOPL_FILEID, 0,
- record_length, sim_opl_read_cb, modem);
-}
-
-static gboolean sim_retrieve_opl(void *user_data)
-{
- struct ofono_modem *modem = user_data;
- struct sim_manager_data *sim = modem->sim_manager;
-
- sim->ops->read_file_info(modem, SIM_EFOPL_FILEID,
- sim_opl_info_cb, modem);
-
- return FALSE;
-}
-
-const char *ofono_operator_name_sim_override(struct ofono_modem *modem,
- const char *mcc, const char *mnc)
-{
- struct sim_manager_data *sim = modem->sim_manager;
- struct sim_operator op;
- GSList *l;
- const struct opl_operator *opl_op;
-
- g_strlcpy(op.mcc, mcc, sizeof(op.mcc));
- g_strlcpy(op.mnc, mnc, sizeof(op.mnc));
-
- l = g_slist_find_custom(sim->opl, &op, opl_operator_compare);
- if (!l)
- return NULL;
- opl_op = l->data;
-
- return sim->pnn[opl_op->id - 1].longname;
-}
-
static void sim_ready(struct ofono_modem *modem)
{
ofono_sim_read(modem, SIM_EFMSISDN_FILEID, sim_msisdn_read_cb, NULL);