Clean up in sim.c.

Remove unused variables and fields.
Move EFadn format parsing to a common function because various files use
this same format.
This commit is contained in:
Andrzej Zaborowski 2009-07-30 10:04:59 +02:00 committed by Denis Kenzior
parent 049e573691
commit ebf6fca07a
5 changed files with 39 additions and 21 deletions

View File

@ -61,8 +61,6 @@ struct sim_file_op {
struct sim_manager_data {
struct ofono_sim_ops *ops;
int flags;
DBusMessage *pending;
char *imsi;
GSList *own_numbers;
GSList *ready_notify;
@ -180,8 +178,6 @@ static void sim_msisdn_read_cb(struct ofono_modem *modem, int ok,
struct sim_manager_data *sim = modem->sim_manager;
int total;
struct ofono_phone_number *ph;
int number_len;
int ton_npi;
if (!ok)
return;
@ -194,23 +190,12 @@ static void sim_msisdn_read_cb(struct ofono_modem *modem, int ok,
total = length / record_length;
/* Skip Alpha-Identifier field */
data += record_length - 14;
number_len = *data++;
ton_npi = *data++;
if (number_len > 11 || ton_npi == 0xff)
goto check;
ph = g_new(struct ofono_phone_number, 1);
ph->type = bit_field(ton_npi, 4, 3);
/* BCD coded, however the TON/NPI is given by the first byte */
number_len = (number_len - 1) * 2;
extract_bcd_number(data, number_len, ph->number);
if (sim_adn_parse(data, record_length, ph) == FALSE) {
g_free(ph);
goto check;
}
sim->own_numbers = g_slist_prepend(sim->own_numbers, ph);
@ -789,5 +774,5 @@ void ofono_sim_manager_exit(struct ofono_modem *modem)
g_free(modem->sim_manager);
modem->sim_manager = 0;
modem->sim_manager = NULL;
}

View File

@ -398,3 +398,31 @@ const struct sim_eons_operator_info *sim_eons_lookup_with_lac(
{
return sim_eons_lookup_common(eons, mcc, mnc, TRUE, lac);
}
gboolean sim_adn_parse(const unsigned char *data, int length,
struct ofono_phone_number *ph)
{
int number_len;
int ton_npi;
if (length < 14)
return FALSE;
/* Skip Alpha-Identifier field */
data += length - 14;
number_len = *data++;
ton_npi = *data++;
if (number_len > 11 || ton_npi == 0xff)
return FALSE;
ph->type = bit_field(ton_npi, 4, 3);
/* BCD coded, however the TON/NPI is given by the first byte */
number_len = (number_len - 1) * 2;
extract_bcd_number(data, number_len, ph->number);
return TRUE;
}

View File

@ -76,3 +76,6 @@ static inline enum sim_file_access file_access_condition_decode(int bcd)
return SIM_FILE_ACCESS_ADM;
return bcd;
}
gboolean sim_adn_parse(const unsigned char *data, int length,
struct ofono_phone_number *ph);

View File

@ -9,7 +9,8 @@ test_sms_SOURCES = test-sms.c $(top_srcdir)/src/util.c \
$(top_srcdir)/src/smsutil.c
test_simutil_SOURCES = test-simutil.c $(top_srcdir)/src/util.c \
$(top_srcdir)/src/simutil.c
$(top_srcdir)/src/simutil.c \
$(top_srcdir)/src/smsutil.c
LDADD = @GLIB_LIBS@ @GTHREAD_LIBS@

View File

@ -24,6 +24,7 @@
#include <assert.h>
#include <glib.h>
#include "driver.h"
#include "simutil.h"
const unsigned char valid_efopl[] = {